Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //'this is a placeholderwidget.dart'
- class PlaceholderWidget extends StatelessWidget {
- final Color color;
- PlaceholderWidget(this.color);
- @override
- Widget build(BuildContext context) {
- return Container(
- color: color,
- );
- }
- }
- //'this is home.dart'
- import 'package:flutter/material.dart';
- import 'placeholder_widget.dart';
- class Home extends StatefulWidget {
- @override
- State<StatefulWidget> createState() {
- return _HomeState();
- }
- }
- class _HomeState extends State<Home> {
- int _currentIndex = 0;
- final List<Widget> _children = [
- PlaceholderWidget(Colors.white),
- PlaceholderWidget(Colors.deepOrange),
- PlaceholderWidget(Colors.green),
- PlaceholderWidget(Colors.blueAccent)
- ];
- void onTabTapped(int index) {
- setState(() {
- _currentIndex = index;
- });
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: _children[_currentIndex],
- bottomNavigationBar: BottomNavigationBar(
- onTap: onTabTapped,
- currentIndex: _currentIndex,
- type: BottomNavigationBarType.fixed,
- selectedItemColor: Colors.black,
- unselectedItemColor: Colors.blue,
- items: [
- BottomNavigationBarItem(
- icon: new Icon(Icons.home),
- title: new Text('Home'),
- ),
- BottomNavigationBarItem(
- icon: new Icon(Icons.map),
- title: new Text('Map',
- ),
- ),
- BottomNavigationBarItem(
- icon: new Icon(Icons.language),
- title: new Text('Useful Links'),
- ),
- BottomNavigationBarItem(
- icon: new Icon(Icons.calendar_today),
- title: new Text('Calendar'),
- ),
- ]
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement