positive_num 2.0.1 copy "positive_num: ^2.0.1" to clipboard
positive_num: ^2.0.1 copied to clipboard

An implementation of immutable value objects PositiveInt and PositiveDouble that encapsulate a positive number of type int or double.

The package contains immutable value objects PositiveInt and PositiveDouble that encapsulate a positive number (any number greater than 0) which can be int or double. The value objects guarantee that their value is always positive and can't be changed after creation. They can't be created with 0 or a negative value.

Getting started #

How to start using the package #

dart pub add positive_num

Or specify the package's git url in pubspec.yaml at the dependencies section.

dependencies:
  positive_num:
    git:
      url: https://github.com/maxeema/positive_num.git

Then import it in your code.

import 'package:positive_num/positive_num.dart';

Usage #

import 'package:positive_num/positive_num.dart';

void main() {
  var someNumber = 1;
  //
  final (:error, :instance) = PositiveInt.create(someNumber);
  if (instance != null) {
    final positiveInt = instance;
    print('Created a PositiveInt, value: $positiveInt');
  } else {
    print('Error. $error');
  }
}

Before run #

dart pub get

Run example #

dart run example/positive_num_example.dart

Run tests #

dart test

© Max Shemetov, 2023

4
likes
150
pub points
0%
popularity

Publisher

unverified uploader

An implementation of immutable value objects PositiveInt and PositiveDouble that encapsulate a positive number of type int or double.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

More

Packages that depend on positive_num