首页 > 解决方案 > 如何将 pageView 添加到我的颤振 main.dart 代码中?

问题描述

我的应用程序在我的设备上完美运行,但是,在日志消息中,我收到一个错误,提示需要 pageView。 这是我刷卡时遇到的错误。所以我希望有人能帮我解决这些我每次在设备上滑动时都会遇到的错误

   void main()
   {
      SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]) 
       .then((_) {
            runApp(new MyApp());
      });
    }

    class MyApp extends StatelessWidget 
    {
              @override
              Widget build(BuildContext context)
              {

                final tabController = new DefaultTabController(
                    length: 4 ,
                    child: new Scaffold(
                      appBar: new AppBar(
                        backgroundColor: Colors.lightGreen,
                        title: new Text("Discover Zambia"),
                        bottom: new TabBar(
                            indicatorColor: Colors.red,
                            indicatorWeight: 4.0,
                            tabs: [
                            new Tab(icon: new Icon(Icons.home),text: "Home"),
                            new Tab(icon: new Icon(Icons.landscape),text: "Sights"),
                            new Tab(icon: new Icon(Icons.local_drink),text: "Nightlife"),
                            new Tab(icon: new Icon(Icons.restaurant),text: "Foods")

                        ]),
                      ),
                      body: new TabBarView(
                          children: [
                            new Home(),
                            new Sights(),
                            new Nightlife(),
                            new Foods()
                          ]
                      ),
                    ));
                return new MaterialApp(
                  debugShowCheckedModeBanner: false,
                  title: "",
                  home: tabController,

                );
              }

      }

标签: layoutdartflutter

解决方案


推荐阅读