状态栏未显示在Flutter中

时间:2019-10-18 11:57:47

标签: android ios flutter dart

Flutter应用未显示状态栏(PFA)。我不希望我的应用全屏显示。 有什么办法可以解决这个问题。

Image

main.dart

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
 return MaterialApp(
  title: '',
  theme: ThemeData(
    primarySwatch: Colors.purple,
    fontFamily: 'FIRSNEUE'
  ),

 home: SplashScreenFirst(),

  routes: <String, WidgetBuilder> {
    '/dashboard': (BuildContext context) => Dashboard(title: 'HOUSR'),
    '/login': (BuildContext context) =>  Login(),
    '/service-dashboard': (BuildContext context) => Service(),
    '/service-exists': (BuildContext context) => ServiceExists(),
    '/partnerOffers' : (BuildContext context) => Partner(),
    '/visitorRequest' : (BuildContext context) => VisitorRequest(),
    '/vistorRequestSuccess' : (BuildContext context) => VisitorRequestSuccess(),
    '/mealPlan' : (BuildContext context) => MealPlan()
  },

);
}
}

login.dart

return Scaffold(
    key: _scaffoldKey,
    body: ListView(
        shrinkWrap: true,
        padding: EdgeInsets.all(15.0),
        children: <Widget>[
          Center(
            child: Container(
              child: Column(
                children: <Widget>[
                  Container(
                      padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
                      width: double.infinity,
                      height: 720,
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                          SizedBox(height: 65.0),
                          SizedBox(
                            height: 43.0,
                            width: 136,
                            child: Image.asset(
                              "images/logo.png",
                              fit: BoxFit.cover,
                            ),
                          ),
                          SizedBox(height: 45.0),
                          Text(
                            'Please login to continue',
                            style: TextStyle(
                                color: Color(0xffB13F8F),
                                fontSize: 16,
                                letterSpacing: 0.15),
                          ),
                          SizedBox(height: 145.0),
                          emailField,
                          _error
                              ? _phoneController.text.length > 0
                                  ? (SizedBox(
                                      height: 1,
                                    ))
                                  : Container(
                                      padding: EdgeInsets.only(top: 20),
                                      child: Text(
                                        'Something went wrong. Please try again',
                                        style: TextStyle(
                                            color: Colors.redAccent,
                                            fontSize: 16),
                                      ),
                                    )
                              : (SizedBox(
                                  height: 1,
                                )),
                          SizedBox(
                            height: 104.0,
                          ),
                          _isLoading
                              ? Center(child: CircularProgressIndicator())
                              : _isDisabled
                                  ? loginButtonDisabled
                                  : loginButon,
                          SizedBox(
                            height: 15.0,
                          ),
                        ],
                      ))
                ],
              ),
            ),
          ),
        ]));
 }

3 个答案:

答案 0 :(得分:4)

请检查在创建flutter项目时创建的两个文件,并注释掉或删除。

  • ./ ios / Runner / Info.plist
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIStatusBarHidden</key>                <- <here>
<true/>                                     <- <here>
<key>UISupportedInterfaceOrientations</key>
  • ./ android / app / src / main / res / values / styles.xml
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
    <item name="android:windowFullscreen">true</item>  <- <here>

答案 1 :(得分:0)

它在那里,但图标颜色为白色,您需要更新状态栏。

请参见How to change status bar color in Flutter?

答案 2 :(得分:0)

在谈论状态栏时,我不知道您的意思是应用栏。如果您不使用Scaffold作为主窗口小部件,则可能不存在。将所有代码包装在:

Scaffold(
    appBar: AppBar(
      title: const Text('Sample Code'),
    ),
    body: //rest of code...