Search code examples
flutterfirebasedartflutter-dependencies

Flutter null safety migration build fails - 'FirebaseFirestoreWeb.runTransaction' has fewer named arguments than those of overridden method


We are trying to upgrade our flutter project to null safety migration using the following link https://dart.dev/null-safety/migration-guide.

After completion of above commands and trying to start app using flutter run

/AppData/Local/Pub/Cache/hosted/pub.dev/cloud_firestore_web-2.6.18/lib/cloud_firestore_web.dart:101:14:    
Error: The method 'FirebaseFirestoreWeb.runTransaction' has fewer named arguments than those of overridden method
'FirebaseFirestorePlatform.runTransaction'.
  Future<T?> runTransaction<T>(TransactionHandler<T> transactionHandler,

/AppData/Local/Pub/Cache/hosted/pub.dev/cloud_firestore_platform_interface-5.7.5/lib/src/platform_interface
/platform_interface_firestore.dart:170:14: Context: This is the overridden method ('runTransaction').
  Future<T?> runTransaction<T>(TransactionHandler<T> transactionHandler,

/AppData/Local/Pub/Cache/hosted/pub.dev/cloud_firestore_web-2.6.18/lib/cloud_firestore_web.dart:101:14:
Error: The method 'FirebaseFirestoreWeb.runTransaction' doesn't have the named parameter 'maxAttempts' of overridden method    
'FirebaseFirestorePlatform.runTransaction'.
  Future<T?> runTransaction<T>(TransactionHandler<T> transactionHandler,

Waiting for connection from debug service on Chrome...             49.6s
Failed to compile application.

We tried resolving the issue by upgrading flutter as below - (https://github.com/firebase/flutterfire/issues/9221)

flutter pub upgrade
Resolving dependencies...
Because project depends on cloud_firestore ^5.1.0 which doesn't match any versions, version solving failed.
pub finished with exit code 1


Solution

  • Try using cloud_firestore: ^4.4.5 which is latest stable on current data.

    cloud_firestore

    Then do

    • flutter clean
    • flutter pub get
    • check if there is any compile error