ini 2.0.1

Dart INI #

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

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.

// List options within a section

// List of key value pairs for a section.

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

Write options:

// Make sure you add sections before using them.

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


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

There is example code in the example/ directory.


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("${label}: Read some values...");
  print("${label}: ${config.hasOption('default', 'default')}");
  print("${label}: ${config.defaults()["default"]}");
  print("${label}: ${config.get("section", "section")}");

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

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

void main() {
      .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:

  ini: ^2.0.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub 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';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Mar 31, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

Fix lib/src/parser.dart. (-4.41 points)

Analysis of lib/src/parser.dart reported 9 hints, including:

line 4 col 43: Unnecessary new keyword.

line 5 col 41: Unnecessary new keyword.

line 6 col 50: Unnecessary new keyword.

line 7 col 41: Unnecessary new keyword.

line 8 col 39: Unnecessary new keyword.

Fix lib/src/model.dart. (-3.93 points)

Analysis of lib/src/model.dart reported 8 hints, including:

line 5 col 35: Unnecessary new keyword.

line 9 col 7: Unnecessary new keyword.

line 17 col 27: Unnecessary new keyword.

line 51 col 13: Unnecessary new keyword.

line 54 col 13: Unnecessary new keyword.

Fix lib/ini.dart. (-1.49 points)

Analysis of lib/ini.dart reported 3 hints:

line 22 col 12: Unnecessary new keyword.

line 26 col 12: Unnecessary new keyword.

line 30 col 12: Unnecessary new keyword.

Maintenance issues and suggestions

Provide a file named (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

Package is getting outdated. (-47.40 points)

The package was last published 76 weeks ago.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


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