I need the user to click on this "Inkwell", an "alertdialog" appears, I tried to do it on another screen, but when clicking the screen goes black.
InkWell(
onTap: () {
Navigator.pushNamed(context, AppRoutes.helpScreen);
},
child: const Text(
"contact us",
style: TextStyle(
color: Color(0xff05498A),
fontWeight: FontWeight.w500,
fontSize: 16,
),
),
),
CodePudding user response:
this was the screen I created, to be called by clicking on "contact us".
import 'package:flutter/material.dart';
class ContactUsDialog extends StatelessWidget {
const ContactUsDialog({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return TextButton(
onPressed: () => showDialog<String>(
context: context,
builder: (BuildContext context) => AlertDialog(
title: Text('Contact us'),
content: Text(
"Please contact our team via email: [email protected]",
),
),
),
child: AlertDialog(),
);
}
}
CodePudding user response:
more context is needed to give an accurate solution. like what is happening inside of "AppRoutes" widget ? did you make sure to register the AppRoutes widget in your main.dart routes?
in your Navigator.pushNamed you are calling "AppRoutes" which is a non existing widget. replace it with
Navigator.pushNamed(ContactUsDialog.helpScreen);
and in your "ContactUsDialog" Widget declare a const outside your build method
static const helpScreen = '/anyNameYouWant';
register it in your routes in main.dart like this
routes: {
ContactUsDialog.helpScreen : (ctx) => ContactUsDialog(),
}