Created
April 28, 2018 09:22
-
-
Save barongun/e218feabe76f44685c1cf1d6e89fc2a7 to your computer and use it in GitHub Desktop.
flutter에서 ListView 이용해보기
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
import 'package:flutter/material.dart'; | |
class HomeView extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return new MaterialApp( | |
home: new Scaffold( | |
appBar: new AppBar( | |
title: const Text('DAILY DAY'), | |
), | |
body: new ListView.builder( | |
itemBuilder: (BuildContext context, int index) => | |
new DdayItem(list[index]), | |
itemCount: list.length, | |
), | |
), | |
); | |
} | |
} | |
class Dday { | |
final int idx; | |
final String title; | |
// final DateTime eventDate; | |
final String imageUrl; | |
Dday(this.idx, this.title, this.imageUrl); | |
} | |
final List<Dday> list = <Dday>[ | |
new Dday(0, 'A', 'https://images.pexels.com/photos/319489/pexels-photo-319489.jpeg?cs=srgb&dl=adult-adventure-background-319489.jpg&fm=jpg'), | |
new Dday(1, 'B', 'https://images.pexels.com/photos/23183/pexels-photo.jpg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260'), | |
new Dday(2, 'C', 'https://images.pexels.com/photos/23149/pexels-photo.jpg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260'), | |
new Dday(3, 'D', 'https://images.pexels.com/photos/91491/pexels-photo-91491.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260'), | |
new Dday(4, 'E', 'https://images.pexels.com/photos/74775/pexels-photo-74775.jpeg?auto=compress&cs=tinysrgb&h=650&w=940'), | |
new Dday(5, 'F', 'https://images.pexels.com/photos/94015/pexels-photo-94015.jpeg?auto=compress&cs=tinysrgb&h=650&w=940'), | |
new Dday(6, 'G', 'https://images.pexels.com/photos/38000/pexels-photo-38000.jpeg?auto=compress&cs=tinysrgb&h=650&w=940'), | |
new Dday(7, 'H', 'https://images.pexels.com/photos/117831/pexels-photo-117831.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260'), | |
]; | |
class DdayItem extends StatelessWidget { | |
DdayItem(this.dday); | |
final Dday dday; | |
@override | |
Widget build(BuildContext context) { | |
return new Container( | |
child: new Center( | |
child: new Image.network(dday.imageUrl), | |
), | |
); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment