native_sample 0.2.1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 47

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:

  • http://localhost:8080/api/random/0.1/systemRand
  • http://localhost:8080/api/random/0.1/systemRand/5
  • http://localhost:8080/api/random/0.1/systemRand/seed/555
  • http://localhost:8080/api/random/0.1/noScopeSystemRand

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

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

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

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]
87 / 100
Overall score:
Weighted score of the above. [more]
47

Platforms

Detected platforms: other

Platform components identified in package: io, mirrors.

Suggestions

  • 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.

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.8
shelf >=0.6.0 <0.7.0 0.6.8 0.7.2
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.5
analyzer 0.31.0+1
args 1.3.0
async 1.13.3 2.0.3
charcode 1.1.1
cli_util 0.1.2+1
collection 1.14.5
concepts 0.2.0
convert 2.0.1
crypto 2.0.2+1
csslib 0.14.1
dart_style 1.0.9+1
discoveryapis_generator 0.9.2 0.9.3
either 0.1.8
front_end 0.1.0-alpha.8
gcloud 0.4.0+1
glob 1.1.5
googleapis 0.44.0 0.49.0
googleapis_beta 0.39.2 0.44.0
html 0.13.2+2
http 0.11.3+16
http_parser 3.1.1
intl 0.15.2
isolate 1.1.0
kernel 0.3.0-alpha.5
matcher 0.12.1+4
meta 1.1.2
mime 0.9.6
option 1.2.0
package_config 1.0.3
path 1.5.1
plugin 0.2.0+2
quiver 0.25.0 0.28.0
shelf_path 0.1.7 0.1.8
source_span 1.4.0
stack_trace 1.9.1
stream_channel 1.6.3
string_scanner 1.0.2
typed_data 1.1.5
uri 0.11.1
utf 0.9.0+4
watcher 0.9.7+7
yaml 2.1.13