Reputation: 11
I have upgraded my flutter version from 3.3.10 to 3.7.0 and now getting the following error.
ModalBottomSheetRoute' is imported from both 'package:flutter/src/material/bottom_sheet.dart' and 'package:modal_bottom_sheet/src/bottom_sheet_route.dart
I tried to follow this Error: 'ModalBottomSheetRoute' is imported from both but solutions didn't work for me.
Upvotes: 1
Views: 3563
Reputation: 7300
After the Flutter 3.7 update, my project started getting this error, however I don't use the ModalBottomSheet
package, at least not directly, a another package I'm using, might be using it, so for now, the workaround (while a formal fix is in place) I added the following dependency override in the pubspec
file, and problem solved
dependency_overrides:
modal_bottom_sheet: ^3.0.0-pre
Upvotes: 4
Reputation: 1782
Make Sure you follow the Migration Guide for flutter 3.7
modal_bottom_sheet:
Update to modal_bottom_sheet: ^3.0.0-pre
Rename any ModalBottomSheetRoute class reference to ModalSheetRoute
sheet:
have a look at the below link:
https://github.com/jamesblasco/modal_bottom_sheet/issues/325
Upvotes: 1
Reputation: 4750
import 'package:modal_bottom_sheet/src/bottom_sheet_route.dart' as mymodal;
mymodal.showModalBottomSheet(
context: context,
// color is applied to main screen when modal bottom screen is displayed
barrierColor: Colors.greenAccent,
//background color for modal bottom screen
backgroundColor: Colors.yellow,
//elevates modal bottom screen
elevation: 10,
// gives rounded corner to modal bottom screen
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
builder: (BuildContext context) {
// UDE : SizedBox instead of Container for whitespaces
return SizedBox(
height: 200,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const <Widget>[
Text('GeeksforGeeks'),
],
),
),
);
},
);
Upvotes: 1