Skip to content

Null check operator used on a null value #46035

Closed
@LiamConan

Description

@LiamConan

Flutter 2.0.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 1d9032c7e1 (13 days ago) • 2021-04-29 17:37:58 -0700
Engine • revision 05e680e202
Tools • Dart 2.12.3

There is my pubspec :

dependencies:
  flutter:
    sdk: flutter
  cached_network_image: ^3.0.0
  camera: ^0.5.8+17
  cupertino_icons: ^1.0.3
  dio: ^4.0.0
  dotted_border: ^2.0.0
  edit_distance: ^0.4.1
  flappy_search_bar: ^1.7.2
  flutter_keyboard_visibility: ^5.0.1
  flutter_rounded_date_picker: ^2.0.2
  flutter_secure_storage: ^4.2.0
  flutter_speed_dial: ^3.0.5
  flutter_staggered_grid_view: ^0.3.0
  flutter_svg: ^0.22.0
  get_it: ^7.1.3
  image_picker: ^0.7.4
  injectable: ^1.4.0
  intl: ^0.17.0
  json_annotation: ^4.0.1
  json_serializable: ^4.1.1
  liquid_progress_indicator: ^0.3.2
  lottie: ^1.0.1
  modal_bottom_sheet: ^2.0.0
  path_provider: ^2.0.1
  qr_mobile_vision: ^3.0.0
  retrofit: ^2.0.0-beta1
  rxdart: ^0.27.0
  simple_animations: ^3.1.1
  smooth_page_indicator: 0.3.0-nullsafety.0
  supercharged: ^2.0.0
  table_calendar: ^3.0.0
  tuple: ^2.0.0
  url_launcher: ^6.0.3
  week_of_year: ^2.0.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  build_runner: ^1.12.2
  injectable_generator: any
  retrofit_generator: any
  test: ^1.15.7

When I run the build runner it crashes this way on a random file :

$ flutter pub run build_runner build --delete-conflicting-outputs
[INFO] Generating build script...
[INFO] Generating build script completed, took 358ms

[WARNING] Deleted previous snapshot due to missing asset graph.
[INFO] Creating build script snapshot......
[INFO] Creating build script snapshot... completed, took 9.5s

[INFO] There was output on stdout while compiling the build script snapshot, run with --verbose to see it (you will need to run a clean first to re-snapshot).

[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 639ms

[INFO] Checking for unexpected pre-existing outputs....
[INFO] Checking for unexpected pre-existing outputs. completed, took 1ms

[INFO] Running build...
[INFO] 1.0s elapsed, 0/16 actions completed.
[INFO] 2.1s elapsed, 0/16 actions completed.
[INFO] 3.1s elapsed, 1/17 actions completed.
[INFO] 4.2s elapsed, 3/19 actions completed.
[INFO] 10.6s elapsed, 15/31 actions completed.
[INFO] 12.9s elapsed, 20/36 actions completed.
[SEVERE] injectable_generator:injectable_builder on lib/application.dart:

Null check operator used on a null value
#0 LinkedElementFactory.isLibraryUri (package:analyzer/src/summary2/linked_element_factory.dart:418:48)
dart-lang/build#1 LibraryContext.isLibraryUri (package:analyzer/src/dart/analysis/library_context.dart:95:27)
dart-lang/build#2 LibraryAnalyzer._isLibrarySource (package:analyzer/src/dart/analysis/library_analyzer.dart:511:25)
dart-lang/build#3 LibraryAnalyzer._resolveDirectives (package:analyzer/src/dart/analysis/library_analyzer.dart:552:36)
dart-lang/build#4 LibraryAnalyzer.analyzeSync (package:analyzer/src/dart/analysis/library_analyzer.dart:128:5)
dart-lang/build#5 LibraryAnalyzer.analyze (package:analyzer/src/dart/analysis/library_analyzer.dart:105:12)
dart-lang/build#6 AnalysisDriver._computeAnalysisResult. (package:analyzer/src/dart/analysis/driver.dart:1590:63)
dart-lang/build#7 PerformanceLog.run (package:analyzer/src/dart/analysis/performance_logger.dart:32:15)
dart-lang/build#8 AnalysisDriver._computeAnalysisResult (package:analyzer/src/dart/analysis/driver.dart:1565:20)
dart-lang/build#9 AnalysisDriver._computeErrors (package:analyzer/src/dart/analysis/driver.dart:1644:26)
dart-lang/build#10 AnalysisDriver.performWork (package:analyzer/src/dart/analysis/driver.dart:1266:20)
dart-lang/build#11 AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2296:24)

The issue is in this function :

bool isLibraryUri(String uriStr) {
  var libraryContext = libraryReaders[uriStr]!; // Here is the issue
  return !libraryContext.hasPartOfDirective;
}

Is there because of the null-safety feature ?
Here it tells that's because of the injectable_generator but if i remove it it will crashes in the same way because of the retrofit generator or the serializable lib.

Metadata

Metadata

Assignees

Labels

P3A lower priority bug or feature requestlegacy-area-analyzerUse area-devexp instead.needs-infoWe need additional information from the issue author (auto-closed after 14 days if no response)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions