如何在Flutter中创建导航栏的前导项目,并带有后退图标和前一个支架的标题。看看图片:
我尝试将Text
小部件放在Row
内,但出现溢出。
CupertinoNavigationBar(
middle: Text('New report'),
leading: Align(
alignment: Alignment(-1.5, -1),
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Icon(
CupertinoIcons.left_chevron,
color: CupertinoColors.destructiveRed,
),
],
),
),
),
),
谢谢!
答案 0 :(得分:0)
您的开头可能是包含图标和文本的行:诸如此类:
CupertinoNavigationBar(
middle: Text('New report'),
leading: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Icon(
CupertinoIcons.left_chevron,
color: CupertinoColors.destructiveRed,
),
Text('Reports')
],
),
),
),
答案 1 :(得分:0)
最简单的解决方法是用Row
包装您的主要小部件,然后再次点击点击将其退回,将其包装到GestureDetector
CupertinoNavigationBar(
leading: GestureDetector(
onTap: () => Navigator.pop(context),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Icon(
CupertinoIcons.left_chevron,
color: CupertinoColors.destructiveRed,
),
Text('Reports', style: TextStyle(color: CupertinoColors.destructiveRed),)
],
),
),
middle: Text('Time report'),
);