main.dart 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import 'package:flutter/material.dart';
  2. import 'single_board_list_example.dart';
  3. import 'multi_board_list_example.dart';
  4. void main() {
  5. runApp(const MyApp());
  6. }
  7. class MyApp extends StatefulWidget {
  8. const MyApp({Key? key}) : super(key: key);
  9. @override
  10. State<MyApp> createState() => _MyAppState();
  11. }
  12. class _MyAppState extends State<MyApp> {
  13. int _currentIndex = 0;
  14. final _bottomNavigationColor = Colors.blue;
  15. final List<Widget> _examples = [
  16. const MultiBoardListExample(),
  17. const SingleBoardListExample(),
  18. ];
  19. @override
  20. void initState() {
  21. super.initState();
  22. }
  23. @override
  24. Widget build(BuildContext context) {
  25. return MaterialApp(
  26. home: Scaffold(
  27. appBar: AppBar(
  28. title: const Text('AppFlowy Board'),
  29. ),
  30. body: Container(color: Colors.white, child: _examples[_currentIndex]),
  31. bottomNavigationBar: BottomNavigationBar(
  32. fixedColor: _bottomNavigationColor,
  33. showSelectedLabels: true,
  34. showUnselectedLabels: false,
  35. currentIndex: _currentIndex,
  36. items: [
  37. BottomNavigationBarItem(
  38. icon: Icon(Icons.grid_on, color: _bottomNavigationColor),
  39. label: "MultiColumn"),
  40. BottomNavigationBarItem(
  41. icon: Icon(Icons.grid_on, color: _bottomNavigationColor),
  42. label: "SingleColumn"),
  43. ],
  44. onTap: (int index) {
  45. setState(() {
  46. _currentIndex = index;
  47. });
  48. },
  49. )),
  50. );
  51. }
  52. }