chore: generate template (#12)
This commit is contained in:
committed by
GitHub
parent
b6e0a6e7c9
commit
a0f5f62cd7
@@ -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 @@
|
||||
# {{#snakeCase}}{{project_name}}{{/snakeCase}}_android
|
||||
|
||||
[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link]
|
||||
|
||||
The Android implementation of `{{#snakeCase}}{{project_name}}{{/snakeCase}}`.
|
||||
|
||||
## Usage
|
||||
|
||||
This package is [endorsed][endorsed_link], which means you can simply use `{{#snakeCase}}{{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
|
||||
8
brick/__brick__/{{#snakeCase}}{{project_name}}{{/snakeCase}}_android/android/.gitignore
vendored
Normal file
8
brick/__brick__/{{#snakeCase}}{{project_name}}{{/snakeCase}}_android/android/.gitignore
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
/.idea/libraries
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
@@ -0,0 +1,50 @@
|
||||
group '{{#dotCase}}{{org_name}}{{/dotCase}}'
|
||||
version '1.0-SNAPSHOT'
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.50'
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = '1.8'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
rootProject.name = '{{#snakeCase}}{{project_name}}{{/snakeCase}}_android'
|
||||
@@ -0,0 +1,3 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="{{#dotCase}}{{org_name}}{{/dotCase}}">
|
||||
</manifest>
|
||||
@@ -0,0 +1,34 @@
|
||||
package {{#dotCase}}{{org_name}}{{/dotCase}}
|
||||
|
||||
import android.content.Context
|
||||
import androidx.annotation.NonNull
|
||||
|
||||
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||
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
|
||||
|
||||
class {{#pascalCase}}{{project_name}}{{/pascalCase}}Plugin : FlutterPlugin, MethodCallHandler {
|
||||
private lateinit var channel: MethodChannel
|
||||
private var context: Context? = null
|
||||
|
||||
override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "{{#snakeCase}}{{project_name}}{{/snakeCase}}_android")
|
||||
channel.setMethodCallHandler(this)
|
||||
context = flutterPluginBinding.applicationContext
|
||||
}
|
||||
|
||||
override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
|
||||
if (call.method == "getPlatformName") {
|
||||
result.success("Android")
|
||||
} else {
|
||||
result.notImplemented()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
|
||||
channel.setMethodCallHandler(null)
|
||||
context = null
|
||||
}
|
||||
}
|
||||
@@ -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:{{#snakeCase}}{{project_name}}{{/snakeCase}}_platform_interface/{{#snakeCase}}{{project_name}}{{/snakeCase}}_platform_interface.dart';
|
||||
|
||||
/// The Android implementation of [{{#pascalCase}}{{project_name}}{{/pascalCase}}Platform].
|
||||
class {{#pascalCase}}{{project_name}}{{/pascalCase}}Android extends {{#pascalCase}}{{project_name}}{{/pascalCase}}Platform {
|
||||
/// The method channel used to interact with the native platform.
|
||||
@visibleForTesting
|
||||
final methodChannel = const MethodChannel('{{#snakeCase}}{{project_name}}{{/snakeCase}}_android');
|
||||
|
||||
/// Registers this class as the default instance of [{{#pascalCase}}{{project_name}}{{/pascalCase}}Platform]
|
||||
static void registerWith() {
|
||||
{{#pascalCase}}{{project_name}}{{/pascalCase}}Platform.instance = {{#pascalCase}}{{project_name}}{{/pascalCase}}Android();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> getPlatformName() {
|
||||
return methodChannel.invokeMethod<String>('getPlatformName');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
name: {{#snakeCase}}{{project_name}}{{/snakeCase}}_android
|
||||
description: Android implementation of the {{#snakeCase}}{{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: {{#snakeCase}}{{project_name}}{{/snakeCase}}
|
||||
platforms:
|
||||
android:
|
||||
package: {{#dotCase}}{{org_name}}{{/dotCase}}
|
||||
pluginClass: {{#pascalCase}}{{project_name}}{{/pascalCase}}Plugin
|
||||
dartPluginClass: {{#pascalCase}}{{project_name}}{{/pascalCase}}Android
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
{{#snakeCase}}{{project_name}}{{/snakeCase}}_platform_interface:
|
||||
path: ../{{#snakeCase}}{{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:{{#snakeCase}}{{project_name}}{{/snakeCase}}_android/{{#snakeCase}}{{project_name}}{{/snakeCase}}_android.dart';
|
||||
import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}_platform_interface/{{#snakeCase}}{{project_name}}{{/snakeCase}}_platform_interface.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
group('{{#pascalCase}}{{project_name}}{{/pascalCase}}Android', () {
|
||||
const kPlatformName = 'Android';
|
||||
late {{#pascalCase}}{{project_name}}{{/pascalCase}}Android myPlugin;
|
||||
late List<MethodCall> log;
|
||||
|
||||
setUp(() async {
|
||||
myPlugin = {{#pascalCase}}{{project_name}}{{/pascalCase}}Android();
|
||||
|
||||
log = <MethodCall>[];
|
||||
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger
|
||||
.setMockMethodCallHandler(myPlugin.methodChannel, (methodCall) async {
|
||||
log.add(methodCall);
|
||||
switch (methodCall.method) {
|
||||
case 'getPlatformName':
|
||||
return kPlatformName;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('can be registered', () {
|
||||
{{#pascalCase}}{{project_name}}{{/pascalCase}}Android.registerWith();
|
||||
expect({{#pascalCase}}{{project_name}}{{/pascalCase}}Platform.instance, isA<{{#pascalCase}}{{project_name}}{{/pascalCase}}Android>());
|
||||
});
|
||||
|
||||
test('getPlatformName returns correct name', () async {
|
||||
final name = await myPlugin.getPlatformName();
|
||||
expect(
|
||||
log,
|
||||
<Matcher>[isMethodCall('getPlatformName', arguments: null)],
|
||||
);
|
||||
expect(name, equals(kPlatformName));
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user