From 50219cc8f38dee5a4ed39e045fb20becdb16253a Mon Sep 17 00:00:00 2001 From: bkioshn Date: Tue, 5 Nov 2024 08:46:43 +0700 Subject: [PATCH] fix: doc and comment Signed-off-by: bkioshn --- docs/src/guides/languages/flutter.md | 33 +++++++++++++++++++ earthly/flutter_rust_bridge/Earthfile | 1 + examples/flutter/example/Earthfile | 16 +++++++++ .../flutter/example/rust_builder/README.md | 3 +- .../cargokit/build_tool/README.md | 3 +- 5 files changed, 54 insertions(+), 2 deletions(-) diff --git a/docs/src/guides/languages/flutter.md b/docs/src/guides/languages/flutter.md index 819e91152..a4849103b 100644 --- a/docs/src/guides/languages/flutter.md +++ b/docs/src/guides/languages/flutter.md @@ -157,6 +157,39 @@ please follow this [guide](./../../onboarding/index.md). It is pretty strait forward for this builder process, because as a part of `+build` target we already creating a docker image. +## Enhancing Flutter + +### Integrating Flutter with Rust using `flutter_rust_bridge` + +The `flutter_rust_bridge` allows you to integrate Rust with Flutter app, while maintaining the rest of the app in +Dart. +This can be useful for situations where you need to run complex algorithms, handle data +processing, or interact with low-level system APIs, but still want to leverage the Flutter ecosystem +for UI and app management. + +Start by creating a new builder where all the necessary setup is done under the `flutter_rust_bridge+builder`, +then copy the Flutter project that already have `flutter_rust_bridge` setup. +Refer to for how to setup the project. + +```Earthfile +builder-frb: + FROM flutter_rust_bridge+builder + COPY . . +``` + +Then generate a binding between Rust and Flutter + +```Earthfile +# Generated necessary files for running Flutter web locally and save it locally. +code-generator-web: + FROM +builder-frb + DO flutter_rust_bridge+CODE_GENERATOR_WEB + + SAVE ARTIFACT ./web/pkg AS LOCAL ./example/web/pkg + SAVE ARTIFACT ./rust/src/frb_generated.rs AS LOCAL ./rust/src/frb_generated.rs + SAVE ARTIFACT ./lib/src AS LOCAL ./lib/src +``` + ## Conclusion You can see the final `Earthfile` diff --git a/earthly/flutter_rust_bridge/Earthfile b/earthly/flutter_rust_bridge/Earthfile index 76f2c1c47..5553d55c8 100644 --- a/earthly/flutter_rust_bridge/Earthfile +++ b/earthly/flutter_rust_bridge/Earthfile @@ -5,6 +5,7 @@ IMPORT ../rust AS rust-ci # This will be refactored in the future # TODO(bkioshn): https://github.com/input-output-hk/catalyst-ci/issues/322 +# builder: Setup necessary tools for `flutter_rust_bridge` builder: FROM debian:stable-slim diff --git a/examples/flutter/example/Earthfile b/examples/flutter/example/Earthfile index 2b791cd6a..b12bcaf75 100644 --- a/examples/flutter/example/Earthfile +++ b/examples/flutter/example/Earthfile @@ -1,6 +1,7 @@ VERSION 0.8 IMPORT ../../../earthly/flutter AS flutter-ci +IMPORT ../../../earthly/flutter_rust_bridge AS flutter_rust_bridge # To see more available functions, navigate to earthly/flutter/Earthfile. @@ -39,3 +40,18 @@ build-web: ARG --required SENTRY_DSN DO flutter-ci+BUILD_WEB --WORKDIR=$WORKDIR --TARGET=$TARGET --SENTRY_DSN=$SENTRY_DSN + +# -----------------flutter_rust_bridge----------------- + +builder-frb: + FROM flutter_rust_bridge+builder + COPY . . + +# Generated necessary files for running Flutter web locally and save it locally. +code-generator-web: + FROM +builder-frb + DO flutter_rust_bridge+CODE_GENERATOR_WEB + + SAVE ARTIFACT ./web/pkg AS LOCAL ./example/web/pkg + SAVE ARTIFACT ./rust/src/frb_generated.rs AS LOCAL ./rust/src/frb_generated.rs + SAVE ARTIFACT ./lib/src AS LOCAL ./lib/src diff --git a/examples/flutter/example/rust_builder/README.md b/examples/flutter/example/rust_builder/README.md index 922615f9c..04b641243 100644 --- a/examples/flutter/example/rust_builder/README.md +++ b/examples/flutter/example/rust_builder/README.md @@ -1 +1,2 @@ -Please ignore this folder, which is just glue to build Rust with Flutter. \ No newline at end of file + +Please ignore this folder, which is just glue to build Rust with Flutter. diff --git a/examples/flutter/example/rust_builder/cargokit/build_tool/README.md b/examples/flutter/example/rust_builder/cargokit/build_tool/README.md index a878c2796..7da957870 100644 --- a/examples/flutter/example/rust_builder/cargokit/build_tool/README.md +++ b/examples/flutter/example/rust_builder/cargokit/build_tool/README.md @@ -1,5 +1,6 @@ + /// This is copied from Cargokit (which is the official way to use it currently) -/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin +/// Details: A sample command-line application with an entrypoint in `bin/`, library code in `lib/`, and example unit test in `test/`.