chore: generate template (#19)

This commit is contained in:
github-actions[bot]
2022-04-12 12:23:59 -05:00
committed by GitHub
parent 1eba29b7ca
commit bb943d2f71
67 changed files with 33 additions and 29 deletions

View File

@@ -0,0 +1,29 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
.packages
build/

View File

@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.
version:
revision: 77d935af4db863f6abd0b9c31c7e6df2a13de57b
channel: stable
project_type: plugin

View File

@@ -0,0 +1,3 @@
# 0.1.0+1
- Initial release of this plugin.

View File

@@ -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.

View File

@@ -0,0 +1,14 @@
# {{project_name.snakeCase()}}_windows
[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link]
The windows 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

View File

@@ -0,0 +1 @@
include: package:very_good_analysis/analysis_options.2.4.0.yaml

View File

@@ -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 Windows implementation of [{{project_name.pascalCase()}}Platform].
class {{project_name.pascalCase()}}Windows extends {{project_name.pascalCase()}}Platform {
/// The method channel used to interact with the native platform.
@visibleForTesting
final methodChannel = const MethodChannel('{{project_name.snakeCase()}}_windows');
/// Registers this class as the default instance of [{{project_name.pascalCase()}}Platform]
static void registerWith() {
{{project_name.pascalCase()}}Platform.instance = {{project_name.pascalCase()}}Windows();
}
@override
Future<String?> getPlatformName() {
return methodChannel.invokeMethod<String>('getPlatformName');
}
}

View File

@@ -0,0 +1,27 @@
name: {{project_name.snakeCase()}}_windows
description: Windows 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:
windows:
pluginClass: {{project_name.pascalCase()}}Windows
dartPluginClass: {{project_name.pascalCase()}}Windows
dependencies:
flutter:
sdk: flutter
{{project_name.snakeCase()}}_platform_interface:
path: ../{{project_name.snakeCase()}}_platform_interface
dev_dependencies:
flutter_test:
sdk: flutter
very_good_analysis: ^2.4.0

View File

@@ -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()}}_platform_interface/{{project_name.snakeCase()}}_platform_interface.dart';
import 'package:{{project_name.snakeCase()}}_windows/{{project_name.snakeCase()}}_windows.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
group('{{project_name.pascalCase()}}Windows', () {
const kPlatformName = 'Windows';
late {{project_name.pascalCase()}}Windows {{project_name.camelCase()}};
late List<MethodCall> log;
setUp(() async {
{{project_name.camelCase()}} = {{project_name.pascalCase()}}Windows();
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()}}Windows.registerWith();
expect({{project_name.pascalCase()}}Platform.instance, isA<{{project_name.pascalCase()}}Windows>());
});
test('getPlatformName returns correct name', () async {
final name = await {{project_name.camelCase()}}.getPlatformName();
expect(
log,
<Matcher>[isMethodCall('getPlatformName', arguments: null)],
);
expect(name, equals(kPlatformName));
});
});
}

View File

@@ -0,0 +1,17 @@
flutter/
# Visual Studio user-specific files.
*.suo
*.user
*.userosscache
*.sln.docstates
# Visual Studio build-related files.
x64/
x86/
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/

View File

@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.14)
set(PROJECT_NAME "{{project_name.snakeCase()}}_windows")
project(${PROJECT_NAME} LANGUAGES CXX)
set(PLUGIN_NAME "${PROJECT_NAME}_plugin")
add_library(${PLUGIN_NAME} SHARED
"{{project_name.snakeCase()}}_windows_plugin.cpp"
"include/{{project_name.snakeCase()}}_windows/{{project_name.snakeCase()}}_windows.h"
)
apply_standard_settings(${PLUGIN_NAME})
set_target_properties(${PLUGIN_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden)
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
target_include_directories(${PLUGIN_NAME} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)
# List of absolute paths to libraries that should be bundled with the plugin
set({{project_name.snakeCase()}}_bundled_libraries
""
PARENT_SCOPE
)

View File

@@ -0,0 +1,23 @@
#ifndef FLUTTER_PLUGIN_MY_PLUGIN_WINDOWS_PLUGIN_H_
#define FLUTTER_PLUGIN_MY_PLUGIN_WINDOWS_PLUGIN_H_
#include <flutter_plugin_registrar.h>
#ifdef FLUTTER_PLUGIN_IMPL
#define FLUTTER_PLUGIN_EXPORT __declspec(dllexport)
#else
#define FLUTTER_PLUGIN_EXPORT __declspec(dllimport)
#endif
#if defined(__cplusplus)
extern "C" {
#endif
FLUTTER_PLUGIN_EXPORT void {{project_name.pascalCase()}}WindowsRegisterWithRegistrar(
FlutterDesktopPluginRegistrarRef registrar);
#if defined(__cplusplus)
} // extern "C"
#endif
#endif // FLUTTER_PLUGIN_MY_PLUGIN_WINDOWS_PLUGIN_H_

View File

@@ -0,0 +1,72 @@
#include "include/{{project_name.snakeCase()}}_windows/{{project_name.snakeCase()}}_windows.h"
// This must be included before many other Windows headers.
#include <windows.h>
#include <flutter/method_channel.h>
#include <flutter/plugin_registrar_windows.h>
#include <flutter/standard_method_codec.h>
#include <map>
#include <memory>
namespace {
using flutter::EncodableValue;
class {{project_name.pascalCase()}}Windows : public flutter::Plugin {
public:
static void RegisterWithRegistrar(flutter::PluginRegistrarWindows *registrar);
{{project_name.pascalCase()}}Windows();
virtual ~{{project_name.pascalCase()}}Windows();
private:
// Called when a method is called on this plugin's channel from Dart.
void HandleMethodCall(
const flutter::MethodCall<flutter::EncodableValue> &method_call,
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
};
// static
void {{project_name.pascalCase()}}Windows::RegisterWithRegistrar(
flutter::PluginRegistrarWindows *registrar) {
auto channel =
std::make_unique<flutter::MethodChannel<flutter::EncodableValue>>(
registrar->messenger(), "{{project_name.snakeCase()}}_windows",
&flutter::StandardMethodCodec::GetInstance());
auto plugin = std::make_unique<{{project_name.pascalCase()}}Windows>();
channel->SetMethodCallHandler(
[plugin_pointer = plugin.get()](const auto &call, auto result) {
plugin_pointer->HandleMethodCall(call, std::move(result));
});
registrar->AddPlugin(std::move(plugin));
}
{{project_name.pascalCase()}}Windows::{{project_name.pascalCase()}}Windows() {}
{{project_name.pascalCase()}}Windows::~{{project_name.pascalCase()}}Windows() {}
void {{project_name.pascalCase()}}Windows::HandleMethodCall(
const flutter::MethodCall<flutter::EncodableValue> &method_call,
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result) {
if (method_call.method_name().compare("getPlatformName") == 0) {
result->Success(EncodableValue("Windows"));
}
else {
result->NotImplemented();
}
}
} // namespace
void {{project_name.pascalCase()}}WindowsRegisterWithRegistrar(
FlutterDesktopPluginRegistrarRef registrar) {
{{project_name.pascalCase()}}Windows::RegisterWithRegistrar(
flutter::PluginRegistrarManager::GetInstance()
->GetRegistrar<flutter::PluginRegistrarWindows>(registrar));
}