|
1 |
| -# flutter_easy_plugin |
| 1 | +# Flutter Easy Plugin |
| 2 | + |
| 3 | +A plugin basic class for Flutter. To implement method of plugin class directly without `handleMethodCall` or `onMethodCall` . |
| 4 | + |
| 5 | + [](https://pub.dartlang.org/packages/flutter_easy_plugin) [](https://app.bitrise.io/app/fa4f5d4bf452bcfb) [](https://github.com/tenhobi/effective_dart) |
| 6 | + |
| 7 | +## Features |
| 8 | + |
| 9 | +* Class `FlutterEasyPlugin` must be as parent class. |
| 10 | +* Subclass implement plugin method directly without `handleMethodCall` or `onMethodCall`. |
| 11 | +* Just like an native method implementation for Flutter channel call. |
| 12 | +* Support result such as return-value, async-return-value and error for implemented method. |
| 13 | +* Try to see examples for detail or see method `getPlatformVersion`. |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +To use this plugin, add `flutter_easy_plugin` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/). For example: |
| 18 | + |
| 19 | +```yaml |
| 20 | +dependencies: |
| 21 | + flutter_easy_plugin: 0.0.1 |
| 22 | +``` |
| 23 | +
|
| 24 | +## API |
| 25 | +
|
| 26 | +### iOS |
| 27 | +
|
| 28 | +```objc |
| 29 | + |
| 30 | +// iOS result |
| 31 | +@interface FlutterEasyPluginResult : NSObject |
| 32 | + |
| 33 | ++ (instancetype)notImplemention; |
| 34 | + |
| 35 | ++ (instancetype)return:(id)value; |
| 36 | + |
| 37 | ++ (instancetype)error:(NSError *)error; |
| 38 | + |
| 39 | ++ (instancetype)async:(void (^)(void (^done)(id value, NSError *_Nullable error)))block; |
| 40 | + |
| 41 | +@end |
| 42 | + |
| 43 | +// iOS base class |
| 44 | +@interface FlutterEasyPlugin : NSObject<FlutterPlugin> |
| 45 | + |
| 46 | +@property (nonatomic, copy, class, readonly) NSString *channelName; |
| 47 | + |
| 48 | +@property (nonatomic, strong, readonly) FlutterMethodChannel *methodChannel; |
| 49 | + |
| 50 | +- (instancetype)initWithMethodChannel:(FlutterMethodChannel *)methodChannel NS_DESIGNATED_INITIALIZER; |
| 51 | + |
| 52 | +@end |
| 53 | + |
| 54 | +``` |
| 55 | + |
| 56 | +### Android |
| 57 | + |
| 58 | +```java |
| 59 | +// Android Result |
| 60 | +public abstract class FlutterEasyPluginResult { |
| 61 | + public static FlutterEasyPluginResult success(Object object) { |
| 62 | + return new FlutterEasyPluginReturnResult(object); |
| 63 | + } |
| 64 | + |
| 65 | + public static FlutterEasyPluginResult error(Error error) { |
| 66 | + return new FlutterEasyPluginErrorResult(error); |
| 67 | + } |
| 68 | + |
| 69 | + public static FlutterEasyPluginResult notImplemented() { |
| 70 | + return new FlutterEasyPluginNotImplementedResult(); |
| 71 | + } |
| 72 | + public static FlutterEasyPluginResult async(AsyncExcutor excutor) { |
| 73 | + return new FlutterEasyPluginAsyncResult(excutor); |
| 74 | + } |
| 75 | +} |
| 76 | + |
| 77 | +// Android base class |
| 78 | +public class FlutterEasyPlugin implements MethodCallHandler {} |
| 79 | +``` |
| 80 | + |
| 81 | + |
| 82 | +## Issues |
| 83 | + |
| 84 | +Please file any issues, bugs or feature request as an issue on our [Github](https://github.com/modool/flutter_easy_plugin/issues) page. |
| 85 | + |
| 86 | +## Want to contribute |
| 87 | + |
| 88 | +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](CONTRIBUTING.md) and send us your [pull request](https://github.com/modool/flutter_easy_plugin/pulls). |
| 89 | + |
| 90 | +## Author |
| 91 | + |
| 92 | +This Flutter easy plugin for Flutter is developed by [modool ](https://github.com/modool). You can contact us at < [email protected]> |
0 commit comments