In my case, it was one of the transitive dependencies that was outdated.
Upgrading dependencies resolved the issue for me.
From the Terminal (inside the project’s folder):
flutter pub upgrade
From Visual Studio Code
- Open Command Palette… (⌘ Command+P on MacOS)
- Type
Flutter: Upgrade Packages
From Android Studio
- Open Search Everywhere (Shift, Shift on MacOS)
- Type
Flutter Pub Upgrade