sqlite_wrapper 0.2.3 sqlite_wrapper: ^0.2.3 copied to clipboard
A simple way to easily use the SQLite library (even in a reactive way)
import 'package:flutter/material.dart';
import 'package:sqlite_wrapper_sample/database_helper.dart';
import 'package:sqlite_wrapper_sample/todo_list.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Init the DB
await DatabaseHelper().initDB();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'SQLiteWrapper Sample',
theme: ThemeData(
primarySwatch: Colors.red,
),
home: const HomePage(title: 'Todos'),
);
}
}
class HomePage extends StatelessWidget {
final String title;
const HomePage({super.key, required this.title});
void _addNewTodo() {
DatabaseHelper().addNewTodo("NEW TODO");
return;
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(title),
),
body: const TodoList(),
floatingActionButton: FloatingActionButton(
onPressed: _addNewTodo,
tooltip: 'Add new todo',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}