native_sample 0.2.0 copy "native_sample: ^0.2.0" to clipboard
native_sample: ^0.2.0 copied to clipboard

outdatedDart 1 only

Sample for using a native library

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

Description #

Two ways of testing this lib:

Command line:

  • dart bin/random.dart

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
0
likes
15
pub points
0%
popularity

Publisher

unverified uploader

Sample for using a native library

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

Dependencies

logging, logging_handlers, rpc, shelf, shelf_route, shelf_rpc

More

Packages that depend on native_sample