push
인자
onTap: () => selectCatagory(context),
함수
void selectCatagory(BuildContext ctx) {
Navigator.of(ctx).push(MaterialPageRoute(builder: (_) {
return CategoryMealsScren();
}
데이터 넘기기
final String categoryId;
final String categoryTitle;
CategoryMealsScren(this.categoryId, this.categoryTitle);
push name
main
routes: {
'/category-meals': (ctx) => CategoryMealsScren(),
},
함수
void selectCatagory(BuildContext ctx) {
Navigator.of(ctx).pushNamed(
'/category-meals',
arguments: {
'id':id,
'title': title
}
);
}
데이터 보내기
@override
Widget build(BuildContext context) {
final routeArgs = ModalRoute.of(context).settings.arguments as Map<String, String>;
final categoryTitle = routeArgs['title'];
final categoryId = routeArgs['id'];