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
f09eb8af
Unverified
Commit
f09eb8af
authored
Apr 09, 2021
by
Jenn Magder
Committed by
GitHub
Apr 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate first_run and bot_detector to null safety (#80096)
parent
ff970cb1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
35 deletions
+29
-35
bot_detector.dart
packages/flutter_tools/lib/src/base/bot_detector.dart
+7
-9
downgrade.dart
packages/flutter_tools/lib/src/commands/downgrade.dart
+1
-1
upgrade.dart
packages/flutter_tools/lib/src/commands/upgrade.dart
+1
-1
globals.dart
packages/flutter_tools/lib/src/globals.dart
+0
-15
globals_null_migrated.dart
packages/flutter_tools/lib/src/globals_null_migrated.dart
+16
-0
first_run.dart
packages/flutter_tools/lib/src/reporting/first_run.dart
+2
-5
first_run_test.dart
...er_tools/test/general.shard/reporting/first_run_test.dart
+2
-4
No files found.
packages/flutter_tools/lib/src/base/bot_detector.dart
View file @
f09eb8af
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'package:meta/meta.dart'
;
...
...
@@ -15,9 +13,9 @@ import 'platform.dart';
class
BotDetector
{
BotDetector
({
@
required
HttpClientFactory
httpClientFactory
,
@
required
Platform
platform
,
@
required
PersistentToolState
persistentToolState
,
required
HttpClientFactory
httpClientFactory
,
required
Platform
platform
,
required
PersistentToolState
persistentToolState
,
})
:
_platform
=
platform
,
_azureDetector
=
AzureDetector
(
...
...
@@ -31,7 +29,7 @@ class BotDetector {
Future
<
bool
>
get
isRunningOnBot
async
{
if
(
_persistentToolState
.
isRunningOnBot
!=
null
)
{
return
_persistentToolState
.
isRunningOnBot
;
return
_persistentToolState
.
isRunningOnBot
!
;
}
if
(
// Explicitly stated to not be a bot.
...
...
@@ -86,18 +84,18 @@ class BotDetector {
@visibleForTesting
class
AzureDetector
{
AzureDetector
({
@
required
HttpClientFactory
httpClientFactory
,
required
HttpClientFactory
httpClientFactory
,
})
:
_httpClientFactory
=
httpClientFactory
;
static
const
String
_serviceUrl
=
'http://169.254.169.254/metadata/instance'
;
final
HttpClientFactory
_httpClientFactory
;
bool
_isRunningOnAzure
;
bool
?
_isRunningOnAzure
;
Future
<
bool
>
get
isRunningOnAzure
async
{
if
(
_isRunningOnAzure
!=
null
)
{
return
_isRunningOnAzure
;
return
_isRunningOnAzure
!
;
}
const
Duration
connectionTimeout
=
Duration
(
milliseconds:
250
);
const
Duration
requestTimeout
=
Duration
(
seconds:
1
);
...
...
packages/flutter_tools/lib/src/commands/downgrade.dart
View file @
f09eb8af
...
...
@@ -13,7 +13,7 @@ import '../base/logger.dart';
import
'../base/process.dart'
;
import
'../base/terminal.dart'
;
import
'../cache.dart'
;
import
'../globals.dart'
as
globals
;
import
'../globals
_null_migrated
.dart'
as
globals
;
import
'../persistent_tool_state.dart'
;
import
'../runner/flutter_command.dart'
;
import
'../version.dart'
;
...
...
packages/flutter_tools/lib/src/commands/upgrade.dart
View file @
f09eb8af
...
...
@@ -13,7 +13,7 @@ import '../base/process.dart';
import
'../base/time.dart'
;
import
'../cache.dart'
;
import
'../dart/pub.dart'
;
import
'../globals.dart'
as
globals
;
import
'../globals
_null_migrated
.dart'
as
globals
;
import
'../runner/flutter_command.dart'
;
import
'../version.dart'
;
...
...
packages/flutter_tools/lib/src/globals.dart
View file @
f09eb8af
...
...
@@ -6,10 +6,7 @@
import
'android/gradle_utils.dart'
;
import
'artifacts.dart'
;
import
'base/bot_detector.dart'
;
import
'base/context.dart'
;
import
'base/io.dart'
;
import
'base/net.dart'
;
import
'build_system/build_system.dart'
;
import
'device.dart'
;
import
'doctor.dart'
;
...
...
@@ -21,7 +18,6 @@ import 'ios/xcodeproj.dart';
import
'macos/cocoapods.dart'
;
import
'macos/cocoapods_validator.dart'
;
import
'macos/xcode.dart'
;
import
'persistent_tool_state.dart'
;
import
'project.dart'
;
import
'reporting/reporting.dart'
;
import
'runner/local_engine.dart'
;
...
...
@@ -32,7 +28,6 @@ Artifacts get artifacts => context.get<Artifacts>();
BuildSystem
get
buildSystem
=>
context
.
get
<
BuildSystem
>();
CrashReporter
get
crashReporter
=>
context
.
get
<
CrashReporter
>();
Doctor
get
doctor
=>
context
.
get
<
Doctor
>();
PersistentToolState
get
persistentToolState
=>
PersistentToolState
.
instance
;
Usage
get
flutterUsage
=>
context
.
get
<
Usage
>();
DeviceManager
get
deviceManager
=>
context
.
get
<
DeviceManager
>();
...
...
@@ -56,15 +51,5 @@ XcodeProjectInterpreter get xcodeProjectInterpreter => context.get<XcodeProjectI
XCDevice
get
xcdevice
=>
context
.
get
<
XCDevice
>();
final
BotDetector
_defaultBotDetector
=
BotDetector
(
httpClientFactory:
context
.
get
<
HttpClientFactory
>()
??
()
=>
HttpClient
(),
platform:
globals
.
platform
,
persistentToolState:
persistentToolState
,
);
BotDetector
get
botDetector
=>
context
.
get
<
BotDetector
>()
??
_defaultBotDetector
;
Future
<
bool
>
get
isRunningOnBot
=>
botDetector
.
isRunningOnBot
;
/// Gradle utils in the current [AppContext].
GradleUtils
get
gradleUtils
=>
context
.
get
<
GradleUtils
>();
packages/flutter_tools/lib/src/globals_null_migrated.dart
View file @
f09eb8af
...
...
@@ -6,6 +6,7 @@ import 'package:process/process.dart';
import
'android/android_sdk.dart'
;
import
'android/android_studio.dart'
;
import
'base/bot_detector.dart'
;
import
'base/config.dart'
;
import
'base/context.dart'
;
import
'base/error_handling_io.dart'
;
...
...
@@ -23,6 +24,7 @@ import 'base/time.dart';
import
'base/user_messages.dart'
;
import
'cache.dart'
;
import
'ios/plist_parser.dart'
;
import
'persistent_tool_state.dart'
;
import
'version.dart'
;
Cache
get
cache
=>
context
.
get
<
Cache
>()!;
...
...
@@ -35,6 +37,20 @@ AndroidStudio? get androidStudio => context.get<AndroidStudio>();
AndroidSdk
?
get
androidSdk
=>
context
.
get
<
AndroidSdk
>();
FlutterVersion
get
flutterVersion
=>
context
.
get
<
FlutterVersion
>()!;
PersistentToolState
?
get
persistentToolState
=>
PersistentToolState
.
instance
;
BotDetector
get
botDetector
=>
context
.
get
<
BotDetector
>()
??
_defaultBotDetector
;
final
BotDetector
_defaultBotDetector
=
BotDetector
(
httpClientFactory:
context
.
get
<
HttpClientFactory
>()
??
()
=>
HttpClient
(),
platform:
platform
,
persistentToolState:
persistentToolState
??
PersistentToolState
(
fileSystem:
fs
,
logger:
logger
,
platform:
platform
,
),
);
Future
<
bool
>
get
isRunningOnBot
=>
botDetector
.
isRunningOnBot
;
/// Currently active implementation of the file system.
///
/// By default it uses local disk-based implementation. Override this in tests
...
...
packages/flutter_tools/lib/src/reporting/first_run.dart
View file @
f09eb8af
...
...
@@ -2,11 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:convert/convert.dart'
;
import
'package:crypto/crypto.dart'
;
import
'package:meta/meta.dart'
;
import
'../convert.dart'
;
import
'../persistent_tool_state.dart'
;
...
...
@@ -46,7 +43,7 @@ const String _kFlutterFirstRunMessage = '''
/// need to be displayed.
class FirstRunMessenger {
FirstRunMessenger({
@
required PersistentToolState persistentToolState
required PersistentToolState persistentToolState
}) : _persistentToolState = persistentToolState;
final PersistentToolState _persistentToolState;
...
...
@@ -64,7 +61,7 @@ class FirstRunMessenger {
if (_persistentToolState.shouldRedisplayWelcomeMessage == false) {
return false;
}
final String oldHash = _persistentToolState.lastActiveLicenseTermsHash;
final String
?
oldHash = _persistentToolState.lastActiveLicenseTermsHash;
return oldHash != _currentHash;
}
...
...
packages/flutter_tools/test/general.shard/reporting/first_run_test.dart
View file @
f09eb8af
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/persistent_tool_state.dart'
;
...
...
@@ -48,7 +46,7 @@ void main() {
});
}
FirstRunMessenger
setUpFirstRunMessenger
(
{
bool
redisplayWelcomeMessage
,
bool
test
=
false
})
{
FirstRunMessenger
setUpFirstRunMessenger
(
{
bool
?
redisplayWelcomeMessage
,
bool
test
=
false
})
{
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
PersistentToolState
state
=
PersistentToolState
.
test
(
directory:
fileSystem
.
currentDirectory
,
logger:
BufferLogger
.
test
());
if
(
redisplayWelcomeMessage
!=
null
)
{
...
...
@@ -63,7 +61,7 @@ FirstRunMessenger setUpFirstRunMessenger({bool redisplayWelcomeMessage, bool tes
class
TestFirstRunMessenger
extends
FirstRunMessenger
{
TestFirstRunMessenger
(
PersistentToolState
persistentToolState
)
:
super
(
persistentToolState:
persistentToolState
);
String
overrideLicenseTerms
;
String
?
overrideLicenseTerms
;
@override
String
get
licenseTerms
=>
overrideLicenseTerms
??
super
.
licenseTerms
;
...
...
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