Fixing `because every version of firebase_ui_localizations depends on flutter_localizations from sdk which depends on intl 0.18.0, firebase_ui_firestore >=1.0.1 requires intl 0.18.0.

Today my Flutter app started breaking with the following error:

because every version of firebase_ui_localizations depends on flutter_localizations from sdk which depends on intl 0.18.0, firebase_ui_firestore >=1.0.1 requires intl 0.18.0.
So, because [project]  depends on both intl ^0.17.0 and firebase_ui_firestore ^1.0.2, version solving failed.

It looks like I should updated my project dependency to use intl ^0.18.0. So I did, but then the now deprecated charts_flutter is unhappy. Fine, charts_flutter has since been replaced by community_charts_flutter anyway (ticket, pub page). Let's remove the charts_flutter for now and see what happens.

Now another project is unhappy:

And because firebase_ui_firestore >=1.3.0 depends on firebase_ui_localizations ^1.3.0 which depends on intl ^0.17.0, firebase_ui_firestore >=1.0.1 requires intl ^0.17.0.
So, because [project] depends on both intl ^0.18.0 and firebase_ui_firestore ^1.0.2, version solving failed.

I am quite puzzled by this message since it seems to contradict the first message. Let's modify my pubspec.yaml so that it depends on intl: any:

dependencies:
  flutter:
    sdk: flutter
  ...
  intl: any
  ...
  firebase_ui_oauth_google: ^1.0.2
  firebase_ui_oauth_apple: ^1.0.2
  firebase_ui_firestore: ^1.0.2
  firebase_ui_auth: ^1.0.2
  ...

I get this error message:

Resolving dependencies...
    Because firebase_ui_firestore >=1.0.1 <1.2.1 depends on firebase_ui_localizations ^1.0.1 and firebase_ui_firestore >=1.2.1 <1.2.3 depends on firebase_ui_localizations ^1.0.2, firebase_ui_firestore >=1.0.1 <1.2.3 requires firebase_ui_localizations ^1.0.1.
    And because firebase_ui_firestore >=1.2.3 <1.2.4 depends on firebase_ui_localizations ^1.1.0 and firebase_ui_firestore >=1.2.4 <1.2.5 depends on firebase_ui_localizations ^1.1.1, firebase_ui_firestore >=1.0.1 <1.2.5 requires firebase_ui_localizations ^1.0.1.
(1) So, because firebase_ui_firestore >=1.2.5 <1.3.0 depends on firebase_ui_localizations ^1.2.0 and firebase_ui_firestore >=1.3.0 depends on firebase_ui_localizations ^1.3.0, firebase_ui_firestore >=1.0.1 requires firebase_ui_localizations ^1.0.1.

    Because every version of firebase_ui_localizations depends on flutter_localizations from sdk which depends on intl 0.18.0, every version of firebase_ui_localizations requires intl 0.18.0.
    And because firebase_ui_localizations >=1.0.0-dev.1 depends on intl ^0.17.0, firebase_ui_localizations >=1.0.0-dev.1 is forbidden.
    And because firebase_ui_firestore >=1.0.1 requires firebase_ui_localizations ^1.0.1 (1), firebase_ui_firestore >=1.0.1 is forbidden.
    So, because flashcards depends on firebase_ui_firestore ^1.0.2, version solving failed.

It seems that because the lower bounds for firebase_ui_firestore are low, so are the lower bounds for firebase_ui_localizations, which depend on intl 0.17.0. It's strange, I thought the package dependency system would look for the correct set of versions that satisfies all conditions. It probably does and I am just not reading the error message correctly.

Let's force my app to use the latest version of firebase_ui_auth: ^1.2.2. Now I get this:

flutter pub upgrade
Resolving dependencies...
Because every version of flutter_localizations from sdk depends on intl 0.18.0 and firebase_ui_localizations >=1.0.0-dev.1 depends on intl ^0.17.0, flutter_localizations from sdk is incompatible with firebase_ui_localizations >=1.0.0-dev.1.
And because firebase_ui_auth >=1.2.0 depends on firebase_ui_localizations ^1.3.0, flutter_localizations from sdk is incompatible with firebase_ui_auth >=1.2.0.
So, because [project] depends on firebase_ui_auth ^1.2.2 which depends on flutter_localizations from sdk, version solving failed.

Someone on a StackOverflow question about that exact topic from 30 days ago, answered "simply add "firebase_ui_auth:" without any version and it will try to pick up the latest that works in your case.". I will not post a link because I don't want Google to suggest that terrible answer. "simply". How I hate that word. "just" is also a word I equally hate. Because the people who use it want to convey how easy the problem is, minimizing the poster's issue. The reality is, it's not easy. And their "obvious" fix does not actually work.

Checking the source code for firebase_ui_localizations, and indeed it seems like on master, it's still relying on intl 0.17.0. https://github.com/firebase/flutterfire/blob/0ac13b6fc06f6839686437dc2d5b6feab179aa83/packages/firebase_ui_localizations/pubspec.yaml#L18

So I have no other resort but to use dependency_overrides:

dependency_overrides:
  # Remove when firebase_ui_firestore stops relying on 0.17.0.
  # https://github.com/firebase/flutterfire/blob/master/packages/firebase_ui_localizations/pubspec.yaml#L18
  intl: ^0.18.0

This works but it is unfortunate I have to resort to such workarounds.