将导航栏添加到屏幕颤动的底部

时间:2021-04-26 23:06:34

标签: flutter user-interface dart

嘿,我的代码有问题,我正在尝试将标签页作为正文添加到页面底部,但这样做时遇到问题,我遵循的代码示例具有这种格式

class MenuFrame extends StatelessWidget {
PageController pageController = PageController();
Duration _animationDuration = Duration(milliseconds: 500);

void _changePage(int page) {
pageController.animateToPage(page,
    duration: _animationDuration, curve: Curves.easeIn);
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
  theme: ThemeData(fontFamily: 'Geometria'),
  home: Scaffold(
    body: Tabs(),
  ),
);
}
}

如您所见,它有一个脚手架,然后是一个附加到选项卡的主体,这是另一个 dart 文件。

这是我下面的代码

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
  debugShowCheckedModeBanner: false,
  theme: ThemeData(
    primaryColor: Colors.white,
    visualDensity: VisualDensity.adaptivePlatformDensity,
  ),
  home: MenuFrame(
  ),
);
}
}

这是我的菜单框架

 Widget build(BuildContext context) {
return Stack(
  children: <Widget>[
    Material(
      color: Colors.transparent,
      child: Container(
        color: Colors.transparent,
        child: Column(
          children: <Widget>[
            SafeArea(
              child: Padding(
                padding:
                    EdgeInsets.symmetric(horizontal: 28.0, vertical: 40.0),
                child: Container(
                  decoration: BoxDecoration(
                    color: Colors.black.withOpacity(0.75),
                    borderRadius: BorderRadius.circular(40.0),
                  ),
                  child: Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: Column(
                      children: <Widget>[
                        Icon(
                          FontAwesomeIcons.heartBroken,
                          color: Color.fromRGBO(245, 48, 111, 1.0),
                          size: 60.0,
                        ),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: <Widget>[
                            Text(
                              'CONN',
                              style: TextStyle(
                                fontSize: 38.0,
                                fontWeight: FontWeight.bold,
                                color: Color.fromRGBO(245, 48, 111, 1.0),
                              ),
                            ),
                            Text(
                              'EXION',
                              style: TextStyle(
                                fontSize: 38.0,
                                fontWeight: FontWeight.bold,
                                color: Colors.white,
                              ),
                            ),
                          ],
                        ),
                        Text(
                          'Find and meet people around to find LOVE',
                          style: TextStyle(
                            color: Colors.white,
                            fontSize: 18.0,
                          ),
                          textAlign: TextAlign.center,
                        ),
                      ],
                    ),
                  ),
                ),
              ),
            ),
            Expanded(
              child: PageView(
                physics: NeverScrollableScrollPhysics(),
                controller: pageController,
                children: <Widget>[
                  HomeSignInWidget(
                    goToPageCallback: (page) {
                      _changePage(page);
                    },
                  ),
                  SignIn(),
                  CreateLogin(
                    cancelBackToHome: () {
                      _changePage(0);
                    },
                  ),
                ],
              ),
            ),
          ],
        ),

这是我的标签页代码,它是用户登录后我希望出现在屏幕底部的小部件。

class Tabs extends StatelessWidget {
Tabs(SingleChildScrollView singleChildScrollView);

@override
Widget build(BuildContext context) {
return DefaultTabController(
  length: 3,
  child: Scaffold(
    backgroundColor: Colors.white,
    body: TabBarView(
      children: <Widget>[
        Programs(),
        Diet(),
        Results(),
      ],
    ),
    bottomNavigationBar: TabBar(
      tabs: <Widget>[
        Tab(
          icon: Icon(Icons.explicit, size: 26.0),
        ),
        Tab(
          icon: Icon(Icons.restaurant_menu, size: 26.0),
        ),
        Tab(
          icon: Icon(Icons.insert_chart, size: 26.0),
        ),
      ],
      labelPadding: EdgeInsets.all(5.0),
      labelColor: Colors.blue,
      unselectedLabelColor: Colors.black12,
      indicatorWeight: 0.01,
    ),
  ),
);
}
}
    

我无法像示例中那样将正文代码添加到我的代码中,因为我不使用脚手架,我的主菜单框是注册/注册/登录登录页面,因此它不会让我添加身体吧。是否有任何解决方案我需要页面底部的选项卡小部件,以便用户可以导航到其他页面而不是停留在一个页面上。我只希望标签页位于除菜单框架页面之外的所有其他页面上。

0 个答案:

没有答案