ini 2.0.1

  • README.md
  • Example
  • Installing
  • Versions
  • 77

Dart INI

This library deals with reading and writing ini files. This implements the standard as defined here:

https://en.wikipedia.org/wiki/INI_file

The ini file reader will return data organized by section and option. The default section will be the blank string.

Examples

Read a file:

import "package:ini/ini.dart";

new File("config.ini").readAsLines()
    .then((lines) => new Config.fromStrings(lines))
    .then((Config config) => ...);

Write a file:

new File("config.ini").writeAsString(config.toString());

Read options:

// List all sections in the configuration, excluding default.
config.sections();

// List options within a section
config.options("default");
config.options("section");
config.hasSection("section");

// List of key value pairs for a section.
config.items("section");

// Read specific options.
config.get("section", "option");
config.hasOption("section", "option");

Write options:

// Make sure you add sections before using them.
config.addSection("section");

config.set("section", "option", "value");

config.removeSection("section");

config.removeOption("section", "option");

There is example code in the example/ directory.

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 :

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  ini: ^2.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:ini/ini.dart';
  
Version Uploaded Documentation Archive
2.0.1 Oct 9, 2018 Go to the documentation of ini 2.0.1 Download ini 2.0.1 archive
2.0.0 Oct 7, 2018 Go to the documentation of ini 2.0.0 Download ini 2.0.0 archive
1.1.0 Mar 24, 2015 Go to the documentation of ini 1.1.0 Download ini 1.1.0 archive
1.0.1 Feb 19, 2015 Go to the documentation of ini 1.0.1 Download ini 1.0.1 archive
1.0.0 Sep 7, 2014 Go to the documentation of ini 1.0.0 Download ini 1.0.0 archive
0.0.6 Sep 8, 2013 Go to the documentation of ini 0.0.6 Download ini 0.0.6 archive
0.0.5 Sep 1, 2013 Go to the documentation of ini 0.0.5 Download ini 0.0.5 archive
0.0.4 Aug 20, 2013 Go to the documentation of ini 0.0.4 Download ini 0.0.4 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
69
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
60
Overall:
Weighted score of the above. [more]
77
Learn more about scoring.

We analyzed this package on Oct 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.4

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:ini/ini.dart.

Maintenance issues and suggestions

Maintain CHANGELOG.md. (-20 points)

Changelog entries help clients to follow the progress in your code.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
stream_channel any
test any