felangel / bloc

A predictable state management library that helps implement the BLoC design pattern
https://bloclibrary.dev
MIT License
11.65k stars 3.38k forks source link

build: Error: 'uthrow' isn't a type uthrow FlutterError( #3433

Closed Elbarqy closed 2 years ago

Elbarqy commented 2 years ago

Description

it used to work on previous commits but when I rebuild the app everything fell apart.. I tried reverting the commits but it still failed.. I even re-installed flutter but any package that uses blocProvider instantly fails with that error message

Describe what changes need to be done to the build system and why

  runApp(
    MultiBlocProvider(
      providers: [BlocProvider<TestBloc>(create: (context) => TestBloc())],
      child: Builder(
        builder: (context) {
          return BlocBuilder<TestBloc, TestState>(
            builder: (context, state) {
              return const MyApp();
            },
          );
        },
      ),
    ),
  );

I have also cloned online repo and it fails to build with the same error message

: Error: 'uthrow' isn't a type. ../…/src/bloc_provider.dart:103 uthrow FlutterError( ^^^^^^ : Error: Expected ';' after this. ../…/src/bloc_provider.dart:103 uthrow FlutterError( ^^^^^^^^^^^^ : Error: Expected ')' before this. ../…/src/bloc_provider.dart:111 ''',

flutter doctor -v

[✓] Flutter (Channel stable, 3.0.4, on Ubuntu 20.04.4 LTS 5.13.0-52-generic, locale en_US.UTF-8) • Flutter version 3.0.4 at /home/barq/dev/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 85684f9300 (13 days ago), 2022-06-30 13:22:47 -0700 • Engine revision 6ba2af10bb • Dart version 2.17.5 • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at /home/barq/Android/Sdk • Platform android-33, build-tools 33.0.0 • Java binary at: /home/barq/dev/android-studio-2021.2.1.15-linux/android-studio/jre/bin/java • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) • All Android licenses accepted.

[✓] Chrome - develop for the web • Chrome at google-chrome

[✗] Linux toolchain - develop for Linux desktop ✗ clang++ is required for Linux development. It is likely available from your distribution (e.g.: apt install clang), or can be downloaded from https://releases.llvm.org/ ✗ CMake is required for Linux development. It is likely available from your distribution (e.g.: apt install cmake), or can be downloaded from https://cmake.org/download/ ✗ ninja is required for Linux development. It is likely available from your distribution (e.g.: apt install ninja-build), or can be downloaded from https://github.com/ninja-build/ninja/releases • pkg-config version 0.29.1 ✗ GTK 3.0 development libraries are required for Linux development. They are likely available from your distribution (e.g.: apt install libgtk-3-dev)

[✓] Android Studio (version 2021.2) • Android Studio at /home/barq/dev/android-studio-2021.2.1.15-linux/android-studio • Flutter plugin version 69.0.2 • Dart plugin version 212.5744 • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.69.0) • VS Code at /usr/share/code • Flutter extension version 3.44.0

[✓] Connected device (3 available) • sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator) • Linux (desktop) • linux • linux-x64 • Ubuntu 20.04.4 LTS 5.13.0-52-generic • Chrome (web) • chrome • web-javascript • Google Chrome 103.0.5060.114

[✓] HTTP Host Availability • All required HTTP hosts are available

flutter build apk -v

