istediğiniz bu tarz birşey mi?
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'TabBar Örnek',
debugShowCheckedModeBanner: false,
home: TabBarim(),
);
}
}
class TabBarim extends StatefulWidget {
@override
_TabBarimState createState() => _TabBarimState();
}
class _TabBarimState extends State<TabBarim>
with SingleTickerProviderStateMixin {
///BURAYA DİKKAT <==
TabController controller;
@override
void initState() {
super.initState();
controller = TabController(length: 3, vsync: this);
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
TabBar getTabBar() {
return TabBar(
controller: controller,
tabs: <Tab>[
Tab(text: "Notlarım", icon: Icon(Icons.favorite)),
Tab(text: "Siparişleri Excel e aktar", icon: Icon(Icons.adb)),
Tab(text: "3", icon: Icon(Icons.airport_shuttle)),
],
);
}
TabBarView getTabBarView(var sayfalar) {
return TabBarView(
children: sayfalar,
controller: controller,
);
}
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Tabbar Kullanım"),
backgroundColor: Colors.blue,
bottom: getTabBar()),
body: getTabBarView(
<Widget>[
Birince(),
Ikinci(),
Ucuncu(),
],
),
);
}
}
class Birince extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
height: 550,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Icon(Icons.android, size: 150.0, color: Colors.red),
NavBar(),
],
),
),
);
}
}
class Ikinci extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Icon(Icons.headset, size: 150.0, color: Colors.green),
NavBar(),
],
),
),
);
}
}
class Ucuncu extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Icon(Icons.phone_android, size: 150.0, color: Colors.black),
NavBar(),
],
),
),
);
}
}
class NavBar extends StatefulWidget {
@override
_NavBarState createState() => _NavBarState();
}
class _NavBarState extends State<NavBar> {
@override
Widget build(BuildContext context) {
return BottomNavigationBar(
//currentIndex: activeButton,
backgroundColor: Colors.blue.shade700,
fixedColor: Colors.white,
unselectedItemColor: Colors.white,
type: BottomNavigationBarType.fixed,
elevation: MediaQuery.of(context).size.height,
onTap: (index) {
setState(() {
//activeButton = index;
});
if (index == 0) {
// Navigator.push(context, MaterialPageRoute(builder:(context)=>AddOrder()));
print("1. Sayfaya gittim ben");
} else if (index == 1) {
// Navigator.push(context, MaterialPageRoute(builder:(context)=>AddOrder()));
print("2. Sayfaya gittim ben");
} else if (index == 2) {
// Navigator.push(context, MaterialPageRoute(builder:(context)=>AddOrder()));
print("3. Sayfaya gittim ben");
}
},
items: [
BottomNavigationBarItem(
icon: Icon(Icons.add),
title: Text('Sipariş Ekle'),
),
BottomNavigationBarItem(
icon: Icon(Icons.add_comment),
title: Text('Not Ekle'),
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
title: Text('Müşteri Ekle'),
),
],
);
}
}
Buradaki dökümandan faydalandım: https://necipakgoz.com/category/flutter/