导致问题的模式底部图纸库



我今天升级了我的flutter版本,发现了这个问题:

../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/bottom_sheets/bar_bottom_sheet.dart:102:13: Error: 'ModalBottomSheetRoute' is imported from both 'package:flutter/src/material/bottom_sheet.dart' and 'package:modal_bottom_sheet/src/bottom_sheet_route.dart'.
.push(ModalBottomSheetRoute<T>(
^^^^^^^^^^^^^^^^^^^^^
../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/bottom_sheets/bar_bottom_sheet.dart:125:10: Error: A value of type 'Object?' can't be returned from an async function with return type 'Future<T?>'.
- 'Object' is from 'dart:core'.
- 'Future' is from 'dart:async'.
return result;
^
../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/bottom_sheets/material_bottom_sheet.dart:28:13: Error: 'ModalBottomSheetRoute' is imported from both 'package:flutter/src/material/bottom_sheet.dart' and 'package:modal_bottom_sheet/src/bottom_sheet_route.dart'.
.push(ModalBottomSheetRoute<T>(
^^^^^^^^^^^^^^^^^^^^^
../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/bottom_sheets/material_bottom_sheet.dart:50:10: Error: A value of type 'Object?' can't be returned from an async function with return type 'Future<T?>'.
- 'Object' is from 'dart:core'.
- 'Future' is from 'dart:async'.
return result;
^
../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/material_with_modal_page_route.dart:4:1: Error: 'ModalBottomSheetRoute' is imported from both 'package:flutter/src/material/bottom_sheet.dart' and 'package:modal_bottom_sheet/src/bottom_sheet_route.dart'.
import '../modal_bottom_sheet.dart';
^^^^^^^^^^^^^^^^^^^^^
Target kernel_snapshot failed: Exception

FAILURE: Build failed with an exception.
* Where:
Script 'C:FlutterSDKflutterpackagesflutter_toolsgradleflutter.gradle' line: 1165
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:FlutterSDKflutterbinflutter.bat'' 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 20s
Exception: Gradle task assembleDebug failed with exit code 1

它出现在我尝试调试它之后,有没有解决方案或者我应该删除这个库?

所以这个问题是由于flutter 3.7和modal_bottom_sheet:2.1.0 中的名称冲突

自从flutter 3.7发布这个编译时问题开始以来,库维护人员已经发布了3.0.0版本,他们将任何ModalBottomSheetRoute类引用重命名为ModalSheetRoute。使用此版本modal_bottom_sheet: ^3.0.0-pre

根据Ashish的说法,对我有效的是,我在我的pubspec.yaml文件中使用依赖重写对默认模式底部表进行了重写,添加了以下行:

dependency_overrides:
modal_bottom_sheet: ^3.0.0-pre

(添加到您的pubspec.yaml文件时始终检查缩进(

我在升级flutter后遇到了同样的问题。我意识到这是一个与flutter开发环境的兼容性问题。解决方案是升级dev通道也:

flutter channel dev
flutter upgrade

我通过添加下面的方法暂时解决了这个问题(直到Flutter团队在下面的版本中解决这个问题(。

pubspec.yaml:中添加此代码

dependency_overrides:
modal_bottom_sheet:
git:
url: https://github.com/danReynolds/modal_bottom_sheet.git
path: modal_bottom_sheet

最新更新