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

This commit is contained in:
Sarah Zakarias
2018-05-24 08:49:17 +02:00
committed by GitHub
parent 54899c7638
commit ca300100b8
7 changed files with 15 additions and 18 deletions

View File

@@ -1,7 +1,6 @@
package {{androidIdentifier}};
import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;

View File

@@ -1,5 +1,5 @@
#import <UIKit/UIKit.h>
#import <Flutter/Flutter.h>
#import <UIKit/UIKit.h>
@interface AppDelegate : FlutterAppDelegate

View File

@@ -3,7 +3,8 @@
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GeneratedPluginRegistrant registerWithRegistry:self];
// Override point for customization after application launch.
return [super application:application didFinishLaunchingWithOptions:launchOptions];

View File

@@ -1,8 +1,8 @@
#import <UIKit/UIKit.h>
#import <Flutter/Flutter.h>
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[]) {
int main(int argc, char* argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}

View File

@@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_driver/driver_extension.dart';
{{/withDriverTest}}
{{#withPluginHook}}
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:{{pluginProjectName}}/{{pluginProjectName}}.dart';
{{/withPluginHook}}
@@ -136,13 +138,13 @@ class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
@override
initState() {
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
initPlatformState() async {
Future<void> initPlatformState() async {
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
@@ -154,8 +156,7 @@ class _MyAppState extends State<MyApp> {
// 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
// setState to update our non-existent appearance.
if (!mounted)
return;
if (!mounted) return;
setState(() {
_platformVersion = platformVersion;
@@ -167,7 +168,7 @@ class _MyAppState extends State<MyApp> {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: new Text('Plugin example app'),
title: const Text('Plugin example app'),
),
body: new Center(
child: new Text('Running on: $_platformVersion\n'),

View File

@@ -1,3 +1,3 @@
## [0.0.1] - TODO: Add release date.
## 0.0.1
* TODO: Describe initial release.

View File

@@ -1,18 +1,14 @@
package {{androidIdentifier}};
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.PluginRegistry.Registrar;
/**
* {{pluginClass}}
*/
/** {{pluginClass}} */
public class {{pluginClass}} implements MethodCallHandler {
/**
* Plugin registration.
*/
/** Plugin registration. */
public static void registerWith(Registrar registrar) {
final MethodChannel channel = new MethodChannel(registrar.messenger(), "{{projectName}}");
channel.setMethodCallHandler(new {{pluginClass}}());