ModalBottomSheetRoute' 是从 'package:flutter/src/material/bottom_sheet.dart' 和 package:modal_bottom_sheet 导入的

Van*_*Nak 3 dart flutter bottom-sheet

\n

错误:\'ModalBottomSheetRoute\' 是从 \'package:flutter/src/material/bottom_sheet.dart\' 和 \'package:modal_bottom_sheet/src/bottom_sheet_route.dart\' 导入的。\n../\xe2\x80 \xa6/src/material_with_modal_page_route.dart:4\n导入 \'../modal_bottom_sheet.dart\';\n^^^^^^^^^^^^^^^^^^^^^

\n
\n

: 错误: \'ModalBottomSheetRoute\' 是从 \'package:flutter/src/material/bottom_sheet.dart\' 和 \'package:modal_bottom_sheet/src/bottom_sheet_route.dart\' 导入的。\n../\xe2\ x80\xa6/bottom_sheets/material_bottom_sheet.dart:28\n.push(ModalBottomSheetRoute(\n^^^^^^^^^^^^^^^^^^^^^^\n: 错误: 类型的值无法从返回类型为“Future<T?>”的异步函数返回“Object?”。\n../\xe2\x80\xa6/bottom_sheets/material_bottom_sheet.dart:50

\n\n

: 错误: \'ModalBottomSheetRoute\' 是从 \'package:flutter/src/material/bottom_sheet.dart\' 和 \'package:modal_bottom_sheet/src/bottom_sheet_route.dart\' 导入的。\n../\xe2\ x80\xa6/bottom_sheets/bar_bottom_sheet.dart:102\n.push(ModalBottomSheetRoute(\n^^^^^^^^^^^^^^^^^^^^^^\n: 错误: 类型的值无法从返回类型为“Future<T?>”的异步函数返回“Object?”。\n../\xe2\x80\xa6/bottom_sheets/bar_bottom_sheet.dart:125

\n
    \n
  • “Object”来自“dart:core”。
  • \n
  • \'Future\' 来自 \'dart:async\'。\n返回结果;\n^
  • \n
\n

目标 kernel_snapshot 失败:异常

\n

失败:构建失败并出现异常。

\n
    \n
  • 其中:\n脚本\'/Users/vannak/Documents/flutter/packages/flutter_tools/gradle/flutter.gradle\'行:1151

    \n
  • \n
  • 出了什么问题:\n任务 \':app:compileFlutterBuildDebug\' 执行失败。

    \n
  • \n
\n
\n

进程\'command\'/Users/vannak/Documents/flutter/bin/flutter\'\'以非零退出值1完成

\n
\n
    \n
  • 尝试:
  • \n
\n
\n

使用 --stacktrace 选项运行以获取堆栈跟踪。\n使用 --info 或 --debug 选项运行以获取更多日志输出。\n使用 --scan 运行以获得完整的见解。

\n
\n\n

在 12m 31s 内构建失败\n异常:Gradle 任务 assembleDebug 失败,退出代码 1

\n

Hap*_*ing 8

我昨天升级 flutter 新版本 3.7.0 后遇到了同样的问题。这是由于使用 pub.dev 中的 ModalBottomSheet 包引起的。

您必须将以下内容添加到您的 pubspec.yaml 文件中。

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

Run Code Online (Sandbox Code Playgroud)

不要删除您的 modal_bottom_sheet,只需复制并粘贴到您的依赖项下方。


小智 6

在 pubspec.yml 下添加以下依赖覆盖函数

dependency_overrides:
 modal_bottom_sheet: ^3.0.0-pre
Run Code Online (Sandbox Code Playgroud)

那么它的工作就很好了:享受吧!