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
302f9f75
Unverified
Commit
302f9f75
authored
Aug 24, 2020
by
Jonah Williams
Committed by
GitHub
Aug 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] remove globals from utils (#63831)
parent
ed4a8e8d
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
104 deletions
+102
-104
utils.dart
packages/flutter_tools/lib/src/base/utils.dart
+31
-25
utils_test.dart
packages/flutter_tools/test/general.shard/utils_test.dart
+71
-79
No files found.
packages/flutter_tools/lib/src/base/utils.dart
View file @
302f9f75
...
...
@@ -9,7 +9,6 @@ import 'package:intl/intl.dart';
import
'package:meta/meta.dart'
;
import
'../convert.dart'
;
import
'../globals.dart'
as
globals
;
import
'file_system.dart'
;
/// Convert `foo_bar` to `fooBar`.
...
...
@@ -206,12 +205,16 @@ const int kMinColumnWidth = 10;
///
/// The [indent] and [hangingIndent] must be smaller than [columnWidth] when
/// added together.
String
wrapText
(
String
text
,
{
int
columnWidth
,
int
hangingIndent
,
int
indent
,
bool
shouldWrap
})
{
String
wrapText
(
String
text
,
{
@required
int
columnWidth
,
@required
bool
shouldWrap
,
int
hangingIndent
,
int
indent
,
})
{
if
(
text
==
null
||
text
.
isEmpty
)
{
return
''
;
}
indent
??=
0
;
columnWidth
??=
globals
.
outputPreferences
.
wrapColumn
;
columnWidth
-=
indent
;
assert
(
columnWidth
>=
0
);
...
...
@@ -287,34 +290,17 @@ class _AnsiRun {
/// If [outputPreferences.wrapText] is false, then the text will be returned
/// simply split at the newlines, but not wrapped. If [shouldWrap] is specified,
/// then it overrides the [outputPreferences.wrapText] setting.
List
<
String
>
_wrapTextAsLines
(
String
text
,
{
int
start
=
0
,
int
columnWidth
,
@required
bool
shouldWrap
})
{
List
<
String
>
_wrapTextAsLines
(
String
text
,
{
int
start
=
0
,
int
columnWidth
,
@required
bool
shouldWrap
,
})
{
if
(
text
==
null
||
text
.
isEmpty
)
{
return
<
String
>[
''
];
}
assert
(
columnWidth
!=
null
);
assert
(
columnWidth
>=
0
);
assert
(
start
>=
0
);
shouldWrap
??=
globals
.
outputPreferences
.
wrapText
;
/// Returns true if the code unit at [index] in [text] is a whitespace
/// character.
///
/// Based on: https://en.wikipedia.org/wiki/Whitespace_character#Unicode
bool
isWhitespace
(
_AnsiRun
run
)
{
final
int
rune
=
run
.
character
.
isNotEmpty
?
run
.
character
.
codeUnitAt
(
0
)
:
0x0
;
return
rune
>=
0x0009
&&
rune
<=
0x000D
||
rune
==
0x0020
||
rune
==
0x0085
||
rune
==
0x1680
||
rune
==
0x180E
||
rune
>=
0x2000
&&
rune
<=
0x200A
||
rune
==
0x2028
||
rune
==
0x2029
||
rune
==
0x202F
||
rune
==
0x205F
||
rune
==
0x3000
||
rune
==
0xFEFF
;
}
// Splits a string so that the resulting list has the same number of elements
// as there are visible characters in the string, but elements may include one
...
...
@@ -396,3 +382,23 @@ List<String> _wrapTextAsLines(String text, { int start = 0, int columnWidth, @re
}
return
result
;
}
/// Returns true if the code unit at [index] in [text] is a whitespace
/// character.
///
/// Based on: https://en.wikipedia.org/wiki/Whitespace_character#Unicode
bool
isWhitespace
(
_AnsiRun
run
)
{
final
int
rune
=
run
.
character
.
isNotEmpty
?
run
.
character
.
codeUnitAt
(
0
)
:
0x0
;
return
rune
>=
0x0009
&&
rune
<=
0x000D
||
rune
==
0x0020
||
rune
==
0x0085
||
rune
==
0x1680
||
rune
==
0x180E
||
rune
>=
0x2000
&&
rune
<=
0x200A
||
rune
==
0x2028
||
rune
==
0x2029
||
rune
==
0x202F
||
rune
==
0x205F
||
rune
==
0x3000
||
rune
==
0xFEFF
;
}
packages/flutter_tools/test/general.shard/utils_test.dart
View file @
302f9f75
This diff is collapsed.
Click to expand it.
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