I have a cardView list DUMMY_CATEGORIES
on my homepage called from a category model with an id
.
I want to pass the id
in my homepage and then open a new page performing a onPressed method.
How can I do that?
This is my Homepage
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: AppBar(
backgroundColor: Colors.deepOrange,
title: Text('Pocket Chef'),
centerTitle: true,
),
body: GridView(
padding: const EdgeInsets.all(20),
children: DUMMY_CATEGORIES.map((categoryItem) => CategoryItems(
categoryItem.name,categoryItem.icon)).toList(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2,
mainAxisSpacing: 20,crossAxisSpacing: 20
),
),
);
And this is my DUMMY_CATEGORIES
const DUMMY_CATEGORIES = const [
Category(
name: "Category 1", id: "1", icon: Icons.food_bank),
Category(
name: "Category 2", id: "2", icon: Icons.food_bank ),