【问题标题】:Flutter / Dart Error: The argument type 'Null Function(Key)' can't be assigned to the parameter type 'void Function(Object)'Flutter / Dart 错误:无法将参数类型“Null Function(Key)”分配给参数类型“void Function(Object)”
【发布时间】:2020-05-15 00:55:35
【问题描述】:

Android Studio:在 iPhone 11 Pro Max 上以调试模式启动 lib/main.dart...

Compiler message:
/Users/[User]/.pub-cache/hosted/pub.dartlang.org/reorderables-0.2.12/lib/src/widgets/reorderable_flex.dart:727:18: Error: The argument type 'Null Function(Key)' can't be assigned to the parameter type 'void Function(Object)'.
 - 'Key' is from 'package:flutter/src/foundation/key.dart' ('/Users/[User]/Development/flutter/packages/flutter/lib/src/foundation/key.dart').
 - 'Object' is from 'dart:core'.
        onLeave: (Key leaving) {},
                 ^
/Users/[User]/.pub-cache/hosted/pub.dartlang.org/reorderables-0.2.12/lib/src/widgets/reorderable_wrap.dart:951:18: Error: The argument type 'Null Function(int)' can't be assigned to the parameter type 'void Function(Object)'.
 - 'Object' is from 'dart:core'.
        onLeave: (int leaving) {},
                 ^
/Users/[User]/.pub-cache/hosted/pub.dartlang.org/reorderables-0.2.12/lib/src/widgets/reorderable_wrap.dart:957:18: Error: The argument type 'Null Function(int)' can't be assigned to the parameter type 'void Function(Object)'.
 - 'Object' is from 'dart:core'.
        onLeave: (int leaving) {},
                 ^
/Users/[User]/.pub-cache/hosted/pub.dartlang.org/reorderables-0.2.12/lib/src/widgets/reorderable_sliver.dart:842:18: Error: The argument type 'Null Function(int)' can't be assigned to the parameter type 'void Function(Object)'.
 - 'Object' is from 'dart:core'.
        onLeave: (int leaving) {},
                 ^
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
Failed to build bundle.
Error launching application on iPhone 11 Pro Max.

无法通过这个问题得到答案,任何帮助将不胜感激☃

【问题讨论】:

  • 尝试清除缓存
  • 感谢@Doc 清除缓存通常会有所帮助,这次不行

标签: android-studio flutter dart compiler-errors


【解决方案1】:

Simon Binder 通过 dart-lang/TALK-general 回答:

这是您可能依赖的 reorderables 包中的错误。报告和解决方法在这里:hanshengchiu/reorderables#52

pubspec.yaml 中的更改:

#  reorderables: ^0.2.12
  reorderables:
    git:
      url: git://github.com/hanshengchiu/reorderables.git

【讨论】:

    猜你喜欢
    • 2021-11-06
    • 2021-09-01
    • 1970-01-01
    • 2021-09-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-28
    • 2022-06-20
    • 2023-04-05
    相关资源
    最近更新 更多