num_extension 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 53

num_extension #

A set of mathematical calculations on num and List<num> objects - using Dart Extension Methods.

https://pub.dev/packages/num_extensionn)

Installation #

dependencies:
  num_extension: ^1.0.0

Import #

import 'package:num_extension/num_extension.dart';

Usage #

You can play out all essential number juggling tasks on num

  var result = 1.plus(3);
  var result = 3.minus(4);
  var result = 2.1.plus(4).times(2);
  var result = 1.plus(3.1).div(7).times(2);

You can as well add/subtract the sum of elements in List<num> to/from the num

  var result = 3.plusList([2, 1, -4, 8]);
  var result = 27.minusList([9, -2, 9, 4]);
  var result = 4.div(2).times(3).minus(4.5).plus(3).plusList([2, 8, 4, 5]);

You can also do the same on List<num>

  var result = [2, 3, 1, -12.1].sum;
  var result = [2, 3, 1, -12].min;
  var result = [2, 3, 1, -12].max;
  var result = [2, 3, 1, -12].average;
  var result = [2, 3, 1, -12].sum.plusList([2,4]).minus(4).div(2);

License #

MIT License

Issues/Requests #

Pull requests are welcome. More so, on the off chance that you experience any issues don't hesitate to open an issue. In the event that you feel the library is feeling the loss of a component if you don't mind raising a ticket on Github and I'll investigate it.

[0.0.1] - Dec 16, 2019.

  • Initial release.

[1.0.0] - Dec 17, 2019.

  • Extend extensions to work for num and List<num>.

example/num_extension_example.dart

import 'package:num_extension/src/extension.dart';

void main() {

  // `num` Extensions
  print(1.plus(3));
  print(3.minus(4));
  print(3.plusList([2, 1, -4, 8]));
  print(27.minusList([9, -2, 9, 4]));
  print(2.1.plus(4).times(2));
  print(1.plus(3.1).div(7).times(2));
  print(4.div(2).times(3).minus(4.5).plus(3).plusList([2, 8, 4, 5]));
  print(3.plusList([2, 3, -5, 2.2]));
  print(3.minusList([2, 3, -5, 2.2]));


  // `List<num>` Extensions
  print([2, 3, 1, -12.1].sum);
  print([2, 3, 1, -12].min);
  print([2, 3, 1, -12].max);
  print([2, 3, 1, -12].average);
  print([2, 3, 1, -12].sum.plusList([2, 4]).minus(4).div(2));

}

Use this package as a library

1. Depend on it

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


dependencies:
  num_extension: ^1.0.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support 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:num_extension/num_extension.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
6
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
53
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health suggestions

Format lib/num_extension.dart.

Run flutter format to format lib/num_extension.dart.

Format lib/src/extension.dart.

Run flutter format to format lib/src/extension.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test