import 'package:flutter/material.dart'; import '../DrawerPage.dart'; import '../api/token.dart'; import '../db/database.dart'; import '../login/logincontext.dart'; class SettingsScreen extends StatefulWidget { const SettingsScreen({Key? key}) : super(key: key); @override State createState() => _SettingsScreenState(); } class _SettingsScreenState extends State { int dbsize = 0; @override void initState() { super.initState(); Db().getDbSize().then((v) => setState(() { dbsize = v; })); } @override Widget build(BuildContext context) { final loginCtx = LoginContext.of(context); return Scaffold( appBar: AppBar( title: Text("Temp"), ), body: Column( children: [ ElevatedButton( onPressed: () async { await Db().clear(); Db().getDbSize().then((v) => setState(() { dbsize = v; })); }, child: const Text("Delete cache!")), Text("db size: ${dbsize / 1024} kb"), ElevatedButton(onPressed: () { loginCtx.onLoggin(false); Token.getInstance().setToken("", ""); Db().clear(); }, child: Text("Logout")) ], ), drawer: MyDrawer()); } }