You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter应用构建/运行报错求助:依赖冲突与类型不匹配等问题

调试Flutter到Motorola One Fusion时的构建错误求助

错误类型概述

  • ModalBottomSheetRoute被重复导入的冲突错误
  • 异步函数返回类型不匹配(Object?无法转为Future<T?>)
  • TextOneLineEllipsisWithFade、RenderParagraphX类未实现指定成员的错误

具体错误日志

/C:/Users/Speed/AppData/Local/Pub/Cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/bottom_sheets/bar_bottom_sheet.dart:102:13: 错误:'ModalBottomSheetRoute' 同时从 'package:flutter/src/material/bottom_sheet.dart' 和 'package:modal_bottom_sheet/src/bottom_sheet_route.dart' 导入。
.push(ModalBottomSheetRoute(
^^^^^^^^^^^^^^^^^^^^^
/C:/Users/Speed/AppData/Local/Pub/Cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/bottom_sheets/bar_bottom_sheet.dart:125:10: 错误:无法从返回类型为 'Future<T?>' 的异步函数返回类型为 'Object?' 的值。
- 'Object' 来自 'dart:core'。
- 'Future' 来自 'dart:async'。
return result;
^
/C:/Users/Speed/AppData/Local/Pub/Cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/bottom_sheets/material_bottom_sheet.dart:28:13: 错误:'ModalBottomSheetRoute' 同时从 'package:flutter/src/material/bottom_sheet.dart' 和 'package:modal_bottom_sheet/src/bottom_sheet_route.dart' 导入。
.push(ModalBottomSheetRoute(
^^^^^^^^^^^^^^^^^^^^^
/C:/Users/Speed/AppData/Local/Pub/Cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/bottom_sheets/material_bottom_sheet.dart:50:10: 错误:无法从返回类型为 'Future<T?>' 的异步函数返回类型为 'Object?' 的值。
- 'Object' 来自 'dart:core'。
- 'Future' 来自 'dart:async'。
return result;
^
/C:/Users/Speed/AppData/Local/Pub/Cache/hosted/pub.dev/modal_bottom_sheet-2.1.2/lib/src/material_with_modal_page_route.dart:4:1: 错误:'ModalBottomSheetRoute' 同时从 'package:flutter/src/material/bottom_sheet.dart' 和 'package:modal_bottom_sheet/src/bottom_sheet_route.dart' 导入。
import '../modal_bottom_sheet.dart';
^^^^^^^^^^^^^^^^^^^^^
/C:/Users/Speed/AppData/Local/Pub/Cache/hosted/pub.dev/assorted_layout_widgets-6.1.1/lib/src/text_one_line_ellipsis_with_fade.dart:20:7: 错误:非抽象类 'TextOneLineEllipsisWithFade' 缺少以下成员的实现:
- Text.selectionColor
请尝试以下操作:
- 提供实现;
- 从父类或混入继承实现;
- 将类标记为抽象类;
- 提供 'noSuchMethod' 实现。

class TextOneLineEllipsisWithFade extends StatelessWidget implements Text {
^^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/flutter2/flutter_windows_3.7.12-stable/flutter/packages/flutter/lib/src/widgets/text.dart:592:16: 上下文:'Text.selectionColor' 定义在此处。
final Color? selectionColor;
^^^^^^^^^^^^^^
/C:/Users/Speed/AppData/Local/Pub/Cache/hosted/pub.dev/assorted_layout_widgets-6.1.1/lib/src/text_one_line_ellipsis_with_fade.dart:201:7: 错误:非抽象类 'RenderParagraphX' 缺少以下成员的实现:
- RenderParagraph.registrar
- RenderParagraph.registrar=
- RenderParagraph.selectionColor
- RenderParagraph.selectionColor=
- RenderParagraph.selections
请尝试以下操作:
- 提供实现;
- 从父类或混入继承实现;
- 将类标记为抽象类;
- 提供 'noSuchMethod' 实现。

class RenderParagraphX extends RenderBox
^^^^^^^^^^^^^^^^
/C:/flutter2/flutter_windows_3.7.12-stable/flutter/packages/flutter/lib/src/rendering/paragraph.dart:194:27: 上下文:'RenderParagraph.registrar' 定义在此处。
SelectionRegistrar? get registrar => _registrar;
^^^^^^^^^
/C:/flutter2/flutter_windows_3.7.12-stable/flutter/packages/flutter/lib/src/rendering/paragraph.dart:196:7: 上下文:'RenderParagraph.registrar=' 定义在此处。
set registrar(SelectionRegistrar? value) {
^^^^^^^^^
/C:/flutter2/flutter_windows_3.7.12-stable/flutter/packages/flutter/lib/src/rendering/paragraph.dart:428:14: 上下文:'RenderParagraph.selectionColor' 定义在此处。
Color? get selectionColor => _selectionColor;
^^^^^^^^^^^^^^
/C:/flutter2/flutter_windows_3.7.12-stable/flutter/packages/flutter/lib/src/rendering/paragraph.dart:430:7: 上下文:'RenderParagraph.selectionColor=' 定义在此处。
set selectionColor(Color? value) {
^^^^^^^^^^^^^^
/C:/flutter2/flutter_windows_3.7.12-stable/flutter/packages/flutter/lib/src/rendering/paragraph.dart:168:27: 上下文:'RenderParagraph.selections' 定义在此处。
List get selections {
^^^^^^^^^^
Target kernel_snapshot failed: Exception

FAILURE: Build failed with an exception.

- 位置:
脚本 'C:\flutter2\flutter_windows_3.7.12-stable\flutter\packages\flutter_tools\gradle\flutter.gradle' 第1157行

- 错误原因:
任务 ':app:compileFlutterBuildDebug' 执行失败。

> 进程 'command 'C:\flutter2\flutter_windows_3.7.12-stable\flutter\bin\flutter.bat'' 以非零退出值1结束

- 尝试方案:
使用 --stacktrace 选项获取堆栈跟踪。
使用 --info 或 --debug 选项获取更多日志输出。
使用 --scan 选项获取完整洞察。

BUILD FAILED in 13s
Running Gradle task 'assembleDebug'

求助说明

尝试自行修复上述错误但未能解决,恳请协助。

内容的提问来源于stack exchange,提问作者SpeediBoi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 14:23:15