gpt4 book ai didi

ios - 为什么 Flutter 的 CupertinoNavigationBar 与 CupertinoPageScaffold 中的子项重叠?

转载 作者:行者123 更新时间:2023-11-29 05:14:00 27 4
gpt4 key购买 nike

我有以下小部件树:

@override
Widget build(BuildContext context) {
final double topMargin = Platform.isAndroid ? 0 : 105; // TODO: (why margin on iOS?)
final double interMargin = Platform.isAndroid ? 0 : 10;
final body = Column(children: <Widget> [
Padding(
padding: EdgeInsets.only(left: 10, right: 10, top: topMargin),
child: Platform.isAndroid // url
? TextField(
decoration: new InputDecoration(hintText: 'Host'),
maxLines: 1,
autofocus: true,
textInputAction: TextInputAction.next,
controller: _hostController)
: CupertinoTextField(
maxLines: 1,
autofocus: true,
textInputAction: TextInputAction.next,
controller: _hostController)),
Padding(
padding: EdgeInsets.only(left: 10, top: interMargin, right: 10),
child: Platform.isAndroid // port
? TextField(
decoration: new InputDecoration(hintText: 'Port'),
keyboardType: TextInputType.number,
maxLines: 1,
controller: _portController)
: CupertinoTextField(
keyboardType: TextInputType.number,
maxLines: 1,
controller: _portController)),
Platform.isAndroid
? RaisedButton(child: Text('OK'), onPressed: () => _onInputFinished())
: CupertinoButton(child: Text('OK'), onPressed: () => _onInputFinished())
]);
return Platform.isAndroid
? Scaffold(
appBar: AppBar(title: Text('Server connection')),
body: body)
: CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(middle: Text('Server connection')),
child: body);
}

只有当我向主体小部件添加上边距时,它看起来才可以:

final double topMargin = Platform.isAndroid ? 0 : 105; // TODO: (why margin on iOS?)
...

iOS screenshot

如果我不添加它,CupertinoNavigationBar 会与子项重叠:

overlapping

我错过了什么?

这是整个项目和 the screen .

最佳答案

您只需为您的 child 的小部件实现“SafeArea”小部件(而不是上边距),以避免被库比蒂诺导航栏重叠。

CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(),
child: SafeArea(
child: [Your widgets] // your children widgets
),
)

关于ios - 为什么 Flutter 的 CupertinoNavigationBar 与 CupertinoPageScaffold 中的子项重叠?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59379899/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com