skip to Main Content

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.

3

Answers


  1.    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'),
                            ],
                          ),
                        ),
                      );
                    },
                  );
    
    Login or Signup to reply.
  2. 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:

    • Update to sheet: ^1.0.0-pre

    have a look at the below link:

    https://github.com/jamesblasco/modal_bottom_sheet/issues/325

    Login or Signup to reply.
  3. 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
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search