Reputation: 71
Error: 'ModalBottomSheetRoute' is imported from both 'package:flutter/src/material/bottom_sheet.dart' and 'package:modal_bottom_sheet/src/bottom_sheet_route.dart'. ../…/src/material_with_modal_page_route.dart:4 import '../modal_bottom_sheet.dart'; ^^^^^^^^^^^^^^^^^^^^^
: Error: 'ModalBottomSheetRoute' is imported from both 'package:flutter/src/material/bottom_sheet.dart' and 'package:modal_bottom_sheet/src/bottom_sheet_route.dart'. ../…/bottom_sheets/material_bottom_sheet.dart:28 .push(ModalBottomSheetRoute( ^^^^^^^^^^^^^^^^^^^^^ : Error: A value of type 'Object?' can't be returned from an async function with return type 'Future<T?>'. ../…/bottom_sheets/material_bottom_sheet.dart:50
'Object' is from 'dart:core'.
'Future' is from 'dart:async'. return result;
^
: Error: 'ModalBottomSheetRoute' is imported from both 'package:flutter/src/material/bottom_sheet.dart' and 'package:modal_bottom_sheet/src/bottom_sheet_route.dart'. ../…/bottom_sheets/bar_bottom_sheet.dart:102 .push(ModalBottomSheetRoute( ^^^^^^^^^^^^^^^^^^^^^ : Error: A value of type 'Object?' can't be returned from an async function with return type 'Future<T?>'. ../…/bottom_sheets/bar_bottom_sheet.dart:125
Target kernel_snapshot failed: Exception
FAILURE: Build failed with an exception.
Where: Script '/Users/vannak/Documents/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1151
What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command '/Users/vannak/Documents/flutter/bin/flutter'' finished with non-zero exit value 1
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
BUILD FAILED in 12m 31s Exception: Gradle task assembleDebug failed with exit code 1
Upvotes: 3
Views: 4523
Reputation: 893
Under pubspec.yml add below dependency override function
dependency_overrides:
modal_bottom_sheet: ^3.0.0-pre
Then its work fine : Enjoy !
Upvotes: 7
Reputation: 217
I had a same issue after upgrading flutter new version 3.7.0 yesterday. It is caused by using ModalBottomSheet package from pub.dev.
You have to add below to your pubspec.yaml file.
dependency_overrides:
modal_bottom_sheet:
git:
url: https://github.com/danReynolds/modal_bottom_sheet.git
path: modal_bottom_sheet
DO NOT DELETE your modal_bottom_sheet and just COPY and PASTE below your dependencies.
Upvotes: 9
Reputation: 63749
Firstly, let's understand this type of issue. If you notice the error
ModalBottomSheetRoute
is imported from bothpackage:flutter/src/material/bottom_sheet.dart
andpackage:modal_bottom_sheet/src/bottom_sheet_route.dart
.
So it is telling you are getting ModalBottomSheetRoute
from two different packages.
Now if you like to use material bottomSheet, you can remove this import
package:modal_bottom_sheet/modal_bottom_sheet.dart
.
but If you like to use this package class. You can do
as
prefiximport 'package:flutter/material.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart' as modalSheet;
.....
modalSheet.ModalBottomSheetRoute(
builder: (context) =>
ModalBottomSheetRoute
of materialimport 'package:flutter/material.dart' hide ModalBottomSheetRoute;
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
Upvotes: 2