This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::any::Any; | |
/// Method that can be use to safely downcast impl Responder to a specific type T | |
/// It returns a reference of type T | |
pub fn downcast<T>(responder: &dyn Any) -> Option<&T> | |
where | |
T: Responder + 'static, | |
{ | |
responder.downcast_ref::<T>() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() async { | |
var f = Future.delayed(Duration(milliseconds: 500), () => 'Hola').then((_) => throw Exception('WTF')); | |
await f.catchError(handleError); | |
// await f; | |
print('Exiting main'); | |
} | |
void handleError(e) { | |
print(e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static Future<String> hello({to: String}) async { | |
final String greetings = await _channel.invokeMethod('hello', {'to': to}); | |
return greetings; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# copy the header to the Classes folder | |
cp ../rust/rustylib.h ios/Classes | |
# create a new libs folder | |
mkdir ios/libs | |
# copy the universal library into the libs folder | |
cp ../rust/target/universal/release/librustylib.a ios/libs/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | |
// this is the line to add including the directory holding our .aar package: | |
implementation fileTree(include: '*.aar', dir: 'rusty-android-lib-release') | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# let's use the flutter folder | |
cd flutter | |
# create a plugin project, set its namespace and its name | |
flutter create --template=plugin --org com.robertohuertas rusty_flutter_lib | |
# now you'll have a folder called rusty_flutter_lib inside the flutter folder | |
# for convenience, we'll move everything to the parent directory (flutter) | |
# this last step is completely optional. | |
mv rusty_flutter_lib/{.,}* . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
implementation project(':rusty-android-lib') | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add it below the use declarations. | |
#[cfg(target_os = "android")] | |
mod android; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![cfg(target_os = "android")] | |
#![allow(non_snake_case)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd rust/src | |
echo > android.rs |