harndb 1.0.0 harndb: ^1.0.0 copied to clipboard
Streamline data management with DartDB is a key-value database for Dart developers. Ideal for high-performance apps, ensuring reliability and user experience.
import 'package:flutter/material.dart';
import 'package:harndb/harnlog.dart';
import 'package:harndb_example/data.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
db.initialize();
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
harnLog.setCallback((p0) => print(p0));
}
void test() async {
int i = 0;
while (i < 500) {
User firstUser = User(id: "id_$i", name: "Andress", age: 33);
await users.insert(firstUser);
i++;
}
final all = users.find();
int l = 0;
while (l < all.length) {
print(all[l].name);
l++;
}
}
void find() {
final all = users.find();
int l = 0;
while (l < all.length) {
print("$l -> ${all[l]}");
l++;
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Column(
children: [
Container(
height: 20,
),
ElevatedButton(onPressed: test, child: const Text("test")),
Container(
height: 20,
),
ElevatedButton(onPressed: find, child: const Text("find")),
],
),
),
);
}
}