yaml_config 0.1.2

Dart native
Flutter Android iOS

A simple configuration using YAML file. It is easy to load a local YAML file as main configuration for application.

yaml_config #

How to use #

import 'dart:io';
import 'package:yaml_config/yaml_config.dart';

void main() async {
  YamlConfig config = await YamlConfig.fromFile(new File('/path/to/file'));
  String foo = config.getString('foo');
  print(foo);
  int baz = config.getInt('baz');
  print(baz);
  bool bar = config.getBool('bar');
  print(bar);
}

Flutter Asset #

In pubspec.yaml

flutter:
  assets:
    - config.yaml
import 'package:flutter/services.dart' show rootBundle;
import 'package:yaml_config/yaml_config.dart';

class FlutterConfiguration extends YamlConfig {
  String endpoint;

  @override
  void init() {
    endpoint = get('endpoint');
  }

  FlutterConfiguration(String text) : super(text);

  static Future<FlutterConfiguration> fromAsset(String asset) {
    return rootBundle.loadString(asset).then((text) => FlutterConfiguration(text));
  }
}
void main() async {
  FlutterConfiguration config = await FlutterConfiguration.fromAsset('config.yaml');
  print(config.endpoint);
}
0
likes
90
pub points
31%
popularity

A simple configuration using YAML file. It is easy to load a local YAML file as main configuration for application.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

me@dotronglong.com

License

MIT (LICENSE)

Dependencies

yaml

More

Packages that depend on yaml_config