bd_bridge_client

Creator: coderz1093

Last updated:

0 purchases

bd_bridge_client Image
bd_bridge_client Images

Languages

Categories

Add to Cart

Description:

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

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.