1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] How do I change the size of a custom button

Discussão em 'Mobile' iniciado por Stack, Setembro 10, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to change the size of a custom Button in my app but the size (width) stays the same no matter what I do

    [​IMG]

    My code can be found here:

    import 'package:flutter/material.dart';

    class CustomAppButton extends StatelessWidget {
    final VoidCallback onPressed;
    final String title;
    final double? height;
    final double? width;

    const CustomAppButton({
    required this.onPressed,
    required this.title,
    this.height = 64,
    this.width = 284,
    super.key,
    });

    @override
    Widget build(BuildContext context) {
    return SizedBox(
    width: width, // Force button to have this width
    height: height, // Force button to have height
    child: ElevatedButton(
    onPressed: onPressed,
    style: ElevatedButton.styleFrom(
    backgroundColor: Colors.white,
    shape: RoundedRectangleBorder(
    borderRadius: BorderRadius.circular(20),
    ),
    ),
    child: Text(
    title,
    style: const TextStyle(
    fontSize: 16,
    fontWeight: FontWeight.bold,
    color: Colors.black,
    ),
    ),
    ),
    );
    }
    }


    How do I fix this and get the button to be that size?

    Continue reading...

Compartilhe esta Página