Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. //'this is a placeholderwidget.dart'
  2.  
  3. class PlaceholderWidget extends StatelessWidget {
  4. final Color color;
  5.  
  6. PlaceholderWidget(this.color);
  7.  
  8. @override
  9. Widget build(BuildContext context) {
  10. return Container(
  11. color: color,
  12. );
  13. }
  14. }
  15.  
  16.  
  17. //'this is home.dart'
  18.  
  19. import 'package:flutter/material.dart';
  20. import 'placeholder_widget.dart';
  21.  
  22. class Home extends StatefulWidget {
  23. @override
  24. State<StatefulWidget> createState() {
  25. return _HomeState();
  26. }
  27. }
  28.  
  29. class _HomeState extends State<Home> {
  30. int _currentIndex = 0;
  31. final List<Widget> _children = [
  32. PlaceholderWidget(Colors.white),
  33. PlaceholderWidget(Colors.deepOrange),
  34. PlaceholderWidget(Colors.green),
  35. PlaceholderWidget(Colors.blueAccent)
  36. ];
  37. void onTabTapped(int index) {
  38. setState(() {
  39. _currentIndex = index;
  40. });
  41. }
  42. @override
  43. Widget build(BuildContext context) {
  44. return Scaffold(
  45. body: _children[_currentIndex],
  46. bottomNavigationBar: BottomNavigationBar(
  47. onTap: onTabTapped,
  48. currentIndex: _currentIndex,
  49. type: BottomNavigationBarType.fixed,
  50. selectedItemColor: Colors.black,
  51. unselectedItemColor: Colors.blue,
  52. items: [
  53. BottomNavigationBarItem(
  54. icon: new Icon(Icons.home),
  55. title: new Text('Home'),
  56. ),
  57. BottomNavigationBarItem(
  58. icon: new Icon(Icons.map),
  59. title: new Text('Map',
  60. ),
  61. ),
  62. BottomNavigationBarItem(
  63. icon: new Icon(Icons.language),
  64. title: new Text('Useful Links'),
  65. ),
  66. BottomNavigationBarItem(
  67. icon: new Icon(Icons.calendar_today),
  68. title: new Text('Calendar'),
  69. ),
  70. ]
  71. ),
  72. );
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement