Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions lib/card_list.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:flutter/material.dart';

class CardList extends StatelessWidget {
final String _text;

CardList(this._text);

@override
Widget build(BuildContext context) {
return Card(
child: Column(mainAxisSize: MainAxisSize.max, children: <Widget>[
ListTile(
leading: FlutterLogo(),
title: Text(_text),
subtitle: Text(
"This is subtitle. Subtitle is very long and use three lines."),
selected: true,
)
]),
);
}
}
84 changes: 50 additions & 34 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_list_app/card_list.dart';

void main() {
runApp(MyApp());
Expand All @@ -20,15 +21,55 @@ class MyApp extends StatelessWidget {
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
MyHomePage({Key key, this.title, this.thumbnail}) : super(key: key);

final String title;
final thumbnail;

@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
var _cardList = List<CardList>();

@override
void initState() {
_cardList.add(CardList(
'Text1',
));
_cardList.add(CardList(
'Text2',
));
_cardList.add(CardList(
'Text3',
));
_cardList.add(CardList(
'Text4',
));
_cardList.add(CardList(
'Text5',
));
_cardList.add(CardList(
'Text6',
));
_cardList.add(CardList(
'Text7',
));
_cardList.add(CardList(
'Text8',
));
_cardList.add(CardList(
'Text9',
));
_cardList.add(CardList(
'Text10',
));
_cardList.add(CardList(
'Text11',
));
super.initState();
}

@override
Widget build(BuildContext context) {
Expand All @@ -37,39 +78,14 @@ class _MyHomePageState extends State<MyHomePage> {
appBar: AppBar(
title: Text('ListViewApp'),
),
body: ListView(
children: [
_menueItem('メニュー1'),
_menueItem('メニュー2'),
_menueItem('メニュー3'),
_menueItem('メニュー4'),
_menueItem('メニュー5'),
_menueItem('メニュー6'),
_menueItem('メニュー7'),
]
),
),
);
}

Widget _menueItem(String title) {
return GestureDetector(
child: Container(
padding: EdgeInsets.all(8.0),
decoration: new BoxDecoration(
border: new Border(bottom: BorderSide(width: 1.0, color: Colors.red))
),
child: Row(
children: <Widget>[
Text(
title,
style: TextStyle(
color: Colors.black,
fontSize: 20.0
)
),
],
),
body: Container(
child: ListView.builder(
itemCount: _cardList.length,
itemBuilder: (BuildContext context, int index) {
return _cardList[index];
},
),
)
),
);
}
Expand Down