Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build_runner watch can not run #100

Closed
hxse opened this issue Jan 21, 2022 · 1 comment
Closed

build_runner watch can not run #100

hxse opened this issue Jan 21, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@hxse
Copy link

hxse commented Jan 21, 2022

Describe the bug

PS D:\Note\02-Computer\program\flutter\flutter_desktop_demo> flutter pub  run build_runner watch
Failed to build build_runner:build_runner:
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:

 - package:build_runner_core
 - package:io
 - package:build_runner
 - package:build
 - package:build_config
 - package:build_daemon
 - package:build_resolvers
 - package:timing
 - package:graphs
 - package:package_config
 - package:code_builder
 - package:dart_style
 - package:http_multi_server
 - package:pubspec_parse
 - package:analyzer
 - package:checked_yaml
 - package:shelf_web_socket
 - package:web_socket_channel
 - package:_fe_analyzer_shared

For solutions, see https://dart.dev/go/unsound-null-safety
/C:/Users/hxse/scoop/apps/flutter/current/.pub-cache/hosted/pub.dartlang.org/build_runner-1.11.5/bin/build_runner.dart:91:37: Error: Operator '[]' cannot be called on 'ArgResults?' because it is potentially null.    
 - 'ArgResults' is from 'package:args/src/arg_results.dart' ('/C:/Users/hxse/scoop/apps/flutter/2.8.1/.pub-cache/hosted/pub.dartlang.org/args-2.3.0/lib/src/arg_results.dart').
    var verbose = parsedArgs.command['verbose'] as bool ?? false;       
                                    ^
/C:/Users/hxse/scoop/apps/flutter/current/.pub-cache/hosted/pub.dartlang.org/build_runner-1.11.5/bin/build_runner.dart:91:49: Warning: Operand of null-aware operation '??' has type 'bool' which excludes null.        
    var verbose = parsedArgs.command['verbose'] as bool ?? false;       
                                                ^
/C:/Users/hxse/scoop/apps/flutter/current/.pub-cache/hosted/pub.dartlang.org/build_runner-1.11.5/bin/build_runner.dart:101:9: Warning: Operand of null-aware operation '?.' has type 'StreamSubscription<dynamic>' which excludes null.
 - 'StreamSubscription' is from 'dart:async'.
  await logListener?.cancel();
        ^
/C:/Users/hxse/scoop/apps/flutter/2.8.1/.pub-cache/hosted/pub.dartlang.org/analyzer-0.41.2/lib/src/error/best_practices_verifier.dart:258:50: Error: The property 'displayString' is defined in multiple extensions for 
'TargetKind' and neither is more specific.
 - 'TargetKind' is from 'package:meta/meta_meta.dart' ('/C:/Users/hxse/scoop/apps/flutter/2.8.1/.pub-cache/hosted/pub.dartlang.org/meta-1.7.0/lib/meta_meta.dart').
Try using an explicit extension application of the wanted extension or hiding unwanted extensions from scope.
        var kindNames = kinds.map((kind) => kind.displayString).toList()                                                 ^^^^^^^^^^^^^
/C:/Users/hxse/scoop/apps/flutter/2.8.1/.pub-cache/hosted/pub.dartlang.org/analyzer-0.41.2/lib/src/error/best_practices_verifier.dart:1950:14: Context: This is one of the extension members.
  String get displayString {
             ^^^^^^^^^^^^^
/C:/Users/hxse/scoop/apps/flutter/2.8.1/.pub-cache/hosted/pub.dartlang.org/meta-1.7.0/lib/meta_meta.dart:91:14: Context: This is one of the extension members.
  String get displayString {
             ^^^^^^^^^^^^^
/C:/Users/hxse/scoop/apps/flutter/2.8.1/.pub-cache/hosted/pub.dartlang.org/analyzer-0.41.2/lib/src/error/best_practices_verifier.dart:260:36: Error: The getter 'commaSeparatedWithOr' isn't defined for the class 'List<dynamic>'.
 - 'List' is from 'dart:core'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'commaSeparatedWithOr'.
        var validKinds = kindNames.commaSeparatedWithOr;
                                   ^^^^^^^^^^^^^^^^^^^^
pub finished with exit code 1

To Reproduce

  1. flutter create .
  2. add following code in main.dart
  3. flutter pub run build_runner watch
import 'package:flutter/foundation.dart';
import 'package:functional_widget_annotation/functional_widget_annotation.dart';
import 'package:flutter/widgets.dart';

part 'main.g.dart';

// we create a widget using a widget decorated by `@swidget`
@swidget
Widget foo(int value) {
  return Container();
}

@swidget
Widget example(
  int foo,
  String bar, {
  ValueChanged<bool>? onChanged,
}) {
  return Container();
}

void main() => runApp(
      // we use the generated class
      const Foo(42),
    );

my pubspec.yaml

name: flutter_desktop_demo
description: A new Flutter project.

publish_to: 'none' # Remove this line if you wish to publish to pub.dev
https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.15.1 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  functional_widget_annotation: ^0.8.0
  flutter_hooks : any

  cupertino_icons: ^1.0.2

dev_dependencies:
  flutter_test:
    sdk: flutter
  functional_widget: ^0.8.0
  build_runner: ^1.9.0

  flutter_lints: ^1.0.0

# The following section is specific to Flutter.
flutter:

  uses-material-design: true

Expected behavior
I just run the example code, I hope to run normally.

@hxse hxse added the bug Something isn't working label Jan 21, 2022
@hxse
Copy link
Author

hxse commented Jan 25, 2022

flutter pub outdated --mode=null-safety
According to command(null-safety) upgrade package solves the problem

@hxse hxse closed this as completed Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant