Try correcting the name to the name of an existing getter, or defining a getter or field named 'MethodChannelFirebase'

Viewed 1348
import 'package:booktest/model/profile.dart';
import 'package:flutter/material.dart';
import 'package:form_field_validator/form_field_validator.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_auth/firebase_auth.dart';

class RegisterScreen extends StatefulWidget {
  const RegisterScreen({Key? key}) : super(key: key);

  @override
  State<RegisterScreen> createState() => _RegisterScreenState();
}

class _RegisterScreenState extends State<RegisterScreen> {
    final formkey = GlobalKey<FormState>();
  Profile profile = Profile(
    email: '',
    password: '',
  );

 final Future<FirebaseApp> firebase = Firebase.initializeApp();
  @override
  Widget build(BuildContext context) {  
    return FutureBuilder(
      future: firebase,
      builder: (context, snapshot) {
         if (snapshot.hasError) {
            return Scaffold(
              appBar: AppBar(
                title: const Text("Error"),
              ),
              body: Center(
                child: Text("${snapshot.error}"),
              ),
            );
          }
          if (snapshot.connectionState == ConnectionState.done){
          }
          if (snapshot.hasData) {
            return const Scaffold(


              body: Center(
                child: CircularProgressIndicator(),
              ),
            );
          }
          return const CircularProgressIndicator();
    });}}

enter image description here

* 
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.4.0/lib/firebase_core_platform_interface.dart:21:6: Error: Can't use '/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.4.0/lib/src/method_channel/method_channel_firebase.dart' as a part, because it has no 'part of' declaration.
part 'src/method_channel/method_channel_firebase.dart';
     ^

/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.4.0/lib/src/method_channel/method_channel_firebase_app.dart:50:11: Error: The getter 'MethodChannelFirebase' isn't defined for the class 'MethodChannelFirebaseApp'.
- 'MethodChannelFirebaseApp' is from 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.4.0/lib/firebase_core_platform_interface.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'MethodChannelFirebase'.
    await MethodChannelFirebase.channel.invokeMethod<void>(
          ^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.4.0/lib/src/method_channel/method_channel_firebase_app.dart:55:5: Error: The getter 'MethodChannelFirebase' isn't defined for the class 'MethodChannelFirebaseApp'.

- 'MethodChannelFirebaseApp' is from 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.4.0/lib/firebase_core_platform_interface.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'MethodChannelFirebase'.
    MethodChannelFirebase.appInstances.remove(name);
    ^^^^^^^^^^^^^^^^^^^^^

/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.4.0/lib/src/method_channel/method_channel_firebase_app.dart:63:11: Error: The getter 'MethodChannelFirebase' isn't defined for the class 'MethodChannelFirebaseApp'.
- 'MethodChannelFirebaseApp' is from 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.4.0/lib/firebase_core_platform_interface.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'MethodChannelFirebase'.
    await MethodChannelFirebase.channel.invokeMethod<void>(
          ^^^^^^^^^^^^^^^^^^^^^

/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.4.0/lib/src/method_channel/method_channel_firebase_app.dart:74:11: Error: The getter 'MethodChannelFirebase' isn't defined for the class 'MethodChannelFirebaseApp'.
- 'MethodChannelFirebaseApp' is from 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.4.0/lib/firebase_core_platform_interface.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'MethodChannelFirebase'.
    await MethodChannelFirebase.channel.invokeMethod<void>(

          ^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.4.0/lib/src/platform_interface/platform_interface_firebase.dart:30:39: Error: Method not found: 'MethodChannelFirebase'.
  static FirebasePlatform _instance = MethodChannelFirebase();
                                      ^^^^^^^^^^^^^^^^^^^^^

FAILURE: Build failed with an exception.

* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1102

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\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
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
*

1 Answers

Changing the version of the failed packages solved my problem.

Related