【发布时间】:2018-09-21 15:50:55
【问题描述】:
我正在开发一个具有 2 个选项卡视图的应用程序,并且想要一个永久的背景图像,同时能够在 2 个选项卡之间滑动或导航。这是小部件的代码:
class MyTabs extends StatefulWidget {
@override
MyTabsState createState() => new MyTabsState();
}
class MyTabsState extends State<MyTabs> with SingleTickerProviderStateMixin {
TabController controller;
@override
void initState() {
super.initState();
controller = new TabController(length: 2, vsync: this);
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Divot', style: new TextStyle(fontFamily: 'Pacifico')),
centerTitle: true,
backgroundColor: Colors.green,
bottom: new TabBar(
controller: controller,
tabs: <Tab>[
new Tab(icon: new Icon(Icons.golf_course)),
new Tab(icon: new Icon(Icons.account_circle)),
]),
),
body: new Stack(
children: <Widget>[
new Container(
decoration: new BoxDecoration(
image: new DecorationImage(image: new AssetImage("image"), fit: BoxFit.fill,),
),
),
new TabBarView(
controller: controller,
children: <Widget>[
new second.GameMenu(),
new third.MyProfilePage(),
],
)
],
)
);
}
}
我没有收到任何错误,但我在第一个选项卡上得到了白色背景,在第二个选项卡上得到了我的 AssetImage 背景。我错过了什么?
【问题讨论】:
标签: image user-interface flutter