Skip to content

Commit

Permalink
pasteboard support web.
Browse files Browse the repository at this point in the history
  • Loading branch information
boyan01 committed May 27, 2022
1 parent c4fd4b7 commit e700e38
Show file tree
Hide file tree
Showing 20 changed files with 423 additions and 140 deletions.
38 changes: 35 additions & 3 deletions packages/pasteboard/.metadata
Original file line number Diff line number Diff line change
@@ -1,10 +1,42 @@
# 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.
# This file should be version controlled.

version:
revision: 15b872266458f3299b6586565024a64530460e73
channel: master
revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
channel: stable

project_type: plugin

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
- platform: ios
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
- platform: linux
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
- platform: macos
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
- platform: web
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
- platform: windows
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268

# 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'
1 change: 1 addition & 0 deletions packages/pasteboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ A flutter plugin which could read image,files from clipboard and write files to
| Linux ||
| macOS ||
| iOS ||
| Web ||

## Getting Started

Expand Down
70 changes: 29 additions & 41 deletions packages/pasteboard/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include: package:very_good_analysis/analysis_options.yaml
include: package:flutter_lints/flutter.yaml

analyzer:
errors:
Expand All @@ -7,46 +7,34 @@ analyzer:
lines_longer_than_80_chars: ignore
avoid_function_literals_in_foreach_calls: ignore
control_flow_in_finally: true
exclude:
- 'bin/cache/**'
# the following two are relative to the stocks example and the flutter package respectively
# see https://github.com/dart-lang/sdk/issues/28463
- 'lib/i18n/messages_*.dart'
- 'lib/src/http/**'
# custom
- 'lib/generated/**'
- '**.g.dart'
# test
- 'test/**'

linter:
rules:
- prefer_const_constructors_in_immutables
- prefer_relative_imports
# - require_trailing_commas
- prefer_final_locals
- avoid_void_async
- always_put_required_named_parameters_first
- unnecessary_await_in_return
- prefer_expression_function_bodies
- avoid_field_initializers_in_const_classes
- file_names
- unnecessary_parenthesis
- prefer_void_to_null
- avoid_bool_literals_in_conditional_expressions
- avoid_returning_null_for_void
- prefer_function_declarations_over_variables
- empty_statements
- prefer_is_not_operator
- cast_nullable_to_non_nullable
- type_annotate_public_apis
- prefer_const_literals_to_create_immutables
- use_named_constants
- use_string_buffers
- unnecessary_raw_strings
- unnecessary_null_checks
- parameter_assignments
- prefer_const_declarations
- sort_unnamed_constructors_first
- use_setters_to_change_properties
- curly_braces_in_flow_control_structures
prefer_const_constructors_in_immutables: true
prefer_relative_imports: true
prefer_final_locals: true
avoid_void_async: true
always_put_required_named_parameters_first: true
unnecessary_await_in_return: true
prefer_expression_function_bodies: true
avoid_field_initializers_in_const_classes: true
file_names: true
unnecessary_parenthesis: true
prefer_void_to_null: true
avoid_bool_literals_in_conditional_expressions: true
avoid_returning_null_for_void: true
prefer_function_declarations_over_variables: true
empty_statements: true
prefer_is_not_operator: true
cast_nullable_to_non_nullable: true
type_annotate_public_apis: true
prefer_const_literals_to_create_immutables: true
use_named_constants: true
use_string_buffers: true
unnecessary_raw_strings: true
unnecessary_null_checks: true
parameter_assignments: true
prefer_const_declarations: true
sort_unnamed_constructors_first: true
use_setters_to_change_properties: true
curly_braces_in_flow_control_structures: true
25 changes: 18 additions & 7 deletions packages/pasteboard/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,24 @@ class _MyAppState extends State<MyApp> {
controller: textController,
maxLines: 10,
),
MaterialButton(
onPressed: () async {
final lines =
const LineSplitter().convert(textController.text);
await Pasteboard.writeFiles(lines);
},
child: const Text('copy'),
Row(
mainAxisSize: MainAxisSize.min,
children: [
TextButton(
onPressed: () async {
final lines =
const LineSplitter().convert(textController.text);
await Pasteboard.writeFiles(lines);
},
child: const Text('copy as files'),
),
TextButton(
onPressed: () {
Pasteboard.writeText(textController.text);
},
child: const Text('copy as text'),
),
],
),
MaterialButton(
onPressed: () async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ list(APPEND FLUTTER_PLUGIN_LIST
pasteboard
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
)

set(PLUGIN_BUNDLED_LIBRARIES)

foreach(plugin ${FLUTTER_PLUGIN_LIST})
Expand All @@ -14,3 +17,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)

foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)
35 changes: 20 additions & 15 deletions packages/pasteboard/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -67,6 +67,18 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.4"
lints:
dependency: transitive
description:
Expand All @@ -87,7 +99,7 @@ packages:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
version: "0.1.4"
meta:
dependency: transitive
description:
Expand All @@ -108,7 +120,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -120,7 +132,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -155,21 +167,14 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.8"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "0.4.9"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.2"
sdks:
dart: ">=2.14.0 <3.0.0"
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=1.20.0"
Binary file added packages/pasteboard/example/web/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions packages/pasteboard/example/web/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html>
<head>
<!--
If you are serving your web app in a path other than the root, change the
href value below to reflect the base path you are serving from.
The path provided below has to start and end with a slash "/" in order for
it to work correctly.
For more details:
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
This is a placeholder for base href that will be replaced by the value of
the `--base-href` argument provided to `flutter build`.
-->
<base href="$FLUTTER_BASE_HREF">

<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="Demonstrates how to use the pasteboard plugin.">

<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="pasteboard_example">
<link rel="apple-touch-icon" href="icons/Icon-192.png">

<!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png"/>

<title>pasteboard_example</title>
<link rel="manifest" href="manifest.json">

<script>
// The value below is injected by flutter build, do not touch.
var serviceWorkerVersion = null;
</script>
<!-- This script adds the flutter initialization JS code -->
<script src="flutter.js" defer></script>
</head>
<body>
<script>
window.addEventListener('load', function(ev) {
// Download main.dart.js
_flutter.loader.loadEntrypoint({
serviceWorker: {
serviceWorkerVersion: serviceWorkerVersion,
}
}).then(function(engineInitializer) {
return engineInitializer.initializeEngine();
}).then(function(appRunner) {
return appRunner.runApp();
});
});
</script>
</body>
</html>
35 changes: 35 additions & 0 deletions packages/pasteboard/example/web/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "pasteboard_example",
"short_name": "pasteboard_example",
"start_url": ".",
"display": "standalone",
"background_color": "#0175C2",
"theme_color": "#0175C2",
"description": "Demonstrates how to use the pasteboard plugin.",
"orientation": "portrait-primary",
"prefer_related_applications": false,
"icons": [
{
"src": "icons/Icon-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "icons/Icon-512.png",
"sizes": "512x512",
"type": "image/png"
},
{
"src": "icons/Icon-maskable-192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "icons/Icon-maskable-512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ list(APPEND FLUTTER_PLUGIN_LIST
pasteboard
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
)

set(PLUGIN_BUNDLED_LIBRARIES)

foreach(plugin ${FLUTTER_PLUGIN_LIST})
Expand All @@ -14,3 +17,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)

foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)
Loading

0 comments on commit e700e38

Please sign in to comment.