【问题标题】:Flutter : SliverAppBar bottom TabBar not shown / overflow / hiddenFlutter:SliverAppBar底部TabBar未显示/溢出/隐藏
【发布时间】:2018-05-24 19:22:40
【问题描述】:

Flutter - SliverAppBar TabBar 未显示

一开始以为是flexibleSpace的问题,所以评论了,但是黄+黑的边框还在。

https://youtu.be/FcNMTg6ok4s

Youtube视频^^^

return new DefaultTabController(
      length: 2,
      child: new Scaffold(
        body: new NestedScrollView(
          headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
            return <Widget>[
              new SliverAppBar(
                forceElevated: innerBoxIsScrolled,
                floating: true,
                //elevation: elevation,
                pinned: true,
                expandedHeight: 250.0,
                bottom: new TabBar(
                  tabs: <Tab>[
                    new Tab(
                      text: 'green',
                      icon: new Icon(Icons.show_chart),
                    ),
                    new Tab(
                      text: 'purple',
                      icon: new Icon(Icons.history),
                    ),
                  ],
                ),
                flexibleSpace: new FlexibleSpaceBar(
                  title: new FarsiText(
                    "آقای نوری",
                    style: titleTextStyle,
                  ),
                  centerTitle: true,
                  background: new Container(
                    decoration: new BoxDecoration(
                      gradient: new LinearGradient(
                        begin: const Alignment(0.5, -0.5),
                        end: const Alignment(-1.5, 1.5),
                        colors: <Color>[
                          Colors.purple[400],
                          Colors.lightBlue[100],
                        ],
                      ),
                    ),
                    padding: new EdgeInsets.only(
                      top: screenWidth / 4,
                      bottom: screenWidth / 7,
                    ),
                    child: new Column(
                      children: <Widget>[
                        new Stack(
                          overflow: Overflow.visible,
                          children: <Widget>[
                            new CircleAvatar2(
                              boxShadow: new BoxShadow(
                                color: Colors.white70,
                                spreadRadius: 0.0,
                                blurRadius: 50.0,
                              ),
                              radius: 40.0,
                              backgroundImage:
                                  const AssetImage("assets/images/noori.jpg"),
                            ),
                            new Positioned(
                              child: new Container(
                                padding: const EdgeInsets.all(3.0),
                                decoration: new BoxDecoration(
                                  borderRadius: new BorderRadius.all(
                                    const Radius.circular(8.0),
                                  ),
                                  border: new Border.all(
                                    color: Colors.white,
                                    width: 1.5,
                                  ),
                                ),
                                child: new FarsiText(
                                  "تایید شده",
                                  color: Colors.white,
                                  fontSize: 15.0,
                                ),
                              ),
                              left: -100.0,
                            ),
                          ],
                        ),
                      ],
                    ),
                  ),
                ),
                leading: getAppBarLeading(context),
              ),
            ];
          },
          body: new TabBarView(
            children: <Widget>[
              new Center(
                child: new Container(
                  height: 1000.0,
                  color: Colors.green.shade200,
                  child: new Center(
                    child: new FlutterLogo(colors: Colors.green),
                  ),
                ),
              ),
              new Center(
                child: new Container(
                  height: 1000.0,
                  color: Colors.purple.shade200,
                  child: new Center(
                    child: new FlutterLogo(colors: Colors.purple),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );

【问题讨论】:

  • 嗨,你用什么FarsiText 代替了那个波斯文本的Text 小部件?将它用于 Fasi 应用程序有什么好处吗?
  • @HossainKhademian 它是 Text Class 的包装器

标签: dart flutter


【解决方案1】:

我将 Flutter 升级到了最新版本。

问题仍然存在。

我使用以下代码作为 MaterialApp 的 ThemeData:

primaryColor: Colors.blue[200],
primaryTextTheme: new TextTheme(
  title: new TextStyle(
    fontSize: 20.0,
    color: Colors.white,
  ),
),
primaryIconTheme: new IconThemeData(
  color: Colors.white,
),

我将其替换为:

primarySwatch: Colors.blue,

现在我可以看到 TabBar!

_

【讨论】:

    猜你喜欢
    • 2014-01-10
    • 1970-01-01
    • 2011-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-05
    • 1970-01-01
    相关资源
    最近更新 更多