Unverified Commit ca300100 authored by Sarah Zakarias's avatar Sarah Zakarias Committed by GitHub

Update plugin template to comply with new type and style rules (#17840)

parent 54899c76
package {{androidIdentifier}}; package {{androidIdentifier}};
import android.os.Bundle; import android.os.Bundle;
import io.flutter.app.FlutterActivity; import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant; import io.flutter.plugins.GeneratedPluginRegistrant;
......
#import <UIKit/UIKit.h>
#import <Flutter/Flutter.h> #import <Flutter/Flutter.h>
#import <UIKit/UIKit.h>
@interface AppDelegate : FlutterAppDelegate @interface AppDelegate : FlutterAppDelegate
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
@implementation AppDelegate @implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GeneratedPluginRegistrant registerWithRegistry:self]; [GeneratedPluginRegistrant registerWithRegistry:self];
// Override point for customization after application launch. // Override point for customization after application launch.
return [super application:application didFinishLaunchingWithOptions:launchOptions]; return [super application:application didFinishLaunchingWithOptions:launchOptions];
......
#import <UIKit/UIKit.h>
#import <Flutter/Flutter.h> #import <Flutter/Flutter.h>
#import <UIKit/UIKit.h>
#import "AppDelegate.h" #import "AppDelegate.h"
int main(int argc, char * argv[]) { int main(int argc, char* argv[]) {
@autoreleasepool { @autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
} }
......
...@@ -3,6 +3,8 @@ import 'package:flutter/material.dart'; ...@@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_driver/driver_extension.dart'; import 'package:flutter_driver/driver_extension.dart';
{{/withDriverTest}} {{/withDriverTest}}
{{#withPluginHook}} {{#withPluginHook}}
import 'dart:async';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:{{pluginProjectName}}/{{pluginProjectName}}.dart'; import 'package:{{pluginProjectName}}/{{pluginProjectName}}.dart';
{{/withPluginHook}} {{/withPluginHook}}
...@@ -136,13 +138,13 @@ class _MyAppState extends State<MyApp> { ...@@ -136,13 +138,13 @@ class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown'; String _platformVersion = 'Unknown';
@override @override
initState() { void initState() {
super.initState(); super.initState();
initPlatformState(); initPlatformState();
} }
// Platform messages are asynchronous, so we initialize in an async method. // Platform messages are asynchronous, so we initialize in an async method.
initPlatformState() async { Future<void> initPlatformState() async {
String platformVersion; String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException. // Platform messages may fail, so we use a try/catch PlatformException.
try { try {
...@@ -154,8 +156,7 @@ class _MyAppState extends State<MyApp> { ...@@ -154,8 +156,7 @@ class _MyAppState extends State<MyApp> {
// If the widget was removed from the tree while the asynchronous platform // If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling // message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance. // setState to update our non-existent appearance.
if (!mounted) if (!mounted) return;
return;
setState(() { setState(() {
_platformVersion = platformVersion; _platformVersion = platformVersion;
...@@ -167,7 +168,7 @@ class _MyAppState extends State<MyApp> { ...@@ -167,7 +168,7 @@ class _MyAppState extends State<MyApp> {
return new MaterialApp( return new MaterialApp(
home: new Scaffold( home: new Scaffold(
appBar: new AppBar( appBar: new AppBar(
title: new Text('Plugin example app'), title: const Text('Plugin example app'),
), ),
body: new Center( body: new Center(
child: new Text('Running on: $_platformVersion\n'), child: new Text('Running on: $_platformVersion\n'),
......
## [0.0.1] - TODO: Add release date. ## 0.0.1
* TODO: Describe initial release. * TODO: Describe initial release.
package {{androidIdentifier}}; package {{androidIdentifier}};
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler; import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result; import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.PluginRegistry.Registrar; import io.flutter.plugin.common.PluginRegistry.Registrar;
/** /** {{pluginClass}} */
* {{pluginClass}}
*/
public class {{pluginClass}} implements MethodCallHandler { public class {{pluginClass}} implements MethodCallHandler {
/** /** Plugin registration. */
* Plugin registration.
*/
public static void registerWith(Registrar registrar) { public static void registerWith(Registrar registrar) {
final MethodChannel channel = new MethodChannel(registrar.messenger(), "{{projectName}}"); final MethodChannel channel = new MethodChannel(registrar.messenger(), "{{projectName}}");
channel.setMethodCallHandler(new {{pluginClass}}()); channel.setMethodCallHandler(new {{pluginClass}}());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment