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

The package contains an immutable value object called PositiveNum that encapsulates a positive number (any number greater than 0) which can be int or double. PositiveNum guarantees that its value is a [...]

The package contains an immutable value object called PositiveNum that encapsulates a positive number (any number greater than 0) which can be int or double. PositiveNum guarantees that its value is always positive and can't be change after creation. PositiveNum can't be created with 0 or 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 like that

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) = PositiveNum.create(someNumber);
  if (instance != null) {
    final positiveNum = instance;
    print('Created a PositiveNum instance with value $positiveNum.');
  } 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
0
pub points
0%
popularity

Publisher

unverified uploader

The package contains an immutable value object called PositiveNum that encapsulates a positive number (any number greater than 0) which can be int or double. PositiveNum guarantees that its value is always positive and can't be change after creation. PositiveNum can't be created with 0 or negative value.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on positive_num