I have a flutter application, and after running the app, i face this error
Error: 'DateUtils' is imported from both 'package:calendarro/date_utils.dart' and
'package:flutter/src/material/date.dart'.
startDate = DateUtils.getFirstDayOfCurrentMonth();
This line is in calendarro.dart file provided by flutter itself. Not only this line, whichever line contains something related to DateUtils, it throws the same error. There are no pre-compilation errors.
Flutter version - 1.22.6 Dart - 2.14 Running on android emulator in android studio(pixel-2 Android9)
CodePudding user response:
The error is clear. The two packages have a similar class named DateUtils
. So to resolve it; in the class where you have both imports, assign an alias to one of the packages using the as
keyword
For example:
import 'package:calendarro/date_utils.dart' as dt
dt.DateUtils.getFirstDayOfCurrentMonth(); //call the class using the alias