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
53c7ca7d
Unverified
Commit
53c7ca7d
authored
Nov 21, 2019
by
Amir Hardon
Committed by
GitHub
Nov 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow unknown fields in pubspec plugin section (#45303)
parent
6b66d794
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
9 deletions
+66
-9
plugins.dart
packages/flutter_tools/lib/src/plugins.dart
+19
-9
plugin_parsing_test.dart
...flutter_tools/test/general.shard/plugin_parsing_test.dart
+47
-0
No files found.
packages/flutter_tools/lib/src/plugins.dart
View file @
53c7ca7d
...
...
@@ -151,15 +151,25 @@ class Plugin {
}
static
List
<
String
>
validatePluginYaml
(
YamlMap
yaml
)
{
if
(
yaml
.
containsKey
(
'platforms'
))
{
final
int
numKeys
=
yaml
.
keys
.
toSet
().
length
;
if
(
numKeys
!=
1
)
{
return
<
String
>[
'Invalid plugin specification. There must be only one key: "platforms", found multiple:
${yaml.keys.join(',')}
'
,
];
}
else
{
return
_validateMultiPlatformYaml
(
yaml
[
'platforms'
]
as
YamlMap
);
}
final
bool
usesOldPluginFormat
=
const
<
String
>{
'androidPackage'
,
'iosPrefix'
,
'pluginClass'
,
}.
any
(
yaml
.
containsKey
);
final
bool
usesNewPluginFormat
=
yaml
.
containsKey
(
'platforms'
);
if
(
usesOldPluginFormat
&&
usesNewPluginFormat
)
{
const
String
errorMessage
=
'The flutter.plugin.platforms key cannot be used in combination with the old'
'flutter.plugin.{androidPackage,iosPrefix,pluginClass} keys.'
'See: https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin'
;
return
<
String
>[
errorMessage
];
}
if
(
usesNewPluginFormat
)
{
return
_validateMultiPlatformYaml
(
yaml
[
'platforms'
]
as
YamlMap
);
}
else
{
return
_validateLegacyYaml
(
yaml
);
}
...
...
packages/flutter_tools/test/general.shard/plugin_parsing_test.dart
View file @
53c7ca7d
...
...
@@ -78,5 +78,52 @@ void main() {
expect
(
webPlugin
.
fileName
,
'web_plugin.dart'
);
expect
(
windowsPlugin
.
pluginClass
,
'WinSamplePlugin'
);
});
test
(
'Unknown fields are allowed (allows some future compatibility)'
,
()
{
const
String
pluginYamlRaw
=
'implements: same_plugin
\n
'
// this should be ignored by the tool
'platforms:
\n
'
' android:
\n
'
' package: com.flutter.dev
\n
'
' pluginClass: ASamplePlugin
\n
'
' anUnknownField: ASamplePlugin
\n
'
// this should be ignored by the tool
' ios:
\n
'
' pluginClass: ISamplePlugin
\n
'
' linux:
\n
'
' pluginClass: LSamplePlugin
\n
'
' macos:
\n
'
' pluginClass: MSamplePlugin
\n
'
' web:
\n
'
' pluginClass: WebSamplePlugin
\n
'
' fileName: web_plugin.dart
\n
'
' windows:
\n
'
' pluginClass: WinSamplePlugin
\n
'
;
final
dynamic
pluginYaml
=
loadYaml
(
pluginYamlRaw
);
final
Plugin
plugin
=
Plugin
.
fromYaml
(
_kTestPluginName
,
_kTestPluginPath
,
pluginYaml
);
final
AndroidPlugin
androidPlugin
=
plugin
.
platforms
[
AndroidPlugin
.
kConfigKey
];
final
IOSPlugin
iosPlugin
=
plugin
.
platforms
[
IOSPlugin
.
kConfigKey
];
final
LinuxPlugin
linuxPlugin
=
plugin
.
platforms
[
LinuxPlugin
.
kConfigKey
];
final
MacOSPlugin
macOSPlugin
=
plugin
.
platforms
[
MacOSPlugin
.
kConfigKey
];
final
WebPlugin
webPlugin
=
plugin
.
platforms
[
WebPlugin
.
kConfigKey
];
final
WindowsPlugin
windowsPlugin
=
plugin
.
platforms
[
WindowsPlugin
.
kConfigKey
];
final
String
androidPluginClass
=
androidPlugin
.
pluginClass
;
final
String
iosPluginClass
=
iosPlugin
.
pluginClass
;
expect
(
iosPluginClass
,
'ISamplePlugin'
);
expect
(
androidPluginClass
,
'ASamplePlugin'
);
expect
(
iosPlugin
.
classPrefix
,
''
);
expect
(
androidPlugin
.
package
,
'com.flutter.dev'
);
expect
(
linuxPlugin
.
pluginClass
,
'LSamplePlugin'
);
expect
(
macOSPlugin
.
pluginClass
,
'MSamplePlugin'
);
expect
(
webPlugin
.
pluginClass
,
'WebSamplePlugin'
);
expect
(
webPlugin
.
fileName
,
'web_plugin.dart'
);
expect
(
windowsPlugin
.
pluginClass
,
'WinSamplePlugin'
);
});
});
}
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