0.Snackbar概况:
- 掌握Builder():
builder才能获取当前控件的上下文context
class study extends StatefulWidget {
@override
_studyState createState() => _studyState();
}
class _studyState extends State<study> {
@override
void initState() {
//相当于构造方法,但控件创建只会执行一次
super.initState();
}
TextEditingController _controller = TextEditingController(); //需要设置这个
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Flutter Widget"),
),
body: Builder(
//建造器,获取Scaffold的context下面ctx就是Scaffold的context,return返回的是放在body位置的东西
builder: (ctx) {
return Center(
child: RaisedButton(
child: Text("按钮"),
onPressed: () {