我正在制作一个颤振应用程序,其中我需要两个放置一个小部件,这对于多个屏幕来说很常见。这是屏幕一的构建方法的代码
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: app_color,
body: _isLoading == false ? Stack(
new Container(//used for whole screen ),
Positioned(
left: 0,
right: 0,
bottom: 0,
//a bottom tab like which is common across screens
),
],
)
:
//code to show progress indicator while loading data in background
Stack(
children: <Widget>[
Center(
child:Container(
height: 50,
width: 50,
child: CircularProgressIndicator(),
)
),
Positioned(
left: 0,
right: 0,
bottom: 0,
//keep this to show bottom tab while loading
), …Run Code Online (Sandbox Code Playgroud) 我正在制作一个颤动应用程序,其中我使用主体作为堆栈,在这个堆栈中我有两个子项。一个是主体,另一个是位于屏幕顶部的后退按钮。堆栈的第一个子项是滚动视图。这是我的构建方法。
Widget build(BuildContext context) {
return Scaffold(
//debugShowCheckedModeBanner: false,
key: scaffoldKey,
backgroundColor: Color(0xFF5E68A6),
body: Stack(
children: <Widget>[
Container(
margin: const EdgeInsets.fromLTRB(0.0, 10.0 , 0.0 , 0.0 ),
height: double.infinity,
child:CustomScrollView(
slivers: <Widget>[
new Container(
margin: EdgeInsets.all(15.0),
child:Text(getTitle(),
style: TextStyle(fontSize: 20.0,fontWeight: FontWeight.bold,color: Colors.white),
),
),
//middle section
_isLoading == false ?
new Expanded(child: GridView.builder(
itemCount: sub_categories_list.length,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
itemBuilder: (context, position){
return InkWell(
child: new Container(
//color: Colors.white,
padding: EdgeInsets.all(20),
margin: EdgeInsets.all(10),
height: 130,
width: 130,
child: …Run Code Online (Sandbox Code Playgroud) 我是 flutter 应用程序开发的新手,遇到了一个问题。我的应用程序包含大约 5-6 个屏幕,所有屏幕都包含像这样的脚手架小部件。
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFF332F43)
);
}
Run Code Online (Sandbox Code Playgroud)
现在在所有屏幕上我都有相同的概念和设计,并且所有屏幕将共享相同的背景颜色。现在我在所有屏幕上都有一个按钮,即“更改主题”按钮,然后单击我想要更改的“更改主题”按钮所有屏幕支架小部件都要更改。现在我怎样才能实现这一点?请帮助我解决我的问题。
我面临一个问题,在 flutter 中更改屏幕后不调用 dispose 方法。首先这里是源代码。
class Game extends StatefulWidget {
Game({Key key, this.title}) : super(key: key);
final String title;
@override
_GameState createState() => new _GameState();
}
class _GameState extends State<Game> with SingleTickerProviderStateMixin {
final CrosswordController myController = CrosswordController();
var chewieController = null;
var videoPlayerController = null;
Widget makeVideoStreaming(){
videoPlayerController = VideoPlayerController.network("https://somelink.com");
chewieController = ChewieController(//paramtere here
);
}
@override
void initState() {
super.initState();
this.makeVideoStreaming();
_controller = AnimationController(vsync: this, duration: Duration(minutes: gameTime));
}
@override
void dispose(){
print('DISPOSE CALLED- GAME---');
videoPlayerController.dispose();
chewieController.dispose();
_controller.dispose(); …Run Code Online (Sandbox Code Playgroud)