mnemo_cards/lib/managers/repository/firebase_config_repository.dart
2024-05-22 23:48:44 +03:00

29 lines
632 B
Dart

import 'dart:convert';
import 'package:cloud_firestore/cloud_firestore.dart';
class FirebaseRepository {
static FirebaseFirestore get _firestore => FirebaseFirestore.instance;
static ConfigModel? _lastConfig;
static ConfigModel get appConfig {
update();
return _lastConfig!;
}
static Future<void> update() async {
_lastConfig = await _firestore
.collection('config')
.get()
.then((v) => v.docs.first)
.then((value) => value.data())
.then((value) => ConfigModel(value['path'] as String));
}
}
class ConfigModel {
final String path;
ConfigModel(this.path);
}