libprimesieve 0.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 50

libprimesieve for Dart #

This is a wrapper for Kim Walisch's primesieve C/C++ library. It requires the library to already be installed. That library is only available for some platforms, please check availability.

If you have the underlying native library installed, you can add this library as libprimesieve to your Dart package.

Looking for a simpler/pure Dart alternative? #

If you only need primes up to about 1E9 or prefer to have a Dart-only implementation, you may want to try Prime-Sieve-Dart instead, which can be installed with pub as prime-sieve (note the dash).

Please note that the pure Dart alternative is significantly slower and lacks many features.

Change Log #

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

0.1.2 - 2020-02-12 #

Added #

Fixed #

Changed #

  • Renamed example to make analyzer happy
  • Longer description

0.1.1 - 2020-02-12 #

Added #

Fixed #

Changed #

  • Package name now libprimesieve to avoid conflicts

0.1.0 - 2020-02-12 #

Added #

Fixed #

Changed #

  • Created initial version.

example/main.dart

import 'package:libprimesieve/libprimesieve.dart';

void main() {
  print("* The primes between 1 and 10 are:");
  printPrimes(1, 10);

  print("* The first prime after 100 is ${nthPrime(1, 100)}");
  print("* The last prime before 1000 is ${nthPrime(-1, 1000)}");
  print("* The first 5 primes after 100000 are ${generateNPrimes(5, 100000)}");

  print("* The prime sextuplets between 1000000000 and 1010000000 are:");
  printSextuplets(1000000000, 1010000000);

  print("* There are ${countPrimes(1, 10)} primes between 1 and 10");
  print("* There are ${countPrimes(1, 10000000000)} primes between 1 and 10000000000");
}

Use this package as an executable

1. Install it

You can install the package from the command line:


$ pub global activate libprimesieve

2. Use it

The package has the following executables:


$ print_primes

Use this package as a library

1. Depend on it

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


dependencies:
  libprimesieve: ^0.1.2

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:libprimesieve/libprimesieve.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
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]
50
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

Format bin/print_primes.dart.

Run dartfmt to format bin/print_primes.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
args ^1.0.0 1.6.0
ffi ^0.1.3 0.1.3
Dev dependencies
path ^1.0.0
test ^1.0.0