Dashboard Example in Flutter with Bottom navigation Bar

Jyotishgher Astrology
By -
0


Dashboard Example in Flutter with Bottom navigation Bar




import 'package:flutter/material.dart';
import 'package:carousel_pro/carousel_pro.dart';
import 'package:flutter_app/splash_screen.dart';

import 'main_dashboard.dart';

void main() => runApp(MyApp());

var globalContext; // Declare global variable to store context from StatelessWidget/// This Widget is the main application widget.class MyApp extends StatelessWidget {
  static const String _title = 'Flutter Code Sample';

  @override  Widget build(BuildContext context) {

   
    return MaterialApp(
      title: _title,
    //  debugShowCheckedModeBanner: false,      theme: ThemeData(
          primarySwatch: Colors.deepPurple      ),
      home: MyStatefulWidget(),
    );
  }
}

class MyStatefulWidget extends StatefulWidget {
  MyStatefulWidget({Key key}) : super(key: key);

  @override  _MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}

class _MyStatefulWidgetState extends State<MyStatefulWidget> {
  int _selectedIndex = 0;
  static const TextStyle optionStyle =
      TextStyle(fontSize: 30, fontWeight: FontWeight.bold);



  static const List<Widget> _widgetOptions = <Widget>[
    Text(
      'Index 0: Home',
      style: optionStyle,
    ),
    Text(
      'Index 1: Business',
      style: optionStyle,
    ),
    Text(
      'Index 2: School',
      style: optionStyle,
    ),
  ];

  void _onItemTapped(int index) {
    setState(() {
      _selectedIndex = index;

      if (_selectedIndex == 0) {
        Login(); //directly call the class to load      } else if (_selectedIndex == 1) {

      } else if (_selectedIndex == 2) {
        Login(); //directly call the class to load      }
    });
  }

  @override  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('RCF KAPURTHALA'),
          elevation: .1,
          backgroundColor: Color.fromRGBO(49, 87, 110, 1.0),
        ),
        body: Container(
          padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 2.0),
          child: GridView.count(
            crossAxisCount: 2,
            padding: EdgeInsets.all(3.0),
            children: <Widget>[


              makeDashboardItem("Ordbog", Icons.book),
              makeDashboardItem("Alphabet", Icons.alarm),
              makeDashboardItem("Alphabet", Icons.alarm),
              makeDashboardItem("Alphabet", Icons.alarm),
              makeDashboardItem("Alphabet", Icons.alarm),
              makeDashboardItem("Alphabet", Icons.alarm)
            ],
          ),
        ),

        bottomNavigationBar: BottomNavigationBar(
          items: const <BottomNavigationBarItem>[
            BottomNavigationBarItem(
              icon: Icon(Icons.home),
              title: Text('Home'),
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.business),
              title: Text('Staff Corner'),
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.school),
              title: Text('Forms'),
            ),
          ],
          currentIndex: _selectedIndex,
          selectedItemColor: Colors.amber[800],
          onTap: _onItemTapped,
        ),
      );

  }

  void Login() {
    Navigator.pushReplacement(
        context, MaterialPageRoute(builder: (context) => main_dasboard()));
  }
}

Card makeDashboardItem(String title, IconData icon) {
  return Card(
      elevation: 1.0,
      margin: new EdgeInsets.all(8.0),
      child: Container(
        decoration: BoxDecoration(color: Color.fromRGBO(220, 220, 220, 1.0)),
        child: new InkWell(
          onTap: () {},
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            mainAxisSize: MainAxisSize.min,
            verticalDirection: VerticalDirection.down,
            children: <Widget>[
              SizedBox(height: 50.0),
              Center(
                  child: Icon(
                    icon,
                    size: 40.0,
                    color: Colors.black,
                  )),
              SizedBox(height: 20.0),
              new Center(
                child: new Text(title,
                    style:
                    new TextStyle(fontSize: 18.0, color: Colors.black)),
              )
            ],
          ),
        ),
      ));
}





Post a Comment

0Comments

Post a Comment (0)