The named parameter 'onTap' isn't defined in my code - flutter

I currently learning Flutter and I'm very new to it. I wanted to go to another page when tap on this text but my bad it gives me this error.
return Expanded(
flex: 1,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
GestureDetector(
oneTap: () { // i got error here
Navigator.push(context, MaterialPageRoute(builder: (context) => SingUpPage()));
},
child: Text(
'Sing up',
style: GoogleFonts.openSans(
fontSize: 18,
fontWeight: FontWeight.w700,
decoration: TextDecoration.underline),
),
),
Text(
'Forgot Password',
style: GoogleFonts.openSans(
fontSize: 18,
fontWeight: FontWeight.w700,
decoration: TextDecoration.underline),
)
],
),
);
}

You are making a typo/mistake on oneTap, change it to onTap.

you mean "onTap" not "oneTap"
onTap: () { // <--- this one
Navigator.push(context, MaterialPageRoute(builder: (context) => SingUpPage()));
}

Rename onTap instead of oneTap
onTap: () { // here change needed
Navigator.push(context, MaterialPageRoute(builder: (context) => SingUpPage()));
},

Related

Flutter showing error while using InkeWell (dirty State)

My Flutter project ain't working, as I used a inkwell for a text, so that when the user clicks on the text it Navigates to another page,and it gets error saying dirty state whenever I try to run it,
const SizedBox(width: 167.5),
InkWell(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: ((context) => const PopAnime()))),
child: const Text(
"See all >",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 15),
),
),
]),
[][1
InkWell(
onTap: () => Navigator.of(context).push(
MaterialPageRoute(
builder: ((context) => const PopAnime()),
),
),
child: const Text(
"See all >",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 15,
),
),
)
you can use navigator like this

RTL not supported if i m using alignment: Alignment.centerRight in text widget in flutter

please check my code and correct me!
my language changed but the text shown in the same position only just language converted but does not support RTL.
Align(
alignment: Alignment.centerRight,
child: TextButton(
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => MyForgot()));
},
child: Text(
'forgot'.tr, //title
style: TextStyle(color: Colors.white, fontSize: 16),
),
),
),
There is an easy way
Row(
children: [
Spacer(), // use Spacer
TextButton(
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => MyForgot()));
},
child: Text(
'forgot'.tr, //title
style: TextStyle(color: Colors.white, fontSize: 16),
),
),
],
)

Firebase Auth systems stopped working after signOut

I was making a profile page. I also added a "Logout" button to the profile page.
The codes are as follows:
InkWell(
child: ListView(
shrinkWrap: true,
children: [
ListTile(
leading: Icon(Icons.person, color: Colors.black,),
title: Text("Profile", style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.black),),
onTap: () {
//Navigator.push(context, MaterialPageRoute(builder: (context) => profileScreen()));
},
),
ListTile(
leading: Icon(Icons.settings, color: Colors.black,),
title: Text("Settings", style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.black),),
onTap: () {
//Navigator.push(context, MaterialPageRoute(builder: (context) => settingsScreen()));
},
),
ListTile(
leading: Icon(Icons.exit_to_app, color: Colors.black,),
title: Text("Logout", style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.black),),
onTap: () {
FirebaseAuth.instance.signOut(); // !!!!!!!!!!!!<<<<<<<
},
),
],
),
onTap: () {
print("clicked");
},
),
Console:
W/System (31904): Ignoring header X-Firebase-Locale because its value was null.
When I press the ListTile with "Logout" written FirebaseAuth.instance.signOut(); the code would work. I pressed it and my access to the account was cut off. It also gave a few errors but those errors were normal errors anyway.
Then I tried to login to the account again, I couldn't. It gave an error other than password and email errors.
Apart from these, functions such as registration and forgot password do not work.
What could have caused this problem? How can I solve it? Thanks in advance for your help.

Why does my CupertinoActionSheet appear from the top?

