Skip to content

Instantly share code, notes, and snippets.

@savioserra
Created March 2, 2020 22:57
Show Gist options
  • Save savioserra/d89b23de1650e3f3c15eef3ffc1a8df2 to your computer and use it in GitHub Desktop.
Save savioserra/d89b23de1650e3f3c15eef3ffc1a8df2 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(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: TodoExample(),
),
),
);
}
}
class TodoExample extends StatefulWidget {
@override
_TodoExampleState createState() => _TodoExampleState();
}
class _TodoExampleState extends State<TodoExample> {
List<Map<String, dynamic>> models = [
{
"userId": 1,
"id": 1,
"title": "delectus aut autem",
"completed": false,
},
{
"userId": 1,
"id": 2,
"title": "quis ut nam facilis et officia qui",
"completed": false
},
{
"userId": 1,
"id": 3,
"title": "fugiat veniam minus",
"completed": false,
}
];
@override
Widget build(BuildContext context) {
return ListView.builder(
itemBuilder: (ctx, idx) => Card(
child: InkWell(
onTap: () => setState(() => models.removeAt(idx)),
child: Text(models[idx]["title"]),
),
),
itemCount: models.length,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment