flutter_localizations null safety issue

I use package jiffy which depends on intl 0.16.0. After I upgrade into latest master it conflicts with the intl 0.17.0-nullsafety.2 from flutter_localizations

Because no versions of jiffy match >3.0.1 <4.0.0 and jiffy 3.0.1 depends on intl ^0.16.0, jiffy ^3.0.1 requires intl ^0.16.0.
And because every version of flutter_localizations from sdk depends on intl 0.17.0-nullsafety.2, jiffy ^3.0.1 is incompatible with flutter_localizations from sdk.

I then try resolve version conflict by using

dependency_overrides:
   intl: ^0.16.0

But when I run the app, I have some null safety issues on flutter_localizations

../flutter/packages/flutter_localizations/lib/src/material_localizations.dart:413:7: Error: Method 'replaceFirst' cannot be called on 'String?' because it is potentially null.
Try calling using ?. instead.
    ).replaceFirst(r'$selectedRowCount', formatDecimal(selectedRowCount));
      ^^^^^^^^^^^^
../flutter/packages/flutter_localizations/lib/src/material_localizations.dart:550:7: Error: Method 'replaceFirst' cannot be called on 'String?' because it is potentially null.
Try calling using ?. instead.
    ).replaceFirst(r'$licenseCount', formatDecimal(licenseCount));
      ^^^^^^^^^^^^
../flutter/packages/flutter_localizations/lib/src/material_localizations.dart:659:7: Error: Method 'replaceFirst' cannot be called on 'String?' because it is potentially null.
Try calling using ?. instead.
    ).replaceFirst(r'$remainingCount', formatDecimal(remainingCount));
      ^^^^^^^^^^^^

Is there anyway to disable null safety on flutter_localizations ? My project is quite big and refactor to null safety takes so much time.

flutter doctor -v
[✓] Flutter (Channel master, 1.24.0-8.0.pre.228, on Mac OS X 10.15.7 19H2 darwin-x64, locale en)
    • Flutter version 1.24.0-8.0.pre.228 at /Users/admin/Documents/Soft/flutter
    • Framework revision 9860f52ea5 (3 hours ago), 2020-11-12 18:14:03 -0800
    • Engine revision c5c7e83b9e
    • Dart version 2.12.0 (build 2.12.0-31.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/admin/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/admin/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/admin/Library/Android/sdk
    • Java binary at: /Applications/Android Studio 3.5 Preview.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.1, Build version 12A7403
    • CocoaPods version 1.9.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio 3.5 Preview.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.51.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.16.0

[✓] Connected device (3 available)
    • macOS (desktop)  • macos      • darwin-x64     • Mac OS X 10.15.7 19H2 darwin-x64
    • Web Server (web) • web-server • web-javascript • Flutter Tools
    • Chrome (web)     • chrome     • web-javascript • Google Chrome 86.0.4240.198

• No issues found!

Author: Fantashit

1 thought on “flutter_localizations null safety issue

  1. I found another workaround:

    dependency_overrides:
       intl: ^0.17.0-nullsafety.2
    

    Instead of forcing intl 0.16.0, I force the new null safety version 0.17.0-nullsafety.2, and it can run well even though I don’t enable null safety on my project.
    I don’t see any issue with the jiffy code

Comments are closed.