Everything works fine, it's just that the sheet appears at the top instead of the bottom. I would like the cupertinoactionsheet to appear from the bottom as default.
I'm currently using an Android emulator but I doubt it's the reason why the sheet is appearing from the top.
Attached is my code
Future<bool> showReportDialog({
#required BuildContext context,
}) async {
return showCupertinoDialog(
context: context,
builder: (context) => CupertinoActionSheet(
title: const Text('Make Your Space Safe',
style: TextStyle(
fontSize: 18, color: Colors.black, fontWeight: FontWeight.w600)),
message: const Text('What to report this user for?',
style: TextStyle(
fontSize: 16.5,
color: Colors.black38,
fontWeight: FontWeight.w500)),
actions: <CupertinoActionSheetAction>[
CupertinoActionSheetAction(
child: const Text(
'Scam',
),
onPressed: () {
afterReport();
print("Reported user for SCAM");
},
),
CupertinoActionSheetAction(
child: const Text('Bots/Spam'),
onPressed: () {
afterReport();
print("Reported user for BOTS/SPAM");
},
),
CupertinoActionSheetAction(
child: const Text('Sexually harassing'),
onPressed: () {
afterReport();
print("Reported user for SEXUALLY HARASSSING");
},
),
CupertinoActionSheetAction(
child: const Text('Offensive/abusive behaviour'),
onPressed: () {
afterReport();
print('Reported user for OFFENSIVE/ABUSIVE BEHAVIOUR');
},
),
CupertinoActionSheetAction(
child: const Text('I want to write more',
style: TextStyle(fontWeight: FontWeight.bold)),
onPressed: () {
Navigator.push(
context,
new MaterialPageRoute(
builder: (BuildContext context) => ReportUser()));
},
),
CupertinoActionSheetAction(
child: const Text('Cancel'),
onPressed: () {
Navigator.pop(context);
},
)
],
),
);
}
You need to use showCupertinoModalPopup instead of showCupertinoDialog:
showCupertinoModalPopup(
context: context,
builder: (context) => CupertinoActionSheet(
title: const Text('Make Your Space Safe',
style: TextStyle(
fontSize: 18,
color: Colors.black,
fontWeight: FontWeight.w600)),
...

Flutter: ShowDialog not working with the OnTap() method of a ListTile

I am using a drawer to create a menu that houses ListTiles for the options. I want to create a popup when the tiles are tapped by the user. Currently, the code displays nothing when the tiles are tapped even though after the showDialog there is a Navigator.pop().
// Drawer that includes the ListTiles in question
Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
DrawerHeader(
child: Text('Smash Tracker'),
),
),
ListTile(
title: Text(
'About',
style: TextStyle(
fontFamily: 'Smash',
fontSize: 15.0,
color: Color.fromRGBO(77, 114, 152, 1.0),
),
),
onTap: () {
// Show PopUp
showDialog(context: context, child:
new AlertDialog(
title: new Text(
'About',
style: TextStyle(fontFamily: "Smash"),
),
content: new Text(
'This is a placeholder. This is a placeholder. This is a placeholder. This is a placeholder.',
style: TextStyle(fontFamily: "Smash"),
),
)
);
// Doesn't run
Navigator.pop(context);
},
),
Here is a demo:
via GIPHY
The other ListTiles have the only have Navigator.pop() inside of their onTap() method.
The dialog isn't showing because you are popping it immediately with the Navigator.pop(context). You can await the Dialog since it returns a Future<T> before popping.
I added a demo using your widget tree as an example:
Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
DrawerHeader(
child: Text('Smash Tracker'),
),
ListTile(
title: Text(
'About',
style: TextStyle(
fontFamily: 'Smash',
fontSize: 15.0,
color: Color.fromRGBO(77, 114, 152, 1.0),
),
),
onTap: () async { // mark the function as async
print('tap');
// Show PopUp
// await the dialog
await showDialog(
context: context,
child: new AlertDialog(
title: new Text(
'About',
style: TextStyle(fontFamily: "Smash"),
),
content: new Text(
'This is a placeholder. This is a placeholder. This is a placeholder. This is a placeholder.',
style: TextStyle(fontFamily: "Smash"),
),
));
// Doesn't run
Navigator.pop(context);
},
),
],
),
),
OUTPUT: