nav tab

Code:

import 'package:flutter/material.dart';

class KeepAliveDemo extends StatefulWidget {
@override
_KeepAliveDemoState createState() => _KeepAliveDemoState();
}
// with similar multiple inheritance
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)),
],
),
),
Piece: Tabs View (
controller: _controller,
children: <Widget>[
Text('111'),
Text('222'),
Text('333')
],
),
);
}
}
to sum up:

Nested tabController lower navigation bar

final TabController _controller

 

 

Multiple inheritance with with keywords

initialization

= tabController _controller (length: XX , VSYNC: the this ) // VSYNC inherit SingleTickerProviderStateMixin vertical layout

 

flutter of tabController is a model which can put data directly 

appBar next release tabController

appBar (

bottom: Tabs (

controller : _controller

tabs: <the widget> [// number of times and for a length above corresponding to the number

Tab(icon:xxx)//

Tab(icon:xxx)//

Tab(icon:xxx)//

]

)

)

Guess you like

Origin www.cnblogs.com/pp-pping/p/12180554.html
Tab
Tab
Tab
Tab