Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying DART Essentials
  • Table Of Contents Toc
  • Feedback & Rating feedback
DART Essentials

DART Essentials

By : Sikora
4.8 (4)
close
close
DART Essentials

DART Essentials

4.8 (4)
By: Sikora

Overview of this book

This book is targeted at expert programmers in JavaScript who want to learn Dart quickly. Some previous experience with OOP programming in other languages and a good knowledge of JavaScript are assumed.
Table of Contents (11 chapters)
close
close
10
Index

Writing a minimal native extension


We'll start by writing a very simple extension with just one function that takes Dart's String object as an argument and returns another String object with characters in a reverse order. Let's start by defining the two mandatory C functions, as we mentioned earlier.

The implementation here is based on the official example from https://github.com/dart-lang/bleeding_edge/blob/master/dart/samples/sample_extension/sample_extension.cc:

// Header files are part of Dart SDK.
#include "include/dart_native_api.h"
#include "include/dart_api.h"

Dart_NativeFunction ResolveName(Dart_Handle name,
                                int argc,
                                bool* auto_setup_scope) {

DART_EXPORT Dart_Handle fuzzy_search_Init(
        Dart_Handle parent_library) {
    if (Dart_IsError(parent_library)) {
        return parent_library;
    }
    // Register handler that is called every
    // time Dart's "native" keyword is used.
    Dart_Handle result_code ...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY