native_sample 0.2.1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 37

Dart Native-Library sample

Some test around building native extensions for Dart

I started this project because of a very old and outdated documentation on the according site: https://www.dartlang.org/articles/dart-vm/native-extensions

You can find the native-part here on GH

Original Dart Documentation

Because it is so outdated 2012 I try to collect some useful information's on CPP-Master

If you have some tips, tricks or other useful information's please go to CPP-Master, file an issue report or add something to the Wiki! - Thanks!

Description

Two ways of testing this lib:

Command line:

  • dart bin/random.dart
pub global install <package> - does not work 

It produces "Cannot load native extensions over http: or https:"

RPC Server:

  • dart bin/rpc.dart

RPC-API:

Project structure

I'm using this approach - the C++-Project is the root project and Dart as a side(or sub)-project

cmake does the heavy lifting and copies the native lib to the right place.

cmake-dart-extension-master:

├── CMakeLists.txt
├── README.md
├── dart
│   ├── LICENSE
│   ├── README.md
│   ├── bin
│   │   ├── random.dart
│   │   └── rpc.dart
│   ├── dart.iml
│   ├── lib
│   │   ├── native
│   │   │   ├── libsample_extension.dylib
│   │   │   ├── libsample_extension.so
│   │   │   └── random.dart
│   │   ├── rpcapi.dart
│   │   └── src
│   ├── pubspec.lock
│   └── pubspec.yaml
├── include
│   └── SampleProject.h
├── lib
│   ├── libsample_extension.dylib
│   └── mac
│       ├── libsample_extension.dylib
│       └── libsample_extension.so
├── src
│   ├── NewCppClass.cpp
│   ├── NewCppClass.h
│   ├── SampleProject.cpp
│   ├── SystemRand.cpp
│   ├── SystemRand.h
│   ├── dartInterface.cpp
│   ├── dartInterface.h
│   └── utils.h
└── tools
    └── install-compiler.sh

Conclusion so far (12 2016)

It's possible to write native extensions for Dart but you have to be a masochist to do this.

Change Log for native_sample

Sample for using a native library

Unreleased

Docs

  • Added some links to the README's b01d391

v0.2.0 - 2016-12-16

Bugs

  • Wrong path in rpcapi.dart to random-package 566363f

Docs

This CHANGELOG.md was generated with Changelog for Dart

Use this package as an executable

1. Install it

You can install the package from the command line:


$ pub global activate native_sample

2. Use it

The package has the following executables:


$ random

Use this package as a library

1. Depend on it

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


dependencies:
  native_sample: "^0.2.1"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


      import 'package:native_sample/rpcapi.dart';
  
Version Uploaded Documentation Archive
0.2.1 Dec 16, 2016 Go to the documentation of native_sample 0.2.1 Download native_sample 0.2.1 archive
0.2.0 Dec 16, 2016 Go to the documentation of native_sample 0.2.0 Download native_sample 0.2.0 archive
0.1.1 Dec 16, 2016 Go to the documentation of native_sample 0.1.1 Download native_sample 0.1.1 archive
0.1.0 Dec 16, 2016 Go to the documentation of native_sample 0.1.0 Download native_sample 0.1.0 archive

Analysis

We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status tool failures using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

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

Platforms

Detected platforms: unsure

Error(s) prevent platform classification:

Make sure dartanalyzer runs.

Suggestions

  • Make sure dartanalyzer runs.

    Running dartanalyzer . failed with the following output:

    Invalid argument(s): dartanalyzer exception: NoSuchMethodError: The getter 'length' was called on null.
    
  • Fix platform conflicts.

    Error(s) prevent platform classification:

    Make sure dartanalyzer runs.

  • Package is getting outdated.

    The package was released 78 weeks ago.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use native_sample.dart.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 2 hints.

    Run dartfmt to format lib/native/random.dart.

    Run dartfmt to format lib/rpcapi.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.9.0 <2.0.0
logging >=0.11.1 <0.12.0 0.11.3+1
logging_handlers >=0.8.0 <0.9.0 0.8.0
rpc >=0.5.0 <0.6.0 0.5.10
shelf >=0.6.0 <0.7.0 0.6.8 0.7.3+1
shelf_route >=0.13.4 <0.14.0 0.13.5 0.14.3
shelf_rpc >=0.0.3 <0.0.4 0.0.3+2
Transitive dependencies
_discoveryapis_commons 0.1.6
analyzer 0.32.1
args 1.4.3
async 1.13.3 2.0.7
charcode 1.1.1
collection 1.14.10
concepts 0.2.0
convert 2.0.1
crypto 2.0.5
csslib 0.14.4
dart_style 1.1.0
discoveryapis_generator 0.9.7
either 0.1.8
front_end 0.1.1
gcloud 0.5.0
glob 1.1.5
googleapis 0.51.0
googleapis_beta 0.46.0
html 0.13.3+1
http 0.11.3+16
http_parser 3.1.2
intl 0.15.6
kernel 0.3.1
matcher 0.12.3
meta 1.1.5
mime 0.9.6+1
option 1.2.0
package_config 1.0.3
path 1.6.1
plugin 0.2.0+2
quiver 0.29.0+1
shelf_path 0.1.7 0.1.8
source_span 1.4.0
stack_trace 1.9.2
stream_channel 1.6.7+1
string_scanner 1.0.2
typed_data 1.1.5
uri 0.11.2
utf 0.9.0+4
watcher 0.9.7+8
yaml 2.1.14