chore: generate template (#19)
This commit is contained in:
committed by
GitHub
parent
1eba29b7ca
commit
bb943d2f71
@@ -0,0 +1,3 @@
|
||||
# 0.1.0+1
|
||||
|
||||
- Initial release of this plugin.
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 Very Good Ventures
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,14 @@
|
||||
# {{project_name.snakeCase()}}_ios
|
||||
|
||||
[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link]
|
||||
|
||||
The ios implementation of `{{project_name.snakeCase()}}`.
|
||||
|
||||
## Usage
|
||||
|
||||
This package is [endorsed][endorsed_link], which means you can simply use `{{project_name.snakeCase()}}`
|
||||
normally. This package will be automatically included in your app when you do.
|
||||
|
||||
[endorsed_link]: https://flutter.dev/docs/development/packages-and-plugins/developing-packages#endorsed-federated-plugin
|
||||
[very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg
|
||||
[very_good_analysis_link]: https://pub.dev/packages/very_good_analysis
|
||||
@@ -0,0 +1,4 @@
|
||||
#import <Flutter/Flutter.h>
|
||||
|
||||
@interface {{project_name.pascalCase()}}Plugin : NSObject <FlutterPlugin>
|
||||
@end
|
||||
@@ -0,0 +1,18 @@
|
||||
#import "{{project_name.pascalCase()}}Plugin.h"
|
||||
|
||||
@implementation {{project_name.pascalCase()}}Plugin
|
||||
|
||||
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
|
||||
FlutterMethodChannel *channel =
|
||||
[FlutterMethodChannel methodChannelWithName:@"{{project_name.snakeCase()}}_ios"
|
||||
binaryMessenger:registrar.messenger];
|
||||
[channel setMethodCallHandler:^(FlutterMethodCall *call, FlutterResult result) {
|
||||
if ([@"getPlatformName" isEqualToString:call.method]) {
|
||||
result(@"iOS");
|
||||
} else {
|
||||
result(FlutterMethodNotImplemented);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
|
||||
#
|
||||
Pod::Spec.new do |s|
|
||||
s.name = '{{project_name.snakeCase()}}_ios'
|
||||
s.version = '0.0.1'
|
||||
s.summary = 'An iOS implementation of the {{project_name.snakeCase()}} plugin.'
|
||||
s.description = <<-DESC
|
||||
An iOS implementation of the {{project_name.snakeCase()}} plugin.
|
||||
DESC
|
||||
s.homepage = 'http://example.com'
|
||||
s.license = { :type => 'BSD', :file => '../LICENSE' }
|
||||
s.author = { 'Your Company' => 'email@example.com' }
|
||||
s.source = { :path => '.' }
|
||||
s.source_files = 'Classes/**/*'
|
||||
s.public_header_files = 'Classes/**/*.h'
|
||||
s.dependency 'Flutter'
|
||||
|
||||
s.platform = :ios, '9.0'
|
||||
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
|
||||
end
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright (c) 2022, Very Good Ventures
|
||||
// https://verygood.ventures
|
||||
//
|
||||
// Use of this source code is governed by an MIT-style
|
||||
// license that can be found in the LICENSE file or at
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:{{project_name.snakeCase()}}_platform_interface/{{project_name.snakeCase()}}_platform_interface.dart';
|
||||
|
||||
/// The iOS implementation of [{{project_name.pascalCase()}}Platform].
|
||||
class {{project_name.pascalCase()}}IOS extends {{project_name.pascalCase()}}Platform {
|
||||
/// The method channel used to interact with the native platform.
|
||||
@visibleForTesting
|
||||
final methodChannel = const MethodChannel('{{project_name.snakeCase()}}_ios');
|
||||
|
||||
/// Registers this class as the default instance of [{{project_name.pascalCase()}}Platform]
|
||||
static void registerWith() {
|
||||
{{project_name.pascalCase()}}Platform.instance = {{project_name.pascalCase()}}IOS();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> getPlatformName() {
|
||||
return methodChannel.invokeMethod<String>('getPlatformName');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
name: {{project_name.snakeCase()}}_ios
|
||||
description: iOS implementation of the {{project_name.snakeCase()}} plugin
|
||||
version: 0.1.0+1
|
||||
publish_to: none
|
||||
|
||||
environment:
|
||||
sdk: ">=2.16.0 <3.0.0"
|
||||
flutter: ">=2.10.0"
|
||||
|
||||
flutter:
|
||||
plugin:
|
||||
implements: {{project_name.snakeCase()}}
|
||||
platforms:
|
||||
ios:
|
||||
pluginClass: {{project_name.pascalCase()}}Plugin
|
||||
dartPluginClass: {{project_name.pascalCase()}}IOS
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
{{project_name.snakeCase()}}_platform_interface:
|
||||
path: ../{{project_name.snakeCase()}}_platform_interface
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
plugin_platform_interface: ^2.0.0
|
||||
very_good_analysis: ^2.4.0
|
||||
@@ -0,0 +1,51 @@
|
||||
// Copyright (c) 2022, Very Good Ventures
|
||||
// https://verygood.ventures
|
||||
//
|
||||
// Use of this source code is governed by an MIT-style
|
||||
// license that can be found in the LICENSE file or at
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:{{project_name.snakeCase()}}_ios/{{project_name.snakeCase()}}_ios.dart';
|
||||
import 'package:{{project_name.snakeCase()}}_platform_interface/{{project_name.snakeCase()}}_platform_interface.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
group('{{project_name.pascalCase()}}IOS', () {
|
||||
const kPlatformName = 'iOS';
|
||||
late {{project_name.pascalCase()}}IOS {{project_name.camelCase()}};
|
||||
late List<MethodCall> log;
|
||||
|
||||
setUp(() async {
|
||||
{{project_name.camelCase()}} = {{project_name.pascalCase()}}IOS();
|
||||
|
||||
log = <MethodCall>[];
|
||||
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger
|
||||
.setMockMethodCallHandler({{project_name.camelCase()}}.methodChannel, (methodCall) async {
|
||||
log.add(methodCall);
|
||||
switch (methodCall.method) {
|
||||
case 'getPlatformName':
|
||||
return kPlatformName;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('can be registered', () {
|
||||
{{project_name.pascalCase()}}IOS.registerWith();
|
||||
expect({{project_name.pascalCase()}}Platform.instance, isA<{{project_name.pascalCase()}}IOS>());
|
||||
});
|
||||
|
||||
test('getPlatformName returns correct name', () async {
|
||||
final name = await {{project_name.camelCase()}}.getPlatformName();
|
||||
expect(
|
||||
log,
|
||||
<Matcher>[isMethodCall('getPlatformName', arguments: null)],
|
||||
);
|
||||
expect(name, equals(kPlatformName));
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user