A plugin basic class for Flutter. To implement method of plugin class directly without handleMethodCall
or onMethodCall
.
- Class
FlutterEasyPlugin
must be as parent class. - Subclass implement plugin method directly without
handleMethodCall
oronMethodCall
. - Just like an native method implementation for Flutter channel call.
- Support result such as return-value, async-return-value and error for implemented method.
- Try to see examples for detail or see method
getPlatformVersion
.
To use this plugin, add flutter_easy_plugin
as a dependency in your pubspec.yaml file. For example:
dependencies:
flutter_easy_plugin: 0.0.1
// iOS result
@interface FlutterEasyPluginResult : NSObject
+ (instancetype)notImplemention;
+ (instancetype)return:(id)value;
+ (instancetype)error:(NSError *)error;
+ (instancetype)async:(void (^)(void (^done)(id value, NSError *_Nullable error)))block;
@end
// iOS base class
@interface FlutterEasyPlugin : NSObject<FlutterPlugin>
@property (nonatomic, copy, class, readonly) NSString *channelName;
@property (nonatomic, strong, readonly) FlutterMethodChannel *methodChannel;
- (instancetype)initWithMethodChannel:(FlutterMethodChannel *)methodChannel NS_DESIGNATED_INITIALIZER;
@end
// Android Result
public abstract class FlutterEasyPluginResult {
public static FlutterEasyPluginResult success(Object object) {
return new FlutterEasyPluginReturnResult(object);
}
public static FlutterEasyPluginResult error(Error error) {
return new FlutterEasyPluginErrorResult(error);
}
public static FlutterEasyPluginResult notImplemented() {
return new FlutterEasyPluginNotImplementedResult();
}
public static FlutterEasyPluginResult async(AsyncExcutor excutor) {
return new FlutterEasyPluginAsyncResult(excutor);
}
}
// Android base class
public class FlutterEasyPlugin implements MethodCallHandler {}
Please file any issues, bugs or feature request as an issue on our Github page.
If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our contribution guide and send us your pull request.
This Flutter easy plugin for Flutter is developed by modool. You can contact us at [email protected]