Flutter中的AppBar不显示

时间:2018-11-12 16:45:37

标签: android dart flutter appbar

我正在尝试在我的应用页面上实现一个AppBar,但它没有显示。我试过了styles.xml文件和Android Manifest,但无济于事。我猜有一种在Flutter中处理AppBar的不同方法。

这是我的代码:

    import 'package:flutter/material.dart';
    import 'package:kain_app/utils/my_navigator.dart';
    import 'package:firebase_auth/firebase_auth.dart';
    import 'package:kain_app/services/user_management.dart';
    import 'package:flutter/widgets.dart';


    class HomeScreen extends StatefulWidget {
      @override
      HomeScreenState createState() {
        return HomeScreenState();
      }

        @override
      Widget build(BuildContext context) {
        return MaterialApp(
          home: Scaffold(
            appBar: new AppBar(
            title: new Text("Kain"),
          ),
          )
        );
      }
    }

    class HomeScreenState extends State<HomeScreen>{
    @override
      noSuchMethod(Invocation invocation) {
        return super.noSuchMethod(invocation);
      }
    @override
    Widget build(BuildContext context){
      return new Scaffold(
        resizeToAvoidBottomPadding: false,
        body: new Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Container(
              child: Stack(
                children: <Widget>[
                  Container(
                    padding: EdgeInsets.fromLTRB(15.0, 110.0, 15.0, 0.0),
                    child: Text(
                      'You are now logged in.',
                      style: TextStyle(
                      fontFamily:'Montserrat', fontSize: 80.0, fontWeight: FontWeight.w700)
                    ),
                  ),
                ],
              ),
            ),
            Container(
              child: new Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  new OutlineButton(
                    onPressed: (){
                      FirebaseAuth.instance.signOut().then((value) {
                        Navigator.of(context).pushReplacementNamed('/login');

                      }).catchError((e) {
                        print(e);
                      });
                    },
                    borderSide: BorderSide(
                      color: Colors.red[900], style: BorderStyle.solid, width: 4.0,),
                      child: Text('Logout',
                      style: TextStyle(
                        fontFamily: 'Montserrat',
                        fontSize: 16.0,
                        fontWeight: FontWeight.w700,
                      ),
                      ),
                  )
                ],
              ),
            )
          ],
        ),
      );
      }
    }

我在HomeScreenState之后立即声明的AppBar无法呈现。 You can see the output here.

如何取消隐藏appBar(如果有的话?)。这是我第一次在Flutter中进行编码,但我仍在学习。谢谢大家!

0 个答案:

没有答案