@override
Widget build(BuildContext context) {
return Scaffold(
appBar: buildAppBar(),
backgroundColor: Colors.white,
body: Body(),
);
}
AppBar buildAppBar() {
return AppBar(
backgroundColor: Colors.white,
elevation: 0,
leading: IconButton(
padding: EdgeInsets.only(left: kDefaultPadding),
icon: SvgPicture.asset("assets/icons/menu.svg"),
onPressed: () {},
),
actions: <Widget>[
Container(
width: 200,
alignment: Alignment(-0.4, 0.0),
child: Text('JOA',
textAlign: TextAlign.center,
style:
TextStyle(
color: kTextColor,
fontSize: 33,
),
),
),
IconButton(
padding: EdgeInsets.symmetric(horizontal: kDefaultPadding),
icon: SvgPicture.asset("assets/icons/logon.svg"),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => WelcomeScreen(),
),
);
},
),
],
);
}
}这里错误代码
lib/home/home_Scre.DAT:47:17: Error: getter‘The’不是为类‘主屏幕’定义的。
“('lib/home/home_screen.dart').:_app/home/home_Scre.DART”
尝试将名称更正为现有getter的名称,或定义名为“context”的getter或字段。上下文,
如何在Appbar之后添加上下文
发布于 2021-12-09 00:47:53
穿着你的脚手架:
appBar: buildAppBar(context),然后在Appbar Widget中:
AppBar buildAppBar(BuildContext context) https://stackoverflow.com/questions/70283005
复制相似问题