Flutter @Error:此库禁用了空安全功能

时间:2020-09-19 13:21:16

标签: ios flutter dart

我正在构建Flutter应用程序,当我在为Android构建应用程序时运行该应用程序,但是当我开始为iOS构建应用程序时,我开始遇到“该库禁用了安全功能”错误

错误如下:

Users/himanshu/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety/lib/path.dart:100:4: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
Uri? _currentUriBase;
   ^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety/lib/path.dart:106:7: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
String? _current;
      ^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety/lib/path.dart:120:16: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
        [String? part2,
               ^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety/lib/path.dart:121:15: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
        String? part3,
              ^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety/lib/path.dart:122:15: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
        String? part4,
              ^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety/lib/path.dart:123:15: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
        String? part5,
              ^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety/lib/path.dart:124:15: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
        String? part6,
              ^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety/lib/path.dart:125:15: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
        String? part7]) =>
              ^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety/lib/path.dart:258:16: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
        [String? part2,
               ^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety/lib/path.dart:259:15: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
        String? part3,
              ^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety/lib/path.dart:260:15: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
        String? part4,
              ^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety/lib/path.dart:261:15: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
        String? part5,
              ^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety/lib/path.dart:262:15: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
        String? part6,
              ^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety/lib/path.dart:263:15: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
        String? part7,
              ^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety/lib/path.dart:264:15: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
        String? part8]) =>
              ^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety/lib/path.dart:358:37: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
String relative(String path, {String? from}) =>
                                    ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:126:9: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  Object? invoke(covariant T intent);
        ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:235:8: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
    Key? key,
       ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:330:50: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  Object invoke(covariant T intent, [BuildContext? context]);
                                                 ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:334:52: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
