Adds requests for total flight time and flight in between timestamps

This commit is contained in:
2025-07-05 10:24:55 +02:00
parent b35656d4ce
commit 5d461d5b0f
2 changed files with 53 additions and 2 deletions

View File

@ -1,6 +1,12 @@
// This file holds a class to represent the configuration/settings of the app
import 'dart:io';
import 'package:json_annotation/json_annotation.dart';
import 'dart:convert';
import 'package:path_provider/path_provider.dart';
import 'package:path/path.dart' as path;
part 'generated/config.g.dart';
@JsonSerializable()
@ -10,7 +16,24 @@ class RTimeConfig {
RTimeConfig({required this.language});
factory RTimeConfig.fromJson(Map<String, dynamic> json) =>
_$PersonFromJson(json);
_$RTimeConfigFromJson(json);
Map<String, dynamic> toJson() => _$PersonToJson(this);
Map<String, dynamic> toJson() => _$RTimeConfigToJson(this);
static Future<RTimeConfig?> readFromConfig() async {
final directory = await getApplicationDocumentsDirectory();
final configName = "rtime_config.json";
final configPath = path.join(directory.path, configName);
final string = jsonDecode(await File(configPath).readAsString());
return RTimeConfig.fromJson(string);
}
void writeConfig() async {
final directory = await getApplicationDocumentsDirectory();
final configName = "rtime_config.json";
final configPath = path.join(directory.path, configName);
await File(configPath).writeAsString(jsonEncode(toJson()));
}
}