File tree Expand file tree Collapse file tree 1 file changed +19
-8
lines changed
Expand file tree Collapse file tree 1 file changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,8 @@ class Home extends StatefulWidget {
2121class _HomeState extends State <Home > {
2222 List <Map > _todoList = [];
2323
24-
25- Map <String ,dynamic > _ultimoRemovido;
26- int _ultimoRemovidoPosicao;
24+ Map <String , dynamic > _ultimoRemovido;
25+ int _ultimoRemovidoPosicao;
2726
2827 final _tarefaController = TextEditingController ();
2928
@@ -138,14 +137,26 @@ class _HomeState extends State<Home> {
138137 });
139138 },
140139 ),
141- onDismissed: (direction){
140+ onDismissed: (direction) {
142141 setState (() {
143142 _ultimoRemovido = Map .from (_todoList[index]);
144- _ultimoRemovidoPosicao = index;
145- _todoList.removeAt (index);
146- _saveTarefas ();
143+ _ultimoRemovidoPosicao = index;
144+ _todoList.removeAt (index);
145+ _saveTarefas ();
146+ final snack = SnackBar (
147+ content: Text ("Tarefa \" ${_ultimoRemovido ["tittle" ]}\" removida" ),
148+ action: SnackBarAction (
149+ label: "Desfazer" ,
150+ onPressed: () {
151+ setState (() {
152+ _todoList.insert (_ultimoRemovidoPosicao, _ultimoRemovido);
153+ _saveTarefas ();
154+ });
155+ }),
156+ duration: Duration (seconds: 3 ),
157+ );
158+ Scaffold .of (context).showSnackBar (snack);
147159 });
148-
149160 },
150161 );
151162 }
You can’t perform that action at this time.
0 commit comments