Skip to content

Instantly share code, notes, and snippets.

@arisupriatna14
Created July 12, 2019 14:25
Show Gist options
  • Save arisupriatna14/387211b75c3ca664c79b195229019797 to your computer and use it in GitHub Desktop.
Save arisupriatna14/387211b75c3ca664c79b195229019797 to your computer and use it in GitHub Desktop.
// 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
},
),
);
}
}
@arisupriatna14
Copy link
Author

Notes:
Buat dua file berbeda, yang pertama untuk file food_list_model dan yang kedua untuk file food_list_screen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment