Flutter Cupertino appbar 隐藏屏幕空间

fly*_*uin 4 ios flutter

我在 Cupertino 小部件上遇到了这个烦人的问题。当我创建一个超级简单的应用程序设置(脚手架、导航栏、一个文本项)时,文本似乎开始在视口之外很远的地方。

继承人的例子:

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _MyAppState();
  }
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return CupertinoApp(
      home: CupertinoPageScaffold(
        navigationBar: CupertinoNavigationBar(
          middle: Text('Me Title'),
        ),
        child: Column(
          children: <Widget>[
            Text(
              "No matter how short or long your journey to your accomplishment is, if you don't begin you can't get there. Beginning is difficult, but unavoidable!",
              style: TextStyle(fontSize: 30),
            ),
          ],
        ),
      ),
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

这导致了这个结果

“原生”小部件(MaterialApp、Scaffold、AppBar)导致了这一点并且工作得很好:

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Me Title'),
        ),
        body: Column(
          children: <Widget>[
            Text(
              "No matter how short or long your journey to your accomplishment is, if you don't begin you can't get there. Beginning is difficult, but unavoidable!",
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?这有点烦人,我想这会搞砸我尝试在其上构建的每个布局。

提前致谢!

fly*_*uin 6

对我有用的解决方案是将中央包装Column成一个SafeArea小部件(截图):

    return CupertinoApp(
      home: CupertinoPageScaffold(
        navigationBar: CupertinoNavigationBar(
          middle: Text('Me Title'),
        ),

        // the SafeArea is new!
        child: SafeArea(

          // that's unchanged.
          child: Column(
            // ... etc.
Run Code Online (Sandbox Code Playgroud)