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
36a49360
Commit
36a49360
authored
Jan 16, 2019
by
Luca Zuccarini
Committed by
Jonah Williams
Jan 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create an injectable factory for application packages. (#26422)
parent
d8db70af
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
29 deletions
+36
-29
application_package.dart
packages/flutter_tools/lib/src/application_package.dart
+32
-27
context_runner.dart
packages/flutter_tools/lib/src/context_runner.dart
+2
-0
resident_runner.dart
packages/flutter_tools/lib/src/resident_runner.dart
+2
-2
No files found.
packages/flutter_tools/lib/src/application_package.dart
View file @
36a49360
...
...
@@ -10,6 +10,7 @@ import 'package:xml/xml.dart' as xml;
import
'android/android_sdk.dart'
;
import
'android/gradle.dart'
;
import
'base/context.dart'
;
import
'base/file_system.dart'
;
import
'base/os.dart'
show
os
;
import
'base/process.dart'
;
...
...
@@ -20,6 +21,37 @@ import 'ios/plist_utils.dart' as plist;
import
'project.dart'
;
import
'tester/flutter_tester.dart'
;
class
ApplicationPackageFactory
{
static
ApplicationPackageFactory
get
instance
=>
context
[
ApplicationPackageFactory
];
Future
<
ApplicationPackage
>
getPackageForPlatform
(
TargetPlatform
platform
,
{
File
applicationBinary
})
async
{
switch
(
platform
)
{
case
TargetPlatform
.
android_arm
:
case
TargetPlatform
.
android_arm64
:
case
TargetPlatform
.
android_x64
:
case
TargetPlatform
.
android_x86
:
return
applicationBinary
==
null
?
await
AndroidApk
.
fromAndroidProject
((
await
FlutterProject
.
current
()).
android
)
:
AndroidApk
.
fromApk
(
applicationBinary
);
case
TargetPlatform
.
ios
:
return
applicationBinary
==
null
?
IOSApp
.
fromIosProject
((
await
FlutterProject
.
current
()).
ios
)
:
IOSApp
.
fromPrebuiltApp
(
applicationBinary
);
case
TargetPlatform
.
tester
:
return
FlutterTesterApp
.
fromCurrentDirectory
();
case
TargetPlatform
.
darwin_x64
:
case
TargetPlatform
.
linux_x64
:
case
TargetPlatform
.
windows_x64
:
case
TargetPlatform
.
fuchsia
:
return
null
;
}
assert
(
platform
!=
null
);
return
null
;
}
}
abstract
class
ApplicationPackage
{
ApplicationPackage
({
@required
this
.
id
})
:
assert
(
id
!=
null
);
...
...
@@ -277,33 +309,6 @@ class PrebuiltIOSApp extends IOSApp {
String
get
_bundlePath
=>
bundleDir
.
path
;
}
Future
<
ApplicationPackage
>
getApplicationPackageForPlatform
(
TargetPlatform
platform
,
{
File
applicationBinary
})
async
{
switch
(
platform
)
{
case
TargetPlatform
.
android_arm
:
case
TargetPlatform
.
android_arm64
:
case
TargetPlatform
.
android_x64
:
case
TargetPlatform
.
android_x86
:
return
applicationBinary
==
null
?
await
AndroidApk
.
fromAndroidProject
((
await
FlutterProject
.
current
()).
android
)
:
AndroidApk
.
fromApk
(
applicationBinary
);
case
TargetPlatform
.
ios
:
return
applicationBinary
==
null
?
IOSApp
.
fromIosProject
((
await
FlutterProject
.
current
()).
ios
)
:
IOSApp
.
fromPrebuiltApp
(
applicationBinary
);
case
TargetPlatform
.
tester
:
return
FlutterTesterApp
.
fromCurrentDirectory
();
case
TargetPlatform
.
darwin_x64
:
case
TargetPlatform
.
linux_x64
:
case
TargetPlatform
.
windows_x64
:
case
TargetPlatform
.
fuchsia
:
return
null
;
}
assert
(
platform
!=
null
);
return
null
;
}
class
ApplicationPackageStore
{
ApplicationPackageStore
({
this
.
android
,
this
.
iOS
});
...
...
packages/flutter_tools/lib/src/context_runner.dart
View file @
36a49360
...
...
@@ -7,6 +7,7 @@ import 'dart:async';
import
'android/android_sdk.dart'
;
import
'android/android_studio.dart'
;
import
'android/android_workflow.dart'
;
import
'application_package.dart'
;
import
'artifacts.dart'
;
import
'asset.dart'
;
import
'base/build.dart'
;
...
...
@@ -54,6 +55,7 @@ Future<T> runInContext<T>(
AndroidWorkflow:
()
=>
AndroidWorkflow
(),
AndroidValidator:
()
=>
AndroidValidator
(),
AndroidLicenseValidator:
()
=>
AndroidLicenseValidator
(),
ApplicationPackageFactory:
()
=>
ApplicationPackageFactory
(),
Artifacts:
()
=>
CachedArtifacts
(),
AssetBundleFactory:
()
=>
AssetBundleFactory
.
defaultInstance
,
BotDetector:
()
=>
const
BotDetector
(),
...
...
packages/flutter_tools/lib/src/resident_runner.dart
View file @
36a49360
...
...
@@ -269,7 +269,7 @@ class FlutterDevice {
printStatus
(
'Launching
${getDisplayPath(hotRunner.mainPath)}
on
${device.name}
in
$modeName
mode...'
);
final
TargetPlatform
targetPlatform
=
await
device
.
targetPlatform
;
package
=
await
getApplication
PackageForPlatform
(
package
=
await
ApplicationPackageFactory
.
instance
.
get
PackageForPlatform
(
targetPlatform
,
applicationBinary:
hotRunner
.
applicationBinary
);
...
...
@@ -319,7 +319,7 @@ class FlutterDevice {
bool
shouldBuild
=
true
,
})
async
{
final
TargetPlatform
targetPlatform
=
await
device
.
targetPlatform
;
package
=
await
getApplication
PackageForPlatform
(
package
=
await
ApplicationPackageFactory
.
instance
.
get
PackageForPlatform
(
targetPlatform
,
applicationBinary:
coldRunner
.
applicationBinary
);
...
...
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