"The name 'Page' is defined in the libraries 'package:burn_off/widgets/page.dart' and 'package:flutter/src/widgets/navigator.dart'

Viewed 1372

I was trying to test this app in flutter, but I was unable to run the app because apper this error "The name 'Page' is defined in the libraries 'package:burn_off/widgets/page.dart' and 'package:flutter/src/widgets/navigator.dart'." I already tried to change the name of the class and variables and it didn't work. I need some help

Project: https://github.com/huextrat/BurnOff

1 Answers

You have 2 libraries referencing 'Page' as a widget: one is inside the widgets folder and the other one is from Flutter itself. So you need to use a prefix in your import; For example:

import 'package:burn_off/widgets/page.dart' as mypage;

and then you need to use your widget with that prefix, for example:

                mypage.Page(
                  title: "HOW TO BURN OFF",
                  background: aliment.background,
                  icon: aliment.bottomImage,
                  child: CardItem(
                    child: AlimentWidget(
                      aliment: aliment,
                      theme: aliment.background,
                    ),
                  ),
                ),
                
Related