【问题标题】:Modal bottom sheet library causing problems导致问题的模态底部工作表库
【发布时间】:2023-01-31 19:46:55
【问题描述】:

我今天升级了我的 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:\FlutterSDK\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1165

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\FlutterSDK\flutter\bin\flutter.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

它在我尝试调试后出现,是否有任何解决方案或者我应该删除该库?

【问题讨论】:

  • 你能提供使用库的代码吗?我认为您正在导入它两次。
  • 遗憾的是我不能提供代码,因为项目很大,我不知道错误在哪里,但我会尝试通过两次导入来确定你是否正确
  • 您的模态底页已经定义。如果那是一个自定义小部件,则必须重命名它,但如果那是一个库,则为导入提供一个别名,如 import 'package...' as modalSheet,类似的东西。
  • @john 我真的试图找到任何按照你所说定义的类,而且我没有任何新的库或没有我的知识,这些是我修改的文件以证明,在周一的 flutter uptade 之前一切都还不错,那些是我修改过的文件 ->
  • " lib/bloc/add_friend/add_friend_bloc.dart lib/bloc/add_friend/add_friend_event.dart lib/bloc/add_friend/add_friend_state.dart lib/bloc/friends_bloc/friends_bloc.dart lib/data/api/friends_service.dart lib/data/ models/post_friends_model.dart lib/presentation/app_router.dart lib/presentation/screens/account/friends/add_friend_screen.dart lib/presentation/screens/account/friends/friends_scanner.dart lib/widgets/dialogs.dart pubspec.lockpubspec.yaml “这里我没有这个库名称中的文件夹

标签: flutter dart


【解决方案1】:

升级 flutter 后我遇到了同样的问题。 我意识到这是与flutter开发环境的兼容性问题。 解决方案是同时更新开发频道:

flutter channel dev
flutter upgdade

【讨论】:

  • 没有为我工作。
【解决方案2】:

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

pubspec.yaml中添加这段代码:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-14
    • 1970-01-01
    • 2021-11-04
    • 2022-01-18
    相关资源
    最近更新 更多