Skip to content

Write iOS&Android Code using Dart. This package liberates you from redundant glue code and low performance of Flutter Channel.

Notifications You must be signed in to change notification settings

lonardo/dart_native

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

458 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dart_native

Write native code using Dart. This package liberates you from native code and low performance channel.

Still under development!!!

pub package Build Status

This is the blue part(DartNative Bridge) in the picture below:

📲 Requirement

DartNative Version Requirements
0.3.0 Flutter 1.20.0 (Dart 2.9.1)
0.2.0 Flutter 1.12.13 (Dart 2.7)

🌟 Feature

  • Support iOS & Android platform.
  • Sync/Async channel with high performance.
  • Generate Dart bridging code from native code.
  • Automatic object marshalling between Dart and native.

🔮 Getting Started

iOS:

Dart code:

// new Objective-C object.
RuntimeStub stub = RuntimeStub();

// Dart function will be converted to Objective-C block.
stub.fooBlock((NSObject a) {
    print('hello block! ${a.toString()}');
    return 101;
});

// support built-in structs.
CGRect rect = stub.fooCGRect(CGRect(4, 3, 2, 1));
print(rect);

Objective-C code:

typedef int(^BarBlock)(NSObject *a);

@interface RuntimeStub

- (CGRect)fooCGRect:(CGRect)rect;
- (void)fooBlock:(BarBlock)block;

@end

More ios example see: ios_unit_test.dart

Android:

Dart code:

// new Java object.
RuntimeStub stub = RuntimeStub();

// get java list.
List list = stub.getList([1, 2, 3, 4]);

// support interface.
stub.setDelegateListener(DelegateStub());

Java code:

public class RuntimeStub {

    public List<Integer> getList(List<Integer> list) {
        List<Integer> returnList = new ArrayList<>();
        returnList.add(1);
        returnList.add(2);
        return returnList;
     }

    public void setDelegateListener(SampleDelegate delegate) {
         delegate.callbackInt(1);
    }
}

More android example see: android_unit_test.dart

📚 Document

Readme

  1. dart_native README.md
  2. dart_native_gen README.md

Blog

🐒 Q&A

Q: Failed to lookup symbol (dlsym(RTLD_DEFAULT, InitDartApiDL): symbol not found) on iOS archive.

There are two Workarounds:

  1. Use dynamic library: Add use_frameworks! in Podfile.
  2. Select Target Runner -> Build Settings -> Strip Style -> change from "All Symbols" to "Non-Global Symbols"

❤️ Contributed

  • If you need help or you'd like to ask a general question, open an issue.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

👮🏻 License

DartNative is available under the BSD 3-Clause License. See the LICENSE file for more info.

About

Write iOS&Android Code using Dart. This package liberates you from redundant glue code and low performance of Flutter Channel.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • C 56.3%
  • Dart 25.4%
  • Objective-C 9.0%
  • C++ 3.4%
  • Objective-C++ 2.4%
  • Java 2.4%
  • Other 1.1%