Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: 'ModalBottomSheetRoute' is imported from both

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;

like image 302
Abdallah Mahmoud Avatar asked Sep 03 '25 05:09

Abdallah Mahmoud


1 Answers

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.

  1. /Users/<usename>/.pub-cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/material_with_modal_page_route.dart
  2. /Users/<usename>/.pub-cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/bottom_sheets/bar_bottom_sheet.dart
  3. /Users/<usename>/.pub-cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/bottom_sheets/material_bottom_sheet.dart
like image 169
Radika Dilanka Avatar answered Sep 04 '25 22:09

Radika Dilanka