Advertisement
Sebuahhobi98

error assets

May 17th, 2022
1,244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 2.62 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:smart_relay/theme.dart';
  3. import 'home_page.dart';
  4.  
  5. class MainPage extends StatefulWidget {
  6.   @override
  7.   State<MainPage> createState() => _MainPageState();
  8. }
  9.  
  10. class _MainPageState extends State<MainPage> {
  11.   int currentIndex = 0;
  12.  
  13.   @override
  14.   Widget build(BuildContext context) {
  15.     Widget customBottomNav() {
  16.       return ClipRRect(
  17.         borderRadius: BorderRadius.vertical(
  18.           top: Radius.circular(30),
  19.         ),
  20.         child: BottomAppBar(
  21.           shape: CircularNotchedRectangle(),
  22.           notchMargin: 12,
  23.           clipBehavior: Clip.antiAlias,
  24.           child: BottomNavigationBar(
  25.             backgroundColor: backgroundColor4,
  26.             currentIndex: currentIndex,
  27.             onTap: (value) {
  28.               setState(() {
  29.                 currentIndex = value;
  30.               });
  31.             },
  32.             type: BottomNavigationBarType.fixed,
  33.             items: [
  34.               BottomNavigationBarItem(
  35.                 icon: Container(
  36.                   margin: const EdgeInsets.only(
  37.                     top: 20,
  38.                     bottom: 10,
  39.                   ),
  40.                   child: Image.asset(
  41.                     'assets/icon_home.png',
  42.                     width: 21,
  43.                     color: currentIndex == 0 ? primaryColor : Color(0xff808191),
  44.                   ),
  45.                 ),
  46.                 label: '',
  47.               ),
  48.               BottomNavigationBarItem(
  49.                 icon: Container(
  50.                   margin: EdgeInsets.only(
  51.                     top: 20,
  52.                     bottom: 10,
  53.                   ),
  54.                   child: Image.asset(
  55.                     'assets/icon_home.png',
  56.                     width: 18,
  57.                     color: currentIndex == 3 ? primaryColor : Color(0xff808191),
  58.                   ),
  59.                 ),
  60.                 label: '',
  61.               ),
  62.             ],
  63.           ),
  64.         ),
  65.       );
  66.     }
  67.  
  68.     Widget body() {
  69.       switch (currentIndex) {
  70.         case 0:
  71.           return HomePage();
  72.         // case 1:
  73.         //   return ChatPage();
  74.         // case 2:
  75.         //   return WishlistPage();
  76.         // case 3:
  77.         //   return ProfilePage();
  78.  
  79.         default:
  80.           return HomePage();
  81.       }
  82.       ;
  83.     }
  84.  
  85.     return Scaffold(
  86.       backgroundColor: currentIndex == 0 ? backgroundColor1 : backgroundColor3,
  87.       // floatingActionButton: cartButton(),
  88.       floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
  89.       bottomNavigationBar: customBottomNav(),
  90.       body: body(),
  91.     );
  92.   }
  93. }
  94.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement