未验证 提交 263bdc25 编写于 作者: S stuartmorgan 提交者: GitHub

Make the color panel a standalone plugin (#69)

This extracts the color panel out of the embedder frameworks and into
a standalone plugin. As part of that, adds the Dart side of the plugin
to the respository.

Since this is the first plugin extracted, it serves as a template for
the plugin structure:
- Creates a new top-level plugins/ directory, with README.
- The plugin is a subdirectory containing:
  - The Dart code as a (local) package.
  - The macOS and Linux code, in macos/ and linux/ subdirectories
    (this code is moved from the framework directories).
    - Each has build files to create the native plugin library.
  - A common/ subdirectory for channel constants shared across
    platforms.
    - The duplicate strings have been extracted from the native
      code into a shared file.

Since the Dart code is now part of the repository, this patch also
does some queued cleanup that required two-sided changes:
- Removes the unnecessary wrapping array from the color callback.
- Moves the normalization to 0-255 to the Dart side, so that it's
  not duplicated in the native code for each platform.
- Adds a callback for the case when the user closes the panel, so
  that the Dart-side understanding of whether the panel is showing
  stays accurate.

Fixes issues #9
上级 69003f34
......@@ -12,16 +12,36 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import 'package:flutter/material.dart';
import 'package:color_panel/color_panel.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
class MyApp extends StatefulWidget {
const MyApp({Key key}) : super(key: key);
@override
_AppState createState() => new _AppState();
}
class _AppState extends State<MyApp> {
static _AppState of(BuildContext context) =>
context.ancestorStateOfType(const TypeMatcher<_AppState>());
Color _primaryColor = Colors.blue;
void setPrimaryColor(Color color) {
setState(() {
_primaryColor = color;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
primaryColor: _primaryColor,
accentColor: _primaryColor,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
......@@ -45,17 +65,35 @@ class _MyHomePageState extends State<MyHomePage> {
});
}
void _changePrimaryThemeColor(BuildContext context) {
final colorPanel = ColorPanel.instance;
if (!colorPanel.showing) {
colorPanel.show((color) {
_AppState.of(context).setPrimaryColor(color);
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
actions: <Widget>[
new IconButton(
icon: new Icon(Icons.color_lens),
tooltip: 'Change theme color',
onPressed: () {
_changePrimaryThemeColor(context);
},
),
],
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
const Text(
'You have pushed the button this many times:',
),
Text(
......
......@@ -43,6 +43,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.6"
color_panel:
dependency: "direct main"
description:
path: "../plugins/color_panel"
relative: true
source: path
version: "0.0.0"
convert:
dependency: transitive
description:
......
......@@ -9,6 +9,9 @@ dependencies:
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.0
color_panel:
path: ../plugins/color_panel
dev_dependencies:
flutter_test:
sdk: flutter
......
......@@ -12,14 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
TARGETS=all clean
SUBDIRS=library example
PLUGINS=color_panel
PLUGIN_DIRS=$(patsubst %,../plugins/%/linux,$(PLUGINS))
COMPONENT_DIRS=library example $(PLUGIN_DIRS)
# Example must be built after library. This prevents accidentally building the
# two in parallel in the event that someone supplies the -j flag to `make`.
example: library
# Enforce relative ordering. This prevents accidentally building the targets
# in parallel in the event that someone supplies the -j flag to `make`.
example: library $(PLUGIN_DIRS)
$(PLUGIN_DIRS): library
$(TARGETS): $(SUBDIRS)
$(SUBDIRS):
$(TARGETS): $(COMPONENT_DIRS)
$(COMPONENT_DIRS):
$(MAKE) -C $@ $(MAKECMDGOALS)
.PHONY: $(TARGETS) $(SUBDIRS)
.PHONY: $(TARGETS) $(COMPONENT_DIRS)
......@@ -16,21 +16,34 @@ FLUTTER_EMBEDDER_LIB=flutter_embedder
FLUTTER_EXAMPLE_DIR=../../example_flutter
FLUTTER_BIN_FROM_EXAMPLE_DIR=../../flutter/bin/flutter
BIN_OUT=flutter_embedder_example
CXX=g++ -std=c++0x
PLUGINS=color_panel
FLUTTER_EMBEDDER_LIB_DIR=$(CURDIR)/../library
PLUGIN_DIRS=$(patsubst %,$(CURDIR)/../../plugins/%/linux,$(PLUGINS))
LIBRARY_DIRS=$(FLUTTER_EMBEDDER_LIB_DIR) $(PLUGIN_DIRS)
CXX=g++ -std=c++14
CXXFLAGS=-Wall -Werror $(shell pkg-config --cflags jsoncpp)
CPPFLAGS=-I$(CURDIR)/../library/include
LDFLAGS=-L$(CURDIR)/../library/ \
CPPFLAGS=$(patsubst %,-I%/include,$(LIBRARY_DIRS))
# TODO: Make the Linux example build a standalone directory with
# the binary and its dependencies (including Flutter resources),
# suitable for relocating, to more closely match the macOS example.
# Then only one -L/-rpath directory will be necessary.
LDFLAGS=$(patsubst %,-L%,$(LIBRARY_DIRS)) \
-lglfw \
$(shell pkg-config --libs jsoncpp) \
-l$(FLUTTER_EMBEDDER_LIB) \
-Wl,-rpath=$(CURDIR)/../library/
$(patsubst %,-lflutter_embedder_%,$(PLUGINS)) \
-Wl,-rpath=$(subst $(eval) ,:,$(LIBRARY_DIRS))
LIBRARIES=$(CURDIR)/../library/lib$(FLUTTER_EMBEDDER_LIB).so
LIBRARIES=$(CURDIR)/../library/lib$(FLUTTER_EMBEDDER_LIB).so \
$(wildcard $(PLUGIN_DIRS)/*.so)
SOURCES=flutter_embedder_example.cc
.PHONY: all
all: $(FLUTTER_EXAMPLE_DIR)/build $(BIN_OUT)
.PHONY: $(FLUTTER_EXAMPLE_DIR)/build
$(FLUTTER_EXAMPLE_DIR)/build:
cd $(FLUTTER_EXAMPLE_DIR); \
$(FLUTTER_BIN_FROM_EXAMPLE_DIR) build bundle
......
......@@ -13,7 +13,9 @@
// limitations under the License.
#include <cstdlib>
#include <iostream>
#include <memory>
#include <color_panel/color_panel_plugin.h>
#include <flutter_desktop_embedding/embedder.h>
int main(int argc, char **argv) {
......@@ -31,6 +33,7 @@ int main(int argc, char **argv) {
"--dart-non-checked-mode",
NULL,
};
// Start the engine.
auto window = flutter_desktop_embedding::CreateFlutterWindowInSnapshotMode(
640, 480, flutter_example_root + "/build/flutter_assets",
flutter_git_root + "/bin/cache/artifacts/engine/linux-x64/icudtl.dat",
......@@ -39,6 +42,11 @@ int main(int argc, char **argv) {
glfwTerminate();
return EXIT_FAILURE;
}
// Register any native plugins.
AddPlugin(window,
std::make_unique<flutter_desktop_embedding::ColorPanelPlugin>());
flutter_desktop_embedding::FlutterWindowLoop(window);
glfwTerminate();
return EXIT_SUCCESS;
......
......@@ -63,7 +63,8 @@ class Plugin {
protected:
// Calls a method in the Flutter engine on this Plugin's channel.
void InvokeMethod(const std::string &method, const Json::Value &arguments);
void InvokeMethod(const std::string &method,
const Json::Value &arguments = Json::Value());
private:
std::string channel_;
......
......@@ -24,13 +24,12 @@
#include <memory>
#include <string>
#include <flutter_embedder.h>
#include <flutter_desktop_embedding/channels.h>
#include <flutter_desktop_embedding/color_picker_plugin.h>
#include <flutter_desktop_embedding/file_chooser_plugin.h>
#include <flutter_desktop_embedding/input/keyboard_hook_handler.h>
#include <flutter_desktop_embedding/plugin_handler.h>
#include <flutter_desktop_embedding/text_input_plugin.h>
#include <flutter_embedder.h>
static_assert(FLUTTER_ENGINE_VERSION == 1, "");
......@@ -289,7 +288,6 @@ GLFWwindow *CreateFlutterWindow(size_t initial_width, size_t initial_height,
glfwSetWindowUserPointer(window, state);
AddPlugin(window, std::make_unique<FileChooserPlugin>());
AddPlugin(window, std::make_unique<ColorPickerPlugin>());
AddPlugin(window, std::move(input_plugin));
int width, height;
......
......@@ -13,3 +13,4 @@
// limitations under the License.
#import <FlutterEmbedderMac/FlutterEmbedderMac.h>
#import <FlutterEmbedderColorPanel/FlutterEmbedderColorPanel.h>
......@@ -21,6 +21,7 @@
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
3329FFFF20C9F5D9002E5F16 /* FlutterEmbedderColorPanel.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = 3329FFFB20C9F5AC002E5F16 /* FlutterEmbedderColorPanel.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; };
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
......@@ -31,6 +32,20 @@
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
3329FFFA20C9F5AC002E5F16 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 3329FFF520C9F5AC002E5F16 /* FlutterEmbedderColorPanel.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 332A46C120C9CFE600C30EB9;
remoteInfo = FlutterEmbedderColorPanel;
};
3329FFFD20C9F5CF002E5F16 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 3329FFF520C9F5AC002E5F16 /* FlutterEmbedderColorPanel.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 332A46C020C9CFE600C30EB9;
remoteInfo = FlutterEmbedderColorPanel;
};
33CC11032044A7620003C045 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 33CC10FE2044A7620003C045 /* FlutterEmbedderMac.xcodeproj */;
......@@ -61,6 +76,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
3329FFFF20C9F5D9002E5F16 /* FlutterEmbedderColorPanel.framework in Bundle Framework */,
33CC110F2044A8940003C045 /* FlutterEmbedderMac.framework in Bundle Framework */,
);
name = "Bundle Framework";
......@@ -69,6 +85,7 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
3329FFF520C9F5AC002E5F16 /* FlutterEmbedderColorPanel.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = FlutterEmbedderColorPanel.xcodeproj; path = ../../plugins/color_panel/macos/FlutterEmbedderColorPanel.xcodeproj; sourceTree = "<group>"; };
33CC10ED2044A3C60003C045 /* Example Embedder.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Example Embedder.app"; sourceTree = BUILT_PRODUCTS_DIR; };
33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
......@@ -92,6 +109,14 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
3329FFF620C9F5AC002E5F16 /* Products */ = {
isa = PBXGroup;
children = (
3329FFFB20C9F5AC002E5F16 /* FlutterEmbedderColorPanel.framework */,
);
name = Products;
sourceTree = "<group>";
};
33CC10E42044A3C60003C045 = {
isa = PBXGroup;
children = (
......@@ -101,6 +126,7 @@
33CC11242044D66E0003C045 /* Resources */,
33CC10EE2044A3C60003C045 /* Products */,
33CC10FE2044A7620003C045 /* FlutterEmbedderMac.xcodeproj */,
3329FFF520C9F5AC002E5F16 /* FlutterEmbedderColorPanel.xcodeproj */,
);
sourceTree = "<group>";
};
......@@ -148,6 +174,7 @@
dependencies = (
33CC11202044C79F0003C045 /* PBXTargetDependency */,
33CC11092044A86F0003C045 /* PBXTargetDependency */,
3329FFFE20C9F5CF002E5F16 /* PBXTargetDependency */,
);
name = "Example Embedder";
productName = "Example Embedder";
......@@ -187,6 +214,10 @@
productRefGroup = 33CC10EE2044A3C60003C045 /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = 3329FFF620C9F5AC002E5F16 /* Products */;
ProjectRef = 3329FFF520C9F5AC002E5F16 /* FlutterEmbedderColorPanel.xcodeproj */;
},
{
ProductGroup = 33CC10FF2044A7620003C045 /* Products */;
ProjectRef = 33CC10FE2044A7620003C045 /* FlutterEmbedderMac.xcodeproj */;
......@@ -201,6 +232,13 @@
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
3329FFFB20C9F5AC002E5F16 /* FlutterEmbedderColorPanel.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = FlutterEmbedderColorPanel.framework;
remoteRef = 3329FFFA20C9F5AC002E5F16 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
33CC11042044A7620003C045 /* FlutterEmbedderMac.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
......@@ -252,6 +290,11 @@
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
3329FFFE20C9F5CF002E5F16 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = FlutterEmbedderColorPanel;
targetProxy = 3329FFFD20C9F5CF002E5F16 /* PBXContainerItemProxy */;
};
33CC11092044A86F0003C045 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = FlutterEmbedderMac;
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
......@@ -19,6 +19,7 @@ class ExampleWindow: NSWindow {
override func awakeFromNib() {
let assets = NSURL.fileURL(withPath: "flutter_assets", relativeTo: Bundle.main.resourceURL)
flutterViewController.add(FLEColorPanelPlugin())
flutterViewController.launchEngine(
withAssetsPath: assets,
asHeadless: false,
......
......@@ -15,7 +15,6 @@
#import "FLEViewController.h"
#import <FlutterEmbedder/FlutterEmbedder.h>
#import "FLEColorPanelPlugin.h"
#import "FLEFileChooserPlugin.h"
#import "FLEReshapeListener.h"
#import "FLETextInputPlugin.h"
......@@ -386,9 +385,6 @@ static bool HeadlessOnMakeResourceCurrent(FLEViewController *controller) { retur
FLETextInputPlugin *textPlugin = [[FLETextInputPlugin alloc] init];
[self _addPlugin:textPlugin];
FLEColorPanelPlugin *colorPlugin = [[FLEColorPanelPlugin alloc] init];
[self _addPlugin:colorPlugin];
FLEFileChooserPlugin *filePlugin = [[FLEFileChooserPlugin alloc] init];
[self _addPlugin:filePlugin];
}
......
......@@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#import "FLEColorPanelPlugin.h"
#import "FLEFileChooserPlugin.h"
#import "FLEOpenGLContextHandling.h"
#import "FLEPlugin.h"
......
......@@ -39,8 +39,6 @@
C4C1FE451FD74F8300691968 /* FlutterEmbedder.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = C4C1FE431FD74F6400691968 /* FlutterEmbedder.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
E558F1C22023A34B00CA618A /* FLEFileChooserPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = E558F1C02023A34B00CA618A /* FLEFileChooserPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; };
E558F1C32023A34B00CA618A /* FLEFileChooserPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = E558F1C12023A34B00CA618A /* FLEFileChooserPlugin.m */; };
E5A3B04F201024E6003A7D68 /* FLEColorPanelPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = E5A3B04E201024E6003A7D68 /* FLEColorPanelPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; };
E5A3B051201024F5003A7D68 /* FLEColorPanelPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = E5A3B050201024F5003A7D68 /* FLEColorPanelPlugin.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
......@@ -87,8 +85,6 @@
C4C1FE431FD74F6400691968 /* FlutterEmbedder.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FlutterEmbedder.framework; path = ../../../flutter_engine_framework/macos/FlutterEmbedder.framework; sourceTree = "<group>"; };
E558F1C02023A34B00CA618A /* FLEFileChooserPlugin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FLEFileChooserPlugin.h; sourceTree = "<group>"; };
E558F1C12023A34B00CA618A /* FLEFileChooserPlugin.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FLEFileChooserPlugin.m; sourceTree = "<group>"; };
E5A3B04E201024E6003A7D68 /* FLEColorPanelPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLEColorPanelPlugin.h; sourceTree = "<group>"; };
E5A3B050201024F5003A7D68 /* FLEColorPanelPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLEColorPanelPlugin.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -110,7 +106,6 @@
1E2492371FCF50BE00DD3BBB /* FlutterEmbedderMac.h */,
1E2492451FCF536200DD3BBB /* Public */,
33D7B59820A4F54400296EFC /* FLEChannels.m */,
E5A3B050201024F5003A7D68 /* FLEColorPanelPlugin.m */,
E558F1C12023A34B00CA618A /* FLEFileChooserPlugin.m */,
AA8AE8B91FD948BA00B6FB31 /* FLETextInputModel.m */,
1E2492341FCF50BE00DD3BBB /* FLETextInputPlugin.m */,
......@@ -134,7 +129,6 @@
isa = PBXGroup;
children = (
33D7B59720A4F54400296EFC /* FLEChannels.h */,
E5A3B04E201024E6003A7D68 /* FLEColorPanelPlugin.h */,
E558F1C02023A34B00CA618A /* FLEFileChooserPlugin.h */,
1E24922F1FCF50BE00DD3BBB /* FLEOpenGLContextHandling.h */,
1E2492311FCF50BE00DD3BBB /* FLEPlugin.h */,
......@@ -169,7 +163,6 @@
1E2492391FCF50BE00DD3BBB /* FLEOpenGLContextHandling.h in Headers */,
E558F1C22023A34B00CA618A /* FLEFileChooserPlugin.h in Headers */,
1E24923D1FCF50BE00DD3BBB /* FLETextInputPlugin.h in Headers */,
E5A3B04F201024E6003A7D68 /* FLEColorPanelPlugin.h in Headers */,
1E24923C1FCF50BE00DD3BBB /* FLEReshapeListener.h in Headers */,
AA8AE8B81FD948AC00B6FB31 /* FLETextInputModel.h in Headers */,
1EEF8E071FD1F0C300DD563C /* FLEView.h in Headers */,
......@@ -273,7 +266,6 @@
E558F1C32023A34B00CA618A /* FLEFileChooserPlugin.m in Sources */,
1EEF8E081FD1F0C300DD563C /* FLEView.m in Sources */,
AA8AE8BA1FD948BA00B6FB31 /* FLETextInputModel.m in Sources */,
E5A3B051201024F5003A7D68 /* FLEColorPanelPlugin.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
# Desktop Plugins
These are optional plugins that can be included in an embedder to access OS
functionality.
## How to use this code
In the long term plugins would be managed via pub, as they are with mobile
Flutter plugins. For now, however, they are designed to be included directly
from this repository.
### Flutter
Add local package references for the plugins you want to use to your
pubspec.yaml. E.g.,:
```
dependencies:
...
color_panel:
path: relative/path/to/plugins/color_panel
```
Then import it in your dart code as you would any other package:
```dart
import 'package:color_panel/color_panel.dart';
```
### macOS
Build the Xcode project under the macos diretory for each plugin you
want to use, then link the resulting framework in your project.
When you set up your FLEViewController, before calling `launchEngine...`,
call `-addPlugin:` with an instance of each plugin you want to use. For
instance:
```objc
[myFlutterViewController addPlugin:[[FLEColorPanelPlugin alloc] init]];
```
### Linux
Run `make` in the linux directory for each plugin you want to use, then
link the resulting library in your application.
After creating your Flutter window, call AddPlugin with an instance of each
plugin you want to use. For instance:
```cpp
AddPlugin(window,
std::make_unique<flutter_desktop_embedding::ColorPanelPlugin>());
```
### Example Application
See the example application under example/ in each platform's top-level
directory to see an example of including optional plugins on that platform.
## Writing your own plugins
You can easily create local packages following the model of plugins here to
use in your own projects.
If you think they would be generally useful, feel free to submit a pull request
and they could potentially be folded into this repository. In the future, as
noted above, desktop plugins would be managed using a model like mobile
plugins where that wouldn't be necessary.
### Caveats
Currently only JSONMethodCodec is supported for desktop plugins. See
https://github.com/google/flutter-desktop-embedding/issues/67
# Copyright 2017 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
analyzer:
strong-mode: true
language:
enableSuperMixins: true
linter:
# Full list available at http://dart-lang.github.io/linter/lints/options/options.html.
rules:
- always_declare_return_types
- always_put_control_body_on_new_line
- always_put_required_named_parameters_first
- always_require_non_null_named_parameters
- annotate_overrides
- avoid_as
- avoid_bool_literals_in_conditional_expressions
- avoid_catches_without_on_clauses
- avoid_catching_errors
- avoid_classes_with_only_static_members
- avoid_empty_else
# Not compatible with VS Code yet.
# - avoid_field_initializers_in_const_classes
- avoid_function_literals_in_foreach_calls
- avoid_init_to_null
- avoid_null_checks_in_equality_operators
- avoid_positional_boolean_parameters
- avoid_private_typedef_functions
- avoid_relative_lib_imports
# This puts an unnecessary burden on API clients.
# - avoid_renaming_method_parameters
- avoid_return_types_on_setters
- avoid_returning_null
- avoid_returning_this
- avoid_single_cascade_in_expression_statements
- avoid_setters_without_getters
- avoid_slow_async_io
- avoid_types_as_parameter_names
- avoid_types_on_closure_parameters
- avoid_unused_constructor_parameters
- await_only_futures
- camel_case_types
- cancel_subscriptions
- cascade_invocations
- close_sinks
- comment_references
- constant_identifier_names
- control_flow_in_finally
- directives_ordering
- empty_catches
- empty_constructor_bodies
- empty_statements
- hash_and_equals
- implementation_imports
- invariant_booleans
- iterable_contains_unrelated_type
- join_return_with_assignment
- library_names
- library_prefixes
- list_remove_unrelated_type
- literal_only_boolean_expressions
- no_adjacent_strings_in_list
- no_duplicate_case_values
- non_constant_identifier_names
- omit_local_variable_types
- one_member_abstracts
- only_throw_errors
- overridden_fields
- package_api_docs
- package_names
- package_prefixed_library_names
- parameter_assignments
- prefer_adjacent_string_concatenation
- prefer_asserts_in_initializer_lists
- prefer_bool_in_asserts
- prefer_collection_literals
- prefer_conditional_assignment
# Disabled until bug is fixed
# https://github.com/dart-lang/linter/issues/995
# - prefer_const_constructors
- prefer_const_constructors_in_immutables
- prefer_const_declarations
- prefer_const_literals_to_create_immutables
- prefer_constructors_over_static_methods
- prefer_contains
- prefer_equal_for_default_values
# Add this when 'short' is better defined.
# - prefer_expression_function_bodies
- prefer_final_fields
- prefer_final_locals
# Seems to have false positive with await for
# - prefer_foreach
- prefer_function_declarations_over_variables