1# EJDB2 Flutter integration 2 3Embeddable JSON Database engine http://ejdb.org Dart binding. 4 5See https://github.com/Softmotions/ejdb/blob/master/README.md 6 7For API usage examples take a look into [/example](https://github.com/Softmotions/ejdb/tree/master/src/bindings/ejdb2_flutter/example) 8application. 9 10## Example 11 12pubspec.yaml 13 14```yaml 15dependencies: 16 ejdb2_flutter: 17``` 18 19```dart 20import 'package:ejdb2_flutter/ejdb2_flutter.dart'; 21 22var db = await EJDB2Builder('test.db').open(); 23 24var id = await db.put('parrots', {'name': 'Bianca', 'age': 4}); 25 print('Bianca record: ${id}'); 26 27id = await db.put('parrots', {'name': 'Darko', 'age': 8}); 28print('Darko record: ${id}'); 29 30final q = db.createQuery('/[age > :age]', 'parrots'); 31await for (final doc in q.setInt('age', 3).execute()) { 32 print('Found ${doc}'); 33} 34 35await db.close(); 36``` 37 38## Supported platforms 39 40- iOS 41- Android 42 43## iOS notes 44 45In order to build app with this binding you have 46to add the following code into application `Podfile`: 47 48```ruby 49pre_install do |installer| 50 # workaround for https://github.com/CocoaPods/CocoaPods/issues/3289 51 Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {} 52end 53``` 54 55## Android notes 56 57For release builds you have to setup proguard rules as follows: 58 59`build.gradle` 60``` 61 buildTypes { 62 ... 63 release { 64 ... 65 minifyEnabled true 66 useProguard true 67 proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 68 } 69 } 70``` 71 72`proguard-rules.pro` 73``` 74... 75 76# Keep EJDB 77-keep class com.softmotions.ejdb2.** { *; } 78 79``` 80 81## How build it manually 82 83```sh 84git clone https://github.com/Softmotions/ejdb.git 85 86cd ./ejdb 87mkdir ./build && cd build 88 89cmake .. -DCMAKE_BUILD_TYPE=Release \ 90 -DANDROID_NDK_HOME=<path to Android NDK> \ 91 -DBUILD_FLUTTER_BINDING=ON 92make 93 94# Move generate to ejdb2 flutter pub package with example app 95cd src/bindings/ejdb2_flutter/pub_publish 96flutter pub get 97cd ./example 98 99# Start Android emulator 100flutter run 101``` 102