SHARE
TWEET

Untitled

a guest Jan 17th, 2020 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class MyApp extends StatefulWidget {
  2.   @override
  3.   State<StatefulWidget> createState() {
  4.     return MyAppState();
  5.   }
  6. }
  7.  
  8.  
  9. class MyAppState extends State<MyApp> with WidgetsBindingObserver {
  10.   var lastloaded;
  11. bool isInactive;
  12. int _selectedPage = 0;
  13. final _pageOptions = [
  14.   HomePage(),
  15.   CategoriesPage(),
  16.   Deals(),
  17.   ProfileAccount(),
  18.   CartPage(),
  19. ];
  20.  
  21. @override
  22.   void initState() {
  23.     super.initState();
  24.     WidgetsBinding.instance.addObserver(this);
  25.   }
  26.  
  27.   @override
  28.   void dispose() {
  29.     WidgetsBinding.instance.removeObserver(this);
  30.     super.dispose();
  31.   }
  32.  
  33.   @override
  34.   void didChangeAppLifecycleState(AppLifecycleState state) {
  35.     super.didChangeAppLifecycleState(state);
  36.     switch(state){
  37.       case AppLifecycleState.paused:
  38.       print("p");
  39.       break;
  40.       case AppLifecycleState.resumed:
  41.       print("r");
  42.       break;
  43.       case AppLifecycleState.inactive:
  44.       print("I");
  45.       break;
  46.       case AppLifecycleState.detached:
  47.       print("D");
  48.       break;
  49.     }
  50.   }
  51.  
  52.   @override
  53.   Widget build(BuildContext context) {
  54.     return MaterialApp(
  55.       debugShowCheckedModeBanner: false,
  56.       title: 'Sync Shop',
  57.       theme: ThemeData(
  58.         primarySwatch: Colors.blue,
  59.       ),
  60.       home: Scaffold(
  61.       body: IndexedStack(
  62.         index: _selectedPage,
  63.         children: _pageOptions,
  64.       ),
  65.       bottomNavigationBar: BottomNavigationBar(
  66.           type: BottomNavigationBarType.fixed,
  67.           currentIndex: _selectedPage,
  68.           onTap: (int index) {
  69.             setState((){
  70.       _selectedPage = index;
  71.             });
  72.           },
  73.           items: [
  74.           BottomNavigationBarItem(icon: Image.asset("assets/home.png",
  75.             height: 25,
  76.             width: 25,
  77.           ),
  78.           title: Text("Home",),
  79.           activeIcon:
  80.           Image.asset("assets/home-active.png",
  81.             height: 25,
  82.             width: 25,
  83.           )
  84.           ),
  85.           BottomNavigationBarItem(icon: Image.asset("assets/categories.png",
  86.             height: 22,
  87.             width: 22,
  88.           ),
  89.           title: Text("Categories",),
  90.           activeIcon:
  91.           Image.asset("assets/categories-active.png",
  92.             height: 22,
  93.             width: 22,
  94.           ),
  95.           ),
  96.           BottomNavigationBarItem(icon: Image.asset("assets/deals.png",
  97.             height: 25,
  98.             width: 25,
  99.           ),
  100.           title: Text("Deals",),
  101.           activeIcon:
  102.             Image.asset("assets/deals-active.png",
  103.             height: 25,
  104.             width: 25,
  105.           )
  106.           ),
  107.           BottomNavigationBarItem(icon: Image.asset("assets/profile.png",
  108.             height: 25,
  109.             width: 25,
  110.           ), title: Text("Profile",),
  111.           activeIcon:
  112.          Image.asset("assets/profile-active.png",
  113.             height: 25,
  114.             width: 25,
  115.           )
  116.           ),
  117.           BottomNavigationBarItem(icon: Image.asset("assets/cart.png",
  118.             height: 25,
  119.             width: 25,
  120.           ), title: Text("Cart"),
  121.           activeIcon:
  122.           Image.asset("assets/cart-active.png",
  123.             height: 25,
  124.             width: 25,
  125.           ),
  126.           ),
  127.           ],
  128.  
  129.           unselectedLabelStyle: TextStyle(color: Colors.grey[600], fontSize: 11),
  130.           selectedItemColor: Color(0xFFEF5021),
  131.           selectedLabelStyle: TextStyle(fontWeight: FontWeight.bold, fontSize: 12),
  132.           ),
  133.       ),
  134.       );
  135.   }
  136. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top