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
60314646
Unverified
Commit
60314646
authored
Jul 23, 2020
by
Greg Spencer
Committed by
GitHub
Jul 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Find the target platform more accurately on the web. (#61587)
parent
d95f79f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
_platform_web.dart
packages/flutter/lib/src/foundation/_platform_web.dart
+17
-3
platform.dart
packages/flutter/lib/src/foundation/platform.dart
+6
-3
No files found.
packages/flutter/lib/src/foundation/_platform_web.dart
View file @
60314646
...
...
@@ -7,9 +7,9 @@ import 'platform.dart' as platform;
/// The dart:html implementation of [platform.defaultTargetPlatform].
platform
.
TargetPlatform
get
defaultTargetPlatform
{
// To get
ter a better guess at the targetPlatform we need to be able to
//
reference the window, but that won't be available until we fix the
//
platforms
configuration for Flutter.
// To get
a better guess at the targetPlatform we need to be able to reference
//
the window, but that won't be available until we fix the platforms
// configuration for Flutter.
platform
.
TargetPlatform
result
=
_browserPlatform
();
if
(
platform
.
debugDefaultTargetPlatformOverride
!=
null
)
result
=
platform
.
debugDefaultTargetPlatformOverride
!;
...
...
@@ -21,10 +21,24 @@ platform.TargetPlatform _browserPlatform() {
if
(
navigatorPlatform
.
startsWith
(
'mac'
))
{
return
platform
.
TargetPlatform
.
macOS
;
}
if
(
navigatorPlatform
.
startsWith
(
'win'
))
{
return
platform
.
TargetPlatform
.
windows
;
}
if
(
navigatorPlatform
.
contains
(
'iphone'
)
||
navigatorPlatform
.
contains
(
'ipad'
)
||
navigatorPlatform
.
contains
(
'ipod'
))
{
return
platform
.
TargetPlatform
.
iOS
;
}
if
(
navigatorPlatform
.
contains
(
'android'
))
{
return
platform
.
TargetPlatform
.
android
;
}
// Since some phones can report a window.navigator.platform as Linux, fall
// back to use CSS to disambiguate Android vs Linux desktop. If the CSS
// indicates that a device has a "fine pointer" (mouse) as the primary
// pointing device, then we'll assume desktop linux, and otherwise we'll
// assume Android.
if
(
html
.
window
.
matchMedia
(
'only screen and (pointer: fine)'
).
matches
)
{
return
platform
.
TargetPlatform
.
linux
;
}
return
platform
.
TargetPlatform
.
android
;
}
packages/flutter/lib/src/foundation/platform.dart
View file @
60314646
...
...
@@ -23,9 +23,12 @@ import '_platform_io.dart'
/// adaptations for iOS later). Tests can check iOS behavior by using the
/// platform override APIs (such as [ThemeData.platform] in the material
/// library) or by setting [debugDefaultTargetPlatformOverride].
///
/// Tests can also create specific platform tests by and adding a `variant:`
/// argument to the test and using a [TargetPlatformVariant].
//
// When adding support for a new platform (e.g. Windows Phone,
macOS), first
// create a new value on the [TargetPlatform] enum, then add a rule for
// When adding support for a new platform (e.g. Windows Phone,
Rasberry Pi),
//
first
create a new value on the [TargetPlatform] enum, then add a rule for
// selecting that platform here.
//
// It would be incorrect to make a platform that isn't supported by
...
...
@@ -42,7 +45,7 @@ enum TargetPlatform {
/// Android: <https://www.android.com/>
android
,
/// Fuchsia: <https://fuchsia.
googlesource.com/
>
/// Fuchsia: <https://fuchsia.
dev/fuchsia-src/concepts
>
fuchsia
,
/// iOS: <https://www.apple.com/ios/>
...
...
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