skip to Main Content

How to get the OutlinedButton as long as the Row’s content ? I have this button inside Column <- SizedBox(width:300) <- Card

OutlinedButton(
        onPressed: null,
        style: OutlinedButton.styleFrom(
          fixedSize: const Size.fromHeight(40),
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(widget.leading,
                style: TextStyle(
                    fontFamily: 'JT', fontSize: 18, color: widget.color)),
            const SizedBox(width: 10),
            Text(widget.txt,
                style: TextStyle(
                    fontFamily: 'NunitoEB', fontSize: 16, color: widget.color)),
            const SizedBox(width: 10),
            Text(widget.suffix,
                style: TextStyle(
                    fontFamily: 'JT', fontSize: 18, color: widget.color)),
          ],
        ));

2

Answers


  1. mainAxisSize: MainAxisSize.min,
    

    use this property in your row

    Edit:
    enter image description here

    Edit 2:

                   SizedBox(
                            width: 300,
                            child: Row(
                              children: [
                                Spacer(),
                                OutlinedButton(
                                    onPressed: null,
                                    style: OutlinedButton.styleFrom(
                                      fixedSize: const Size.fromHeight(40),
                                    ),
                                    child: Row(
                                      mainAxisAlignment: MainAxisAlignment.center,
                                      mainAxisSize: MainAxisSize.min,
                                      children: [
                                        Text('leading',
                                            style: TextStyle(
                                              fontFamily: 'JT',
                                              fontSize: 18,
                                            )),
                                        const SizedBox(width: 10),
                                        Text('txt',
                                            style: TextStyle(
                                                fontFamily: 'NunitoEB',
                                                fontSize: 16)),
                                        const SizedBox(width: 10),
                                        Text('suffix',
                                            style: TextStyle(
                                              fontFamily: 'JT',
                                              fontSize: 18,
                                            )),
                                      ],
                                    )),
                                Spacer(),
                              ],
                            ),
                          )
    

    try this out and see if it works even with your container as parent

    Login or Signup to reply.
  2. I’m Try To Solve Your Problem :

    Use SizedBox to Set Width of OutlinedButton

    Here is Code:

    SizedBox(
            width: 250,
            height: 50,
            child: OutlinedButton(
                onPressed: null,
                style: OutlinedButton.styleFrom(
                  fixedSize: const Size.fromHeight(40),
                ),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Text(widget.leading,
                        style: TextStyle(
                            fontFamily: 'JT', fontSize: 18, color: widget.color)),
                    const SizedBox(width: 10),
                    Text(widget.txt,
                        style: TextStyle(
                            fontFamily: 'NunitoEB', fontSize: 16, color: widget.color)),
                    const SizedBox(width: 10),
                    Text(widget.suffix,
                        style: TextStyle(
                            fontFamily: 'JT', fontSize: 18, color: widget.color)),
                  ],
                )),
          );
    

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search