OpenMediacenterMobileFlutter/lib/navigation/settings_screen.dart
lukas-heiligenbrunner 5fc77b4abb linux build
cache previews in sqlite db
actor page
outsouce different players in seperate classes
2022-08-28 22:51:12 +02:00

48 lines
1.1 KiB
Dart

import 'package:flutter/material.dart';
import '../db/database.dart';
class SettingsScreen extends StatefulWidget {
const SettingsScreen({Key? key}) : super(key: key);
@override
State<SettingsScreen> createState() => _SettingsScreenState();
}
class _SettingsScreenState extends State<SettingsScreen> {
int dbsize = 0;
@override
void initState() {
super.initState();
loadDBSize();
}
void loadDBSize() async {
final int cnt = (await Db().db().rawQuery("pragma page_count;"))[0]
["page_count"] as int;
final int pagesize =
(await Db().db().rawQuery("pragma page_size;"))[0]["page_size"] as int;
setState(() {
dbsize = cnt * pagesize;
});
}
@override
Widget build(BuildContext context) {
return Column(
children: [
ElevatedButton(
onPressed: () async {
await Db().db().delete("previews");
// shrink the db file size
await Db().db().execute("VACUUM");
loadDBSize();
},
child: const Text("Delete cache!")),
Text("db size: ${dbsize / 1024} kb")
],
);
}
}