Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // A model class
- class Recipe {
- String name;
- String description;
- List<String> ingredients;
- }
- // A list of Recipes
- class RecipeListPage extends StatelessWidget {
- List<Recipe> recipes = [
- // ...
- ];
- @override
- Widget build(BuildContext context) {
- // Render your list here
- }
- // Navigate to the next page.
- void showDetails(BuildContext context, Recipe recipe) {
- Navigator.push(context,
- MaterialPageRoute(builder: (context) => RecipePage(recipe: recipe)));
- }
- }
- // Details for one Recipe
- class RecipePage extends StatelessWidget {
- // The recipe that we want details for
- final Recipe recipe;
- RecipePage({this.recipe});
- @override
- Widget build(BuildContext context) {
- return Container(
- child: Text(recipe.name),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement