Created
July 12, 2019 14:25
-
-
Save arisupriatna14/387211b75c3ca664c79b195229019797 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Models | |
class FoodList { | |
final String name; | |
final String imageUrl; | |
FoodList({this.name, this.imageUrl}); | |
} | |
List<FoodList> foodList = [ | |
FoodList( | |
name: 'Battenberg Cake', | |
imageUrl: 'https://www.themealdb.com/images/media/meals/ywwrsp1511720277.jpg' | |
), | |
FoodList( | |
name: 'BeaverTails', | |
imageUrl: 'https://www.themealdb.com/images/media/meals/ryppsv1511815505.jpg' | |
), | |
]; | |
// Screen | |
import 'package:flutter/material.dart'; | |
import 'food_list.dart'; | |
class FoodListScreen extends StatelessWidget { | |
const FoodListScreen({Key key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: ListView.builder( | |
itemCount: foodList.length, | |
itemBuilder: (BuildContext context, int index) { | |
return YOUR_WIDGET_HERE | |
}, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Notes:
Buat dua file berbeda, yang pertama untuk file food_list_model dan yang kedua untuk file food_list_screen.