yamlcfg 1.0.2 copy "yamlcfg: ^1.0.2" to clipboard
yamlcfg: ^1.0.2 copied to clipboard

A type-safe configuration file parser with support for YAML notation.

example/yamlcfg_example.dart

// Example to read our own `pubspec.yaml` using the yamlcfg package.

import 'dart:io';

import 'package:yamlcfg/yamlcfg.dart';

void main() {
  final root = YamlCfg.fromFile(File('pubspec.yaml'));

  // Get our project name by retrieving a simple String field.
  final name = root.get<String>('name');
  stdout.writeln('name: $name');

  // Get our SDK version by digging into our environment field, then retrieving
  // the sdk variable.
  final sdk = root.into('environment').get<String>('sdk');
  stdout.writeln('sdk: $sdk');

  // Fallback to a default value if we try to retrieve a non-existent field.
  final nonexistent = root.get<String>('nonexistent', () => '<missing>');
  stdout.writeln('nonexistent: $nonexistent');
}
0
likes
140
pub points
2%
popularity

Publisher

verified publishertytydraco.xyz

A type-safe configuration file parser with support for YAML notation.

Repository

Documentation

API reference

License

BSD-2-Clause (LICENSE)

Dependencies

yaml

More

Packages that depend on yamlcfg