我正在尝试在颤振应用程序中实现 appbar。我可以添加一个关闭应用程序的操作图标。我愿意在关闭操作图标旁边显示用户名。我尝试在 appar 部分的操作小部件数组中添加 new Text() 。但无法对齐。有没有办法直接添加动作文本?
代码:
@override
Widget build(BuildContext context) {
//build a form widget using the form key we created above
return new Scaffold(
appBar: new AppBar(
title: new Text(StringRef.appName),
actions: <Widget>[
new Container(),
new Text(
userName,
textScaleFactor: 1.5,
style: new TextStyle(
fontSize: 12.0,
color: Colors.white,
),
),
new IconButton(
icon: new Icon(Icons.close),
tooltip: 'Closes application',
onPressed: () => exit(0),
),
],
),
}