skip to Main Content

When I am used BottomNavigationBarItem, I can’t showing my navigation icons.

I am trying this code:

import 'package:flutter/material.dart';
import 'package:task_manager/style/style.dart';

BottomNavigationBar AppBottomNav(currentIndex, OnItemTapped) {
  return BottomNavigationBar(
    items: const [
      BottomNavigationBarItem(
        icon: Icon(Icons.list_alt),
        label: "New",
      ),
      BottomNavigationBarItem(
        icon: Icon(Icons.access_time_rounded),
        label: "Progress",
      ),
      BottomNavigationBarItem(
        icon: Icon(Icons.check_circle_outlined),
        label: "Completed",
      ),
      BottomNavigationBarItem(
        icon: Icon(Icons.cancel),
        label: "Canceled",
      ),
    ],
    selectedItemColor: colorGreen,
    unselectedItemColor: colorLightGray,
    currentIndex: currentIndex,
    showSelectedLabels: true,
    showUnselectedLabels: true,
    onTap: OnItemTapped,
    type: BottomNavigationBarType.shifting,
  );
}

Result

2

Answers


  1. You need to set uses-material-design: true in pubspec.yaml

    BottomNavigationBar With Icons

    Login or Signup to reply.
  2. Like Alejandro Cumpa said, you need to add uses-material-design: true in your pubspec.yaml.

    You need to add this to the bottom:

    name: …
    description: …
    
    publish_to: …
    
    version: …
    
    environment:
      …
    
    dependencies:
      …
    
    dev_dependencies:
      …
    
    flutter:
      …
      uses-material-design: true
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search