Reputation: 41
I Got This Weird Error:
"The named parameter 'default' isn't defined.Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'default'."
I think error in bracket?
But I don't know at which place ?
Pls Anyone knows then help me
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("LogIn"),
body: Column(
children: [
TextField(
controller: _email,
obscureText: false,
enableSuggestions: false,
autocorrect: false,
keyboardType: TextInputType.emailAddress,
decoration: const InputDecoration (
hintText: 'Enter Your Email Here',
),
),
TextField(
controller: _password,
obscureText: true,
enableSuggestions: false,
autocorrect: false,
decoration: const InputDecoration (
hintText: 'Enter Your Password Here',
),
),
TextButton(
onPressed: () async {
final email = _email.text;
final password = _password.text;
try { final userCredential =
await FirebaseAuth.instance.signInWithEmailAndPassword (
email: email,
password: password,
);
print(userCredential);
} on FirebaseAuthExceptions catch (e){
If (e.code == 'user-not-found') {
print("User is not Found");
} Else if (e.code == 'wrong password') {
print("Wrong Password");
}
}
},
child: Text("LogIn"),
),
TextButton(
onPressed:() {
Navigator.of(context).pushNamedAndRemoveUntil(
'/Register/',
(route) => false,
);
},
child: const Text("Not Register Yet? Register Here"),
)
],
)
default:
return const Text("Loading...");
},
}
)
)
}
}
Upvotes: 0
Views: 943
Reputation: 876
This means default
is on the wrong place... check the parentheses
Update because of new code snippet:
You shared not enough code... but if you have a switch case statement it should look like this:
Widget getWidget(String input) {
switch (input) {
case 'lala':
return Container();
case 'bibi':
return TextButton(
onPressed: () {
Navigator.of(context).pushNamedAndRemoveUntil(
'/Register/',
(route) => false,
);
},
child: const Text("Not Register Yet? Register Here"),
);
default:
return const Text("Loading...");
}
}
please share your whole code for detailed help.
2. Update
Thank you for sharing. At this place a default value can't be set. I checked your Widget for wrong parentheses and this should work for you:
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("LogIn"),
),
body: Column(
children: [
TextField(
controller: _email,
obscureText: false,
enableSuggestions: false,
autocorrect: false,
keyboardType: TextInputType.emailAddress,
decoration: const InputDecoration (
hintText: 'Enter Your Email Here',
),
),
TextField(
controller: _password,
obscureText: true,
enableSuggestions: false,
autocorrect: false,
decoration: const InputDecoration (
hintText: 'Enter Your Password Here',
),
),
TextButton(
onPressed: () async {
final email = _email.text;
final password = _password.text;
try { final userCredential =
await FirebaseAuth.instance.signInWithEmailAndPassword (
email: email,
password: password,
);
print(userCredential);
} on FirebaseAuthExceptions catch (e){
if (e.code == 'user-not-found') {
print("User is not Found");
} Else if (e.code == 'wrong password') {
print("Wrong Password");
}
}
},
child: Text("LogIn"),
),
TextButton(
onPressed:() {
Navigator.of(context).pushNamedAndRemoveUntil(
'/Register/',
(route) => false,
);
},
child: const Text("Not Register Yet? Register Here"),
)
],
),
);
}
Upvotes: 2