loadFromAsset method

Future<GlobalConfiguration> loadFromAsset(
  1. String name
)

Loading a json configuration file with the given name into the current app config.

If the given name does not have the file extension .json, it will be automatically added.

The file has to be placed at assets/cfg/.

Use the loadFromPath method if you want to store the file at another place.

Implementation

Future<GlobalConfiguration> loadFromAsset(String name) async {
  if (!name.endsWith(".json")) {
    name = "$name.json";
  }
  String content = await rootBundle.loadString("assets/cfg/$name");
  Map<String, dynamic> configAsMap = json.decode(content);
  appConfig.addAll(configAsMap);
  return _singleton;
}