Skip to content

Commit

Permalink
책장 추가 기능 구현
Browse files Browse the repository at this point in the history
.gitignore의 pubspec.lock 관련 내용 수정.
  • Loading branch information
kangsudal committed Oct 30, 2019
1 parent c39cc59 commit 7eef345
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
.pub-cache/
.pub/
/build/
pubspec.lock // Except for application packages
pubspec.lock

# Android related
**/android/**/gradle-wrapper.jar
Expand Down
12 changes: 10 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,20 @@ class MyHomePage extends StatefulWidget {

class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
List<dynamic> myShelves = [];

void _incrementCounter() {
setState(() {
_counter++;
});
}

void _addShelf(String newShelf){
setState((){
myShelves.add(newShelf);
});
}

Future<String> _asyncInputDialog(BuildContext context) async {
String shelfName = '';
return showDialog<String>(
Expand Down Expand Up @@ -141,6 +148,7 @@ class _MyHomePageState extends State<MyHomePage> {
onTap: () async {
final String newShelf = await _asyncInputDialog(context);
print("New shelf name is $newShelf");
_addShelf(newShelf);
},
),
Container(
Expand All @@ -157,7 +165,7 @@ class _MyHomePageState extends State<MyHomePage> {
// color: Colors.blue,
child: listItem(index));
},
itemCount: 10,
itemCount: myShelves.length,
shrinkWrap: true,
physics: ClampingScrollPhysics(),
),
Expand Down Expand Up @@ -188,7 +196,7 @@ class _MyHomePageState extends State<MyHomePage> {

Widget listItem(int index) {
return ListTile(
title: Text('기본 책장$index'),
title: Text('기본 책장$index ${myShelves[index]}'),
onTap: () {
// Update the state of the app
// ...
Expand Down

0 comments on commit 7eef345

Please sign in to comment.