[ +55 ms] executing: uname -m [ +25 ms] Exit code 0 from: uname -m [ ] x86_64 [ +5 ms] executing: [/home/barq/dev/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H [ +10 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H [ +1 ms] 85684f9300908116a78138ea4c6036c35c9a1236 [ ] executing: [/home/barq/dev/flutter/] git tag --points-at 85684f9300908116a78138ea4c6036c35c9a1236 [ +11 ms] Exit code 0 from: git tag --points-at 85684f9300908116a78138ea4c6036c35c9a1236 [ ] 3.0.4 [ +13 ms] executing: [/home/barq/dev/flutter/] git rev-parse --abbrev-ref --symbolic @{u} [ +7 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u} [ ] origin/stable [ ] executing: [/home/barq/dev/flutter/] git ls-remote --get-url origin [ +6 ms] Exit code 0 from: git ls-remote --get-url origin [ ] https://github.com/flutter/flutter.git [ +68 ms] executing: [/home/barq/dev/flutter/] git rev-parse --abbrev-ref HEAD [ +6 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD [ ] stable [ +42 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update. [ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update. [ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update. [ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update. [ +2 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update. [ ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update. [ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update. [ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update. [ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update. [ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update. [ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update. [ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update. [ +40 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update. [ ] Artifact Instance of 'GradleWrapper' is not required, skipping update. [ +2 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update. [ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update. [ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update. [ ] Artifact Instance of 'FlutterSdk' is not required, skipping update. [ ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update. [ ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update. [ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update. [ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update. [ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update. [ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update. [ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update. [ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update. [ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update. [ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update. [ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update. [ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update. [ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update. [ ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update. [ ] Artifact Instance of 'PubDependencies' is not required, skipping update. [ +83 ms] Skipping pub get: version match. [ +41 ms] Found plugin location at /home/barq/.pub-cache/hosted/pub.dartlang.org/location-4.4.0/ [ +5 ms] Found plugin location_web at /home/barq/.pub-cache/hosted/pub.dartlang.org/location_web-3.1.1/ [ +61 ms] Found plugin location at /home/barq/.pub-cache/hosted/pub.dartlang.org/location-4.4.0/ [ +2 ms] Found plugin location_web at /home/barq/.pub-cache/hosted/pub.dartlang.org/location_web-3.1.1/ [ +19 ms] Generating /home/barq/projects/barq-migration/migration/android/app/src/main/java/io/flutte r/plugins/GeneratedPluginRegistrant.java [ +53 ms] 💪 Building with sound null safety 💪 [ +13 ms] Running Gradle task 'assembleRelease'... [ +3 ms] Using gradle from /home/barq/projects/barq-migration/migration/android/gradlew. [ +17 ms] executing: /home/barq/dev/android-studio-2021.2.1.15-linux/android-studio/jre/bin/java -version [ +97 ms] Exit code 0 from: /home/barq/dev/android-studio-2021.2.1.15-linux/android-studio/jre/bin/java -version [ ] openjdk version "11.0.12" 2021-07-20 OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) OpenJDK 64-Bit Server VM (build 11.0.12+0-b1504.28-7817840, mixed mode) [ +4 ms] executing: [/home/barq/projects/barq-migration/migration/android/] /home/barq/projects/barq-migration/migration/android/gradlew -Pverbose=true -Ptarget-platform=android-arm,android-arm64,android-x64 -Ptarget=lib/main.dart -Pbase-application-name=android.app.Application -Pdart-obfuscation=false -Ptrack-widget-creation=true -Ptree-shake-icons=true assembleRelease [+1197 ms] > Task :location:preBuild UP-TO-DATE [ ] > Task :location:preReleaseBuild UP-TO-DATE [ ] > Task :location:compileReleaseAidl NO-SOURCE [ ] > Task :location:mergeReleaseJniLibFolders [ ] > Task :location:mergeReleaseNativeLibs NO-SOURCE [ ] > Task :location:stripReleaseDebugSymbols NO-SOURCE [ ] > Task :location:compileReleaseRenderscript NO-SOURCE [ ] > Task :location:copyReleaseJniLibsProjectAndLocalJars [ +88 ms] > Task :location:generateReleaseBuildConfig [ ] > Task :location:generateReleaseResValues [ ] > Task :location:generateReleaseResources [ +99 ms] > Task :location:packageReleaseResources [ +99 ms] > Task :location:javaPreCompileRelease [ ] > Task :location:mergeReleaseShaders [ ] > Task :location:compileReleaseShaders NO-SOURCE [ ] > Task :location:generateReleaseAssets UP-TO-DATE [ ] > Task :location:packageReleaseAssets [ ] > Task :location:packageReleaseRenderscript NO-SOURCE [ ] > Task :location:prepareLintJarForPublish UP-TO-DATE [ ] > Task :location:prepareReleaseArtProfile [ ] > Task :location:processReleaseJavaRes NO-SOURCE [ ] > Task :location:writeReleaseAarMetadata [ ] > Task :app:buildKotlinToolingMetadata [ ] > Task :location:parseReleaseLocalResources [ +198 ms] > Task :location:processReleaseManifest [+4101 ms] > Task :app:compileFlutterBuildRelease [ ] ../../../.pub-cache/hosted/pub.dartlang.org/flutter_bloc-8.0.1/lib/src/bloc_provider.dart:103:8: Error: 'uthrow' isn't a type. [ +1 ms] uthrow FlutterError( [ ] ^^^^^^ [ ] ../../../.pub-cache/hosted/pub.dartlang.org/flutter_bloc-8.0.1/lib/src/bloc_provider.dart:103:15: Error: Expected ';' after this. [ ] uthrow FlutterError( [ ] ^^^^^^^^^^^^ [ ] ../../../.pub-cache/hosted/pub.dartlang.org/flutter_bloc-8.0.1/lib/src/bloc_provider.dart:111:12: Error: Expected ')' before this. [ ] ''', [ ] ^ [ ] ../../../.pub-cache/hosted/pub.dartlang.org/flutter_bloc-8.0.1/lib/src/bloc_provider.dart:95:12: Error: A non-null value must be returned since the return type 'T' doesn't allow null. [ ] static T of<T extends StateStreamableSource<Object?>>( [ ] ^ [+5094 ms] > Task :app:compileFlutterBuildRelease FAILED [ ] Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0. [ ] FAILURE: Build failed with an exception. [ ] Where: [ ] Script '/home/barq/dev/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1156 [ ] What went wrong: [ ] Execution failed for task ':app:compileFlutterBuildRelease'. [ ] > Process 'command '/home/barq/dev/flutter/bin/flutter'' finished with non-zero exit value 1 [ ] Try: [ ] > Run with --stacktrace option to get the stack trace. [ ] > Run with --info or --debug option to get more log output. [ ] > Run with --scan to get full insights. [ ] Get more help at https://help.gradle.org [ ] BUILD FAILED in 10s [ ] You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins. [ ] See https://docs.gradle.org/7.4/userguide/command_line_interface.html#sec:command_line_warnings [ ] 15 actionable tasks: 14 executed, 1 up-to-date [ +373 ms] Running Gradle task 'assembleRelease'... (completed in 11.4s) [ +3 ms] "flutter apk" took 11,748ms. [ +4 ms] Gradle task assembleRelease failed with exit code 1 [ ]

0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)

       #1      AndroidGradleBuilder.buildGradleApp (package:flutter_tools/src/android/gradle.dart:406:9)
       <asynchronous suspension>
       #2      AndroidGradleBuilder.buildApk (package:flutter_tools/src/android/gradle.dart:184:5)
       <asynchronous suspension>
       #3      BuildApkCommand.runCommand (package:flutter_tools/src/commands/build_apk.dart:109:5)
       <asynchronous suspension>
       #4      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1183:27)
       <asynchronous suspension>
       #5      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
       <asynchronous suspension>
       #6      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
       <asynchronous suspension>
       #7      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9)
       <asynchronous suspension>
       #8      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
       <asynchronous suspension>
       #9      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
       <asynchronous suspension>
       #10     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
       <asynchronous suspension>
       #11     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
       <asynchronous suspension>
       #12     main (package:flutter_tools/executable.dart:94:3)
       <asynchronous suspension>
Elbarqy commented 2 years ago

after some hours something worked .. just remove the pub cache and redownload

flutter clean
flutter pub cache clean
flutter pub get
flutter build apk

it's wierd as it was working and suddenly started complaining to waste my life xD