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
7a52fb67
Commit
7a52fb67
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 (stocks) (#8573)
parent
4c8c420e
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
26 additions
and
26 deletions
+26
-26
main.dart
examples/stocks/lib/main.dart
+2
-2
stock_arrow.dart
examples/stocks/lib/stock_arrow.dart
+8
-8
stock_data.dart
examples/stocks/lib/stock_data.dart
+3
-3
stock_home.dart
examples/stocks/lib/stock_home.dart
+1
-1
stock_settings.dart
examples/stocks/lib/stock_settings.dart
+1
-1
stock_symbol_viewer.dart
examples/stocks/lib/stock_symbol_viewer.dart
+2
-2
icon_color_test.dart
examples/stocks/test/icon_color_test.dart
+6
-6
scroll_perf_test.dart
examples/stocks/test_driver/scroll_perf_test.dart
+3
-3
No files found.
examples/stocks/lib/main.dart
View file @
7a52fb67
...
...
@@ -80,7 +80,7 @@ class StocksAppState extends State<StocksApp> {
}
Route
<
Null
>
_getRoute
(
RouteSettings
settings
)
{
List
<
String
>
path
=
settings
.
name
.
split
(
'/'
);
final
List
<
String
>
path
=
settings
.
name
.
split
(
'/'
);
if
(
path
[
0
]
!=
''
)
return
null
;
if
(
path
[
1
]
==
'stock'
)
{
...
...
@@ -97,7 +97,7 @@ class StocksAppState extends State<StocksApp> {
}
Future
<
LocaleQueryData
>
_onLocaleChanged
(
Locale
locale
)
async
{
String
localeString
=
locale
.
toString
();
final
String
localeString
=
locale
.
toString
();
await
initializeMessages
(
localeString
);
Intl
.
defaultLocale
=
localeString
;
return
StockStrings
.
instance
;
...
...
examples/stocks/lib/stock_arrow.dart
View file @
7a52fb67
...
...
@@ -14,16 +14,16 @@ class StockArrowPainter extends CustomPainter {
@override
void
paint
(
Canvas
canvas
,
Size
size
)
{
Paint
paint
=
new
Paint
()..
color
=
color
;
final
Paint
paint
=
new
Paint
()..
color
=
color
;
paint
.
strokeWidth
=
1.0
;
const
double
padding
=
2.0
;
assert
(
padding
>
paint
.
strokeWidth
/
2.0
);
// make sure the circle remains inside the box
double
r
=
(
size
.
shortestSide
-
padding
)
/
2.0
;
// radius of the circle
double
centerX
=
padding
+
r
;
double
centerY
=
padding
+
r
;
final
double
r
=
(
size
.
shortestSide
-
padding
)
/
2.0
;
// radius of the circle
final
double
centerX
=
padding
+
r
;
final
double
centerY
=
padding
+
r
;
// Draw the arrow.
double
w
=
8.0
;
final
double
w
=
8.0
;
double
h
=
5.0
;
double
arrowY
;
if
(
percentChange
<
0.0
)
{
...
...
@@ -32,7 +32,7 @@ class StockArrowPainter extends CustomPainter {
}
else
{
arrowY
=
centerX
-
1.0
;
}
Path
path
=
new
Path
();
final
Path
path
=
new
Path
();
path
.
moveTo
(
centerX
,
arrowY
-
h
);
// top of the arrow
path
.
lineTo
(
centerX
+
w
,
arrowY
+
h
);
path
.
lineTo
(
centerX
-
w
,
arrowY
+
h
);
...
...
@@ -58,8 +58,8 @@ class StockArrow extends StatelessWidget {
final
double
percentChange
;
int
_colorIndexForPercentChange
(
double
percentChange
)
{
double
maxPercent
=
10.0
;
double
normalizedPercentChange
=
math
.
min
(
percentChange
.
abs
(),
maxPercent
)
/
maxPercent
;
final
double
maxPercent
=
10.0
;
final
double
normalizedPercentChange
=
math
.
min
(
percentChange
.
abs
(),
maxPercent
)
/
maxPercent
;
return
100
+
(
normalizedPercentChange
*
8.0
).
floor
()
*
100
;
}
...
...
examples/stocks/lib/stock_data.dart
View file @
7a52fb67
...
...
@@ -44,7 +44,7 @@ class StockData {
void
appendTo
(
Map
<
String
,
Stock
>
stocks
,
List
<
String
>
symbols
)
{
for
(
List
<
String
>
fields
in
_data
)
{
Stock
stock
=
new
Stock
.
fromFields
(
fields
);
final
Stock
stock
=
new
Stock
.
fromFields
(
fields
);
symbols
.
add
(
stock
.
symbol
);
stocks
[
stock
.
symbol
]
=
stock
;
}
...
...
@@ -73,12 +73,12 @@ class StockDataFetcher {
if
(!
actuallyFetchData
)
return
;
http
.
get
(
_urlToFetch
(
_nextChunk
++)).
then
<
Null
>((
http
.
Response
response
)
{
String
json
=
response
.
body
;
final
String
json
=
response
.
body
;
if
(
json
==
null
)
{
print
(
"Failed to load stock data chunk
${_nextChunk - 1}
"
);
return
null
;
}
JsonDecoder
decoder
=
const
JsonDecoder
();
final
JsonDecoder
decoder
=
const
JsonDecoder
();
callback
(
new
StockData
(
decoder
.
convert
(
json
)));
if
(
_nextChunk
<
_kChunkCount
)
_fetchNextChunk
();
...
...
examples/stocks/lib/stock_home.dart
View file @
7a52fb67
...
...
@@ -241,7 +241,7 @@ class StockHomeState extends State<StockHome> {
Iterable
<
Stock
>
_filterBySearchQuery
(
Iterable
<
Stock
>
stocks
)
{
if
(
_searchQuery
.
text
.
isEmpty
)
return
stocks
;
RegExp
regexp
=
new
RegExp
(
_searchQuery
.
text
,
caseSensitive:
false
);
final
RegExp
regexp
=
new
RegExp
(
_searchQuery
.
text
,
caseSensitive:
false
);
return
stocks
.
where
((
Stock
stock
)
=>
stock
.
symbol
.
contains
(
regexp
));
}
...
...
examples/stocks/lib/stock_settings.dart
View file @
7a52fb67
...
...
@@ -102,7 +102,7 @@ class StockSettingsState extends State<StockSettings> {
}
Widget
buildSettingsPane
(
BuildContext
context
)
{
List
<
Widget
>
rows
=
<
Widget
>[
final
List
<
Widget
>
rows
=
<
Widget
>[
new
DrawerItem
(
icon:
new
Icon
(
Icons
.
thumb_up
),
onPressed:
()
=>
_confirmOptimismChange
(),
...
...
examples/stocks/lib/stock_symbol_viewer.dart
View file @
7a52fb67
...
...
@@ -15,12 +15,12 @@ class _StockSymbolView extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
String
lastSale
=
"
\$
${stock.lastSale.toStringAsFixed(2)}
"
;
final
String
lastSale
=
"
\$
${stock.lastSale.toStringAsFixed(2)}
"
;
String
changeInPrice
=
"
${stock.percentChange.toStringAsFixed(2)}
%"
;
if
(
stock
.
percentChange
>
0
)
changeInPrice
=
"+"
+
changeInPrice
;
TextStyle
headings
=
Theme
.
of
(
context
).
textTheme
.
body2
;
final
TextStyle
headings
=
Theme
.
of
(
context
).
textTheme
.
body2
;
return
new
Container
(
padding:
const
EdgeInsets
.
all
(
20.0
),
child:
new
Column
(
...
...
examples/stocks/test/icon_color_test.dart
View file @
7a52fb67
...
...
@@ -41,10 +41,10 @@ void checkIconColor(WidgetTester tester, String label, Color color) {
// The icon is going to be in the same merged semantics box as the text
// regardless of how the menu item is represented, so this is a good
// way to find the menu item. I hope.
Element
semantics
=
findElementOfExactWidgetTypeGoingUp
(
tester
.
element
(
find
.
text
(
label
)),
MergeSemantics
);
final
Element
semantics
=
findElementOfExactWidgetTypeGoingUp
(
tester
.
element
(
find
.
text
(
label
)),
MergeSemantics
);
expect
(
semantics
,
isNotNull
);
Element
asset
=
findElementOfExactWidgetTypeGoingDown
(
semantics
,
RichText
);
RichText
richText
=
asset
.
widget
;
final
Element
asset
=
findElementOfExactWidgetTypeGoingDown
(
semantics
,
RichText
);
final
RichText
richText
=
asset
.
widget
;
expect
(
richText
.
text
.
style
.
color
,
equals
(
color
));
}
...
...
@@ -64,9 +64,9 @@ void main() {
expect
(
find
.
text
(
'Account Balance'
),
findsNothing
);
// drag the drawer out
Point
left
=
new
Point
(
0.0
,
ui
.
window
.
physicalSize
.
height
/
2.0
);
Point
right
=
new
Point
(
ui
.
window
.
physicalSize
.
width
,
left
.
y
);
TestGesture
gesture
=
await
tester
.
startGesture
(
left
);
final
Point
left
=
new
Point
(
0.0
,
ui
.
window
.
physicalSize
.
height
/
2.0
);
final
Point
right
=
new
Point
(
ui
.
window
.
physicalSize
.
width
,
left
.
y
);
final
TestGesture
gesture
=
await
tester
.
startGesture
(
left
);
await
tester
.
pump
();
await
gesture
.
moveTo
(
right
);
await
tester
.
pump
();
...
...
examples/stocks/test_driver/scroll_perf_test.dart
View file @
7a52fb67
...
...
@@ -21,9 +21,9 @@ void main() {
});
test
(
'measure'
,
()
async
{
Timeline
timeline
=
await
driver
.
traceAction
(()
async
{
final
Timeline
timeline
=
await
driver
.
traceAction
(()
async
{
// Find the scrollable stock list
SerializableFinder
stockList
=
find
.
byValueKey
(
'stock-list'
);
final
SerializableFinder
stockList
=
find
.
byValueKey
(
'stock-list'
);
expect
(
stockList
,
isNotNull
);
// Scroll down
...
...
@@ -39,7 +39,7 @@ void main() {
}
});
TimelineSummary
summary
=
new
TimelineSummary
.
summarize
(
timeline
);
final
TimelineSummary
summary
=
new
TimelineSummary
.
summarize
(
timeline
);
summary
.
writeSummaryToFile
(
'stocks_scroll_perf'
,
pretty:
true
);
summary
.
writeTimelineToFile
(
'stocks_scroll_perf'
,
pretty:
true
);
});
...
...
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