Created
February 18, 2019 14:27
-
-
Save friebetill/08c27cf7caffe7805b0634371c903797 to your computer and use it in GitHub Desktop.
This file contains 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'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: ItemList(), | |
); | |
} | |
} | |
class ItemList extends StatefulWidget { | |
ItemList({Key key}) : super(key: key); | |
@override | |
_ItemListState createState() => _ItemListState(); | |
} | |
class _ItemListState extends State<ItemList> { | |
List<String> items; | |
List<int> ids; | |
List<Widget> widgetItem; | |
@override | |
void initState() { | |
super.initState(); | |
items = ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5']; | |
ids = [1, 2, 3, 4, 5]; | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: ListView.builder( | |
itemCount: items.length, | |
itemBuilder: (BuildContext context, int index) { | |
return ExpansionTile( | |
title: Text('Title'), | |
children: <Widget>[ | |
Row( | |
children: <Widget>[ | |
Text(items[index]), | |
IconButton( | |
icon: Icon(Icons.delete), | |
onPressed: () => setState(() => items.removeAt(index)), | |
), | |
], | |
), | |
], | |
); | |
}, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment