小编raf*_*tta的帖子

Flutter TabBar 和 TabBarView 在应用程序主体内

我试图像这样为我的应用程序构建一个 UI。但是选项卡的视图不可见。我在许多 flutter 应用程序中使用过标签,但 UI 必须完全像下面一样

  • 以图片为背景的应用栏
  • appbar 部分中用户图像的一半部分,其余部分位于其下方
  • 这些下面的标签栏。. . .

当前用户界面 在此处输入图片说明

我的代码在这里

class _MyHomePageState extends State<MyHomePage> with 
TickerProviderStateMixin{
double screenSize;
double screenRatio;
AppBar appBar;
List<Tab> tabList = List();
TabController _tabController;
@override
void initState() {
tabList.add(new Tab(text:'Overview',));
tabList.add(new Tab(text:'Workouts',));
_tabController = new TabController(vsync: this, length: 
tabList.length);
super.initState();
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
screenSize = MediaQuery.of(context).size.width;
appBar = AppBar(
 backgroundColor: Colors.transparent,
 elevation: 0.0,
);
return Container(
 color: Colors.white,
 child: Stack(
   children: <Widget>[
     new …
Run Code Online (Sandbox Code Playgroud)

flutter flutter-layout

15
推荐指数
2
解决办法
2万
查看次数

Flutter不会重建具有不同参数的相同小部件

我正在使用类似的子窗口小部件进行底部导航,其中仅更改了参数。仅当小部件为StatefulWidget时才发生此问题,否则没有问题,bottomnavbar中的指示正在更改,但主体没有更改。

儿童1: 在此处输入图片说明

儿童2: 在此处输入图片说明

实际结果: 在此处输入图片说明

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;

@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
Widget body;
@override
void initState() {
//    body = getBody(0);
super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
  appBar: AppBar(
    title: Text(widget.title),
    elevation: 0,
  ),
  body: body,
  bottomNavigationBar: BottomNavigationBar(
    currentIndex: _counter,
    onTap: (index){
      _counter = index;
      setState(() {
        body = getBody(index);
      });
    },items: [ …
Run Code Online (Sandbox Code Playgroud)

dart flutter flutter-layout

7
推荐指数
1
解决办法
750
查看次数

标签 统计

flutter ×2

flutter-layout ×2

dart ×1