Getting the Error when using the package Badge in Flutter


I have recently used the commands ‘flutter clean’ and then ‘flutter pub get’, before this the Badge package was working perfectly, but now after using these commands I am facing this error. Even though the package is properly imported. I guess this happened after the ‘flutter pub get’ when it resolved the dependencies.

Need help!

>Solution :

Badge is coming from both flutter material and badge package. Flutter material provide by default.

In order to use the package one, you can do

import 'package:badges/badges.dart' as badge; 

You can call badge.Badge(....

If you like to hide the material Badges, you can do

import 'package:badges/badges.dart';
import 'package:flutter/material.dart' hide Badge;

Leave a Reply Cancel reply