ini 2.1.0 copy "ini: ^2.1.0" to clipboard
ini: ^2.1.0 copied to clipboard

Read and write .ini files

example/example.dart

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

File file = new File("example/config.ini");

void doConfigThings(Config config, String label) {
  print("${label}: loaded config from ${file.path}");
  print('');

  print("${label}: Read some values...");
  print("${label}: ${config.hasOption('default', 'default')}");
  print("${label}: ${config.defaults()["default"]}");
  print("${label}: ${config.get("section", "section")}");
  print('');

  print("${label}: Write some values...");
  config.addSection("new");
  config.set("new", "entry", "result");
  print("${label}: Added a new section and entry");
  print('');

  print("${label}: Write out config (to screen)");
  print("${label}: ${config.toString()}");
}

void main() {
  file
      .readAsLines()
      .then((lines) => new Config.fromStrings(lines))
      .then((Config config) {
    doConfigThings(config, "async");
  });

  Config config = new Config.fromStrings(file.readAsLinesSync());
  doConfigThings(config, "sync");
}

// vim: set ai et sw=2 syntax=dart :
22
likes
135
pub points
91%
popularity

Publisher

unverified uploader

Read and write .ini files

Repository (GitLab)
View/report issues

Documentation

API reference

License

LGPL-3.0 (license)

More

Packages that depend on ini