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
96eea437
Commit
96eea437
authored
Mar 04, 2017
by
Chris Bracken
Committed by
GitHub
Mar 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Declare locals final where not reassigned (gallery) (#8571)
parent
aa07d147
Changes
30
Show whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
73 additions
and
73 deletions
+73
-73
logic.dart
examples/flutter_gallery/lib/demo/calculator/logic.dart
+9
-9
colors_demo.dart
examples/flutter_gallery/lib/demo/colors_demo.dart
+1
-1
contacts_demo.dart
examples/flutter_gallery/lib/demo/contacts_demo.dart
+2
-2
buttons_demo.dart
examples/flutter_gallery/lib/demo/material/buttons_demo.dart
+1
-1
cards_demo.dart
examples/flutter_gallery/lib/demo/material/cards_demo.dart
+3
-3
chip_demo.dart
examples/flutter_gallery/lib/demo/material/chip_demo.dart
+1
-1
date_and_time_picker_demo.dart
..._gallery/lib/demo/material/date_and_time_picker_demo.dart
+2
-2
grid_list_demo.dart
...les/flutter_gallery/lib/demo/material/grid_list_demo.dart
+1
-1
leave_behind_demo.dart
.../flutter_gallery/lib/demo/material/leave_behind_demo.dart
+1
-1
overscroll_demo.dart
...es/flutter_gallery/lib/demo/material/overscroll_demo.dart
+2
-2
page_selector_demo.dart
...flutter_gallery/lib/demo/material/page_selector_demo.dart
+1
-1
progress_indicator_demo.dart
...er_gallery/lib/demo/material/progress_indicator_demo.dart
+1
-1
selection_controls_demo.dart
...er_gallery/lib/demo/material/selection_controls_demo.dart
+1
-1
text_field_demo.dart
...es/flutter_gallery/lib/demo/material/text_field_demo.dart
+4
-4
pesto_demo.dart
examples/flutter_gallery/lib/demo/pesto_demo.dart
+1
-1
shrine_order.dart
examples/flutter_gallery/lib/demo/shrine/shrine_order.dart
+1
-1
shrine_page.dart
examples/flutter_gallery/lib/demo/shrine/shrine_page.dart
+1
-1
demo.dart
examples/flutter_gallery/lib/gallery/demo.dart
+2
-2
syntax_highlighter.dart
examples/flutter_gallery/lib/gallery/syntax_highlighter.dart
+3
-3
updates.dart
examples/flutter_gallery/lib/gallery/updates.dart
+2
-2
smoke_test.dart
examples/flutter_gallery/test/calculator/smoke_test.dart
+4
-4
example_code_display_test.dart
examples/flutter_gallery/test/example_code_display_test.dart
+1
-1
example_code_parser_test.dart
examples/flutter_gallery/test/example_code_parser_test.dart
+3
-3
pesto_test.dart
examples/flutter_gallery/test/pesto_test.dart
+1
-1
simple_smoke_test.dart
examples/flutter_gallery/test/simple_smoke_test.dart
+2
-2
smoke_test.dart
examples/flutter_gallery/test/smoke_test.dart
+7
-7
update_test.dart
examples/flutter_gallery/test/update_test.dart
+2
-2
memory_nav_test.dart
examples/flutter_gallery/test_driver/memory_nav_test.dart
+2
-2
scroll_perf_test.dart
examples/flutter_gallery/test_driver/scroll_perf_test.dart
+2
-2
transitions_perf_test.dart
...es/flutter_gallery/test_driver/transitions_perf_test.dart
+9
-9
No files found.
examples/flutter_gallery/lib/demo/calculator/logic.dart
View file @
96eea437
...
@@ -139,7 +139,7 @@ class CalcExpression {
...
@@ -139,7 +139,7 @@ class CalcExpression {
/// in the calculator's display panel.
/// in the calculator's display panel.
@override
@override
String
toString
()
{
String
toString
()
{
StringBuffer
buffer
=
new
StringBuffer
(
''
);
final
StringBuffer
buffer
=
new
StringBuffer
(
''
);
buffer
.
writeAll
(
_list
);
buffer
.
writeAll
(
_list
);
return
buffer
.
toString
();
return
buffer
.
toString
();
}
}
...
@@ -162,12 +162,12 @@ class CalcExpression {
...
@@ -162,12 +162,12 @@ class CalcExpression {
newToken
=
new
IntToken
(
'-
$digit
'
);
newToken
=
new
IntToken
(
'-
$digit
'
);
break
;
break
;
case
ExpressionState
.
Number
:
case
ExpressionState
.
Number
:
ExpressionToken
last
=
outList
.
removeLast
();
final
ExpressionToken
last
=
outList
.
removeLast
();
newToken
=
new
IntToken
(
'
${last.stringRep}$digit
'
);
newToken
=
new
IntToken
(
'
${last.stringRep}$digit
'
);
break
;
break
;
case
ExpressionState
.
Point
:
case
ExpressionState
.
Point
:
case
ExpressionState
.
NumberWithPoint
:
case
ExpressionState
.
NumberWithPoint
:
ExpressionToken
last
=
outList
.
removeLast
();
final
ExpressionToken
last
=
outList
.
removeLast
();
newState
=
ExpressionState
.
NumberWithPoint
;
newState
=
ExpressionState
.
NumberWithPoint
;
newToken
=
new
FloatToken
(
'
${last.stringRep}$digit
'
);
newToken
=
new
FloatToken
(
'
${last.stringRep}$digit
'
);
break
;
break
;
...
@@ -191,7 +191,7 @@ class CalcExpression {
...
@@ -191,7 +191,7 @@ class CalcExpression {
break
;
break
;
case
ExpressionState
.
LeadingNeg
:
case
ExpressionState
.
LeadingNeg
:
case
ExpressionState
.
Number
:
case
ExpressionState
.
Number
:
ExpressionToken
last
=
outList
.
removeLast
();
final
ExpressionToken
last
=
outList
.
removeLast
();
newToken
=
new
FloatToken
(
last
.
stringRep
+
'.'
);
newToken
=
new
FloatToken
(
last
.
stringRep
+
'.'
);
break
;
break
;
case
ExpressionState
.
Point
:
case
ExpressionState
.
Point
:
...
@@ -282,14 +282,14 @@ class CalcExpression {
...
@@ -282,14 +282,14 @@ class CalcExpression {
// We make a copy of _list because CalcExpressions are supposed to
// We make a copy of _list because CalcExpressions are supposed to
// be immutable.
// be immutable.
List
<
ExpressionToken
>
list
=
_list
.
toList
();
final
List
<
ExpressionToken
>
list
=
_list
.
toList
();
// We obey order-of-operations by computing the sum of the 'terms',
// We obey order-of-operations by computing the sum of the 'terms',
// where a "term" is defined to be a sequence of numbers separated by
// where a "term" is defined to be a sequence of numbers separated by
// multiplcation or division symbols.
// multiplcation or division symbols.
num
currentTermValue
=
removeNextTerm
(
list
);
num
currentTermValue
=
removeNextTerm
(
list
);
while
(
list
.
isNotEmpty
)
{
while
(
list
.
isNotEmpty
)
{
OperationToken
opToken
=
list
.
removeAt
(
0
);
final
OperationToken
opToken
=
list
.
removeAt
(
0
);
num
nextTermValue
=
removeNextTerm
(
list
);
final
num
nextTermValue
=
removeNextTerm
(
list
);
switch
(
opToken
.
operation
)
{
switch
(
opToken
.
operation
)
{
case
Operation
.
Addition
:
case
Operation
.
Addition
:
currentTermValue
+=
nextTermValue
;
currentTermValue
+=
nextTermValue
;
...
@@ -317,7 +317,7 @@ class CalcExpression {
...
@@ -317,7 +317,7 @@ class CalcExpression {
num
currentValue
=
firstNumToken
.
number
;
num
currentValue
=
firstNumToken
.
number
;
while
(
list
.
isNotEmpty
)
{
while
(
list
.
isNotEmpty
)
{
bool
isDivision
=
false
;
bool
isDivision
=
false
;
OperationToken
nextOpToken
=
list
.
first
;
final
OperationToken
nextOpToken
=
list
.
first
;
switch
(
nextOpToken
.
operation
)
{
switch
(
nextOpToken
.
operation
)
{
case
Operation
.
Addition
:
case
Operation
.
Addition
:
case
Operation
.
Subtraction
:
case
Operation
.
Subtraction
:
...
@@ -332,7 +332,7 @@ class CalcExpression {
...
@@ -332,7 +332,7 @@ class CalcExpression {
list
.
removeAt
(
0
);
list
.
removeAt
(
0
);
// Remove the next number token.
// Remove the next number token.
final
NumberToken
nextNumToken
=
list
.
removeAt
(
0
);
final
NumberToken
nextNumToken
=
list
.
removeAt
(
0
);
num
nextNumber
=
nextNumToken
.
number
;
final
num
nextNumber
=
nextNumToken
.
number
;
if
(
isDivision
)
if
(
isDivision
)
currentValue
/=
nextNumber
;
currentValue
/=
nextNumber
;
else
else
...
...
examples/flutter_gallery/lib/demo/colors_demo.dart
View file @
96eea437
...
@@ -82,7 +82,7 @@ class ColorSwatchTabView extends StatelessWidget {
...
@@ -82,7 +82,7 @@ class ColorSwatchTabView extends StatelessWidget {
final
TextTheme
textTheme
=
Theme
.
of
(
context
).
textTheme
;
final
TextTheme
textTheme
=
Theme
.
of
(
context
).
textTheme
;
final
TextStyle
whiteTextStyle
=
textTheme
.
body1
.
copyWith
(
color:
Colors
.
white
);
final
TextStyle
whiteTextStyle
=
textTheme
.
body1
.
copyWith
(
color:
Colors
.
white
);
final
TextStyle
blackTextStyle
=
textTheme
.
body1
.
copyWith
(
color:
Colors
.
black
);
final
TextStyle
blackTextStyle
=
textTheme
.
body1
.
copyWith
(
color:
Colors
.
black
);
List
<
Widget
>
colorItems
=
swatch
.
colors
.
keys
.
map
((
int
index
)
{
final
List
<
Widget
>
colorItems
=
swatch
.
colors
.
keys
.
map
((
int
index
)
{
return
new
DefaultTextStyle
(
return
new
DefaultTextStyle
(
style:
index
>
swatch
.
threshold
?
whiteTextStyle
:
blackTextStyle
,
style:
index
>
swatch
.
threshold
?
whiteTextStyle
:
blackTextStyle
,
child:
new
ColorItem
(
index:
index
,
color:
swatch
.
colors
[
index
]),
child:
new
ColorItem
(
index:
index
,
color:
swatch
.
colors
[
index
]),
...
...
examples/flutter_gallery/lib/demo/contacts_demo.dart
View file @
96eea437
...
@@ -49,10 +49,10 @@ class _ContactItem extends StatelessWidget {
...
@@ -49,10 +49,10 @@ class _ContactItem extends StatelessWidget {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
final
ThemeData
themeData
=
Theme
.
of
(
context
);
final
ThemeData
themeData
=
Theme
.
of
(
context
);
List
<
Widget
>
columnChildren
=
lines
.
sublist
(
0
,
lines
.
length
-
1
).
map
((
String
line
)
=>
new
Text
(
line
)).
toList
();
final
List
<
Widget
>
columnChildren
=
lines
.
sublist
(
0
,
lines
.
length
-
1
).
map
((
String
line
)
=>
new
Text
(
line
)).
toList
();
columnChildren
.
add
(
new
Text
(
lines
.
last
,
style:
themeData
.
textTheme
.
caption
));
columnChildren
.
add
(
new
Text
(
lines
.
last
,
style:
themeData
.
textTheme
.
caption
));
List
<
Widget
>
rowChildren
=
<
Widget
>[
final
List
<
Widget
>
rowChildren
=
<
Widget
>[
new
Expanded
(
new
Expanded
(
child:
new
Column
(
child:
new
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
...
...
examples/flutter_gallery/lib/demo/material/buttons_demo.dart
View file @
96eea437
...
@@ -49,7 +49,7 @@ class ButtonsDemo extends StatefulWidget {
...
@@ -49,7 +49,7 @@ class ButtonsDemo extends StatefulWidget {
class
_ButtonsDemoState
extends
State
<
ButtonsDemo
>
{
class
_ButtonsDemoState
extends
State
<
ButtonsDemo
>
{
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
List
<
ComponentDemoTabData
>
demos
=
<
ComponentDemoTabData
>[
final
List
<
ComponentDemoTabData
>
demos
=
<
ComponentDemoTabData
>[
new
ComponentDemoTabData
(
new
ComponentDemoTabData
(
tabName:
'RAISED'
,
tabName:
'RAISED'
,
description:
_raisedText
,
description:
_raisedText
,
...
...
examples/flutter_gallery/lib/demo/material/cards_demo.dart
View file @
96eea437
...
@@ -45,9 +45,9 @@ class TravelDestinationItem extends StatelessWidget {
...
@@ -45,9 +45,9 @@ class TravelDestinationItem extends StatelessWidget {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
ThemeData
theme
=
Theme
.
of
(
context
);
final
ThemeData
theme
=
Theme
.
of
(
context
);
TextStyle
titleStyle
=
theme
.
textTheme
.
headline
.
copyWith
(
color:
Colors
.
white
);
final
TextStyle
titleStyle
=
theme
.
textTheme
.
headline
.
copyWith
(
color:
Colors
.
white
);
TextStyle
descriptionStyle
=
theme
.
textTheme
.
subhead
;
final
TextStyle
descriptionStyle
=
theme
.
textTheme
.
subhead
;
return
new
SizedBox
(
return
new
SizedBox
(
height:
height
,
height:
height
,
...
...
examples/flutter_gallery/lib/demo/material/chip_demo.dart
View file @
96eea437
...
@@ -22,7 +22,7 @@ class _ChipDemoState extends State<ChipDemo> {
...
@@ -22,7 +22,7 @@ class _ChipDemoState extends State<ChipDemo> {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
List
<
Widget
>
chips
=
<
Widget
>[
final
List
<
Widget
>
chips
=
<
Widget
>[
new
Chip
(
new
Chip
(
label:
new
Text
(
'Apple'
)
label:
new
Text
(
'Apple'
)
),
),
...
...
examples/flutter_gallery/lib/demo/material/date_and_time_picker_demo.dart
View file @
96eea437
...
@@ -61,7 +61,7 @@ class _DateTimePicker extends StatelessWidget {
...
@@ -61,7 +61,7 @@ class _DateTimePicker extends StatelessWidget {
final
ValueChanged
<
TimeOfDay
>
selectTime
;
final
ValueChanged
<
TimeOfDay
>
selectTime
;
Future
<
Null
>
_selectDate
(
BuildContext
context
)
async
{
Future
<
Null
>
_selectDate
(
BuildContext
context
)
async
{
DateTime
picked
=
await
showDatePicker
(
final
DateTime
picked
=
await
showDatePicker
(
context:
context
,
context:
context
,
initialDate:
selectedDate
,
initialDate:
selectedDate
,
firstDate:
new
DateTime
(
2015
,
8
),
firstDate:
new
DateTime
(
2015
,
8
),
...
@@ -72,7 +72,7 @@ class _DateTimePicker extends StatelessWidget {
...
@@ -72,7 +72,7 @@ class _DateTimePicker extends StatelessWidget {
}
}
Future
<
Null
>
_selectTime
(
BuildContext
context
)
async
{
Future
<
Null
>
_selectTime
(
BuildContext
context
)
async
{
TimeOfDay
picked
=
await
showTimePicker
(
final
TimeOfDay
picked
=
await
showTimePicker
(
context:
context
,
context:
context
,
initialTime:
selectedTime
initialTime:
selectedTime
);
);
...
...
examples/flutter_gallery/lib/demo/material/grid_list_demo.dart
View file @
96eea437
...
@@ -185,7 +185,7 @@ class GridDemoPhotoItem extends StatelessWidget {
...
@@ -185,7 +185,7 @@ class GridDemoPhotoItem extends StatelessWidget {
)
)
);
);
IconData
icon
=
photo
.
isFavorite
?
Icons
.
star
:
Icons
.
star_border
;
final
IconData
icon
=
photo
.
isFavorite
?
Icons
.
star
:
Icons
.
star_border
;
switch
(
tileStyle
)
{
switch
(
tileStyle
)
{
case
GridDemoTileStyle
.
imageOnly
:
case
GridDemoTileStyle
.
imageOnly
:
...
...
examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart
View file @
96eea437
...
@@ -77,7 +77,7 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
...
@@ -77,7 +77,7 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
}
}
void
handleUndo
(
LeaveBehindItem
item
)
{
void
handleUndo
(
LeaveBehindItem
item
)
{
int
insertionIndex
=
lowerBound
(
leaveBehindItems
,
item
);
final
int
insertionIndex
=
lowerBound
(
leaveBehindItems
,
item
);
setState
(()
{
setState
(()
{
leaveBehindItems
.
insert
(
insertionIndex
,
item
);
leaveBehindItems
.
insert
(
insertionIndex
,
item
);
});
});
...
...
examples/flutter_gallery/lib/demo/material/overscroll_demo.dart
View file @
96eea437
...
@@ -25,7 +25,7 @@ class OverscrollDemoState extends State<OverscrollDemo> {
...
@@ -25,7 +25,7 @@ class OverscrollDemoState extends State<OverscrollDemo> {
];
];
Future
<
Null
>
_handleRefresh
()
{
Future
<
Null
>
_handleRefresh
()
{
Completer
<
Null
>
completer
=
new
Completer
<
Null
>();
final
Completer
<
Null
>
completer
=
new
Completer
<
Null
>();
new
Timer
(
const
Duration
(
seconds:
3
),
()
{
completer
.
complete
(
null
);
});
new
Timer
(
const
Duration
(
seconds:
3
),
()
{
completer
.
complete
(
null
);
});
return
completer
.
future
.
then
((
_
)
{
return
completer
.
future
.
then
((
_
)
{
_scaffoldKey
.
currentState
?.
showSnackBar
(
new
SnackBar
(
_scaffoldKey
.
currentState
?.
showSnackBar
(
new
SnackBar
(
...
@@ -63,7 +63,7 @@ class OverscrollDemoState extends State<OverscrollDemo> {
...
@@ -63,7 +63,7 @@ class OverscrollDemoState extends State<OverscrollDemo> {
padding:
const
EdgeInsets
.
all
(
8.0
),
padding:
const
EdgeInsets
.
all
(
8.0
),
itemCount:
_items
.
length
,
itemCount:
_items
.
length
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
itemBuilder:
(
BuildContext
context
,
int
index
)
{
String
item
=
_items
[
index
];
final
String
item
=
_items
[
index
];
return
new
ListItem
(
return
new
ListItem
(
isThreeLine:
true
,
isThreeLine:
true
,
leading:
new
CircleAvatar
(
child:
new
Text
(
item
)),
leading:
new
CircleAvatar
(
child:
new
Text
(
item
)),
...
...
examples/flutter_gallery/lib/demo/material/page_selector_demo.dart
View file @
96eea437
...
@@ -10,7 +10,7 @@ class _PageSelector extends StatelessWidget {
...
@@ -10,7 +10,7 @@ class _PageSelector extends StatelessWidget {
final
List
<
IconData
>
icons
;
final
List
<
IconData
>
icons
;
void
_handleArrowButtonPress
(
BuildContext
context
,
int
delta
)
{
void
_handleArrowButtonPress
(
BuildContext
context
,
int
delta
)
{
TabController
controller
=
DefaultTabController
.
of
(
context
);
final
TabController
controller
=
DefaultTabController
.
of
(
context
);
if
(!
controller
.
indexIsChanging
)
if
(!
controller
.
indexIsChanging
)
controller
.
animateTo
(
controller
.
index
+
delta
);
controller
.
animateTo
(
controller
.
index
+
delta
);
}
}
...
...
examples/flutter_gallery/lib/demo/material/progress_indicator_demo.dart
View file @
96eea437
...
@@ -62,7 +62,7 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> with Sing
...
@@ -62,7 +62,7 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> with Sing
}
}
Widget
_buildIndicators
(
BuildContext
context
,
Widget
child
)
{
Widget
_buildIndicators
(
BuildContext
context
,
Widget
child
)
{
List
<
Widget
>
indicators
=
<
Widget
>[
final
List
<
Widget
>
indicators
=
<
Widget
>[
new
SizedBox
(
new
SizedBox
(
width:
200.0
,
width:
200.0
,
child:
new
LinearProgressIndicator
()
child:
new
LinearProgressIndicator
()
...
...
examples/flutter_gallery/lib/demo/material/selection_controls_demo.dart
View file @
96eea437
...
@@ -35,7 +35,7 @@ class SelectionControlsDemo extends StatefulWidget {
...
@@ -35,7 +35,7 @@ class SelectionControlsDemo extends StatefulWidget {
class
_SelectionControlsDemoState
extends
State
<
SelectionControlsDemo
>
{
class
_SelectionControlsDemoState
extends
State
<
SelectionControlsDemo
>
{
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
List
<
ComponentDemoTabData
>
demos
=
<
ComponentDemoTabData
>[
final
List
<
ComponentDemoTabData
>
demos
=
<
ComponentDemoTabData
>[
new
ComponentDemoTabData
(
new
ComponentDemoTabData
(
tabName:
"CHECKBOX"
,
tabName:
"CHECKBOX"
,
description:
_checkboxText
,
description:
_checkboxText
,
...
...
examples/flutter_gallery/lib/demo/material/text_field_demo.dart
View file @
96eea437
...
@@ -37,7 +37,7 @@ class TextFieldDemoState extends State<TextFieldDemo> {
...
@@ -37,7 +37,7 @@ class TextFieldDemoState extends State<TextFieldDemo> {
GlobalKey
<
FormState
>
_formKey
=
new
GlobalKey
<
FormState
>();
GlobalKey
<
FormState
>
_formKey
=
new
GlobalKey
<
FormState
>();
GlobalKey
<
FormFieldState
<
InputValue
>>
_passwordFieldKey
=
new
GlobalKey
<
FormFieldState
<
InputValue
>>();
GlobalKey
<
FormFieldState
<
InputValue
>>
_passwordFieldKey
=
new
GlobalKey
<
FormFieldState
<
InputValue
>>();
void
_handleSubmitted
()
{
void
_handleSubmitted
()
{
FormState
form
=
_formKey
.
currentState
;
final
FormState
form
=
_formKey
.
currentState
;
if
(!
form
.
validate
())
{
if
(!
form
.
validate
())
{
_autovalidate
=
true
;
// Start validating on every change.
_autovalidate
=
true
;
// Start validating on every change.
showInSnackBar
(
'Please fix the errors in red before submitting.'
);
showInSnackBar
(
'Please fix the errors in red before submitting.'
);
...
@@ -51,7 +51,7 @@ class TextFieldDemoState extends State<TextFieldDemo> {
...
@@ -51,7 +51,7 @@ class TextFieldDemoState extends State<TextFieldDemo> {
_formWasEdited
=
true
;
_formWasEdited
=
true
;
if
(
value
.
text
.
isEmpty
)
if
(
value
.
text
.
isEmpty
)
return
'Name is required.'
;
return
'Name is required.'
;
RegExp
nameExp
=
new
RegExp
(
r'^[A-za-z ]+$'
);
final
RegExp
nameExp
=
new
RegExp
(
r'^[A-za-z ]+$'
);
if
(!
nameExp
.
hasMatch
(
value
.
text
))
if
(!
nameExp
.
hasMatch
(
value
.
text
))
return
'Please enter only alphabetical characters.'
;
return
'Please enter only alphabetical characters.'
;
return
null
;
return
null
;
...
@@ -59,7 +59,7 @@ class TextFieldDemoState extends State<TextFieldDemo> {
...
@@ -59,7 +59,7 @@ class TextFieldDemoState extends State<TextFieldDemo> {
String
_validatePhoneNumber
(
InputValue
value
)
{
String
_validatePhoneNumber
(
InputValue
value
)
{
_formWasEdited
=
true
;
_formWasEdited
=
true
;
RegExp
phoneExp
=
new
RegExp
(
r'^\d\d\d-\d\d\d\-\d\d\d\d$'
);
final
RegExp
phoneExp
=
new
RegExp
(
r'^\d\d\d-\d\d\d\-\d\d\d\d$'
);
if
(!
phoneExp
.
hasMatch
(
value
.
text
))
if
(!
phoneExp
.
hasMatch
(
value
.
text
))
return
'###-###-#### - Please enter a valid phone number.'
;
return
'###-###-#### - Please enter a valid phone number.'
;
return
null
;
return
null
;
...
@@ -67,7 +67,7 @@ class TextFieldDemoState extends State<TextFieldDemo> {
...
@@ -67,7 +67,7 @@ class TextFieldDemoState extends State<TextFieldDemo> {
String
_validatePassword
(
InputValue
value
)
{
String
_validatePassword
(
InputValue
value
)
{
_formWasEdited
=
true
;
_formWasEdited
=
true
;
FormFieldState
<
InputValue
>
passwordField
=
_passwordFieldKey
.
currentState
;
final
FormFieldState
<
InputValue
>
passwordField
=
_passwordFieldKey
.
currentState
;
if
(
passwordField
.
value
==
null
||
passwordField
.
value
.
text
.
isEmpty
)
if
(
passwordField
.
value
==
null
||
passwordField
.
value
.
text
.
isEmpty
)
return
'Please choose a password.'
;
return
'Please choose a password.'
;
if
(
passwordField
.
value
.
text
!=
value
.
text
)
if
(
passwordField
.
value
.
text
!=
value
.
text
)
...
...
examples/flutter_gallery/lib/demo/pesto_demo.dart
View file @
96eea437
...
@@ -147,7 +147,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
...
@@ -147,7 +147,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
),
),
delegate:
new
SliverChildBuilderDelegate
(
delegate:
new
SliverChildBuilderDelegate
(
(
BuildContext
context
,
int
index
)
{
(
BuildContext
context
,
int
index
)
{
Recipe
recipe
=
config
.
recipes
[
index
];
final
Recipe
recipe
=
config
.
recipes
[
index
];
return
new
RecipeCard
(
return
new
RecipeCard
(
recipe:
recipe
,
recipe:
recipe
,
onTap:
()
{
showRecipePage
(
context
,
recipe
);
},
onTap:
()
{
showRecipePage
(
context
,
recipe
);
},
...
...
examples/flutter_gallery/lib/demo/shrine/shrine_order.dart
View file @
96eea437
...
@@ -149,7 +149,7 @@ class _OrderPageState extends State<OrderPage> {
...
@@ -149,7 +149,7 @@ class _OrderPageState extends State<OrderPage> {
}
}
void
updateOrder
({
int
quantity
,
bool
inCart
})
{
void
updateOrder
({
int
quantity
,
bool
inCart
})
{
Order
newOrder
=
currentOrder
.
copyWith
(
quantity:
quantity
,
inCart:
inCart
);
final
Order
newOrder
=
currentOrder
.
copyWith
(
quantity:
quantity
,
inCart:
inCart
);
if
(
currentOrder
!=
newOrder
)
{
if
(
currentOrder
!=
newOrder
)
{
setState
(()
{
setState
(()
{
config
.
shoppingCart
[
newOrder
.
product
]
=
newOrder
;
config
.
shoppingCart
[
newOrder
.
product
]
=
newOrder
;
...
...
examples/flutter_gallery/lib/demo/shrine/shrine_page.dart
View file @
96eea437
...
@@ -41,7 +41,7 @@ class ShrinePageState extends State<ShrinePage> {
...
@@ -41,7 +41,7 @@ class ShrinePageState extends State<ShrinePage> {
int
_appBarElevation
=
0
;
int
_appBarElevation
=
0
;
bool
_handleScrollNotification
(
ScrollNotification
notification
)
{
bool
_handleScrollNotification
(
ScrollNotification
notification
)
{
int
elevation
=
notification
.
metrics
.
extentBefore
<=
0.0
?
0
:
1
;
final
int
elevation
=
notification
.
metrics
.
extentBefore
<=
0.0
?
0
:
1
;
if
(
elevation
!=
_appBarElevation
)
{
if
(
elevation
!=
_appBarElevation
)
{
setState
(()
{
setState
(()
{
_appBarElevation
=
elevation
;
_appBarElevation
=
elevation
;
...
...
examples/flutter_gallery/lib/gallery/demo.dart
View file @
96eea437
...
@@ -24,7 +24,7 @@ class ComponentDemoTabData {
...
@@ -24,7 +24,7 @@ class ComponentDemoTabData {
bool
operator
==(
Object
other
)
{
bool
operator
==(
Object
other
)
{
if
(
other
.
runtimeType
!=
runtimeType
)
if
(
other
.
runtimeType
!=
runtimeType
)
return
false
;
return
false
;
ComponentDemoTabData
typedOther
=
other
;
final
ComponentDemoTabData
typedOther
=
other
;
return
typedOther
.
tabName
==
tabName
&&
typedOther
.
description
==
description
;
return
typedOther
.
tabName
==
tabName
&&
typedOther
.
description
==
description
;
}
}
...
@@ -42,7 +42,7 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
...
@@ -42,7 +42,7 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
final
String
title
;
final
String
title
;
void
_showExampleCode
(
BuildContext
context
)
{
void
_showExampleCode
(
BuildContext
context
)
{
String
tag
=
demos
[
DefaultTabController
.
of
(
context
).
index
].
exampleCodeTag
;
final
String
tag
=
demos
[
DefaultTabController
.
of
(
context
).
index
].
exampleCodeTag
;
if
(
tag
!=
null
)
{
if
(
tag
!=
null
)
{
Navigator
.
push
(
context
,
new
MaterialPageRoute
<
FullScreenCodeDialog
>(
Navigator
.
push
(
context
,
new
MaterialPageRoute
<
FullScreenCodeDialog
>(
builder:
(
BuildContext
context
)
=>
new
FullScreenCodeDialog
(
exampleCodeTag:
tag
)
builder:
(
BuildContext
context
)
=>
new
FullScreenCodeDialog
(
exampleCodeTag:
tag
)
...
...
examples/flutter_gallery/lib/gallery/syntax_highlighter.dart
View file @
96eea437
...
@@ -93,7 +93,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
...
@@ -93,7 +93,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
if
(
_generateSpans
())
{
if
(
_generateSpans
())
{
// Successfully parsed the code
// Successfully parsed the code
List
<
TextSpan
>
formattedText
=
<
TextSpan
>[];
final
List
<
TextSpan
>
formattedText
=
<
TextSpan
>[];
int
currentPosition
=
0
;
int
currentPosition
=
0
;
for
(
_HighlightSpan
span
in
_spans
)
{
for
(
_HighlightSpan
span
in
_spans
)
{
...
@@ -134,7 +134,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
...
@@ -134,7 +134,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
// Line comments
// Line comments
if
(
_scanner
.
scan
(
"//"
))
{
if
(
_scanner
.
scan
(
"//"
))
{
int
startComment
=
_scanner
.
lastMatch
.
start
;
final
int
startComment
=
_scanner
.
lastMatch
.
start
;
bool
eof
=
false
;
bool
eof
=
false
;
int
endComment
;
int
endComment
;
...
@@ -310,7 +310,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
...
@@ -310,7 +310,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
bool
_firstLetterIsUpperCase
(
String
str
)
{
bool
_firstLetterIsUpperCase
(
String
str
)
{
if
(
str
.
isNotEmpty
)
{
if
(
str
.
isNotEmpty
)
{
String
first
=
str
.
substring
(
0
,
1
);
final
String
first
=
str
.
substring
(
0
,
1
);
return
first
==
first
.
toUpperCase
();
return
first
==
first
.
toUpperCase
();
}
}
return
false
;
return
false
;
...
...
examples/flutter_gallery/lib/gallery/updates.dart
View file @
96eea437
...
@@ -37,9 +37,9 @@ class UpdaterState extends State<Updater> {
...
@@ -37,9 +37,9 @@ class UpdaterState extends State<Updater> {
}
}
_lastUpdateCheck
=
new
DateTime
.
now
();
_lastUpdateCheck
=
new
DateTime
.
now
();
String
updateUrl
=
await
config
.
updateUrlFetcher
();
final
String
updateUrl
=
await
config
.
updateUrlFetcher
();
if
(
updateUrl
!=
null
)
{
if
(
updateUrl
!=
null
)
{
bool
wantsUpdate
=
await
showDialog
(
context:
context
,
child:
_buildDialog
());
final
bool
wantsUpdate
=
await
showDialog
(
context:
context
,
child:
_buildDialog
());
if
(
wantsUpdate
!=
null
&&
wantsUpdate
)
if
(
wantsUpdate
!=
null
&&
wantsUpdate
)
UrlLauncher
.
launch
(
updateUrl
);
UrlLauncher
.
launch
(
updateUrl
);
}
}
...
...
examples/flutter_gallery/test/calculator/smoke_test.dart
View file @
96eea437
...
@@ -7,7 +7,7 @@ import 'package:flutter_gallery/demo/calculator_demo.dart';
...
@@ -7,7 +7,7 @@ import 'package:flutter_gallery/demo/calculator_demo.dart';
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
void
main
(
)
{
TestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
();
final
TestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
();
if
(
binding
is
LiveTestWidgetsFlutterBinding
)
if
(
binding
is
LiveTestWidgetsFlutterBinding
)
binding
.
allowAllFrames
=
true
;
binding
.
allowAllFrames
=
true
;
...
@@ -16,10 +16,10 @@ void main() {
...
@@ -16,10 +16,10 @@ void main() {
testWidgets
(
'Flutter calculator app smoke test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Flutter calculator app smoke test'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
new
CalculatorDemo
());
await
tester
.
pumpWidget
(
new
CalculatorDemo
());
Finder
oneButton
=
find
.
widgetWithText
(
InkResponse
,
'1'
);
final
Finder
oneButton
=
find
.
widgetWithText
(
InkResponse
,
'1'
);
expect
(
oneButton
,
findsOneWidget
);
expect
(
oneButton
,
findsOneWidget
);
Finder
twoButton
=
find
.
widgetWithText
(
InkResponse
,
'2'
);
final
Finder
twoButton
=
find
.
widgetWithText
(
InkResponse
,
'2'
);
expect
(
twoButton
,
findsOneWidget
);
expect
(
twoButton
,
findsOneWidget
);
await
tester
.
tap
(
oneButton
);
await
tester
.
tap
(
oneButton
);
...
@@ -28,7 +28,7 @@ void main() {
...
@@ -28,7 +28,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// Wait until it has finished.
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// Wait until it has finished.
Finder
display
=
find
.
widgetWithText
(
Expanded
,
'12'
);
final
Finder
display
=
find
.
widgetWithText
(
Expanded
,
'12'
);
expect
(
display
,
findsOneWidget
);
expect
(
display
,
findsOneWidget
);
});
});
}
}
examples/flutter_gallery/test/example_code_display_test.dart
View file @
96eea437
...
@@ -7,7 +7,7 @@ import 'package:flutter_gallery/gallery/app.dart';
...
@@ -7,7 +7,7 @@ import 'package:flutter_gallery/gallery/app.dart';
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
void
main
(
)
{
TestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
();
final
TestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
();
if
(
binding
is
LiveTestWidgetsFlutterBinding
)
if
(
binding
is
LiveTestWidgetsFlutterBinding
)
binding
.
allowAllFrames
=
true
;
binding
.
allowAllFrames
=
true
;
...
...
examples/flutter_gallery/test/example_code_parser_test.dart
View file @
96eea437
...
@@ -11,12 +11,12 @@ import 'package:test/test.dart';
...
@@ -11,12 +11,12 @@ import 'package:test/test.dart';
void
main
(
)
{
void
main
(
)
{
test
(
'Flutter gallery example code parser test'
,
()
async
{
test
(
'Flutter gallery example code parser test'
,
()
async
{
TestAssetBundle
bundle
=
new
TestAssetBundle
();
final
TestAssetBundle
bundle
=
new
TestAssetBundle
();
String
codeSnippet0
=
await
getExampleCode
(
'test_0'
,
bundle
);
final
String
codeSnippet0
=
await
getExampleCode
(
'test_0'
,
bundle
);
expect
(
codeSnippet0
,
'test 0 0
\n
test 0 1'
);
expect
(
codeSnippet0
,
'test 0 0
\n
test 0 1'
);
String
codeSnippet1
=
await
getExampleCode
(
'test_1'
,
bundle
);
final
String
codeSnippet1
=
await
getExampleCode
(
'test_1'
,
bundle
);
expect
(
codeSnippet1
,
'test 1 0
\n
test 1 1'
);
expect
(
codeSnippet1
,
'test 1 0
\n
test 1 1'
);
});
});
}
}
...
...
examples/flutter_gallery/test/pesto_test.dart
View file @
96eea437
...
@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
...
@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
import
'package:flutter_gallery/gallery/app.dart'
;
import
'package:flutter_gallery/gallery/app.dart'
;
void
main
(
)
{
void
main
(
)
{
TestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
();
final
TestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
();
if
(
binding
is
LiveTestWidgetsFlutterBinding
)
if
(
binding
is
LiveTestWidgetsFlutterBinding
)
binding
.
allowAllFrames
=
true
;
binding
.
allowAllFrames
=
true
;
...
...
examples/flutter_gallery/test/simple_smoke_test.dart
View file @
96eea437
...
@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
...
@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
import
'package:flutter_gallery/main.dart'
as
flutter_gallery_main
;
import
'package:flutter_gallery/main.dart'
as
flutter_gallery_main
;
void
main
(
)
{
void
main
(
)
{
TestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
();
final
TestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
();
if
(
binding
is
LiveTestWidgetsFlutterBinding
)
if
(
binding
is
LiveTestWidgetsFlutterBinding
)
binding
.
allowAllFrames
=
true
;
binding
.
allowAllFrames
=
true
;
...
@@ -16,7 +16,7 @@ void main() {
...
@@ -16,7 +16,7 @@ void main() {
await
tester
.
pump
();
// see https://github.com/flutter/flutter/issues/1865
await
tester
.
pump
();
// see https://github.com/flutter/flutter/issues/1865
await
tester
.
pump
();
// triggers a frame
await
tester
.
pump
();
// triggers a frame
Finder
finder
=
find
.
byWidgetPredicate
((
Widget
widget
)
{
final
Finder
finder
=
find
.
byWidgetPredicate
((
Widget
widget
)
{
return
widget
is
Tooltip
&&
widget
.
message
==
'Open navigation menu'
;
return
widget
is
Tooltip
&&
widget
.
message
==
'Open navigation menu'
;
});
});
expect
(
finder
,
findsOneWidget
);
expect
(
finder
,
findsOneWidget
);
...
...
examples/flutter_gallery/test/smoke_test.dart
View file @
96eea437
...
@@ -32,16 +32,16 @@ void reportToStringError(String name, String route, int lineNumber, List<String>
...
@@ -32,16 +32,16 @@ void reportToStringError(String name, String route, int lineNumber, List<String>
// If you're on line 12, then it has index 11.
// If you're on line 12, then it has index 11.
// If you want 1 line before and 1 line after, then you want lines with index 10, 11, and 12.
// If you want 1 line before and 1 line after, then you want lines with index 10, 11, and 12.
// That's (lineNumber-1)-margin .. (lineNumber-1)+margin, or lineNumber-(margin+1) .. lineNumber+(margin-1)
// That's (lineNumber-1)-margin .. (lineNumber-1)+margin, or lineNumber-(margin+1) .. lineNumber+(margin-1)
int
margin
=
5
;
final
int
margin
=
5
;
int
firstLine
=
math
.
max
(
0
,
lineNumber
-
margin
);
final
int
firstLine
=
math
.
max
(
0
,
lineNumber
-
margin
);
int
lastLine
=
math
.
min
(
lines
.
length
,
lineNumber
+
margin
);
final
int
lastLine
=
math
.
min
(
lines
.
length
,
lineNumber
+
margin
);
print
(
'
$name
:
$route
: line
$lineNumber
of
${lines.length}
:
$message
; nearby lines were:
\n
${lines.sublist(firstLine, lastLine).join("\n ")}
'
);
print
(
'
$name
:
$route
: line
$lineNumber
of
${lines.length}
:
$message
; nearby lines were:
\n
${lines.sublist(firstLine, lastLine).join("\n ")}
'
);
errors
+=
1
;
errors
+=
1
;
}
}
void
verifyToStringOutput
(
String
name
,
String
route
,
String
testString
)
{
void
verifyToStringOutput
(
String
name
,
String
route
,
String
testString
)
{
int
lineNumber
=
0
;
int
lineNumber
=
0
;
List
<
String
>
lines
=
testString
.
split
(
'
\n
'
);
final
List
<
String
>
lines
=
testString
.
split
(
'
\n
'
);
if
(!
testString
.
endsWith
(
'
\n
'
))
if
(!
testString
.
endsWith
(
'
\n
'
))
reportToStringError
(
name
,
route
,
lines
.
length
,
lines
,
'does not end with a line feed'
);
reportToStringError
(
name
,
route
,
lines
.
length
,
lines
,
'does not end with a line feed'
);
for
(
String
line
in
lines
)
{
for
(
String
line
in
lines
)
{
...
@@ -103,7 +103,7 @@ Future<Null> smokeDemo(WidgetTester tester, String routeName) async {
...
@@ -103,7 +103,7 @@ Future<Null> smokeDemo(WidgetTester tester, String routeName) async {
await
tester
.
pump
(
const
Duration
(
milliseconds:
400
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
400
));
// Go back
// Go back
Finder
backButton
=
find
.
byTooltip
(
'Back'
);
final
Finder
backButton
=
find
.
byTooltip
(
'Back'
);
expect
(
backButton
,
findsOneWidget
);
expect
(
backButton
,
findsOneWidget
);
await
tester
.
tap
(
backButton
);
await
tester
.
tap
(
backButton
);
await
tester
.
pump
();
// Start the pop "back" operation.
await
tester
.
pump
();
// Start the pop "back" operation.
...
@@ -125,7 +125,7 @@ Future<Null> runSmokeTest(WidgetTester tester) async {
...
@@ -125,7 +125,7 @@ Future<Null> runSmokeTest(WidgetTester tester) async {
expect
(
find
.
text
(
kCaption
),
findsOneWidget
);
expect
(
find
.
text
(
kCaption
),
findsOneWidget
);
for
(
String
routeName
in
routeNames
)
{
for
(
String
routeName
in
routeNames
)
{
Finder
finder
=
findGalleryItemByRouteName
(
tester
,
routeName
);
final
Finder
finder
=
findGalleryItemByRouteName
(
tester
,
routeName
);
Scrollable
.
ensureVisible
(
tester
.
element
(
finder
),
alignment:
0.5
);
Scrollable
.
ensureVisible
(
tester
.
element
(
finder
),
alignment:
0.5
);
await
tester
.
pump
();
await
tester
.
pump
();
await
tester
.
pumpUntilNoTransientCallbacks
();
await
tester
.
pumpUntilNoTransientCallbacks
();
...
@@ -135,7 +135,7 @@ Future<Null> runSmokeTest(WidgetTester tester) async {
...
@@ -135,7 +135,7 @@ Future<Null> runSmokeTest(WidgetTester tester) async {
expect
(
errors
,
0
);
expect
(
errors
,
0
);
Finder
navigationMenuButton
=
find
.
byTooltip
(
'Open navigation menu'
);
final
Finder
navigationMenuButton
=
find
.
byTooltip
(
'Open navigation menu'
);
expect
(
navigationMenuButton
,
findsOneWidget
);
expect
(
navigationMenuButton
,
findsOneWidget
);
await
tester
.
tap
(
navigationMenuButton
);
await
tester
.
tap
(
navigationMenuButton
);
await
tester
.
pump
();
// Start opening drawer.
await
tester
.
pump
();
// Start opening drawer.
...
...
examples/flutter_gallery/test/update_test.dart
View file @
96eea437
...
@@ -11,7 +11,7 @@ Future<String> mockUpdateUrlFetcher() {
...
@@ -11,7 +11,7 @@ Future<String> mockUpdateUrlFetcher() {
}
}
void
main
(
)
{
void
main
(
)
{
TestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
();
final
TestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
();
if
(
binding
is
LiveTestWidgetsFlutterBinding
)
binding
.
allowAllFrames
=
true
;
if
(
binding
is
LiveTestWidgetsFlutterBinding
)
binding
.
allowAllFrames
=
true
;
// Regression test for https://github.com/flutter/flutter/pull/5168
// Regression test for https://github.com/flutter/flutter/pull/5168
...
@@ -29,7 +29,7 @@ void main() {
...
@@ -29,7 +29,7 @@ void main() {
await
tester
.
pump
();
// Launch shrine
await
tester
.
pump
();
// Launch shrine
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// transition is complete
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// transition is complete
Finder
backButton
=
find
.
byTooltip
(
'Back'
);
final
Finder
backButton
=
find
.
byTooltip
(
'Back'
);
expect
(
backButton
,
findsOneWidget
);
expect
(
backButton
,
findsOneWidget
);
await
tester
.
tap
(
backButton
);
await
tester
.
tap
(
backButton
);
await
tester
.
pump
();
// Start the pop "back" operation.
await
tester
.
pump
();
// Start the pop "back" operation.
...
...
examples/flutter_gallery/test_driver/memory_nav_test.dart
View file @
96eea437
...
@@ -18,9 +18,9 @@ void main() {
...
@@ -18,9 +18,9 @@ void main() {
});
});
test
(
'navigation'
,
()
async
{
test
(
'navigation'
,
()
async
{
Completer
<
Null
>
completer
=
new
Completer
<
Null
>();
final
Completer
<
Null
>
completer
=
new
Completer
<
Null
>();
bool
scroll
=
true
;
bool
scroll
=
true
;
SerializableFinder
menuItem
=
find
.
text
(
'Text fields'
);
final
SerializableFinder
menuItem
=
find
.
text
(
'Text fields'
);
driver
.
waitFor
(
menuItem
).
then
<
Null
>((
Null
value
)
async
{
driver
.
waitFor
(
menuItem
).
then
<
Null
>((
Null
value
)
async
{
scroll
=
false
;
scroll
=
false
;
await
new
Future
<
Null
>.
delayed
(
kWaitBetweenActions
);
await
new
Future
<
Null
>.
delayed
(
kWaitBetweenActions
);
...
...
examples/flutter_gallery/test_driver/scroll_perf_test.dart
View file @
96eea437
...
@@ -21,9 +21,9 @@ void main() {
...
@@ -21,9 +21,9 @@ void main() {
});
});
test
(
'measure'
,
()
async
{
test
(
'measure'
,
()
async
{
Timeline
timeline
=
await
driver
.
traceAction
(()
async
{
final
Timeline
timeline
=
await
driver
.
traceAction
(()
async
{
// Find the scrollable stock list
// Find the scrollable stock list
SerializableFinder
stockList
=
find
.
byValueKey
(
'Gallery List'
);
final
SerializableFinder
stockList
=
find
.
byValueKey
(
'Gallery List'
);
expect
(
stockList
,
isNotNull
);
expect
(
stockList
,
isNotNull
);
await
driver
.
tap
(
find
.
text
(
'Demos'
));
await
driver
.
tap
(
find
.
text
(
'Demos'
));
...
...
examples/flutter_gallery/test_driver/transitions_perf_test.dart
View file @
96eea437
...
@@ -91,7 +91,7 @@ Future<Null> saveDurationsHistogram(List<Map<String, dynamic>> events, String ou
...
@@ -91,7 +91,7 @@ Future<Null> saveDurationsHistogram(List<Map<String, dynamic>> events, String ou
// Verify that the durations data is valid.
// Verify that the durations data is valid.
if
(
durations
.
keys
.
isEmpty
)
if
(
durations
.
keys
.
isEmpty
)
throw
'no "Start Transition" timeline events found'
;
throw
'no "Start Transition" timeline events found'
;
Map
<
String
,
int
>
unexpectedValueCounts
=
<
String
,
int
>{};
final
Map
<
String
,
int
>
unexpectedValueCounts
=
<
String
,
int
>{};
durations
.
forEach
((
String
routeName
,
List
<
int
>
values
)
{
durations
.
forEach
((
String
routeName
,
List
<
int
>
values
)
{
if
(
values
.
length
!=
2
)
{
if
(
values
.
length
!=
2
)
{
unexpectedValueCounts
[
routeName
]
=
values
.
length
;
unexpectedValueCounts
[
routeName
]
=
values
.
length
;
...
@@ -99,21 +99,21 @@ Future<Null> saveDurationsHistogram(List<Map<String, dynamic>> events, String ou
...
@@ -99,21 +99,21 @@ Future<Null> saveDurationsHistogram(List<Map<String, dynamic>> events, String ou
});
});
if
(
unexpectedValueCounts
.
isNotEmpty
)
{
if
(
unexpectedValueCounts
.
isNotEmpty
)
{
StringBuffer
error
=
new
StringBuffer
(
'Some routes recorded wrong number of values (expected 2 values/route):
\n\n
'
);
final
StringBuffer
error
=
new
StringBuffer
(
'Some routes recorded wrong number of values (expected 2 values/route):
\n\n
'
);
unexpectedValueCounts
.
forEach
((
String
routeName
,
int
count
)
{
unexpectedValueCounts
.
forEach
((
String
routeName
,
int
count
)
{
error
.
writeln
(
' -
$routeName
recorded
$count
values.'
);
error
.
writeln
(
' -
$routeName
recorded
$count
values.'
);
});
});
error
.
writeln
(
'
\n
Full event sequence:'
);
error
.
writeln
(
'
\n
Full event sequence:'
);
Iterator
<
Map
<
String
,
dynamic
>>
eventIter
=
events
.
iterator
;
final
Iterator
<
Map
<
String
,
dynamic
>>
eventIter
=
events
.
iterator
;
String
lastEventName
=
''
;
String
lastEventName
=
''
;
String
lastRouteName
=
''
;
String
lastRouteName
=
''
;
while
(
eventIter
.
moveNext
())
{
while
(
eventIter
.
moveNext
())
{
String
eventName
=
eventIter
.
current
[
'name'
];
final
String
eventName
=
eventIter
.
current
[
'name'
];
if
(!<
String
>[
'Start Transition'
,
'Frame'
].
contains
(
eventName
))
if
(!<
String
>[
'Start Transition'
,
'Frame'
].
contains
(
eventName
))
continue
;
continue
;
String
routeName
=
eventName
==
'Start Transition'
final
String
routeName
=
eventName
==
'Start Transition'
?
eventIter
.
current
[
'args'
][
'to'
]
?
eventIter
.
current
[
'args'
][
'to'
]
:
''
;
:
''
;
...
@@ -147,12 +147,12 @@ void main() {
...
@@ -147,12 +147,12 @@ void main() {
});
});
test
(
'all demos'
,
()
async
{
test
(
'all demos'
,
()
async
{
Timeline
timeline
=
await
driver
.
traceAction
(()
async
{
final
Timeline
timeline
=
await
driver
.
traceAction
(()
async
{
// Scroll each demo menu item into view, launch the demo and
// Scroll each demo menu item into view, launch the demo and
// return to the demo menu 2x.
// return to the demo menu 2x.
for
(
String
demoTitle
in
demoTitles
)
{
for
(
String
demoTitle
in
demoTitles
)
{
print
(
'Testing "
$demoTitle
" demo'
);
print
(
'Testing "
$demoTitle
" demo'
);
SerializableFinder
menuItem
=
find
.
text
(
demoTitle
);
final
SerializableFinder
menuItem
=
find
.
text
(
demoTitle
);
await
driver
.
scrollIntoView
(
menuItem
,
alignment:
0.5
);
await
driver
.
scrollIntoView
(
menuItem
,
alignment:
0.5
);
await
new
Future
<
Null
>.
delayed
(
kWaitBetweenActions
);
await
new
Future
<
Null
>.
delayed
(
kWaitBetweenActions
);
...
@@ -180,9 +180,9 @@ void main() {
...
@@ -180,9 +180,9 @@ void main() {
// Save the duration (in microseconds) of the first timeline Frame event
// Save the duration (in microseconds) of the first timeline Frame event
// that follows a 'Start Transition' event. The Gallery app adds a
// that follows a 'Start Transition' event. The Gallery app adds a
// 'Start Transition' event when a demo is launched (see GalleryItem).
// 'Start Transition' event when a demo is launched (see GalleryItem).
TimelineSummary
summary
=
new
TimelineSummary
.
summarize
(
timeline
);
final
TimelineSummary
summary
=
new
TimelineSummary
.
summarize
(
timeline
);
await
summary
.
writeSummaryToFile
(
'transitions'
,
pretty:
true
);
await
summary
.
writeSummaryToFile
(
'transitions'
,
pretty:
true
);
String
histogramPath
=
path
.
join
(
testOutputsDirectory
,
'transition_durations.timeline.json'
);
final
String
histogramPath
=
path
.
join
(
testOutputsDirectory
,
'transition_durations.timeline.json'
);
await
saveDurationsHistogram
(
timeline
.
json
[
'traceEvents'
],
histogramPath
);
await
saveDurationsHistogram
(
timeline
.
json
[
'traceEvents'
],
histogramPath
);
},
timeout:
const
Timeout
(
const
Duration
(
minutes:
5
)));
},
timeout:
const
Timeout
(
const
Duration
(
minutes:
5
)));
});
});
...
...
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