Skip to content

Instantly share code, notes, and snippets.

@friebetill
Created February 18, 2019 14:27
Show Gist options
  • Save friebetill/08c27cf7caffe7805b0634371c903797 to your computer and use it in GitHub Desktop.
Save friebetill/08c27cf7caffe7805b0634371c903797 to your computer and use it in GitHub Desktop.
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