abuanwar072/Flutter-Responsive-Admin-Panel-or-Dashboard

MenuController Build Errors

Closed this issue · 3 comments

Describe the bug
MenuController Build Errors

One example

The name 'MenuController' is defined in the libraries 'package:admin/controllers/MenuController.dart' and 'package:flutter/src/material/menu_anchor.dart (via package:flutter/material.dart)'.
Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports.

See screenshot of other errors.

To Reproduce

  • flutter run
  • Chrome
  • Error in terminal
Launching lib\main.dart on Chrome in debug mode...
lib/main.dart:28:34: Error: 'MenuController' is imported from both 'package:admin/controllers/MenuController.dart' and
'package:flutter/src/material/menu_anchor.dart'.
            create: (context) => MenuController(),
                                 ^^^^^^^^^^^^^^
lib/screens/main/main_screen.dart:12:43: Error: The getter 'scaffoldKey' isn't defined for the class 'MenuController'.
 - 'MenuController' is from 'package:flutter/src/material/menu_anchor.dart'
 ('../flutter/packages/flutter/lib/src/material/menu_anchor.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'scaffoldKey'.
      key: context.read<MenuController>().scaffoldKey,
                                          ^^^^^^^^^^^
lib/screens/dashboard/components/header.dart:3:1: Error: 'MenuController' is imported from both
'package:admin/controllers/MenuController.dart' and 'package:flutter/src/material/menu_anchor.dart'.
import 'package:flutter/material.dart';
^^^^^^^^^^^^^^

Expected behavior
Clean Build/Run

Screenshots

image

Desktop (please complete the following information):

  • OS: Win 10
  • Browser Chrome
  • Version Flutter 3.7.0 • channel stable • https://github.com/flutter/flutter.git
    Framework • revision b06b8b2710 (9 days ago) • 2023-01-23 16:55:55 -0800
    Engine • revision b24591ed32
    Tools • Dart 2.19.0 • DevTools 2.20.1

Additional context
I believe I didn't have this issue with a prior version of Flutter. I am new to this so I am not entirely sure, but I think its flutter 3.7 that is causing this?

Sorry - total noob here...

The bandaid I found was: In controllers\MenuController.dart, I renamed MenuController to SideMenuController and fixed all references. I can build now. There likely is a better/cleaner way to resolve this.

i got the same issues, yet it didn't solve the problems for me

Solved. Check the latest marge.