Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.81 KB | None | 0 0
  1. // A model class
  2. class Recipe {
  3.   String name;
  4.   String description;
  5.   List<String> ingredients;
  6. }
  7.  
  8. // A list of Recipes
  9. class RecipeListPage extends StatelessWidget {
  10.  
  11.   List<Recipe> recipes = [
  12.     // ...
  13.   ];
  14.  
  15.   @override
  16.   Widget build(BuildContext context) {
  17.     // Render your list here
  18.   }
  19.  
  20.   //  Navigate to the next page.
  21.   void showDetails(BuildContext context, Recipe recipe) {
  22.     Navigator.push(context,
  23.         MaterialPageRoute(builder: (context) => RecipePage(recipe: recipe)));
  24.   }
  25. }
  26.  
  27. // Details for one Recipe
  28. class RecipePage extends StatelessWidget {
  29.  
  30.   // The recipe that we want details for
  31.   final Recipe recipe;
  32.  
  33.   RecipePage({this.recipe});
  34.  
  35.   @override
  36.   Widget build(BuildContext context) {
  37.     return Container(
  38.       child: Text(recipe.name),
  39.     );
  40.   }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement