I have a problem during develop my app, I understand navigation of page can used "Navigation.of(context)" with pass an argument with ID, however I would like to do same thing with page but could not find any solution. If anyone have idea how to make it please providing me some clue. Thank you so much!! Anything missed out will be updated
Dialog
There have another "Custom Dialog" class which define for the dialog and doing onSaved stuff once user key in information. Each of the link been saved will auto generate an ID so would like to pass the "ID" for update using but stuck on how to pass "ID" argument.
Future<dynamic> callDialog(BuildContext context) {
String label;
if (appTitle == "Instagram") {
label = "Please Enter Your Username";
} else if (appTitle == "Whatsapp") {
label = "Please Enter Your Phone Number";
} else if (appTitle == "LinkedIn") {
label = "Please Enter Your URL";
} else if (appTitle == "Mail") {
label = "Please Enter Your E-mail";
}
return showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return CustomDialogBox(
title: appTitle,
descriptions: "$label",
button1: "Cancel",
button2: "Save",
img: appImage,
);
},
);
}
Navigation
In part of navigation have been tried to do something similar pass argument "ID" but it's not work so is there any way to pass argument from a page to dialog?
Widget build(BuildContext context) {
return Card(
child: Hero(
tag: appTitle,
child: InkWell(
onTap: () {
callDialog(context,);
},
child: GridTile(
footer: GridTileBar(
backgroundColor: Colors.black54,
title: Text(
appTitle,
textAlign: TextAlign.center,
),
),
child: Image.asset(
appImage,
fit: BoxFit.cover,
),
),
),
),
);
}
didChangeDependencies Dialog
@override
void didChangeDependencies() {
if (_isInit) {
final appId = ModalRoute.of(context).settings.arguments as String;
if (appId != null) {
//check product exist
_editedApp = Provider.of<UserProfileLogic>(context, listen: false)
.findByAppId(appId);
_initValues = {
"title": _editedApp.title,
"urlLink": _editedApp.appLink,
"imageUrl": _editedApp.appImage,
};
}
}
_isInit = false;
super.didChangeDependencies();
}