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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../widgets/todo_list.dart';
|
||||
import 'create_todo_page.dart';
|
||||
|
||||
class DashboardPage extends StatelessWidget {
|
||||
@@ -14,6 +15,7 @@ class DashboardPage extends StatelessWidget {
|
||||
Navigator.of(context).pushNamed(CreateTodoPage.routeName),
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
body: const TodoList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user