【发布时间】:2020-12-01 09:38:09
【问题描述】:
我尝试在脚手架上创建一个小吃店,但错误是使用不包含脚手架的上下文调用 Scaffold.of()。我无法解决它,我尝试放置一个密钥,但上面有错误并且无法设置密钥,这是我的代码:
class Login extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.transparent,
elevation: 0.0,
title: Text('Log in',
style: TextStyle(color: Colors.black),
textAlign: TextAlign.center),
),
SizedBox(
width: 500,
height: 50.0,
child: RaisedButton(
textColor: Colors.white,
color: Colors.blue,
child: Text('Log In'),
onPressed: () => {
Scaffold.of(context).showSnackBar(SnackBar(content: Text('Done!'),))
}))
])
],
),
),
),
));
}
}
【问题讨论】:
-
这能回答你的问题吗? stackoverflow.com/questions/51304568/…