There are Error Messagge, Error Code and some HomePageCode. What is matter??
I did that error message said to do. But I CAN'T SOLVE PLOBLEM.
[Error Message]
lib/create_page.dart:194:63: Error: Too few positional arguments: 1 required, 0 given.
context, MaterialPageRoute(builder:(context) => HomePage()),
^
lib/home_page.dart:10:3: Context: Found this candidate, but the arguments don't match.
HomePage(this.user);
^^^^^^^^
[Error Code]
Navigator.push(
context, MaterialPageRoute(builder:(context) => HomePage()),
);
[HomePage]
class HomePage extends StatelessWidget {
final FirebaseUser user;
HomePage(this.user);
CodePudding user response:
As for the HomePage
class, you need to pass a FirebaseUser
instance. If you like to make it optional, you can use named argument constructor with nullable datatype.
class HomePage extends StatelessWidget {
final FirebaseUser? user;
const HomePage({super.key, this.user});
}
CodePudding user response:
final FirebaseUser user;
here user is required argument,which is causing the error, either you pass it or make it nullable like
final FirebaseUser? user;
CodePudding user response:
This is because HomePage
widget expects an argument of type FirebaseUser
. You need to add this argument in the navigator
Navigator.push(
context, MaterialPageRoute(builder:(context) => HomePage(user)),
);