Skip to content

Commit 00654e5

Browse files
committed
add ui_device package
1 parent b62ac87 commit 00654e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+3729
-0
lines changed

packages/ui_device/.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
26+
/pubspec.lock
27+
**/doc/api/
28+
.dart_tool/
29+
.packages
30+
build/

packages/ui_device/.metadata

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled.
5+
6+
version:
7+
revision: 4f9d92fbbdf072a70a70d2179a9f87392b94104c
8+
channel: stable
9+
10+
project_type: plugin_ffi
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: 4f9d92fbbdf072a70a70d2179a9f87392b94104c
17+
base_revision: 4f9d92fbbdf072a70a70d2179a9f87392b94104c
18+
- platform: ios
19+
create_revision: 4f9d92fbbdf072a70a70d2179a9f87392b94104c
20+
base_revision: 4f9d92fbbdf072a70a70d2179a9f87392b94104c
21+
22+
# User provided section
23+
24+
# List of Local paths (relative to this file) that should be
25+
# ignored by the migrate tool.
26+
#
27+
# Files that are not part of the templates will be ignored by default.
28+
unmanaged_files:
29+
- 'lib/main.dart'
30+
- 'ios/Runner.xcodeproj/project.pbxproj'

packages/ui_device/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.0.1
2+
3+
* TODO: Describe initial release.

packages/ui_device/LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TODO: Add your license here.

packages/ui_device/README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# ui_device
2+
3+
A new Flutter FFI plugin project.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter
8+
[FFI plugin](https://docs.flutter.dev/development/platform-integration/c-interop),
9+
a specialized package that includes native code directly invoked with Dart FFI.
10+
11+
## Project stucture
12+
13+
This template uses the following structure:
14+
15+
* `src`: Contains the native source code, and a CmakeFile.txt file for building
16+
that source code into a dynamic library.
17+
18+
* `lib`: Contains the Dart code that defines the API of the plugin, and which
19+
calls into the native code using `dart:ffi`.
20+
21+
* platform folders (`android`, `ios`, `windows`, etc.): Contains the build files
22+
for building and bundling the native code library with the platform application.
23+
24+
## Buidling and bundling native code
25+
26+
The `pubspec.yaml` specifies FFI plugins as follows:
27+
28+
```yaml
29+
plugin:
30+
platforms:
31+
some_platform:
32+
ffiPlugin: true
33+
```
34+
35+
This configuration invokes the native build for the various target platforms
36+
and bundles the binaries in Flutter applications using these FFI plugins.
37+
38+
This can be combined with dartPluginClass, such as when FFI is used for the
39+
implementation of one platform in a federated plugin:
40+
41+
```yaml
42+
plugin:
43+
implements: some_other_plugin
44+
platforms:
45+
some_platform:
46+
dartPluginClass: SomeClass
47+
ffiPlugin: true
48+
```
49+
50+
A plugin can have both FFI and method channels:
51+
52+
```yaml
53+
plugin:
54+
platforms:
55+
some_platform:
56+
pluginClass: SomeName
57+
ffiPlugin: true
58+
```
59+
60+
The native build systems that are invoked by FFI (and method channel) plugins are:
61+
62+
* For Android: Gradle, which invokes the Android NDK for native builds.
63+
* See the documentation in android/build.gradle.
64+
* For iOS and MacOS: Xcode, via CocoaPods.
65+
* See the documentation in ios/ui_device.podspec.
66+
* See the documentation in macos/ui_device.podspec.
67+
* For Linux and Windows: CMake.
68+
* See the documentation in linux/CMakeLists.txt.
69+
* See the documentation in windows/CMakeLists.txt.
70+
71+
## Binding to native code
72+
73+
To use the native code, bindings in Dart are needed.
74+
To avoid writing these by hand, they are generated from the header file
75+
(`src/ui_device.h`) by `package:ffigen`.
76+
Regenerate the bindings by running `flutter pub run ffigen --config ffigen.yaml`.
77+
78+
## Invoking native code
79+
80+
Very short-running native functions can be directly invoked from any isolate.
81+
For example, see `sum` in `lib/ui_device.dart`.
82+
83+
Longer-running functions should be invoked on a helper isolate to avoid
84+
dropping frames in Flutter applications.
85+
For example, see `sumAsync` in `lib/ui_device.dart`.
86+
87+
## Flutter help
88+
89+
For help getting started with Flutter, view our
90+
[online documentation](https://flutter.dev/docs), which offers tutorials,
91+
samples, guidance on mobile development, and a full API reference.
92+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include: package:flutter_lints/flutter.yaml
2+
3+
# Additional information about this file can be found at
4+
# https://dart.dev/guides/language/analysis-options

packages/ui_device/example/.gitignore

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
**/doc/api/
26+
**/ios/Flutter/.last_build_id
27+
.dart_tool/
28+
.flutter-plugins
29+
.flutter-plugins-dependencies
30+
.packages
31+
.pub-cache/
32+
.pub/
33+
/build/
34+
35+
# Symbolication related
36+
app.*.symbols
37+
38+
# Obfuscation related
39+
app.*.map.json
40+
41+
# Android Studio will place build artifacts here
42+
/android/app/debug
43+
/android/app/profile
44+
/android/app/release

packages/ui_device/example/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# ui_device_example
2+
3+
Demonstrates how to use the ui_device plugin.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter application.
8+
9+
A few resources to get you started if this is your first Flutter project:
10+
11+
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
12+
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
13+
14+
For help getting started with Flutter development, view the
15+
[online documentation](https://docs.flutter.dev/), which offers tutorials,
16+
samples, guidance on mobile development, and a full API reference.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
7+
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
11+
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at
17+
# https://dart-lang.github.io/linter/lints/index.html.
18+
#
19+
# Instead of disabling a lint rule for the entire project in the
20+
# section below, it can also be suppressed for a single line of code
21+
# or a specific dart file by using the `// ignore: name_of_lint` and
22+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
23+
# producing the lint.
24+
rules:
25+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
26+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27+
28+
# Additional information about this file can be found at
29+
# https://dart.dev/guides/language/analysis-options
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
**/dgph
2+
*.mode1v3
3+
*.mode2v3
4+
*.moved-aside
5+
*.pbxuser
6+
*.perspectivev3
7+
**/*sync/
8+
.sconsign.dblite
9+
.tags*
10+
**/.vagrant/
11+
**/DerivedData/
12+
Icon?
13+
**/Pods/
14+
**/.symlinks/
15+
profile
16+
xcuserdata
17+
**/.generated/
18+
Flutter/App.framework
19+
Flutter/Flutter.framework
20+
Flutter/Flutter.podspec
21+
Flutter/Generated.xcconfig
22+
Flutter/ephemeral/
23+
Flutter/app.flx
24+
Flutter/app.zip
25+
Flutter/flutter_assets/
26+
Flutter/flutter_export_environment.sh
27+
ServiceDefinitions.json
28+
Runner/GeneratedPluginRegistrant.*
29+
30+
# Exceptions to above rules.
31+
!default.mode1v3
32+
!default.mode2v3
33+
!default.pbxuser
34+
!default.perspectivev3

0 commit comments

Comments
 (0)