implemented way to add todo
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user