Problem buliding old project with flutter 2.0.0

1,572
flutter clean

and

flutter pub get

should solve your problem.

Share:
1,572
Amir Ebrahimi
Author by

Amir Ebrahimi

I'm a new to android developing and i love it , and i'm looking forward to be one of the best android developers. and I apologize for my bad English.

Updated on December 28, 2022

Comments

  • Amir Ebrahimi
    Amir Ebrahimi over 1 year

    After upgrading to flutter 2.0.0 I can't build the app anymore. this is the output. My problem is I have heavy usage of libraries and a lot of them are not null safe and I can't upgrade all of my dependencies to null safe mode. Does anyone have any suggestions on this?

    Try calling using ?. instead.
        ).replaceFirst(r'$remainingCount', formatDecimal(remainingCount));
          ^^^^^^^^^^^^
    ../../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/extended_image-1.6.0/lib/src/extended_image.dart:785:44: Error: No named parameter with the name 'nullOk'.
        _invertColors = MediaQuery.of(context, nullOk: true)?.invertColors ??
                                               ^^^^^^
    ../../flutter/flutter/packages/flutter/lib/src/widgets/media_query.dart:818:25: Context: Found this candidate, but the arguments don't match.
      static MediaQueryData of(BuildContext context) {
    
                            ^^
    ../../flutter/flutter/.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/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) {
    
                    ^^^^^^^^
    

    update 1: After updating to flutter 2.0.1 and flutter pub cache repair and flutter clean. and running with flag flutter run --no-sound-null-safety. Still, no chance to run the app and this is the output.

    ../../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_neumorphic-3.0.3/lib/src/widget/app_bar.dart:147:57: Error: No named parameter with the name 'nullOk'.
        final ScaffoldState scaffold = Scaffold.of(context, nullOk: true);
                                                            ^^^^^^
    ../../flutter/flutter/packages/flutter/lib/src/material/scaffold.dart:1944:24: Context: Found this candidate, but the arguments don't match.
      static ScaffoldState of(BuildContext context) {
                           ^^
    ../../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.19.1/lib/src/picture_provider.dart:52:59: Error: No named parameter with the name 'nullOk'.     
            context != null ? Localizations.localeOf(context, nullOk: true) : null,
                                                              ^^^^^^
    ../../flutter/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) {
                    ^^^^^^^^
    
    
    FAILURE: Build failed with an exception.
    
    * Where:
    Script 'D:\Documents\flutter\flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991
    
    * What went wrong:
    Execution failed for task ':app:compileFlutterBuildDebug'.
    > Process 'command 'D:\Documents\flutter\flutter\flutter\bin\flutter.bat'' 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 26s
    

    Update 2: Here is an output of flutter doctor

    Doctor summary (to see all details, run flutter doctor -v):
    [√] Flutter (Channel stable, 2.0.1, on Microsoft Windows [Version 10.0.19042.804], locale en-US)
    [√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    [√] Chrome - develop for the web
    [√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.8.4)   
    [√] Android Studio (version 4.1.0)
    [√] IntelliJ IDEA Ultimate Edition (version 2020.3)
    [√] VS Code (version 1.54.1)
    [√] Connected device (4 available)
    
    • No issues found!
    
  • Amir Ebrahimi
    Amir Ebrahimi over 3 years
    Yes I know, I never updated the dart SDK of my project. Still I cannot build
  • Sadegh Ghanbari
    Sadegh Ghanbari about 3 years
    I had the same problem and solved it by setting the SDK to ">=2.7.0 <=2.12.2"