optional 1.2.3+1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 49

Optional.dart

Optional.dart is an implementation of the Optional type, inspired by Java 8's Optional class.

Changelog

1.2.3

  • Add an optional orElse parameter to ifPresent.

1.2.2

  • Optional.empty() constructor is now const.

1.2.1

  • Absent and Present are now subclasses of Optional. You should continue to use constructors in Optional, and not the Absent or Present ones.
  • EMPTY is now a top-level constant.

1.2.0

  • Operators are now overloaded, so you can add, subtract, etc., Optionals. Any operation involving an empty Optional will return an empty Optional.
  • Added examples.

1.1.0

  • Optional.ofNullable() and Optional.empty() constructors are now const.
  • Optional.of() constructor now throws ArgumentError when passed null, instead of NoValuePresentError.
  • NoValuePresentError now extends StateError.

1.0.0

  • Initial release

1. Depend on it

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


dependencies:
  optional: "^1.2.3+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 packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:optional/optional.dart';
        
Version Uploaded Documentation Archive
1.2.3+1 Dec 15, 2015 Go to the documentation of optional 1.2.3+1 Download optional 1.2.3+1 archive
1.2.3 Dec 15, 2015 Go to the documentation of optional 1.2.3 Download optional 1.2.3 archive
1.2.2 Oct 2, 2014 Go to the documentation of optional 1.2.2 Download optional 1.2.2 archive
1.2.1+4 Sep 14, 2014 Go to the documentation of optional 1.2.1+4 Download optional 1.2.1+4 archive
1.2.1+3 Sep 12, 2014 Go to the documentation of optional 1.2.1+3 Download optional 1.2.1+3 archive
1.2.1+2 Sep 12, 2014 Go to the documentation of optional 1.2.1+2 Download optional 1.2.1+2 archive
1.2.1+1 Sep 12, 2014 Go to the documentation of optional 1.2.1+1 Download optional 1.2.1+1 archive
1.2.1 Sep 8, 2014 Go to the documentation of optional 1.2.1 Download optional 1.2.1 archive
1.2.0 Aug 22, 2014 Go to the documentation of optional 1.2.0 Download optional 1.2.0 archive
1.1.0 Aug 22, 2014 Go to the documentation of optional 1.1.0 Download optional 1.1.0 archive

All 11 versions...

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • tool failures on Jan 17, 2018
  • Dart: 2.0.0-dev.15.0
  • pana: 0.9.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
53 / 100
Health:
Code health derived from static analysis. [more]
75 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0 / 100
Overall score:
Weighted score of the above. [more]
49

Platforms

Detected platforms: Flutter, server, web

No platform restriction found in libraries.

Suggestions

  • Fix lib/src/present.dart.

    Strong-mode analysis of lib/src/present.dart failed with the following error:

    line: 14 col: 17
    The return type 'Absent' isn't a 'Optional<T>', as defined by the method 'filter'.

  • Fix issues reported by dartanalyzer.

    dartanalyzer reported 1 error(s) and 0 warning(s).

  • The description is too short.

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

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use optional.dart.

Dependencies

Package Constraint Resolved Available
Dev dependencies
mock >=0.11.0 <0.12.0
unittest >=0.11.0 <0.12.0