Browse Source

init commit

master
commit
7fd25b824e
  1. 29
      .gitignore
  2. 30
      .metadata
  3. 3
      CHANGELOG.md
  4. 1
      LICENSE
  5. 15
      README.md
  6. 4
      analysis_options.yaml
  7. 23
      aurora/CMakeLists.txt
  8. 38
      aurora/clipboard_plugin.cpp
  9. 18
      aurora/include/clipboard/clipboard_plugin.h
  10. 10
      aurora/include/clipboard/globals.h
  11. 8
      lib/clipboard.dart
  12. 17
      lib/clipboard_method_channel.dart
  13. 29
      lib/clipboard_platform_interface.dart
  14. 69
      pubspec.yaml

29
.gitignore vendored

@ -0,0 +1,29 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/
# 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/
build/

30
.metadata

@ -0,0 +1,30 @@
# 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: "d3e00ac70443dbc0df7d0b56bff94c18d760b02f"
channel: "master"
project_type: plugin
# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: d3e00ac70443dbc0df7d0b56bff94c18d760b02f
base_revision: d3e00ac70443dbc0df7d0b56bff94c18d760b02f
- platform: aurora
create_revision: d3e00ac70443dbc0df7d0b56bff94c18d760b02f
base_revision: d3e00ac70443dbc0df7d0b56bff94c18d760b02f
# User provided section
# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'

3
CHANGELOG.md

@ -0,0 +1,3 @@
## 0.0.1
* TODO: Describe initial release.

1
LICENSE

@ -0,0 +1 @@
TODO: Add your license here.

15
README.md

