Add svg in custom bottomnavigation menu flutter

1

Good day. I need paste svg image between custom icons. Custom BottomNavigationBarItem in flutter. I can't paste image between custom icons. How to do it,

enter image description here

My code

class NavBarCustomer extends StatefulWidget {
@override
_NavBarCustomerState createState() => _NavBarCustomerState();
}

class _NavBarCustomerState extends State<NavBarCustomer> {
int _itemIndex = 0;
final List<Widget> _pages = [
HomeScreenCustomer(),
AllRequests(),
NewRequest(),
NotificationPage(),
MainSettings(),
];

 @override
 Widget build(BuildContext context) {
 return Scaffold(
  body: _pages[_itemIndex],
  bottomNavigationBar: BottomNavigationBar(
    backgroundColor: Colors.white,
    selectedItemColor: Color(0xFF606060),
    unselectedItemColor: Color(0x80606060),
    type: BottomNavigationBarType.fixed,
    items: <BottomNavigationBarItem>[
      navBarItem('Главная',
          index: 0,
          icon: CustomIcons.home,
          firstColor: Color(0xFF02EFFD),
          secondColor: Color(0xFF48AFFD)),
      navBarItem('Мои заявки',
          index: 1,
          icon: Icons.check_circle_outline,
          firstColor: Color(0xFF34F8DA),
          secondColor: Color(0xFF43E980),
          badgeCounter: 0),
      navBarItem('',
          iconImage: Image.asset('assets/images/adding-icon.png')),
      navBarItem('Уведомления',
          index: 3,
          icon: CustomIcons.notification,
          firstColor: Color(0xFFFFBCDE),
          secondColor: Color(0xFFFC337C),
          badgeCounter: 0),
      navBarItem('Настройки',
          index: 4,
          icon: CustomIcons.settings,
          firstColor: Color(0xFFA3D5FF),
          secondColor: Color(0xFF6581D2)),
    ],
    currentIndex: _itemIndex,
    onTap: (index) => setState(() {
      _itemIndex = index;
    }),
     ),
     );
     }

  BottomNavigationBarItem navBarItem(String title,
  {int badgeCounter = 0,
  IconData icon,
  Image iconImage,
  double iconSize,
  Color firstColor,
  Color secondColor,
  int index}) {
  return BottomNavigationBarItem(
  title: Text(title,
          style: TextStyle(
              color: Color(
                  0xFF606060 - ((index == _itemIndex) ? 0 : 0x90000000)),
              fontSize: 11.w,
              fontWeight: FontWeight.w500))
      .padding(EdgeInsets.only(top: 7.w)),
  icon: Stack(
    alignment: Alignment.topRight,
    children: <Widget>[
      Opacity(
        opacity: (index == _itemIndex) ? 1 : 0.5,
        child: RoundedGradientIcon(
          iconSize: iconSize,
          firstColor: firstColor,
          secondColor: secondColor,
          icon: icon,
          radius: 30.w,
        ),
      ),
      Visibility(
        visible: badgeCounter != 0,
        child: Container(
          padding: EdgeInsets.all(1.w),
          height: 15.w,
          width: 15.w,
          alignment: Alignment.center,
          child: AutoSizeText(
            badgeCounter.toString(),
            minFontSize: 6,
            style: TextStyle(
                fontSize: 10.w,
                color: Colors.white,
                fontWeight: FontWeight.bold),
          ),
          decoration: BoxDecoration(
            color: Color(0xFFFF0000),
            borderRadius: BorderRadius.circular(100),
          ),
         

When I paste image, write error "The argument type 'Image' can't be assigned to the parameter type 'IconData'.",

Please help. Thanks.

flutter
flutter-dependencies

1 Answer

0

Try ImageIcon instead of IconData.

answered on Stack Overflow Sep 11, 2020 by Md. Khairul Islam

User contributions licensed under CC BY-SA 3.0