我正在尝试了解有关BuildContext和Scaffold.of()的更多信息。我了解到,当您显示SnackBar时,您通常需要添加一个Builder以获取您添加的脚手架“下”的上下文。因此:classMyScreenextendsStatelessWidget{build(BuildContextcontext){returnScaffold(body:Builder(builder:(context)=>RaisedButton(child:Text('pushme'),onPressed:()=>Scaffold.of(context).showSnackBar(SnackBa
我正在尝试了解有关BuildContext和Scaffold.of()的更多信息。我了解到,当您显示SnackBar时,您通常需要添加一个Builder以获取您添加的脚手架“下”的上下文。因此:classMyScreenextendsStatelessWidget{build(BuildContextcontext){returnScaffold(body:Builder(builder:(context)=>RaisedButton(child:Text('pushme'),onPressed:()=>Scaffold.of(context).showSnackBar(SnackBa
将snackbar显示为Action的输出需要为Scaffold.of()创建一个子上下文,如Scaffold的手册中所述ofmethod.但我找不到此处描述的这种更“有效方法”的示例。Amoreefficientsolutionistosplityourbuildfunctionintoseveralwidgets.ThisintroducesanewcontextfromwhichyoucanobtaintheScaffold.Inthissolution,youwouldhaveanouterwidgetthatcreatestheScaffoldpopulatedbyinsta
将snackbar显示为Action的输出需要为Scaffold.of()创建一个子上下文,如Scaffold的手册中所述ofmethod.但我找不到此处描述的这种更“有效方法”的示例。Amoreefficientsolutionistosplityourbuildfunctionintoseveralwidgets.ThisintroducesanewcontextfromwhichyoucanobtaintheScaffold.Inthissolution,youwouldhaveanouterwidgetthatcreatestheScaffoldpopulatedbyinsta
我发布这个问题是因为很难找到我需要的回复,但我想它一定已经在某个地方得到了回复。如果确实在其他地方被询问和回复,请指出正确的方向请参见下图,取自kitkat设备。脚手架的背景是红色的,主体是绿色的。我需要绿色覆盖所有脚手架,包括导航栏后面的区域。Ps.:代码,按要求import'package:flutter/material.dart';voidmain()=>runApp(MyApp());classMyAppextendsStatelessWidget{//Thiswidgetistherootofyourapplication.@overrideWidgetbuild(Buil
我发布这个问题是因为很难找到我需要的回复,但我想它一定已经在某个地方得到了回复。如果确实在其他地方被询问和回复,请指出正确的方向请参见下图,取自kitkat设备。脚手架的背景是红色的,主体是绿色的。我需要绿色覆盖所有脚手架,包括导航栏后面的区域。Ps.:代码,按要求import'package:flutter/material.dart';voidmain()=>runApp(MyApp());classMyAppextendsStatelessWidget{//Thiswidgetistherootofyourapplication.@overrideWidgetbuild(Buil
我注意到Scaffold.drawer的Drawer只有在存在Scaffold的AppBar时才会显示。但是,我使用了位于BottomNavigationBar中的BottomAppBar,而不是AppBar。如何让Drawer与BottomAppBar一起使用?这是我的代码下面没有出现抽屉classhomieclassextendsState{@覆盖小部件构建(BuildContext上下文){返回Material应用程序(debugShowCheckedModeBanner:假,家:新脚手架(backgroundColor:Colors.white70.withOpacity(0.
我注意到Scaffold.drawer的Drawer只有在存在Scaffold的AppBar时才会显示。但是,我使用了位于BottomNavigationBar中的BottomAppBar,而不是AppBar。如何让Drawer与BottomAppBar一起使用?这是我的代码下面没有出现抽屉classhomieclassextendsState{@覆盖小部件构建(BuildContext上下文){返回Material应用程序(debugShowCheckedModeBanner:假,家:新脚手架(backgroundColor:Colors.white70.withOpacity(0.
如您所见,我的按钮位于Scaffold内的body。但我得到了这个异常(exception):使用不包含Scaffold的上下文调用Scaffold.of()。import'package:flutter/material.dart';voidmain()=>runApp(MyApp());classMyAppextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){returnMaterialApp(title:'FlutterDemo',theme:ThemeData(primarySwatch:Colors.
如您所见,我的按钮位于Scaffold内的body。但我得到了这个异常(exception):使用不包含Scaffold的上下文调用Scaffold.of()。import'package:flutter/material.dart';voidmain()=>runApp(MyApp());classMyAppextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){returnMaterialApp(title:'FlutterDemo',theme:ThemeData(primarySwatch:Colors.