Skip to content

Commit e700e38

Browse files
committed
pasteboard support web.
1 parent c4fd4b7 commit e700e38

20 files changed

+423
-140
lines changed

packages/pasteboard/.metadata

+35-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,42 @@
11
# This file tracks properties of this Flutter project.
22
# Used by Flutter tool to assess capabilities and perform upgrades etc.
33
#
4-
# This file should be version controlled and should not be manually edited.
4+
# This file should be version controlled.
55

66
version:
7-
revision: 15b872266458f3299b6586565024a64530460e73
8-
channel: master
7+
revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
8+
channel: stable
99

1010
project_type: plugin
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
17+
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
18+
- platform: ios
19+
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
20+
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
21+
- platform: linux
22+
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
23+
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
24+
- platform: macos
25+
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
26+
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
27+
- platform: web
28+
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
29+
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
30+
- platform: windows
31+
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
32+
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
33+
34+
# User provided section
35+
36+
# List of Local paths (relative to this file) that should be
37+
# ignored by the migrate tool.
38+
#
39+
# Files that are not part of the templates will be ignored by default.
40+
unmanaged_files:
41+
- 'lib/main.dart'
42+
- 'ios/Runner.xcodeproj/project.pbxproj'

packages/pasteboard/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ A flutter plugin which could read image,files from clipboard and write files to
1010
| Linux ||
1111
| macOS ||
1212
| iOS ||
13+
| Web ||
1314

1415
## Getting Started
1516

+29-41
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include: package:very_good_analysis/analysis_options.yaml
1+
include: package:flutter_lints/flutter.yaml
22

33
analyzer:
44
errors:
@@ -7,46 +7,34 @@ analyzer:
77
lines_longer_than_80_chars: ignore
88
avoid_function_literals_in_foreach_calls: ignore
99
control_flow_in_finally: true
10-
exclude:
11-
- 'bin/cache/**'
12-
# the following two are relative to the stocks example and the flutter package respectively
13-
# see https://github.com/dart-lang/sdk/issues/28463
14-
- 'lib/i18n/messages_*.dart'
15-
- 'lib/src/http/**'
16-
# custom
17-
- 'lib/generated/**'
18-
- '**.g.dart'
19-
# test
20-
- 'test/**'
2110

2211
linter:
2312
rules:
24-
- prefer_const_constructors_in_immutables
25-
- prefer_relative_imports
26-
# - require_trailing_commas
27-
- prefer_final_locals
28-
- avoid_void_async
29-
- always_put_required_named_parameters_first
30-
- unnecessary_await_in_return
31-
- prefer_expression_function_bodies
32-
- avoid_field_initializers_in_const_classes
33-
- file_names
34-
- unnecessary_parenthesis
35-
- prefer_void_to_null
36-
- avoid_bool_literals_in_conditional_expressions
37-
- avoid_returning_null_for_void
38-
- prefer_function_declarations_over_variables
39-
- empty_statements
40-
- prefer_is_not_operator
41-
- cast_nullable_to_non_nullable
42-
- type_annotate_public_apis
43-
- prefer_const_literals_to_create_immutables
44-
- use_named_constants
45-
- use_string_buffers
46-
- unnecessary_raw_strings
47-
- unnecessary_null_checks
48-
- parameter_assignments
49-
- prefer_const_declarations
50-
- sort_unnamed_constructors_first
51-
- use_setters_to_change_properties
52-
- curly_braces_in_flow_control_structures
13+
prefer_const_constructors_in_immutables: true
14+
prefer_relative_imports: true
15+
prefer_final_locals: true
16+
avoid_void_async: true
17+
always_put_required_named_parameters_first: true
18+
unnecessary_await_in_return: true
19+
prefer_expression_function_bodies: true
20+
avoid_field_initializers_in_const_classes: true
21+
file_names: true
22+
unnecessary_parenthesis: true
23+
prefer_void_to_null: true
24+
avoid_bool_literals_in_conditional_expressions: true
25+
avoid_returning_null_for_void: true
26+
prefer_function_declarations_over_variables: true
27+
empty_statements: true
28+
prefer_is_not_operator: true
29+
cast_nullable_to_non_nullable: true
30+
type_annotate_public_apis: true
31+
prefer_const_literals_to_create_immutables: true
32+
use_named_constants: true
33+
use_string_buffers: true
34+
unnecessary_raw_strings: true
35+
unnecessary_null_checks: true
36+
parameter_assignments: true
37+
prefer_const_declarations: true
38+
sort_unnamed_constructors_first: true
39+
use_setters_to_change_properties: true
40+
curly_braces_in_flow_control_structures: true

