optional 3.0.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 88

Optional.dart #

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

Changelog #

3.0.0 #

  • (Breaking change) Removed operator overloads. They were breaking strong-mode type checks.
  • (Breaking change) Made equality checks more consistent with Dart standards. Now any two empty Optionals are equal, and two non-empty Optionals are equal if their values are equal, regardless of their types.
  • Added a cast() method, similar to List.cast().

2.0.2 #

  • Better use of generic methods (no more dynamic).

2.0.0 #

  • Compatibility with Dart 2

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

Use this package as a library

1. Depend on it

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


dependencies:
  optional: ^3.0.0

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:optional/optional.dart';
  
Version Uploaded Documentation Archive
3.0.2 Apr 29, 2019 Go to the documentation of optional 3.0.2 Download optional 3.0.2 archive
3.0.1 Mar 18, 2019 Go to the documentation of optional 3.0.1 Download optional 3.0.1 archive
3.0.0+2 Aug 9, 2018 Go to the documentation of optional 3.0.0+2 Download optional 3.0.0+2 archive
3.0.0+1 Jul 30, 2018 Go to the documentation of optional 3.0.0+1 Download optional 3.0.0+1 archive
3.0.0 Jul 30, 2018 Go to the documentation of optional 3.0.0 Download optional 3.0.0 archive
2.0.2 Jun 26, 2018 Go to the documentation of optional 2.0.2 Download optional 2.0.2 archive
2.0.1+2 Jun 6, 2018 Go to the documentation of optional 2.0.1+2 Download optional 2.0.1+2 archive
2.0.1+1 Jun 6, 2018 Go to the documentation of optional 2.0.1+1 Download optional 2.0.1+1 archive
2.0.1 Jun 6, 2018 Go to the documentation of optional 2.0.1 Download optional 2.0.1 archive
2.0.0 Jun 6, 2018 Go to the documentation of optional 2.0.0 Download optional 2.0.0 archive

All 21 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
85
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
88
Learn more about scoring.

We analyzed this package on May 8, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.0
  • pana: 0.12.15

Platforms

Detected platforms: Flutter, web, other

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

Health suggestions

Fix lib/optional_internal.dart. (-2.48 points)

Analysis of lib/optional_internal.dart reported 5 hints:

line 10 col 1: Prefer using /// for doc comments.

line 16 col 3: Prefer using /// for doc comments.

line 29 col 3: Prefer using /// for doc comments.

line 43 col 3: Prefer using /// for doc comments.

line 59 col 3: Prefer using /// for doc comments.

Format lib/optional.dart.

Run dartfmt to format lib/optional.dart.

Format lib/src/absent.dart.

Run dartfmt to format lib/src/absent.dart.

Format lib/src/novaluepresent.dart.

Run dartfmt to format lib/src/novaluepresent.dart.

Format lib/src/present.dart.

Run dartfmt to format lib/src/present.dart.

Maintenance suggestions

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.

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and optional.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <3.0.0
Dev dependencies
mockito >=2.2.0 <4.0.0
test >=0.12.0 <2.0.0