Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applying the target family in the template similar to the project usage #409

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions flutter_ffi_plugin/template/native/hub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ crate-type = ["lib", "cdylib", "staticlib"]
[dependencies]
rinf = "6.15.0"
prost = "0.12.6"

[target.'cfg(not(target_family = "wasm"))'.dependencies]
tokio = { version = "1", features = ["sync", "rt"] }

# Uncomment below to target the web.
# tokio_with_wasm = { version = "0.6.0", features = ["sync", "rt"] }
# wasm-bindgen = "0.2.92"
# Web
[target.'cfg(target_family = "wasm")'.dependencies]
tokio_with_wasm = { version = "0.6.0", features = ["sync", "rt"] }
wasm-bindgen = { version = "0.2.92" }
8 changes: 6 additions & 2 deletions flutter_ffi_plugin/template/native/hub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ mod common;
mod messages;

use crate::common::*;
use tokio; // Comment this line to target the web.
// use tokio_with_wasm::alias as tokio; // Uncomment this line to target the web.

#[cfg(not(target_family = "wasm"))]
use tokio;

#[cfg(target_family = "wasm")]
use tokio_with_wasm::alias as tokio;

rinf::write_interface!();

Expand Down