options_file 0.11.0

options_file #

Dart library for reading options files

OptionsFile reads options from a file. The options must be stored in name=value pairs, one pair per line. E.g.:

# stuff
name=James
age=9
height=256

Spaces around the key and value are trimmed. Any line which starts with a hash (#) is ignored. Any line which does not contain an equals sign is ignored.

Usage #

OptionsFile options = new OptionsFile('example/local.options', 'example/default.options');

String user = options.getString('user', 'bob');
int port = options.getInt('port', 1234);

For further information on using optionsfile, see the dartdoc in options.dart, and the example files.

example/main.dart

import 'package:options_file/options_file.dart';

void main() {
  OptionsFile options = new OptionsFile('example/local.options', 'example/default.options');
  
  // these values are read from default.options, as they aren't in local.options
  String user = options.getString('user', 'bob');
  String type = options.getString('type', 'advanced');

  // these values are read from local.options
  int port = options.getInt('port', 1234);
  String host = options.getString('host', 'www.dartlang.org');
  
  // this value isn't in either file, so the default here is used
  String parity = options.getString('parity', 'even');
  
  print("user=$user");
  print("type=$type");
  print("port=$port");
  print("host=$host");
  print("parity=$parity");
}

Use this package as a library

1. Depend on it

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


dependencies:
  options_file: ^0.11.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:options_file/options_file.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
62
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
31
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://dart.dev/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=0.11.0 <2.0.0