Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter @Error: Null safety features are disabled for this library

Tags:

I am building a Flutter application, the app ran upto mark while i was building for Android but as i started building the app for iOS i started facing error of "Null Safety features are disabled for this library"

The Error is as follows :

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. 

The error also shows that required isn't a type

/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();                ^^^^^^^^ 

The flutter doctor -v goes as follows :

[√] 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 

Thank you.

like image 944
M Ashutosh Rao Avatar asked Sep 19 '20 13:09

M Ashutosh Rao


People also ask

How do I enable null safety in Flutter?

To enable null safety, you must go to your pubspec. yaml file and then navigates to the environment tag. You'll see that under the tag, there is an SDK tag version. Null Safety complies with the SDK version 2.12 and up.

Which Flutter version has null safety?

Enabling null safety Sound null safety is available in Dart 2.12 and Flutter 2.


2 Answers

I solved it by doing the following (for Visual Code on Windows 10):

in Command prompt (or whichever terminal you use with flutter in PATH):

flutter upgrade

And made sure that the version is at least 2.12 (which is the minimum required version for enabling null safety without using it as an experimental feature (I believe 🧐))

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 

When that was confirmed, then I checked what my current sdk-version in the project was (in my case it was the following: sdk: ">=2.7.0 <3.0.0")

So I updated it to be the following instead: sdk: ">=2.12.0 <3.0.0".

So the environment should look as following:

environment:   sdk: ">=2.12.0 <3.0.0" 
like image 110
Reitenator Avatar answered Sep 29 '22 18:09

Reitenator


switch to dev/master channel

try to add sdk (that supports null safety) in pubspec.yaml file. In my case

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

create analysis_options.yaml & add

analyzer:   enable-experiment:     - non-nullable 

[optional]

if u r using vs code try to add

{ // 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",         ],     } ] } 
like image 22
GJJ2019 Avatar answered Sep 29 '22 17:09

GJJ2019