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
0fc1c6f6
Unverified
Commit
0fc1c6f6
authored
Feb 07, 2020
by
Harry Terkelsen
Committed by
GitHub
Feb 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tool] Make the registrant import relative to the entrypoint (#50302)
parent
181cdec0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
build_script.dart
...ages/flutter_tools/lib/src/build_runner/build_script.dart
+9
-1
build_script_test.dart
...ls/test/general.shard/build_runner/build_script_test.dart
+15
-0
No files found.
packages/flutter_tools/lib/src/build_runner/build_script.dart
View file @
0fc1c6f6
...
...
@@ -351,13 +351,14 @@ class FlutterWebShellBuilder implements Builder {
return;
}
final AssetId outputId = buildStep.inputId.changeExtension('
_web_entrypoint
.
dart
');
final String pluginRegistrantPath = _getPluginRegistrantPath(dartEntrypointId.path);
if (hasPlugins) {
await buildStep.writeAsString(outputId, '''
import
'dart:ui'
as
ui
;
import
'package:flutter_web_plugins/flutter_web_plugins.dart'
;
import
'
generated_plugin_registrant.dart
'
;
import
'
$pluginRegistrantPath
'
;
import
"
${path.url.basename(buildStep.inputId.path)}
"
as
entrypoint
;
Future
<
void
>
main
()
async
{
...
...
@@ -384,6 +385,13 @@ Future<void> main() async {
}
}
/// Gets the relative path to the generated plugin registrant from the app
/// app entrypoint.
String _getPluginRegistrantPath(String entrypoint) {
return path.url.relative('
lib
/
generated_plugin_registrant
.
dart
',
from: path.url.dirname(entrypoint));
}
@override
Map<String, List<String>> get buildExtensions => const <String, List<String>>{
'
.
dart
': <String>['
_web_entrypoint
.
dart
'],
...
...
packages/flutter_tools/test/general.shard/build_runner/build_script_test.dart
View file @
0fc1c6f6
...
...
@@ -69,6 +69,21 @@ void main() {
verify
(
mockBuildStep
.
writeAsString
(
any
,
argThat
(
isNot
(
contains
(
'registerPlugins(webPluginRegistry)'
))))).
called
(
1
);
});
test
(
'FlutterWebShellBuilder correctly imports registrant'
,
()
async
{
final
AssetId
nestedEntrypoint
=
AssetId
(
'hello_world'
,
'lib/src/nested_main.dart'
);
when
(
mockBuildStep
.
inputId
).
thenReturn
(
nestedEntrypoint
);
const
FlutterWebShellBuilder
builder
=
FlutterWebShellBuilder
(
hasPlugins:
true
,
initializePlatform:
true
,
);
await
builder
.
build
(
mockBuildStep
);
verify
(
mockBuildStep
.
writeAsString
(
any
,
argThat
(
contains
(
"import '../generated_plugin_registrant.dart';"
)))).
called
(
1
);
});
}
class
MockBuildStep
extends
Mock
implements
BuildStep
{}
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