aboutsummaryrefslogtreecommitdiffstats
path: root/lib/utils/app_config.dart
blob: 8f5c566ea9cc28019b31a87011e63fabf8d1c69e (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
import 'dart:convert';
import 'dart:async';
import 'package:flutter/services.dart';

class AppConfig {
  late String grpcHost;
  late int grpcPort;

  AppConfig({required this.grpcHost, required this.grpcPort});

  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'],
    );
  }
}