解决modal_bottom_sheet 的引入报错

10 min read
 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

'Object' is from 'dart:core'.
'Future' is from 'dart:async'. return result; ^
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

Try:
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.

Get more help at https://help.gradle.org
BUILD FAILED in 12m 31s Exception: Gradle task assembleDebug failed with exit code 1

Under pubspec.yml add below dependency override function

dependency_overrides:
 modal_bottom_sheet: ^3.0.0-pre