flutter 如何在屏幕的按钮中排列行()(我想在按钮中放置屏幕导航图标)

amrnrhlw  于 2022-11-17  发布在  Flutter
关注(0)|答案(2)|浏览(158)
Column(
                    crossAxisAlignment: CrossAxisAlignment.end,
                    mainAxisAlignment: MainAxisAlignment.end,
                    children: <Widget>[
                      Row(
                        //    crossAxisAlignment: CrossAxisAlignment.end,
                        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                        children: <Widget>[
                          FloatingActionButton(
                            onPressed: () {
                              //ClearSession();
                              if (Navigator.canPop(context)) {
                                Navigator.pop(context, true);
                              }
                              Navigator.pushReplacement(
                                  context,
                                  MaterialPageRoute(
                                      builder: (context) =>
                                          Home(22.0, 22.0)));
                            }
                            // Add your onPressed code here!
                            ,
                            backgroundColor: Colors.green,
                            child: const Icon(Icons.home),
                          ),
                          FloatingActionButton(
                            onPressed: () {
                              //ClearSession();
                              if (Navigator.canPop(context)) {
                                Navigator.pop(context, true);
                              }
                              Navigator.pushReplacement(
                                  context,
                                  MaterialPageRoute(
                                      builder: (context) =>
                                          const Calender()));
                            }
                            // Add your onPressed code here!
                            ,
                            backgroundColor: Colors.green,
                            child: const Icon(Icons.calendar_month),
                          ),
                          FloatingActionButton(
                            onPressed: () {
                              //ClearSession();
                              if (Navigator.canPop(context)) {
                                Navigator.pop(context, true);
                              }
                              Navigator.pushReplacement(
                                  context,
                                  MaterialPageRoute(
                                      builder: (context) =>
                                          const Community()));
                            },
                            backgroundColor: Colors.green,
                            child: const Icon(Icons.article_rounded),
                          ),
                          FloatingActionButton(
                            onPressed: () {
                              // Add your onPressed code here!
                            },
                            backgroundColor: Colors.green,
                            child: const Icon(
                                Icons.settings_accessibility_sharp),
                          ),
                        ],
                      ),
                    ],
                  ),

它应该与所有类型的屏幕兼容,无论屏幕大小我不想使用填充,因为它只适用于某些屏幕,而不是所有类型的屏幕图标都在屏幕的中间,
我想把它们都放在屏幕的按钮上

它应该与所有类型的屏幕兼容,无论屏幕大小我不想使用填充,因为它只适用于某些屏幕,而不是所有类型的屏幕图标都在屏幕的中间,我想把所有的屏幕按钮

vnzz0bqm

vnzz0bqm1#

使用scaffold(),然后将Row()放入floatingActionButton属性中,如下所示:

Scaffold(
  appBar: ...
  body:...
  floatingActionButton: // your Row()
);
bvuwiixz

bvuwiixz2#

您可以使用bottomNavigationBar轻松放置所有按钮,bottomNavigationBar是scaffold小部件可用的属性

相关问题