packages/pasteboard/example/lib/main.dart

+18-7
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,24 @@ class _MyAppState extends State<MyApp> {
4646
controller: textController,
4747
maxLines: 10,
4848
),
49-
MaterialButton(
50-
onPressed: () async {
51-
final lines =
52-
const LineSplitter().convert(textController.text);
53-
await Pasteboard.writeFiles(lines);
54-
},
55-
child: const Text('copy'),
49+
Row(
50+
mainAxisSize: MainAxisSize.min,
51+
children: [
52+
TextButton(
53+
onPressed: () async {
54+
final lines =
55+
const LineSplitter().convert(textController.text);
56+
await Pasteboard.writeFiles(lines);
57+
},
58+
child: const Text('copy as files'),
59+
),
60+
TextButton(
61+
onPressed: () {
62+
Pasteboard.writeText(textController.text);
63+
},
64+
child: const Text('copy as text'),
65+
),
66+
],
5667
),
5768
MaterialButton(
5869
onPressed: () async {

packages/pasteboard/example/linux/flutter/generated_plugins.cmake

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ list(APPEND FLUTTER_PLUGIN_LIST
66
pasteboard
77
)
88

9+
list(APPEND FLUTTER_FFI_PLUGIN_LIST
10+
)
11+
912
set(PLUGIN_BUNDLED_LIBRARIES)
1013

1114
foreach(plugin ${FLUTTER_PLUGIN_LIST})
@@ -14,3 +17,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
1417
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
1518
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
1619
endforeach(plugin)
20+
21+
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
22+
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
23+
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
24+
endforeach(ffi_plugin)

packages/pasteboard/example/pubspec.lock

+20-15
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ packages:
4242
name: collection
4343
url: "https://pub.dartlang.org"
4444
source: hosted
45-
version: "1.15.0"
45+
version: "1.16.0"
4646
fake_async:
4747
dependency: transitive
4848
description:
4949
name: fake_async
5050
url: "https://pub.dartlang.org"
5151
source: hosted
52-
version: "1.2.0"
52+
version: "1.3.0"
5353
flutter:
5454
dependency: "direct main"
5555
description: flutter
@@ -67,6 +67,18 @@ packages:
6767
description: flutter
6868
source: sdk
6969
version: "0.0.0"
70+
flutter_web_plugins:
71+
dependency: transitive
72+
description: flutter
73+
source: sdk
74+
version: "0.0.0"
75+
js:
76+
dependency: transitive
77+
description:
78+
name: js
79+
url: "https://pub.dartlang.org"
80+
source: hosted
81+
version: "0.6.4"
7082
lints:
7183
dependency: transitive
7284
description:
@@ -87,7 +99,7 @@ packages:
8799
name: material_color_utilities
88100
url: "https://pub.dartlang.org"
89101
source: hosted
90-
version: "0.1.3"
102+
version: "0.1.4"
91103
meta:
92104
dependency: transitive
93105
description:
@@ -108,7 +120,7 @@ packages:
108120
name: path
109121
url: "https://pub.dartlang.org"
110122
source: hosted
111-
version: "1.8.0"
123+
version: "1.8.1"
112124
sky_engine:
113125
dependency: transitive
114126
description: flutter
@@ -120,7 +132,7 @@ packages:
120132
name: source_span
121133
url: "https://pub.dartlang.org"
122134
source: hosted
123-
version: "1.8.1"
135+
version: "1.8.2"
124136
stack_trace:
125137
dependency: transitive
126138
description:
@@ -155,21 +167,14 @@ packages:
155167
name: test_api
156168
url: "https://pub.dartlang.org"
157169
source: hosted
158-
version: "0.4.8"
159-
typed_data:
160-
dependency: transitive
161-
description:
162-
name: typed_data
163-
url: "https://pub.dartlang.org"
164-
source: hosted
165-
version: "1.3.0"
170+
version: "0.4.9"
166171
vector_math:
167172
dependency: transitive
168173
description:
169174
name: vector_math
170175
url: "https://pub.dartlang.org"
171176
source: hosted
172-
version: "2.1.1"
177+
version: "2.1.2"
173178
sdks:
174-
dart: ">=2.14.0 <3.0.0"
179+
dart: ">=2.17.0-0 <3.0.0"
175180
flutter: ">=1.20.0"
917 Bytes
Loading
Loading
Loading
Loading
Loading
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<!--
5+
If you are serving your web app in a path other than the root, change the
6+
href value below to reflect the base path you are serving from.
7+
8+
The path provided below has to start and end with a slash "/" in order for
9+
it to work correctly.
10+
11+
For more details:
12+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
13+
14+
This is a placeholder for base href that will be replaced by the value of
15+
the `--base-href` argument provided to `flutter build`.
16+
-->
17+
<base href="$FLUTTER_BASE_HREF">
18+
19+
<meta charset="UTF-8">
20+
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
21+
<meta name="description" content="Demonstrates how to use the pasteboard plugin.">
22+
23+
<!-- iOS meta tags & icons -->
24+
<meta name="apple-mobile-web-app-capable" content="yes">
25+
<meta name="apple-mobile-web-app-status-bar-style" content="black">
26+
<meta name="apple-mobile-web-app-title" content="pasteboard_example">
27+
<link rel="apple-touch-icon" href="icons/Icon-192.png">
28+
29+
<!-- Favicon -->
30+
<link rel="icon" type="image/png" href="favicon.png"/>
31+
32+
<title>pasteboard_example</title>
33+
<link rel="manifest" href="manifest.json">
34+
35+
<script>
36+
// The value below is injected by flutter build, do not touch.
37+
var serviceWorkerVersion = null;
38+
</script>
39+
<!-- This script adds the flutter initialization JS code -->
40+
<script src="flutter.js" defer></script>
41+
</head>
42+
<body>
43+
<script>
44+
window.addEventListener('load', function(ev) {
45+
// Download main.dart.js
46+
_flutter.loader.loadEntrypoint({
47+
serviceWorker: {
48+
serviceWorkerVersion: serviceWorkerVersion,
49+
}
50+
}).then(function(engineInitializer) {
51+
return engineInitializer.initializeEngine();
52+
}).then(function(appRunner) {
53+
return appRunner.runApp();
54+
});
55+
});
56+
</script>
57+
</body>
58+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "pasteboard_example",
3+
"short_name": "pasteboard_example",
4+
"start_url": ".",
5+
"display": "standalone",
6+
"background_color": "#0175C2",
7+
"theme_color": "#0175C2",
8+
"description": "Demonstrates how to use the pasteboard plugin.",
9+
"orientation": "portrait-primary",
10+
"prefer_related_applications": false,
11+
"icons": [
12+
{
13+
"src": "icons/Icon-192.png",
14+
"sizes": "192x192",
15+
"type": "image/png"
16+
},
17+
{
18+
"src": "icons/Icon-512.png",
19+
"sizes": "512x512",
20+
"type": "image/png"
21+
},
22+
{
23+
"src": "icons/Icon-maskable-192.png",
24+
"sizes": "192x192",
25+
"type": "image/png",
26+
"purpose": "maskable"
27+
},
28+
{
29+
"src": "icons/Icon-maskable-512.png",
30+
"sizes": "512x512",
31+
"type": "image/png",
32+
"purpose": "maskable"
33+
}
34+
]
35+
}

packages/pasteboard/example/windows/flutter/generated_plugins.cmake

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ list(APPEND FLUTTER_PLUGIN_LIST
66
pasteboard
77
)
88

9+
list(APPEND FLUTTER_FFI_PLUGIN_LIST
10+
)
11+
912
set(PLUGIN_BUNDLED_LIBRARIES)
1013

1114
foreach(plugin ${FLUTTER_PLUGIN_LIST})
@@ -14,3 +17,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
1417
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
1518
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
1619
endforeach(plugin)
20+
21+
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
22+
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
23+
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
24+
endforeach(ffi_plugin)

0 commit comments

Comments
 (0)