.github
.vscode
android
assets
buildtools
ios
lib
database
models
pods
call.dart
call.freezed.dart
call.g.dart
chat_summary.dart
chat_summary.g.dart
config.dart
config.freezed.dart
config.g.dart
database.dart
event_calendar.dart
event_calendar.g.dart
message.dart
network.dart
theme.dart
userinfo.dart
websocket.dart
websocket.freezed.dart
websocket.g.dart
screens
services
widgets
firebase_options.dart
main.dart
route.dart
route.gr.dart
linux
macos
web
windows
.gitignore
.metadata
README.md
analysis_options.yaml
build.yaml
devtools_options.yaml
firebase.json
pubspec.lock
pubspec.yaml
27 lines
706 B
Dart
27 lines
706 B
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:island/pods/database.dart';
|
|
import 'package:path/path.dart';
|
|
import 'package:path_provider/path_provider.dart';
|
|
|
|
Future<void> resetDatabase(WidgetRef ref) async {
|
|
if (kIsWeb) return;
|
|
|
|
final db = ref.read(databaseProvider);
|
|
final basepath = await getApplicationSupportDirectory();
|
|
final file = File(join(basepath.path, 'solar_network_data.sqlite'));
|
|
|
|
// Close current database connection
|
|
db.close();
|
|
|
|
// Delete database file
|
|
if (await file.exists()) {
|
|
await file.delete();
|
|
}
|
|
|
|
// Force refresh the database provider
|
|
ref.invalidate(databaseProvider);
|
|
}
|