Search code examples
flutterflutter-layout

Flutter : Error after add Spacer() in my row Children


I do a row for many button that can do scroll vertical, but i need some space between button, so i add Spacer() for create a space

            SingleChildScrollView(
              .....
              child: Column(
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      TextButton(
                        ....
                      ),
                      Spacer(),
                      TextButton(
                        ....
                      ),
                    ],
                  )
                ],
              ),
            )

After I add syntax Spacer() there, I got this Error Error screenshot,


Solution

  • I change my Row() to Wrap(), then I add spacing: from wrap widget

    Wrap(
      spacing: 100,
      ....
    )
    

    and Done, Thx everyone