Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
e43a69a9
Unverified
Commit
e43a69a9
authored
Nov 22, 2019
by
Amir Hardon
Committed by
GitHub
Nov 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow a no-op default_package key for a plugin platform (#45364)
parent
90718da0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
7 deletions
+46
-7
plugins.dart
packages/flutter_tools/lib/src/plugins.dart
+23
-7
plugin_parsing_test.dart
...flutter_tools/test/general.shard/plugin_parsing_test.dart
+23
-0
No files found.
packages/flutter_tools/lib/src/plugins.dart
View file @
e43a69a9
...
...
@@ -81,7 +81,7 @@ class Plugin {
final
Map
<
String
,
PluginPlatform
>
platforms
=
<
String
,
PluginPlatform
>{};
if
(
platformsYaml
[
AndroidPlugin
.
kConfigKey
]
!=
null
)
{
if
(
_providesImplementationForPlatform
(
platformsYaml
,
AndroidPlugin
.
kConfigKey
)
)
{
platforms
[
AndroidPlugin
.
kConfigKey
]
=
AndroidPlugin
.
fromYaml
(
name
,
platformsYaml
[
AndroidPlugin
.
kConfigKey
]
as
YamlMap
,
...
...
@@ -89,27 +89,27 @@ class Plugin {
);
}
if
(
platformsYaml
[
IOSPlugin
.
kConfigKey
]
!=
null
)
{
if
(
_providesImplementationForPlatform
(
platformsYaml
,
IOSPlugin
.
kConfigKey
)
)
{
platforms
[
IOSPlugin
.
kConfigKey
]
=
IOSPlugin
.
fromYaml
(
name
,
platformsYaml
[
IOSPlugin
.
kConfigKey
]
as
YamlMap
);
}
if
(
platformsYaml
[
LinuxPlugin
.
kConfigKey
]
!=
null
)
{
if
(
_providesImplementationForPlatform
(
platformsYaml
,
LinuxPlugin
.
kConfigKey
)
)
{
platforms
[
LinuxPlugin
.
kConfigKey
]
=
LinuxPlugin
.
fromYaml
(
name
,
platformsYaml
[
LinuxPlugin
.
kConfigKey
]
as
YamlMap
);
}
if
(
platformsYaml
[
MacOSPlugin
.
kConfigKey
]
!=
null
)
{
if
(
_providesImplementationForPlatform
(
platformsYaml
,
MacOSPlugin
.
kConfigKey
)
)
{
platforms
[
MacOSPlugin
.
kConfigKey
]
=
MacOSPlugin
.
fromYaml
(
name
,
platformsYaml
[
MacOSPlugin
.
kConfigKey
]
as
YamlMap
);
}
if
(
platformsYaml
[
WebPlugin
.
kConfigKey
]
!=
null
)
{
if
(
_providesImplementationForPlatform
(
platformsYaml
,
WebPlugin
.
kConfigKey
)
)
{
platforms
[
WebPlugin
.
kConfigKey
]
=
WebPlugin
.
fromYaml
(
name
,
platformsYaml
[
WebPlugin
.
kConfigKey
]
as
YamlMap
);
}
if
(
platformsYaml
[
WindowsPlugin
.
kConfigKey
]
!=
null
)
{
if
(
_providesImplementationForPlatform
(
platformsYaml
,
WindowsPlugin
.
kConfigKey
)
)
{
platforms
[
WindowsPlugin
.
kConfigKey
]
=
WindowsPlugin
.
fromYaml
(
name
,
platformsYaml
[
WindowsPlugin
.
kConfigKey
]
as
YamlMap
);
}
...
...
@@ -178,7 +178,13 @@ class Plugin {
static
List
<
String
>
_validateMultiPlatformYaml
(
YamlMap
yaml
)
{
bool
isInvalid
(
String
key
,
bool
Function
(
YamlMap
)
validate
)
{
final
dynamic
value
=
yaml
[
key
];
return
value
is
YamlMap
&&
!
validate
(
value
);
if
(!(
value
is
YamlMap
))
{
return
false
;
}
if
(
value
.
containsKey
(
'default_package'
))
{
return
false
;
}
return
!
validate
(
value
);
}
final
List
<
String
>
errors
=
<
String
>[];
if
(
isInvalid
(
AndroidPlugin
.
kConfigKey
,
AndroidPlugin
.
validate
))
{
...
...
@@ -213,6 +219,16 @@ class Plugin {
return
errors
;
}
static
bool
_providesImplementationForPlatform
(
YamlMap
platformsYaml
,
String
platformKey
)
{
if
(!
platformsYaml
.
containsKey
(
platformKey
))
{
return
false
;
}
if
(
platformsYaml
[
platformKey
].
containsKey
(
'default_package'
))
{
return
false
;
}
return
true
;
}
final
String
name
;
final
String
path
;
...
...
packages/flutter_tools/test/general.shard/plugin_parsing_test.dart
View file @
e43a69a9
...
...
@@ -125,5 +125,28 @@ void main() {
expect
(
webPlugin
.
fileName
,
'web_plugin.dart'
);
expect
(
windowsPlugin
.
pluginClass
,
'WinSamplePlugin'
);
});
test
(
'A default_package field is allowed'
,
()
{
const
String
pluginYamlRaw
=
'platforms:
\n
'
' android:
\n
'
' default_package: sample_package_android
\n
'
' ios:
\n
'
' default_package: sample_package_ios
\n
'
' linux:
\n
'
' default_package: sample_package_linux
\n
'
' macos:
\n
'
' default_package: sample_package_macos
\n
'
' web:
\n
'
' default_package: sample_package_web
\n
'
' windows:
\n
'
' default_package: sample_package_windows
\n
'
;
final
dynamic
pluginYaml
=
loadYaml
(
pluginYamlRaw
);
final
Plugin
plugin
=
Plugin
.
fromYaml
(
_kTestPluginName
,
_kTestPluginPath
,
pluginYaml
);
expect
(
plugin
.
platforms
,
<
String
,
PluginPlatform
>
{});
});
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment