Skip to content

Instantly share code, notes, and snippets.

@Jahidul007
Created December 23, 2021 19:34
Show Gist options
  • Save Jahidul007/74520ea23873ba6f5de63cce93064574 to your computer and use it in GitHub Desktop.
Save Jahidul007/74520ea23873ba6f5de63cce93064574 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: _title,
home: MainPage(),
);
}
}
class MainPage extends StatefulWidget {
const MainPage({Key? key}) : super(key: key);
@override
State<MainPage> createState() => _MainPageState();
}
class _MainPageState extends State<MainPage> {
int currentIndex = 0;
final screens = const[
HomePage(),
BuisnessPage(),
HomePage(),
BuisnessPage(),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Bottom Navigation Bar'),
centerTitle: true,
),
body: screens[currentIndex],
bottomNavigationBar: BottomNavigationBar(
backgroundColor: Colors.white70,
selectedItemColor: Colors.white,
unselectedItemColor: Colors.grey,
type: BottomNavigationBarType.fixed,
iconSize: 30,
//selectedFontSize: 16,
//unselectedFontSize: 14,
//showUnselectedLabels: false,
currentIndex: currentIndex,
onTap: (index) => setState(() => currentIndex = index),
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Home',
backgroundColor: Colors.red,
),
BottomNavigationBarItem(
icon: Icon(Icons.business),
label: 'Business',
backgroundColor: Colors.green,
),
BottomNavigationBarItem(
icon: Icon(Icons.school),
label: 'School',
backgroundColor: Colors.purple,
),
BottomNavigationBarItem(
icon: Icon(Icons.settings),
label: 'Settings',
backgroundColor: Colors.pink,
),
],
),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: const Text('Test A'),
),
body:
const Center(child: Text('Test A', style: TextStyle(fontSize: 60))),
);
}
class BuisnessPage extends StatelessWidget {
const BuisnessPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: const Text('Test B'),
),
body:
const Center(child: Text('Test B', style: TextStyle(fontSize: 60))),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment