Skip to content

Running apps with sound null safety from VSCode or Android Studio throws  #68627

@mit-mit

Description

@mit-mit

Running simple Flutter apps with null safety from VSCode or Android Studio triggers a throw in the WidgetInspectorService:

Repro steps for VSCode

  1. Create simple null safety app:
    flutter create nulltest
    cd nulltest
    dart migrate --apply-changes --no-web-preview
    
  2. Open VSCode: code .
  3. Open lib/main.dart
  4. Open launch.json (cmd-shift-p + type launch.json)
  5. Change:
             "type": "dart",
    
    to:
             "type": "dart",
             "args": [
                 "--enable-experiment=non-nullable",
             ],
    
    
  6. Hit F5

=>

�[38;5;248mLaunching lib/main.dart on Android SDK built for x86 in debug mode...�[39;49m
 lib/main.dart
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:53806/6tm7oVyrvok=/ws
D/EGL_emulation( 7933): eglMakeCurrent: 0xeec7eda0: ver 3 0 (tinfo 0xe3a8c350)

�[38;5;248m════════ Exception caught by Flutter framework ═════════════════════════════════�[39;49m
�[38;5;244mThe following _CastError was thrown during a service extension callback for "ext.flutter.inspector.setPubRootDirectories":�[39;49m
type 'Null' is not a subtype of type 'String' in type cast

�[38;5;244mWhen the exception was thrown, this was the stack�[39;49m
�[38;5;244m#0      List.length= (dart:core-patch/growable_array.dart:148:12)�[39;49m
�[38;5;244m#1      WidgetInspectorService._registerServiceExtensionVarArgs.<anonymous closure>.<anonymous closure>�[39;49m
 package:flutter/…/widgets/widget_inspector.dart
�[38;5;244m#2      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)�[39;49m
�[38;5;244m#3      WidgetInspectorService._registerServiceExtensionVarArgs.<anonymous closure>�[39;49m
 package:flutter/…/widgets/widget_inspector.dart
�[38;5;244m#4      BindingBase.registerServiceExtension.<anonymous closure>�[39;49m
 package:flutter/…/foundation/binding.dart
�[38;5;244m...�[39;49m
�[38;5;248m════════════════════════════════════════════════════════════════════════════════�[39;49m
Error handling 'serviceExtension' custom request: ext.flutter.inspector.setPubRootDirectories: (-32000) Server error
{"exception":"type 'Null' is not a subtype of type 'String' in type cast","stack":"#0      List.length= (dart:core-patch/growable_array.dart:148:12)\n#1      WidgetInspectorService._registerServiceExtensionVarArgs.<anonymous closure>.<anonymous closure> (package:flutter/src/widgets/widget_inspector.dart:889:20)\n#2      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)\n#3      WidgetInspectorService._registerServiceExtensionVarArgs.<anonymous closure> (package:flutter/src/widgets/widget_inspector.dart:885:20)\n#4      BindingBase.registerServiceExtension.<anonymous closure> (package:flutter/src/foundation/binding.dart:546:32)\n<asynchronous suspension>\n#5      BindingBase.registerServiceExtension.<anonymous closure> (package:flutter/src/foundation/binding.dart)\n#6      _runExtension (dart:developer-patch/developer.dart:84:23)\n","method":"ext.flutter.inspector.setPubRootDirectories"}

Repro steps for Android Studio

  1. Step 1 from VSCode above
  2. Open Android Studio
  3. File > Open Existing Project + pick folder with project
  4. Click Run > Edit Configurations, and in 'Additional arguments' add --enable-experiment=non-nullable
  5. Hit F5

Version information

mit-macbookpro4:foo mit$ flutter --version
Flutter 1.24.0-2.0.pre.86 • channel master • https://github.com/flutter/flutter.git
Framework • revision dde2044 (12 hours ago) • 2020-10-20 00:59:56 -0400
Engine • revision ea2aea1
Tools • Dart 2.11.0 (build 2.11.0-234.0.dev)

Metadata

Metadata

Assignees

Labels

P0Critical issues such as a build break or regressiona: null-safetySupport for Dart's null safety feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions