Why can't I increase my button width in flutter buttonbar

Viewed 46

I am trying to increase my button bar buttons' width so I used buttonMinWidth, but for some reason it isn't working, here's my code:

ButtonBar(
  children: [
    TextButton.icon(
      onPressed: null,
      icon: const Icon(
        Icons.replay,
        color: Colors.red,
      ),
      label: const Text(
        "Retry",
        style: TextStyle(color: Colors.red),
      ),
    ),
    TextButton.icon(
      onPressed: null,
      icon: const Icon(
        Icons.replay,
        color: Colors.green,
      ),
      label: const Text(
        "Continue",
        style: TextStyle(color: Colors.green),
      ),
    ),
  ],
  buttonMinWidth: 100,
),

It's probably simple but I can't seem to find the problem.

1 Answers

You can wrap ButtonBar widget with SizedBox widget and you can give width. but i don't this is the best solution but this will solve your problem.

    SizedBox(
      width: 300,
      child: ButtonBar(
        children: [
          TextButton.icon(
            onPressed: null,
            icon: const Icon(
              Icons.replay,
              color: Colors.red,
            ),
            label: const Text(
              "Retry",
              style: TextStyle(color: Colors.red),
            ),
          ),
          TextButton.icon(
            onPressed: null,
            icon: const Icon(
              Icons.replay,
              color: Colors.green,
            ),
            label: const Text(
              "Continue",
              style: TextStyle(color: Colors.green),
            ),
          ),
        ],
      ),
    ),
Related