typedef OnInvokeCallback<T extends Intent> = Object? Function(T intent);
                                                   ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:361:9: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  Object? invoke(covariant T intent) => onInvoke(intent);
        ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:386:9: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  Object? invokeAction(covariant Action<Intent> action, covariant Intent intent, [BuildContext? context]) {
        ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:386:95: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  Object? invokeAction(covariant Action<Intent> action, covariant Intent intent, [BuildContext? context]) {
                                                                                              ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:420:8: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
    Key? key,
       ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:436:25: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  final ActionDispatcher? dispatcher;
                        ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:495:22: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  static VoidCallback? handler<T extends Intent>(BuildContext context, T intent, {bool nullOk = false}) {
                     ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:510:19: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  static Action<T>? find<T extends Intent>(BuildContext context, {bool nullOk = false}) {
                  ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:595:16: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  static Object? invoke<T extends Intent>(
               ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:653:22: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  Set<Action<Intent>>? listenedActions = <Action<Intent>>{};
                     ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:718:8: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
    Key? key,
       ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:719:21: Error: Expected '}' before this.
    required Widget child,
                    ^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:724:25: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  final ActionDispatcher? dispatcher;
                        ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:887:8: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
    Key? key,
       ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:914:18: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  final FocusNode? focusNode;
                 ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:920:34: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  final Map<Type, Action<Intent>>? actions;
                                 ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:923:35: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  final Map<LogicalKeySet, Intent>? shortcuts;
                                  ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:929:27: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  final ValueChanged<bool>? onShowFocusHighlight;
                          ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:934:27: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  final ValueChanged<bool>? onShowHoverHighlight;
                          ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:939:27: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  final ValueChanged<bool>? onFocusChange;
                          ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:1031:41: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  void _mayTriggerCallback({VoidCallback? task, FocusableActionDetector? oldWidget}) {
                                        ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/actions.dart:1031:72: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  void _mayTriggerCallback({VoidCallback? task, FocusableActionDetector? oldWidget}) {
                                                                       ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_cross_fade.dart:121:8: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
    Key? key,
       ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_cross_fade.dart:164:17: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  final Duration? reverseDuration;
                ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_cross_fade.dart:250:22: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  AnimationController? _controller;
                     ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_cross_fade.dart:251:8: Error: A method declaration needs an explicit list of parameters.
Try adding a parameter list to the method declaration.
  late Animation<double> _firstAnimation;
       ^^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_cross_fade.dart:251:26: Error: Expected '{' before this.
  late Animation<double> _firstAnimation;
                         ^^^^^^^^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_cross_fade.dart:251:26: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
Try adding the name of the type of the variable or the keyword 'var'.
  late Animation<double> _firstAnimation;
                         ^^^^^^^^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_cross_fade.dart:252:8: Error: A method declaration needs an explicit list of parameters.
Try adding a parameter list to the method declaration.
  late Animation<double> _secondAnimation;
       ^^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_cross_fade.dart:252:26: Error: Expected '{' before this.
  late Animation<double> _secondAnimation;
                         ^^^^^^^^^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_cross_fade.dart:252:8: Error: 'Animation' is already declared in this scope.
  late Animation<double> _secondAnimation;
       ^^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_cross_fade.dart:251:8: Context: Previous declaration of 'Animation'.
  late Animation<double> _firstAnimation;
       ^^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_cross_fade.dart:252:26: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
Try adding the name of the type of the variable or the keyword 'var'.
  late Animation<double> _secondAnimation;
                         ^^^^^^^^^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_cross_fade.dart:274:3: Error: 'Animation' isn't a type.
  Animation<double> _initAnimation(Curve curve, bool inverted) {
  ^^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_cross_fade.dart:274:3: Context: This isn't a type.
  Animation<double> _initAnimation(Curve curve, bool inverted) {
  ^^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_list.dart:33:28: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  final AnimationController? controller;
                           ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_list.dart:34:39: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  final AnimatedListRemovedItemBuilder? removedItemBuilder;
                                      ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_list.dart:272:8: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
    Key? key,
       ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_list.dart:340:25: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  final ScrollController? controller;
                        ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_list.dart:350:13: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  final bool? primary;
            ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_list.dart:358:22: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  final ScrollPhysics? physics;
                     ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_list.dart:377:27: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  final EdgeInsetsGeometry? padding;
                          ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_list.dart:388:27: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  static AnimatedListState? of(BuildContext context, { bool nullOk = false }) {
                          ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_list.dart:737:8: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
    Key? key,
       ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_list.dart:774:33: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  static SliverAnimatedListState? of(BuildContext context, {bool nullOk = false}) {
                                ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_list.dart:837:14: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  _ActiveItem? _removeActiveItemAt(List<_ActiveItem> items, int itemIndex) {
             ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_list.dart:842:14: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  _ActiveItem? _activeItemAt(List<_ActiveItem> items, int itemIndex) {
             ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_size.dart:57:8: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
    Key? key,
       ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_size.dart:58:11: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
    Widget? child,
          ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_size.dart:101:17: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  final Duration? reverseDuration;
                ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_switcher.dart:64:63: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
typedef AnimatedSwitcherLayoutBuilder = Widget Function(Widget? currentChild, List<Widget> previousChildren);
                                                              ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_switcher.dart:149:8: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
    Key? key,
       ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_switcher.dart:175:15: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.
  final Widget? child;
              ^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/animated_switcher.dart:192:17: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.10 or higher.

错误还显示必填不是一种类型

/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.2/lib/meta.dart:224:16: Context: This isn't a type.
const Required required = Required();
               ^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/basic.dart:400:5: Error: 'required' isn't a type.
    required this.filter,
    ^^^^^^^^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.2/lib/meta.dart:224:16: Context: This isn't a type.
const Required required = Required();
               ^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/basic.dart:820:5: Error: 'required' isn't a type.
    required ShapeBorder shape,
    ^^^^^^^^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.2/lib/meta.dart:224:16: Context: This isn't a type.
const Required required = Required();
               ^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/basic.dart:907:5: Error: 'required' isn't a type.
    required this.color,
    ^^^^^^^^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.2/lib/meta.dart:224:16: Context: This isn't a type.
const Required required = Required();
               ^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/basic.dart:999:5: Error: 'required' isn't a type.
    required this.clipper,
    ^^^^^^^^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.2/lib/meta.dart:224:16: Context: This isn't a type.
const Required required = Required();
               ^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/basic.dart:1002:5: Error: 'required' isn't a type.
    required this.color,
    ^^^^^^^^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.2/lib/meta.dart:224:16: Context: This isn't a type.
const Required required = Required();
               ^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/basic.dart:1114:5: Error: 'required' isn't a type.
    required this.transform,
    ^^^^^^^^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.2/lib/meta.dart:224:16: Context: This isn't a type.
const Required required = Required();
               ^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/basic.dart:1151:5: Error: 'required' isn't a type.
    required double angle,
    ^^^^^^^^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.2/lib/meta.dart:224:16: Context: This isn't a type.
const Required required = Required();
               ^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/basic.dart:1180:5: Error: 'required' isn't a type.
    required Offset offset,
    ^^^^^^^^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.2/lib/meta.dart:224:16: Context: This isn't a type.
const Required required = Required();
               ^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/basic.dart:1219:5: Error: 'required' isn't a type.
    required double scale,
    ^^^^^^^^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.2/lib/meta.dart:224:16: Context: This isn't a type.
const Required required = Required();
               ^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/basic.dart:1301:5: Error: 'required' isn't a type.
    required this.link,
    ^^^^^^^^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.2/lib/meta.dart:224:16: Context: This isn't a type.
const Required required = Required();
               ^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/basic.dart:1361:5: Error: 'required' isn't a type.
    required this.link,
    ^^^^^^^^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.2/lib/meta.dart:224:16: Context: This isn't a type.
const Required required = Required();
               ^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/basic.dart:1507:5: Error: 'required' isn't a type.
    required this.translation,
    ^^^^^^^^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.2/lib/meta.dart:224:16: Context: This isn't a type.
const Required required = Required();
               ^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/basic.dart:1569:5: Error: 'required' isn't a type.
    required this.quarterTurns,
    ^^^^^^^^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.2/lib/meta.dart:224:16: Context: This isn't a type.
const Required required = Required();
               ^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/basic.dart:1644:5: Error: 'required' isn't a type.
    required this.padding,
    ^^^^^^^^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.2/lib/meta.dart:224:16: Context: This isn't a type.
const Required required = Required();
               ^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/basic.dart:1921:5: Error: 'required' isn't a type.
    required this.delegate,
    ^^^^^^^^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.2/lib/meta.dart:224:16: Context: This isn't a type.
const Required required = Required();
               ^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/basic.dart:1951:5: Error: 'required' isn't a type.
    required this.id,
    ^^^^^^^^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.2/lib/meta.dart:224:16: Context: This isn't a type.
const Required required = Required();
               ^^^^^^^^
/Users/himanshu/flutter/packages/flutter/lib/src/widgets/basic.dart:1952:5: Error: 'required' isn't a type.
    required Widget child,
    ^^^^^^^^
/Users/himanshu/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.2/lib/meta.dart:224:16: Context: This isn't a type.
const Required required = Required();
               ^^^^^^^^

扑打医生-v如下:

[√] Flutter (Channel stable, 1.20.3, on Microsoft Windows [Version 10.0.19041.508], locale en-US)
    • Flutter version 1.20.3 at C:\src\flutter
    • Framework revision 216dee60c0 (3 weeks ago), 2020-09-01 12:24:47 -0700
    • Engine revision d1bc06f032
    • Dart version 2.9.2

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.0-rc2)
    • Android SDK at C:\Users\Ashu\AppData\Local\Android\Sdk
    • Platform android-29, build-tools 30.0.0-rc2
    • Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)   
    • All Android licenses accepted.

[!] Android Studio (version 3.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 31.3.1
    • Dart plugin version 181.5656
    X Unable to determine bundled Java version.
    • Try updating or re-installing Android Studio.

[√] Android Studio (version 3.6)
    • Android Studio at C:\Program Files\Android\Android Studio1
    • Flutter plugin version 31.3.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[√] VS Code (version 1.49.0)
    • VS Code at C:\Users\Ashu\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.14.1

[!] Connected device
    ! No devices available

谢谢。

4 个答案:

答案 0 :(得分:13)

我通过执行以下操作(对于 Windows 10 上的 Visual Code)解决了这个问题:

在命令提示符(或您在 PATH 中使用 flutter 的任何终端):

flutter upgrade

并确保版本至少为 2.12(这是启用 null 安全而不将其用作实验性功能的最低要求版本(我相信?))

PS C:\> flutter upgrade
Flutter is already up to date on channel stable
Flutter 2.0.2 • channel stable • https://github.com/flutter/flutter.git 
Framework • revision 8962f6dc68 (2 days ago) • 2021-03-11 13:22:20 -0800
Engine • revision 5d8bf811b3
Tools • Dart 2.12.1

确认后,我检查了项目中当前的 sdk 版本是什么(在我的例子中是:sdk: ">=2.7.0 <3.0.0"

所以我将其更新为以下内容:sdk: ">=2.12.0 <3.0.0"

所以环境应该如下所示:

environment:
  sdk: ">=2.12.0 <3.0.0"

答案 1 :(得分:2)

这是我在 Android Studio 中的解决方案

  1. 将以下行添加到您的 pubspec.yaml
<块引用>
analyzer:
  enable-experiment:
  - non-nullable
  1. 在 pubspec.yaml 中升级您的 SDK
<块引用>
environment:
  sdk: ">=2.13.0-68.0.dev <3.0.0"

这对我有用...!!!!

示例

>     analyzer:
>       enable-experiment:
>       - non-nullable
>     
>     environment:   
>       sdk: ">=2.13.0-68.0.dev <3.0.0"

答案 2 :(得分:1)

切换到开发者/主渠道

尝试在pubspec.yaml文件中添加sdk(支持null安全)。 就我而言

environment:
  sdk: ">=2.12.0-27.0.dev <2.12.0"

创建analysis_options.yaml并添加

analyzer:
  enable-experiment:
    - non-nullable

[可选]

如果您使用vs代码尝试添加

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
    {
        "name": "name",
        "request": "launch",
        "type": "dart",
        "vmAdditionalArgs": [
            "--enable-experiment=non-nullable",
        ],
    }
]
}

答案 3 :(得分:0)

[Like here]

1这是我的解决方案(在android studio上) 对我来说很好----------->

version: 1.0.0+1

analyzer:
  enable-experiment:[![enter image description here][1]][1]
    - non-nullable

environment:
  sdk: ">=2.11.0-213.1.beta <3.0.0"