implemented way to add todo

This commit is contained in:
SomnusVeritas
2023-11-08 11:34:39 +01:00
parent d2f3eb109d
commit 15c404c962
5 changed files with 50 additions and 8 deletions

View File

@@ -1,5 +1,8 @@
import 'package:flutter/material.dart';
import '../models/todo.dart';
import '../services/dbhelper.dart';
class CreateTodoPage extends StatefulWidget {
const CreateTodoPage({super.key});
static const routeName = '/create';
@@ -17,7 +20,7 @@ class _CreateTodoPageState extends State<CreateTodoPage> {
return Scaffold(
floatingActionButton: _title.isNotEmpty
? FloatingActionButton(
onPressed: () {},
onPressed: _onSubmitted,
child: const Icon(Icons.save),
)
: null,
@@ -51,4 +54,9 @@ class _CreateTodoPageState extends State<CreateTodoPage> {
),
);
}
void _onSubmitted() {
DbHelper.addTodo(Todo(title: _title, description: _description));
Navigator.of(context).pop();
}
}