Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/12562' into feat/12562
Browse files Browse the repository at this point in the history
  • Loading branch information
fzyzcjy committed Sep 12, 2024
2 parents 1c32cb1 + dc669b4 commit edc1dd9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
14 changes: 14 additions & 0 deletions website/docs/guides/how-to/stack-trace.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,17 @@ The standard Rust does not provide stack traces when catching a panic.
If you want to know the stack traces, you can use approaches like
https://stackoverflow.com/questions/69593235/how-to-get-panic-information-i-e-stack-trace-with-catch-unwind.
The builtin utils do use it.

## Other solutions

There are many products to help you capture errors and provide a central panel to look at them.
[This official Flutter page](https://docs.flutter.dev/cookbook/maintenance/error-reporting)
lists some of them: Bugsnag, Datadog, Firebase Crashlytics, Rollbar, or Sentry.
This will be especially useful for your app in production.

## Behavior on Windows

It seems that Rust+Windows(+Flutter) does not handle stack traces well,
which is not a bug of flutter_rust_bridge, but something on upstream.

The current discussions and workarounds are in https://github.com/fzyzcjy/flutter_rust_bridge/issues/2200.
19 changes: 19 additions & 0 deletions website/docs/guides/misc-features/rust-ui-utilities.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Rust-GUI-via-Flutter Utilities

If you want to use Flutter as GUI of Rust,
please refer to the article in https://cjycode.com/posts/rust-ui-flutter/,
which contains background, pros, cons, tutorial, examples, etc.

Firstly, this is just one of the infinitely many approaches to let Flutter be the GUI of Rust,
and you are free to choose whatever other approaches that suits your need.

In that article, the `#[frb(ui_state)]` and `#[frb(ui_mutation)]` lightweight attributes are utilized.
They are not stabilized, i.e. can have breaking changes without major version bumping.
More details are as follows:

* `#[frb(ui_state)]`: Annotate on your state struct.
* `#[frb(ui_mutation)]`: Annotate on state methods that mutates the state. It can also be annotated on the `impl` block,
which is equivalent to annotate on each method in that block.

Then, whenever a method with `#[frb(ui_mutation)]` is called,
the Flutter UI will know the state is changed and needs to automatically refresh the UI.
1 change: 1 addition & 0 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ const sidebars = {
items: [
'guides/misc-features/dart-code',
'guides/misc-features/preambles',
'guides/misc-features/rust-ui-utilities',
'guides/misc-features/proxy',
'guides/misc-features/multi-input',
'guides/misc-features/modules',
Expand Down

0 comments on commit edc1dd9

Please sign in to comment.