Skip to content

Commit

Permalink
fix: doc and comment
Browse files Browse the repository at this point in the history
Signed-off-by: bkioshn <[email protected]>
  • Loading branch information
bkioshn committed Nov 5, 2024
1 parent 0ae7c4c commit 50219cc
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 2 deletions.
33 changes: 33 additions & 0 deletions docs/src/guides/languages/flutter.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://cjycode.com/flutter_rust_bridge/> 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`
Expand Down
1 change: 1 addition & 0 deletions earthly/flutter_rust_bridge/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 16 additions & 0 deletions examples/flutter/example/Earthfile
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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
3 changes: 2 additions & 1 deletion examples/flutter/example/rust_builder/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Please ignore this folder, which is just glue to build Rust with Flutter.
<!-- markdownlint-disable -->
Please ignore this folder, which is just glue to build Rust with Flutter.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!-- markdownlint-disable -->
/// 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: <https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin>

A sample command-line application with an entrypoint in `bin/`, library code
in `lib/`, and example unit test in `test/`.

0 comments on commit 50219cc

Please sign in to comment.