blob: eacb10f33df52dedd05dc75b08046e5d0b93d93f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import 'dart:convert';
import 'dart:async';
import 'package:flutter/services.dart';
class AppConfig {
late String grpcHost;
late int grpcPort;
late String theme;
AppConfig(
{required this.grpcHost, required this.grpcPort, required this.theme});
factory AppConfig.fromAsset() {
return AppConfig._();
}
AppConfig._();
static Future<AppConfig> loadFromAsset() async {
final configString = await rootBundle.loadString('assets/config.json');
final jsonMap = json.decode(configString);
return AppConfig(
grpcHost: jsonMap['grpc_host'],
grpcPort: jsonMap['grpc_port'],
theme: jsonMap['theme'],
);
}
}
|