Navigation - BottomTabbar
BottomTabbar
Source Code
import 'package:flutter/material.dart';
void main() {
runApp( MaterialApp(
title:" BottomTabbar ",
home:Scaffold(appBar: AppBar(title: Text(' BottomTabbar ',),),
body: Material(
child: Center(
child:
BottomTabbarExample()
,
),
) ,
),
));
}
class BottomTabbarExample extends StatefulWidget {
const BottomTabbarExample({Key? key}) : super(key: key);
@override
State<StatefulWidget> createState() => _BottomTabbarExampleState();
}
class _BottomTabbarExampleState extends State<BottomTabbarExample>
with SingleTickerProviderStateMixin {
late TabController _tabController;
static const _kTabPages = <Widget>[
Center(child: Icon(Icons.cloud, size: 64.0, color: Colors.teal)),
Center(child: Icon(Icons.alarm, size: 64.0, color: Colors.cyan)),
Center(child: Icon(Icons.forum, size: 64.0, color: Colors.blue)),
];
static const _kTabs = <Tab>[
Tab(icon: Icon(Icons.cloud), text: 'Tab1'),
Tab(icon: Icon(Icons.alarm), text: 'Tab2'),
Tab(icon: Icon(Icons.forum), text: 'Tab3'),
];
@override
void initState() {
super.initState();
_tabController = TabController(
length: _kTabPages.length,
vsync: this,
);
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: TabBarView(
controller: _tabController,
children: _kTabPages,
),
bottomNavigationBar: Material(
color: Colors.blue,
child: TabBar(
tabs: _kTabs,
controller: _tabController,
),
),
);
}
}
Comments
Post a Comment