Flutter debug compilation error from /root/.pub-cache/hosted/pub.dartlang.org packages

1,404

I had the same problems. Turned out that some of my packages where not compatible with flutter 2.0.

I solved the problem by upgrading my packages to the newest version. You can either do it by updating them manually in the pubspec.yaml or by flutter pub upgrade --major-versions

Share:
1,404
Ratnadeep
Author by

Ratnadeep

Currently working with Flutter and loving it. Have worked with NodeJs and PHP too.

Updated on December 28, 2022

Comments

  • Ratnadeep
    Ratnadeep over 1 year

    I upgraded to Flutter 2.0 two days back and started to face Execution failed for task ':app:compileFlutterBuildDebug' due to some packages.

    Then I downgraded but the errors remain. My pubspec.yaml looks like below,

    name: news_app
    description: A news app
    
    # The following defines the version and build number for your application.
    # A version number is three numbers separated by dots, like 1.2.43
    # followed by an optional build number separated by a +.
    # Both the version and the builder number may be overridden in flutter
    # build by specifying --build-name and --build-number, respectively.
    # In Android, build-name is used as versionName while build-number used as versionCode.
    # Read more about Android versioning at https://developer.android.com/studio/publish/versioning
    # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
    # Read more about iOS versioning at
    # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
    version: 1.0.3+11
    
    environment:
      sdk: ">=2.1.0 <3.0.0"
    
    dependencies:
      flutter:
        sdk: flutter
      curved_navigation_bar: ^0.3.1
      http: ^0.12.0
      webview_flutter:
      flutter_webview_plugin:
      flutter_cache_manager: ^1.1.2
      flutter_widget_from_html_core:
      flutter_widget_from_html:
      flutter_html:
      flutter_swiper: ^1.1.6
      page_view_indicators: ^1.3.0
      splashscreen: ^1.2.0
      intl: ^0.16.1
      jiffy: ^2.2.0
      dio: ^3.0.8
      dio_http_cache: ^0.2.4
      shared_preferences: ^0.5.3
      connectivity: ^0.4.2
      share: ^0.6.3+3
      sqflite: any
      path_provider:
      timeago: any
      auto_size_text: ^2.1.0
      flutter_tts: ^0.6.0
      firebase_messaging: ^6.0.16
      in_app_update: ^1.1.11
      upgrader: ^0.10.0
      imei_plugin: 1.1.6
      firebase_analytics: ^5.0.14
      flutter_local_notifications: ^1.4.4+1
      # The following adds the Cupertino Icons font to your application.
      # Use with the CupertinoIcons class for iOS style icons.
      cupertino_icons: ^0.1.2
    
    dev_dependencies:
      flutter_test:
        sdk: flutter
    
      flutter_launcher_icons: any
    
    flutter_icons:
      image_path: "assets/TBS_logo.jpg"
      android: true
      ios: true
    
    # For information on the generic Dart part of this file, see the
    # following page: https://dart.dev/tools/pub/pubspec
    
    # The following section is specific to Flutter.
    flutter:
      fonts:
        - family: sourcePro
          fonts:
            - asset: assets/SourceSansPro-Light.ttf
        - family: serifPro
          fonts:
            - asset: assets/SourceSerifPro-Light.otf
        - family: metaSerifPro
          fonts:
            - asset: assets/FFMetaSerifPro-Light.ttf
      # The following line ensures that the Material Icons font is
      # included with your application, so that you can use the icons in
      # the material Icons class.
      uses-material-design: true
      assets:
        - assets/logo.jpeg
        - assets/tbs_logo_transparent.png
        - assets/TBS.png
        - assets/TBS_logo.jpg
      # To add assets to your application, add an assets section, like this:
      # assets:
      #  - images/a_dot_burr.jpeg
      #  - images/a_dot_ham.jpeg
    
      # An image asset can refer to one or more resolution-specific "variants", see
      # https://flutter.dev/assets-and-images/#resolution-aware.
    
      # For details regarding adding assets from package dependencies, see
      # https://flutter.dev/assets-and-images/#from-packages
    
      # To add custom fonts to your application, add a fonts section here,
      # in this "flutter" section. Each entry in this list should have a
      # "family" key with the font family name, and a "fonts" key with a
      # list giving the asset and other descriptors for the font. For
      # example:
      # fonts:
      #   - family: Schyler
      #     fonts:
      #       - asset: fonts/Schyler-Regular.ttf
      #       - asset: fonts/Schyler-Italic.ttf
      #         style: italic
      #   - family: Trajan Pro
      #     fonts:
      #       - asset: fonts/TrajanPro.ttf
      #       - asset: fonts/TrajanPro_Bold.ttf
      #         weight: 700
      #
      # For details regarding fonts from package dependencies,
      # see https://flutter.dev/custom-fonts/#from-packages
    
    

    The packages that are causing the errors are chewie-0.9.10 and flutter_svg-0.18.1. But the thing is none of these two packages are in my pubspec.yaml. The errors are given below.

    /root/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.18.1/lib/src/picture_provider.dart:50:59: Error: No named parameter with the name 'nullOk'.
            context != null ? Localizations.localeOf(context, nullOk: true) : null,
    
                                                              ^^^^^^        
    ../../flutter/packages/flutter/lib/src/widgets/localizations.dart:413:17: Context: Found this candidate, but the arguments don't match.
      static Locale localeOf(BuildContext context) {                        
                    ^^^^^^^^                                                
    
    /root/.pub-cache/hosted/pub.dartlang.org/chewie-0.9.10/lib/src/chewie_player.dart:83:7: Error: No named parameter with the name 'resizeToAvoidBottomPadding'.
          resizeToAvoidBottomPadding: false,                                
          ^^^^^^^^^^^^^^^^^^^^^^^^^^                                        
    
    ../../flutter/packages/flutter/lib/src/material/scaffold.dart:1449:9: Context: Found this candidate, but the arguments don't match.
      const Scaffold({                                                      
            ^^^^^^^^                                                        
    
    /root/.pub-cache/hosted/pub.dartlang.org/chewie-0.9.10/lib/src/chewie_player.dart:276:17: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
     - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../flutter/packages/flutter/lib/src/widgets/framework.dart').
    
    Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
            context.inheritFromWidgetOfExactType(_ChewieControllerProvider) 
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^                            
                                 
    

    Everything I tried,

    1. Downgraded from flutter 2.0 because everything was fine before upgrading.
    2. Tried running flutter clean and then run.
    3. Tried running flutter pub cache repair
    4. I deleted the entire /root/.pub-cache/hosted/ directory and did run flutter pub get.
    5. Tried running dart pub upgrade
    6. I even reinstalled flutter entirely.

    Nothing worked for me. I tried everything that I found by searching in SO and other places.

    Thanks for reading.