@ -0,0 +1,15 @@
# clipboard
A new Flutter plugin project.
## Getting Started
This project is a starting point for a Flutter
[plug-in package](https://flutter.dev/developing-packages/),
a specialized package that includes platform-specific implementation code for
Android and/or iOS.
For help getting started with Flutter development, view the
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.

4
analysis_options.yaml

@ -0,0 +1,4 @@
include: package:flutter_lints/flutter.yaml
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options

23
aurora/CMakeLists.txt

@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 3.10)
set(PROJECT_NAME clipboard)
set(PLUGIN_NAME clipboard_platform_plugin)
project(${PROJECT_NAME} LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-psabi")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
find_package(PkgConfig REQUIRED)
pkg_check_modules(FlutterEmbedder REQUIRED IMPORTED_TARGET flutter-embedder)
add_library(${PLUGIN_NAME} SHARED clipboard_plugin.cpp)
set_target_properties(${PLUGIN_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden)
target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::FlutterEmbedder)
target_include_directories(${PLUGIN_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_compile_definitions(${PLUGIN_NAME} PRIVATE PLUGIN_IMPL)

38
aurora/clipboard_plugin.cpp

@ -0,0 +1,38 @@
#include <clipboard/clipboard_plugin.h>
#include <flutter/method-channel.h>
#include <sys/utsname.h>
void ClipboardPlugin::RegisterWithRegistrar(PluginRegistrar &registrar)
{
registrar.RegisterMethodChannel("clipboard",
MethodCodecType::Standard,
[this](const MethodCall &call) { this->onMethodCall(call); });
}
void ClipboardPlugin::onMethodCall(const MethodCall &call)
{
const auto &method = call.GetMethod();
if (method == "getPlatformVersion") {
onGetPlatformVersion(call);
return;
}
unimplemented(call);
}
void ClipboardPlugin::onGetPlatformVersion(const MethodCall &call)
{
utsname uname_data{};
uname(&uname_data);
std::string preamble = "Aurora (Linux): ";
std::string version = preamble + uname_data.version;
call.SendSuccessResponse(version);
}
void ClipboardPlugin::unimplemented(const MethodCall &call)
{
call.SendSuccessResponse(nullptr);
}

18
aurora/include/clipboard/clipboard_plugin.h

@ -0,0 +1,18 @@
#ifndef FLUTTER_PLUGIN_CLIPBOARD_PLUGIN_H
#define FLUTTER_PLUGIN_CLIPBOARD_PLUGIN_H
#include <flutter/plugin-interface.h>
#include <clipboard/globals.h>
class PLUGIN_EXPORT ClipboardPlugin final : public PluginInterface
{
public:
void RegisterWithRegistrar(PluginRegistrar &registrar) override;
private:
void onMethodCall(const MethodCall &call);
void onGetPlatformVersion(const MethodCall &call);
void unimplemented(const MethodCall &call);
};
#endif /* FLUTTER_PLUGIN_CLIPBOARD_PLUGIN_H */

10
aurora/include/clipboard/globals.h

@ -0,0 +1,10 @@
#ifndef FLUTTER_PLUGIN_CLIPBOARD_PLUGIN_GLOBALS_H
#define FLUTTER_PLUGIN_CLIPBOARD_PLUGIN_GLOBALS_H
#ifdef PLUGIN_IMPL
#define PLUGIN_EXPORT __attribute__((visibility("default")))
#else
#define PLUGIN_EXPORT
#endif
#endif /* FLUTTER_PLUGIN_CLIPBOARD_PLUGIN_GLOBALS_H */

8
lib/clipboard.dart

@ -0,0 +1,8 @@
import 'clipboard_platform_interface.dart';
class Clipboard {
Future<String?> getPlatformVersion() {
return ClipboardPlatform.instance.getPlatformVersion();
}
}

17
lib/clipboard_method_channel.dart

@ -0,0 +1,17 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'clipboard_platform_interface.dart';
/// An implementation of [ClipboardPlatform] that uses method channels.
class MethodChannelClipboard extends ClipboardPlatform {
/// The method channel used to interact with the native platform.
@visibleForTesting
final methodChannel = const MethodChannel('clipboard');
@override
Future<String?> getPlatformVersion() async {
final version = await methodChannel.invokeMethod<String>('getPlatformVersion');
return version;
}
}

29
lib/clipboard_platform_interface.dart

@ -0,0 +1,29 @@
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'clipboard_method_channel.dart';
abstract class ClipboardPlatform extends PlatformInterface {
/// Constructs a ClipboardPlatform.
ClipboardPlatform() : super(token: _token);
static final Object _token = Object();
static ClipboardPlatform _instance = MethodChannelClipboard();
/// The default instance of [ClipboardPlatform] to use.
///
/// Defaults to [MethodChannelClipboard].
static ClipboardPlatform get instance => _instance;
/// Platform-specific implementations should set this with their own
/// platform-specific class that extends [ClipboardPlatform] when
/// they register themselves.
static set instance(ClipboardPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
_instance = instance;
}
Future<String?> getPlatformVersion() {
throw UnimplementedError('platformVersion() has not been implemented.');
}
}

69
pubspec.yaml

@ -0,0 +1,69 @@
name: clipboard
description: "A new Flutter plugin project."
version: 0.0.1
homepage:
environment:
sdk: '>=3.2.2 <4.0.0'
flutter: '>=3.3.0'
dependencies:
flutter:
sdk: flutter
plugin_platform_interface: ^2.0.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
flutter:
# This section identifies this Flutter project as a plugin project.
# The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.)
# which should be registered in the plugin registry. This is required for
# using method channels.
# The Android 'package' specifies package in which the registered class is.
# This is required for using method channels on Android.
# The 'ffiPlugin' specifies that native code should be built and bundled.
# This is required for using `dart:ffi`.
# All these are used by the tooling to maintain consistency when
# adding or updating assets for this project.
plugin:
platforms:
aurora:
pluginClass: ClipboardPlugin
# To add assets to your plugin package, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
#
# For details regarding assets in packages, see
# https://flutter.dev/assets-and-images/#from-packages
#
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
# To add custom fonts to your plugin package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts in packages, see
# https://flutter.dev/custom-fonts/#from-packages
Loading…
Cancel
Save