diff --git a/Makefile b/Makefile index c70cc73..95c48a5 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,9 @@ run: build-go flutter-config-devices build: build-go flutter-config-devices flutter build -d ${FLUTTER_DEVICE} +clean: + flutter clean + flutter-config-devices: flutter config --enable-linux-desktop diff --git a/lib/create_message.dart b/lib/create_message.dart index 8c71ec6..9f0d8dc 100644 --- a/lib/create_message.dart +++ b/lib/create_message.dart @@ -1,17 +1,41 @@ import 'dart:ffi' as ffi; // For FFI +import 'dart:io'; + import 'package:ffi/ffi.dart'; +import 'package:flutter/services.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:flutter/widgets.dart' show WidgetsFlutterBinding; typedef CreateMessageFunctionTemplate = ffi.Pointer Function( ffi.Pointer message); typedef CreateMessage = CreateMessageFunctionTemplate; -final dylib = ffi.DynamicLibrary.open('./vendor/out/text.a'); +// Future vendorFuture = +// copyAssetToLocal().then((value) => vendorPath = value); + +// final dylib = ffi.DynamicLibrary.open('vendor/out/text.a'); -final CreateMessage _createMessage = dylib - .lookup>('CreateMessage') - .asFunction(); +void createMessage(String text) async { + String path = await copyAssetToLocal(); + final dylib = ffi.DynamicLibrary.open(path); -void createMessage(String text) { + final CreateMessage _createMessage = dylib + .lookup>( + 'CreateMessage') + .asFunction(); + print("log :: writing using $path"); _createMessage(text.toNativeUtf8()); } + +Future copyAssetToLocal() async { + try { + var content = await rootBundle.load("vendor/out/text.a"); + final directory = await getApplicationDocumentsDirectory(); + var file = File("${directory.path}/text.a"); + file.writeAsBytesSync(content.buffer.asUint8List()); + return file.path; + } catch (e) { + rethrow; + } +} diff --git a/pubspec.lock b/pubspec.lock index bfdea44..c44a42a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -21,21 +21,14 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" + version: "1.2.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: @@ -56,7 +49,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" ffi: dependency: "direct main" description: @@ -64,6 +57,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.2" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.4" flutter: dependency: "direct main" description: flutter @@ -94,28 +94,98 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" + path_provider: + dependency: "direct dev" + description: + name: path_provider + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.11" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.20" + path_provider_ios: + dependency: transitive + description: + name: path_provider_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.11" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.7" + path_provider_macos: + dependency: transitive + description: + name: path_provider_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.6" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.7" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.3" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.4" sky_engine: dependency: transitive description: flutter @@ -127,7 +197,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.2" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -148,21 +218,21 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.9" + version: "0.4.12" vector_math: dependency: transitive description: @@ -170,5 +240,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.2" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "2.6.1" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0+2" sdks: - dart: ">=2.17.0-0 <3.0.0" + dart: ">=2.17.0 <3.0.0" + flutter: ">=2.10.0" diff --git a/pubspec.yaml b/pubspec.yaml index 0803a94..40984d2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -46,6 +46,7 @@ dev_dependencies: # package. See that file for information about deactivating specific lint # rules and activating additional ones. flutter_lints: ^1.0.0 + path_provider: ^2.0.11 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec @@ -53,6 +54,15 @@ dev_dependencies: # The following section is specific to Flutter. flutter: + plugin: + platforms: + android: + package: io.swhh.plugin1 + pluginClass: Plugin1Plugin + ios: + pluginClass: Plugin1Plugin + + # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class.