Reputation: 937
Error: 'ModalBottomSheetRoute' is imported from both 'package:flutter/src/material/bottom_sheet.dart' and 'package:modal_bottom_sheet/src/bottom_sheet_route.dart'.
import 'material.dart' hide ModalBottomSheetRoute;
Upvotes: 31
Views: 30439
Reputation: 1
if ypu are using country_code_picker package then upgrade it or any package that use modal_bottom_sheet upgrade it if yoou don't want to upgrade simply add below lines in pubspec file
dependency_overrides:
modal_bottom_sheet: ^3.0.0-pre
Upvotes: 0
Reputation: 232
in addition to @Texv said,
if you are using smart_country_code_picker: ^0.0.2 also update to country_code_picker: ^3.0.0
it will solve the problem
Upvotes: 0
Reputation: 281
use
modal_bottom_sheet: 3.0.0-pre
This goes under your dependency_overrides:
in the pubspec.yaml
file such as:
dependency_overrides:
modal_bottom_sheet: ^3.0.0-pre
Upvotes: 28
Reputation: 11
Add modal_bottom_sheet: ^3.0.0-pre
under dependecy_overrides: in pubspec.yaml
that will solve the problem
Upvotes: 1
Reputation: 1782
this error occur due to new flutter SDK update
Here is a Migration Guide for flutter 3.7 or later
modal_bottom_sheet:
Update to modal_bottom_sheet: ^3.0.0-pre
change import 'packa ge:flutter/material.dart'
to import 'package:flutter/material.dart' hide ModalBottomSheetRoute;
in every file, you are using the bottom sheet plugin.
Like this:
upvote the answer if it's helpful.
Upvotes: 16
Reputation: 1894
If you're using the library package country_code_picker
in your project change it with country_picker
. The package uses an old version of modal_bottom_sheet and is conflicting.
Upvotes: 10
Reputation: 167
In order to fix this issue we have to hide one of the ModalBottomSheetRoute
. since we need this to be imported from bottom_sheet_route
we need to hide it from material
This is the way that we can fix,
Relace
import 'package:flutter/material.dart'
with
import 'package:flutter/material.dart' hide ModalBottomSheetRoute;
in the following files.
Basic Path: \Users\<username>\AppData\Local\Pub\Cache\hosted\pub.dev\modal_bottom_sheet-2.1.2\lib\src
\bottom_sheets\material_bottom_sheet.dart
\bottom_sheets\bar_bottom_sheet.dart
\material_with_modal_page_route.dart
Upvotes: 2
Reputation: 296
There's already a hot fix on the package
add this in the pubspec.yaml
modal_bottom_sheet:
git:
url: https://github.com/followthemoney1/modal_bottom_sheet.git
ref: main
path: modal_bottom_sheet
It has already been pull requested but it has not been merged yet
Upvotes: 17
Reputation: 592
The reason behind the error is says both material/bottom_sheet.dart
and bottom_sheet_route
exports the ModalBottomSheetRoute
.
'ModalBottomSheetRoute' is imported from both
'package:flutter/src/material/bottom_sheet.dart' and 'package:modal_bottom_sheet/src/bottom_sheet_route.dart'.
In order to fix this issue we have to hide one of the ModalBottomSheetRoute
. since we need this to be imported from bottom_sheet_route
we need to hide it from material
This is the way that we can fix,
Relace
import 'package:flutter/material.dart'
with
import 'package:flutter/material.dart' hide ModalBottomSheetRoute;
in the following files.
/Users/<usename>/.pub-cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/material_with_modal_page_route.dart
/Users/<usename>/.pub-cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/bottom_sheets/bar_bottom_sheet.dart
/Users/<usename>/.pub-cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/bottom_sheets/material_bottom_sheet.dart
Upvotes: 29
Reputation: 63749
You can use as prefix to import.
import 'package:modal_bottom_sheet/src/bottom_sheet_route.dart' as mbs;
then use the package like mbs.YourClass()
Upvotes: 0
Reputation: 937
The problem there is both class named "ModalBottomSheetRoute" found in flutter material and plugin "modal_bottom_sheet"
this happened with me when try to use flutter v3.7.0 beta sdk
#Fix this issue
import 'material.dart';
import 'material.dart' hide ModalBottomSheetRoute;
Upvotes: 5