我想放置自定义窗口小部件代替应用程序栏,并希望在其下方显示选项卡视图

问题描述 投票:0回答:1

我建立了一个自定义的小部件(“ cab”),其中显示了一个帐户登录圈,但没有。用户拥有的积分。我希望在它下面有一个选项卡视图。现在,我已经将此自定义窗口小部件放置在选项卡本身内:

bottomNavigationBar: Material(child: TabBar(
           tabs: const <Widget>[
            Tab( icon: Icon(Icons.add)),
          Tab( icon: Icon(Icons.search))
          ]
      ),),


       body :TabBarView(
        children: <Widget>[
          Column(
            children: <Widget>[
              cab
            ],
          ), 

enter image description here

但是我希望此窗口小部件显示在选项卡视图上方,而不是选项卡视图本身的一部分。我能怎么做这个?谢谢。

flutter flutter-layout
1个回答
0
投票

用下面的您自己的小部件替换AppBar小部件:

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: DefaultTabController(
        length: 2,
        child: Scaffold(
          bottomNavigationBar: TabBar(
            labelColor: Colors.orange,
            unselectedLabelColor: Colors.grey,
            indicatorSize: TabBarIndicatorSize.tab,
            indicatorColor: Colors.orange,
            tabs: [
              Tab(
                icon: Icon(Icons.add),
              ),
              Tab(
                icon: Icon(Icons.search),
              ),
            ],
          ),
          body: Column(
            children: <Widget>[
              // Remove the AppBar code below and put your "cab" widget
              AppBar(
                primary: true,
                title: Text('Here is your cab'),
                centerTitle: true,
                backgroundColor: Colors.orange,
              ),
              Expanded(
                child: TabBarView(
                  children: [
                    Icon(Icons.add),
                    Icon(Icons.search),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.