Adds requests for total flight time and flight in between timestamps
This commit is contained in:
@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user