0 purchases
bd bridge client
bridge_client #
Usage #
Bridge Interface Define
import 'package:meta/meta.dart';
import 'package:bd_bridge_client/annotation.dart';
import 'package:bd_bridge_client/client.dart';
part "ui.g.dart";
@Bridge('UI')
mixin UI on BridgeModule {
@BridgeMethod()
Future<void> toast({String message});
}
copied to clipboard
Run Codegen
flutter packages pub run build_runner build
copied to clipboard
Generate ui.g.dart file part:
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'ui.dart';
// **************************************************************************
// BridgeGenerator
// **************************************************************************
class UIBridge extends BridgeModule with UI {
UIBridge({BridgeClient client}) : super(client: client);
Future<void> toast({
String message,
}) {
var _$params = {
'message': message,
};
var _$result = client.getData<void>('TTRUI.toast', params: _$params);
return _$result;
}
}
copied to clipboard
Usage in Dart
bridge.ui.toast(message: 'Send Message~');
copied to clipboard
Get In Native Side
public class ToastMethod extends BridgeMethods.PublicMethod {
@Override
public Single<IBridgeResult> call(IBridgeContext context, JsonObject params) {
Toast.makeText(getApplicationContext(), params.get("message").getAsString(), Toast.LENGTH_SHORT).show();
return BridgeResult.createSingleSuccessBridgeResult(params);
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.