10
在不包含Scaffold的上下文中调用Scaffold.of()
如您所见,我的按钮在Scaffold的体内。但是我得到这个异常: 在不包含Scaffold的上下文中调用Scaffold.of()。 import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: HomePage(), ); } } class HomePage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('SnackBar Playground'), …