title: The argument type 'Widget Function(BuildContext)' cant be assigned to the parameter type 'Widget Function(BuildContext, Widget)' Error in Flutter
body: <p>This is a code:</p>
  <pre><code>import 'package:flutter/material.dart';
  import 'package:flutterapp/ui/pages/notes_home.dart';
  import 'package:provider/provider.dart';
  import 'package:flutterapp/ui/pages/splash.dart';
  import 'package:flutterapp/ui/pages/user_info.dart';
  import 'package:flutterapp/ui/pages/auth/login.dart';
  import 'package:flutterapp/model/user_repository.dart';
  import 'package:path/path.dart';
  
  class HomePage extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return ChangeNotifierProvider(
        builder: (_) =&gt; UserRepository.instance(),
        child: Consumer
          // ignore: missing_return
          (builder: (context, UserRepository user, _) {
            // ignore: missing_return
            switch (user.status){
              case Status.Uninitialized:
                return Splash();
              case Status.Unauthenticated:
              case Status.Authenticating:
                return LoginPage();
              case Status.Authenticated:
                return NotesHomePage();
            }
        }),
      );
    }
  }
  </code></pre>
  <p>The line &quot;builder: (_) =&gt; UserRepository.instance(),&quot; in above code shows a error</p>
  <p>The argument type 'Widget Function(BuildContext)' cant be assigned to the parameter type 'Widget Function(BuildContext, Widget)'</p>
  <p>and whenever I run the program it shows that</p>
  <p>Could not find the correct Providerabove this LoginPage Widget</p>
  <p>UserRepository code:</p>
  <pre><code>import 'package:flutter/material.dart';
  import 'package:firebase_auth/firebase_auth.dart';
  import 'package:google_sign_in/google_sign_in.dart';
  
  enum Status { Uninitialized, Authenticated, Authenticating, Unauthenticated }
  
  class UserRepository with ChangeNotifier {
    FirebaseAuth _auth;
    FirebaseUser _user;
    GoogleSignIn _googleSignIn;
    Status _status = Status.Uninitialized;
  
    UserRepository.instance()
        : _auth = FirebaseAuth.instance,
          _googleSignIn = GoogleSignIn() {
        _auth.onAuthStateChanged.listen(_onAuthStateChanged);
    }
  
    Status get status =&gt; _status;
    FirebaseUser get user =&gt; _user;
  
    Future&lt;bool&gt; signIn(String email, String password) async{
      try {
        _status = Status.Authenticating;
        notifyListeners();
        await _auth.signInWithEmailAndPassword(email: email, password: password);
        return true;
      }catch(e){
        _status = Status.Unauthenticated;
        notifyListeners();
        return false;
      }
    }
  
    Future&lt;bool&gt; signUp(String email, String password) async{
      try {
        _status = Status.Authenticating;
        notifyListeners();
        await _auth.createUserWithEmailAndPassword(email: email, password: password);
        return true;
      }catch(e){
        _status = Status.Unauthenticated;
        notifyListeners();
        return false;
      }
    }
  
    Future&lt;bool&gt; signInWithGoogle() async{
      try{
        _status =Status.Authenticating;
        notifyListeners();
        final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
        final GoogleSignInAuthentication googleAuth =
            await googleUser.authentication;
        final AuthCredential credential = GoogleAuthProvider.getCredential(idToken: googleAuth.idToken, accessToken: googleAuth.accessToken);
        await _auth.signInWithCredential(credential);
        return true;
      }catch(e) {
        print(e);
        _status = Status.Unauthenticated;
        notifyListeners();
        return false;
      }
    }
  
    Future signOut() async {
      _auth.signOut();
      _googleSignIn.signOut();
      _status = Status.Unauthenticated;
      notifyListeners();
      return Future.delayed(Duration.zero);
    }
  
    Future&lt;void&gt; _onAuthStateChanged(FirebaseUser firebaseUser) async{
      if(firebaseUser == null) {
        _status = Status.Unauthenticated;
      }else{
        _user = firebaseUser;
        _status = Status.Authenticated;
      }
      notifyListeners();
    }
  }
  </code></pre>
  <p>Please help</p>
  <p>Here is a login page code:</p>
  <pre><code>import 'package:flutter/material.dart';
  import 'package:flutterapp/model/user_repository.dart';
  import 'package:provider/provider.dart';
  
  class LoginPage extends StatefulWidget {
    @override
    _LoginPageState createState() =&gt; _LoginPageState();
  }
  
  class _LoginPageState extends State&lt;LoginPage&gt; {
    final GlobalKey&lt;ScaffoldState&gt; _key = GlobalKey&lt;ScaffoldState&gt;();
    bool signInForm;
    @override
    void initState() {
      // TODO: implement initState
      super.initState();
      signInForm = true;
    }
  
    @override
    Widget build(BuildContext context) {
      final user = Provider.of&lt;UserRepository&gt;(context);
      return WillPopScope(
        onWillPop: () async{
          if(!signInForm) {
            setState(() {
              signInForm = true;
            });
            return false;
          }else{
            return true;
          }
        },
        child: Scaffold(
          key: _key,
          backgroundColor: Colors.red,
          body: SingleChildScrollView(
            padding: const EdgeInsets.all(16.0),
            child: SizedBox(
              width: double.infinity,
              child: Column(
                children: &lt;Widget&gt;[
                  const SizedBox(height: kToolbarHeight),
                  Container(
                    decoration: BoxDecoration(
                      color: Colors.white,
                      shape: BoxShape.circle,
                    ),
                    width: 60.0,
                    height: 60.0,
                  ),
                  const SizedBox(height: 30.0),
                  RaisedButton(
                    textColor: Colors.red,
                    color: Colors.white,
                    child: Text('Google'),
                    onPressed: () async{
                      if(!await user.signInWithGoogle())
                        showmessage();
                    },
                  ),
                  const SizedBox(height: 30.0),
                  AnimatedSwitcher(
                    child: signInForm ? LoginForm() : SignupForm(),
                    duration: Duration(milliseconds: 200),
                  ),
                  const SizedBox(height: 20.0,),
                  OutlineButton(
                    textColor: Colors.white,
                    child: signInForm ? Text(&quot;Sign Up&quot;, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0),) : Icon(Icons.arrow_back),
                    onPressed: () {
                      setState(() {
                        signInForm = !signInForm;
                      });
                    },
                    color: Colors.white,
                    borderSide: BorderSide(color: Colors.white),
                    highlightColor: Colors.white,
                  )
                ],
              ),
            )
          ),
        ),
      );
    }
    void showmessage(){
      _key.currentState.showSnackBar(SnackBar(
        content: Text(&quot;Somethimg is wrong&quot;),
      ));
    }
  }
  
  class LoginForm extends StatefulWidget {
    final Function showError;
  
    const LoginForm({Key key, this.showError}) : super(key: key);
    @override
    _LoginFormState createState() =&gt; _LoginFormState();
  }
  
  class _LoginFormState extends State&lt;LoginForm&gt; {
    final GlobalKey&lt;FormState&gt; _formKey = GlobalKey&lt;FormState&gt;();
    final FocusNode passwordField = FocusNode();
    TextEditingController _email;
    TextEditingController _password;
  
    @override
    void initState() {
      _email = TextEditingController();
      _password = TextEditingController();
      super.initState();
    }
  
    @override
    Widget build(BuildContext context) {
      final user = Provider.of&lt;UserRepository&gt;(context);
      return Container(
        padding: const EdgeInsets.all(16.0),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(10.0),
        ),
        child: Form(
          key: _formKey,
          child: Column(
            children: &lt;Widget&gt;[
              Text(&quot;Login&quot;, style: Theme.of(context).textTheme.display1,),
              const SizedBox(height: 20.0),
              TextFormField(
                controller: _email,
                textInputAction: TextInputAction.next,
                decoration: InputDecoration(
                    labelText: &quot;Email&quot;
                ),
                onEditingComplete: (){
                  FocusScope.of(context).requestFocus(passwordField);
                },
              ),
              const SizedBox(height: 16.0,),
              TextFormField(
                controller: _password,
                focusNode: passwordField,
                obscureText: true,
                decoration: InputDecoration(
                    labelText: &quot;Password&quot;
                ),
              ),
              const SizedBox(height: 20.0),
              RaisedButton(
                textColor: Colors.red,
                child: Text(&quot;Login&quot;),
                onPressed: () async{
                  if(_formKey.currentState.validate()){
                    if(!await user.signIn(
                      _email.text, _password.text))
                      widget.showError();
                  }
                },
              )
            ],
          ),
        ),
      );
    }
  }
  
  class SignupForm extends StatefulWidget {
    @override
    _SignupFormState createState() =&gt; _SignupFormState();
  }
  
  class _SignupFormState extends State&lt;SignupForm&gt; {
    final FocusNode passwordField = FocusNode();
    final FocusNode confirmPasswordField = FocusNode();
    TextEditingController _email;
    TextEditingController _password;
    TextEditingController _confirmpassword;
    final GlobalKey&lt;FormState&gt; _formKey = GlobalKey&lt;FormState&gt;();
  
    @override
    void initState() {
      _email = TextEditingController();
      _password = TextEditingController();
      _confirmpassword = TextEditingController();
      super.initState();
    }
  
    @override
    Widget build(BuildContext context) {
      final user = Provider.of&lt;UserRepository&gt;(context);
      return Container(
        padding: const EdgeInsets.all(16.0),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(10.0),
        ),
        child: Form(
          key: _formKey,
          child: Column(
            children: &lt;Widget&gt;[
              Text(&quot;Sign Up&quot;, style: Theme.of(context).textTheme.display1,),
              const SizedBox(height: 20.0),
              TextFormField(
                controller: _email,
                textInputAction: TextInputAction.next,
                decoration: InputDecoration(
                    labelText: &quot;Email&quot;
                ),
                onEditingComplete: (){
                  FocusScope.of(context).requestFocus(passwordField);
                },
              ),
              const SizedBox(height: 16.0,),
              TextFormField(
                obscureText: true,
                controller: _password,
                focusNode: passwordField,
                decoration: InputDecoration(
                    labelText: &quot;Password&quot;
                ),
                onEditingComplete: ()=&gt; FocusScope.of(context).requestFocus(confirmPasswordField),
              ),
              const SizedBox(height: 16.0,),
              TextFormField(
                obscureText: true,
                controller: _confirmpassword,
                focusNode: confirmPasswordField,
                decoration: InputDecoration(
                    labelText: &quot;Confirm Password&quot;
                ),
                onEditingComplete: (){
                  FocusScope.of(context).requestFocus(passwordField);
                },
              ),
              const SizedBox(height: 20.0),
              RaisedButton(
                textColor: Colors.red,
                child: Text(&quot;Create Account&quot;),
                onPressed: () async{
                  if(_formKey.currentState.validate()){
                    if(_confirmpassword.text == _password.text)
                      if(!await user.signUp(
                        _email.text, _password.text))
                        print(&quot;Failed to Signup&quot;);
                  }
                },
              )
            ],
          ),
        ),
      );
    }
  }
  </code></pre>