Here's my Alert dialog code: I've added Navigator.pop(context); in the tapped method call. But it's not closing.
showLoginDialog(BuildContext context,
{TextEditingController usernameController,
TextEditingController loginController}) {
var textController = new TextEditingController();
var nameTextController = new TextEditingController();
String dateToPost;
Alert(
context: context,
title: "Add Profile",
content: Column(
children: <Widget>[
TextField(
controller: nameTextController,
decoration: InputDecoration(
labelText: 'Name',
),
),
TextField(
controller: textController,
onTap: () async {
DateTime date = DateTime(1900);
//FocusScope.of(context).requestFocus(new FocusNode());
date = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(1900),
lastDate: DateTime.now());
var formatter = new DateFormat('dd MMM yyyy');
var formatterToPost = new DateFormat('yyyy-MM-dd');
String formatted = formatter.format(date);
dateToPost = formatterToPost.format(date);
print(formatted);
textController.text = formatted;
},
decoration: InputDecoration(
labelText: 'Birth Date',
),
),
],
),
buttons: [
DialogButton(
onPressed: () {
Navigator.pop(context);
_saveData(textController.text, nameTextController.text,
dateToPost);
},
child: Text(
"Add",
style: TextStyle(color: Colors.white, fontSize: 20),
),
)
]).show();
}
Also, is shows error on second time click: The method 'call' was called on null. Receiver: null Tried calling: call()
I've solved this issue using
Navigator.of(context, rootNavigator: true).pop();