• nav 选项卡


    代码:

    import 'package:flutter/material.dart';

    class KeepAliveDemo extends StatefulWidget {
    @override
    _KeepAliveDemoState createState() => _KeepAliveDemoState();
    }
    //with类似多重继承
    class _KeepAliveDemoState extends State<KeepAliveDemo> with SingleTickerProviderStateMixin {
    TabController _controller;

    @override
    void initState(){

    super.initState();
    _controller = TabController(length: 3,vsync: this);//vsync 垂直
    }
    @override
    void dispose(){
    _controller.dispose();
    super.dispose();
    }

    @override
    Widget build(BuildContext context) {
    return Scaffold(
    appBar: AppBar(
    title: Text('keepAlive'),
    elevation: 8.0,
    bottom: TabBar(
    controller: _controller,
    tabs: <Widget>[
    Tab(icon: Icon(Icons.directions_bike)),
    Tab(icon: Icon(Icons.directions_boat)),
    Tab(icon: Icon(Icons.directions_car)),
    ],
    ),
    ),
    body: TabBarView(
    controller: _controller,
    children: <Widget>[
    Text('111'),
    Text('222'),
    Text('333')
    ],
    ),
    );
    }
    }
    总结:

    导航栏下嵌套tabController

    final TabController _controller

     

     

    多重继承with 关键字

    初始化

    _controller = TabController(length:xx,vsync:this)//vsync 继承于 SingleTickerProviderStateMixin 垂直布局

     

    flutter 的tabController 是个模型 里面可以直接放数据 

    appBar 放 tabController

    appBar(

    bottom:Tabbar(

    controller : _controller

    tabs:<widget>[//次数个数要和上面的length 个数对应

    Tab(icon:xxx)//

    Tab(icon:xxx)//

    Tab(icon:xxx)//

    ]

    )

    )

  • 相关阅读:
    git checkout 命令详解
    Ubuntu下配置samba实现文件夹共享
    修改Apache配置文件开启gzip压缩传输
    java调用shell获取返回值
    VMWARE虚拟机CentOS6.4系统使用主机无线网卡上网的三种方法介绍
    Source Insight 3.X utf8支持插件震撼发布
    Sizeof与Strlen的区别与联系
    推荐!手把手教你使用Git
    base64编码、解码的C语言实现
    C语言中main函数的参数
  • 原文地址:https://www.cnblogs.com/pp-pping/p/12180554.html
Copyright © 2020-2023  润新知