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
6795efac
Commit
6795efac
authored
Mar 10, 2016
by
Hixie
Committed by
Ian Hickson
Mar 12, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable always_specify_types lint
And fix the zillion issues that uncovered.
parent
b36ac833
Changes
114
Show whitespace changes
Inline
Side-by-side
Showing
114 changed files
with
773 additions
and
691 deletions
+773
-691
card_collection.dart
dev/manual_tests/card_collection.dart
+2
-2
pageable_list.dart
dev/manual_tests/pageable_list.dart
+1
-1
media_service.dart
examples/layers/services/media_service.dart
+6
-6
buttons_demo.dart
examples/material_gallery/lib/demo/buttons_demo.dart
+5
-5
colors_demo.dart
examples/material_gallery/lib/demo/colors_demo.dart
+4
-4
date_picker_demo.dart
examples/material_gallery/lib/demo/date_picker_demo.dart
+1
-1
dialog_demo.dart
examples/material_gallery/lib/demo/dialog_demo.dart
+8
-8
fitness_demo.dart
examples/material_gallery/lib/demo/fitness_demo.dart
+4
-4
grid_list_demo.dart
examples/material_gallery/lib/demo/grid_list_demo.dart
+2
-2
leave_behind_demo.dart
examples/material_gallery/lib/demo/leave_behind_demo.dart
+2
-2
list_demo.dart
examples/material_gallery/lib/demo/list_demo.dart
+1
-1
menu_demo.dart
examples/material_gallery/lib/demo/menu_demo.dart
+1
-1
modal_bottom_sheet_demo.dart
...es/material_gallery/lib/demo/modal_bottom_sheet_demo.dart
+1
-1
page_selector_demo.dart
examples/material_gallery/lib/demo/page_selector_demo.dart
+2
-2
scrolling_techniques_demo.dart
.../material_gallery/lib/demo/scrolling_techniques_demo.dart
+1
-1
tabs_demo.dart
examples/material_gallery/lib/demo/tabs_demo.dart
+4
-4
tabs_fab_demo.dart
examples/material_gallery/lib/demo/tabs_fab_demo.dart
+2
-2
time_picker_demo.dart
examples/material_gallery/lib/demo/time_picker_demo.dart
+1
-1
weather_demo.dart
examples/material_gallery/lib/demo/weather_demo.dart
+1
-1
section.dart
examples/material_gallery/lib/gallery/section.dart
+2
-2
main.dart
examples/stocks/lib/main.dart
+2
-2
stock_data.dart
examples/stocks/lib/stock_data.dart
+1
-1
stock_home.dart
examples/stocks/lib/stock_home.dart
+2
-2
stock_list.dart
examples/stocks/lib/stock_list.dart
+1
-1
locale_test.dart
examples/stocks/test/locale_test.dart
+3
-2
scroll_perf_test.dart
examples/stocks/test_driver/scroll_perf_test.dart
+2
-2
expression.dart
packages/cassowary/lib/expression.dart
+59
-48
param.dart
packages/cassowary/lib/param.dart
+8
-8
row.dart
packages/cassowary/lib/row.dart
+6
-5
solver.dart
packages/cassowary/lib/solver.dart
+31
-24
cassowary_test.dart
packages/cassowary/test/cassowary_test.dart
+107
-107
animation_controller.dart
packages/flutter/lib/src/animation/animation_controller.dart
+9
-9
http.dart
packages/flutter/lib/src/http/http.dart
+1
-1
app.dart
packages/flutter/lib/src/material/app.dart
+1
-1
bottom_sheet.dart
packages/flutter/lib/src/material/bottom_sheet.dart
+9
-9
colors.dart
packages/flutter/lib/src/material/colors.dart
+14
-14
dialog.dart
packages/flutter/lib/src/material/dialog.dart
+3
-3
drawer.dart
packages/flutter/lib/src/material/drawer.dart
+1
-1
dropdown.dart
packages/flutter/lib/src/material/dropdown.dart
+3
-3
ink_well.dart
packages/flutter/lib/src/material/ink_well.dart
+1
-1
material.dart
packages/flutter/lib/src/material/material.dart
+1
-1
page.dart
packages/flutter/lib/src/material/page.dart
+1
-1
popup_menu.dart
packages/flutter/lib/src/material/popup_menu.dart
+6
-6
progress_indicator.dart
packages/flutter/lib/src/material/progress_indicator.dart
+4
-4
scaffold.dart
packages/flutter/lib/src/material/scaffold.dart
+26
-14
scrollbar_painter.dart
packages/flutter/lib/src/material/scrollbar_painter.dart
+2
-2
switch.dart
packages/flutter/lib/src/material/switch.dart
+1
-1
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+21
-21
theme.dart
packages/flutter/lib/src/material/theme.dart
+2
-2
box_painter.dart
packages/flutter/lib/src/painting/box_painter.dart
+1
-1
text_painter.dart
packages/flutter/lib/src/painting/text_painter.dart
+4
-4
basic_types.dart
packages/flutter/lib/src/rendering/basic_types.dart
+3
-3
editable_line.dart
packages/flutter/lib/src/rendering/editable_line.dart
+3
-3
flex.dart
packages/flutter/lib/src/rendering/flex.dart
+1
-1
proxy_box.dart
packages/flutter/lib/src/rendering/proxy_box.dart
+3
-3
shifted_box.dart
packages/flutter/lib/src/rendering/shifted_box.dart
+1
-1
stack.dart
packages/flutter/lib/src/rendering/stack.dart
+3
-3
scheduler.dart
packages/flutter/lib/src/scheduler/scheduler.dart
+1
-1
ticker.dart
packages/flutter/lib/src/scheduler/ticker.dart
+4
-4
asset_bundle.dart
packages/flutter/lib/src/services/asset_bundle.dart
+1
-1
image_cache.dart
packages/flutter/lib/src/services/image_cache.dart
+5
-2
image_resource.dart
packages/flutter/lib/src/services/image_resource.dart
+6
-1
asset_vendor.dart
packages/flutter/lib/src/widgets/asset_vendor.dart
+2
-2
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+8
-8
binding.dart
packages/flutter/lib/src/widgets/binding.dart
+3
-1
checked_mode_banner.dart
packages/flutter/lib/src/widgets/checked_mode_banner.dart
+6
-6
drag_target.dart
packages/flutter/lib/src/widgets/drag_target.dart
+10
-10
editable.dart
packages/flutter/lib/src/widgets/editable.dart
+1
-1
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+71
-55
heroes.dart
packages/flutter/lib/src/widgets/heroes.dart
+12
-11
implicit_animations.dart
packages/flutter/lib/src/widgets/implicit_animations.dart
+8
-8
locale_query.dart
packages/flutter/lib/src/widgets/locale_query.dart
+3
-3
mimic.dart
packages/flutter/lib/src/widgets/mimic.dart
+1
-1
mixed_viewport.dart
packages/flutter/lib/src/widgets/mixed_viewport.dart
+3
-1
navigator.dart
packages/flutter/lib/src/widgets/navigator.dart
+26
-26
notification_listener.dart
packages/flutter/lib/src/widgets/notification_listener.dart
+3
-3
pageable_list.dart
packages/flutter/lib/src/widgets/pageable_list.dart
+8
-6
pages.dart
packages/flutter/lib/src/widgets/pages.dart
+2
-2
routes.dart
packages/flutter/lib/src/widgets/routes.dart
+15
-15
scrollable.dart
packages/flutter/lib/src/widgets/scrollable.dart
+24
-23
scrollable_grid.dart
packages/flutter/lib/src/widgets/scrollable_grid.dart
+4
-2
scrollable_list.dart
packages/flutter/lib/src/widgets/scrollable_list.dart
+5
-3
semantics_debugger.dart
packages/flutter/lib/src/widgets/semantics_debugger.dart
+2
-2
virtual_viewport.dart
packages/flutter/lib/src/widgets/virtual_viewport.dart
+9
-7
box_test.dart
packages/flutter/test/rendering/box_test.dart
+2
-2
asset_vendor_test.dart
packages/flutter/test/widget/asset_vendor_test.dart
+2
-2
bottom_sheet_rebuild_test.dart
packages/flutter/test/widget/bottom_sheet_rebuild_test.dart
+2
-2
bottom_sheet_test.dart
packages/flutter/test/widget/bottom_sheet_test.dart
+4
-3
custom_one_child_layout_test.dart
...ges/flutter/test/widget/custom_one_child_layout_test.dart
+1
-1
draggable_test.dart
packages/flutter/test/widget/draggable_test.dart
+30
-30
heroes_test.dart
packages/flutter/test/widget/heroes_test.dart
+1
-1
modal_barrier_test.dart
packages/flutter/test/widget/modal_barrier_test.dart
+4
-4
navigator_test.dart
packages/flutter/test/widget/navigator_test.dart
+2
-2
page_forward_transitions_test.dart
...es/flutter/test/widget/page_forward_transitions_test.dart
+5
-5
page_transitions_test.dart
packages/flutter/test/widget/page_transitions_test.dart
+1
-1
remember_scroll_position_test.dart
...es/flutter/test/widget/remember_scroll_position_test.dart
+5
-4
snack_bar_test.dart
packages/flutter/test/widget/snack_bar_test.dart
+2
-2
snap_scrolling_test.dart
packages/flutter/test/widget/snap_scrolling_test.dart
+1
-1
stack_test.dart
packages/flutter/test/widget/stack_test.dart
+2
-2
test_matchers.dart
packages/flutter/test/widget/test_matchers.dart
+4
-4
driver.dart
packages/flutter_driver/lib/src/driver.dart
+12
-12
matcher_util.dart
packages/flutter_driver/lib/src/matcher_util.dart
+2
-2
retry.dart
packages/flutter_driver/lib/src/retry.dart
+2
-2
action.dart
packages/flutter_sprites/lib/src/action.dart
+1
-1
physics_body.dart
packages/flutter_sprites/lib/src/physics_body.dart
+2
-2
physics_world.dart
packages/flutter_sprites/lib/src/physics_world.dart
+1
-1
sprite_box.dart
packages/flutter_sprites/lib/src/sprite_box.dart
+1
-1
spritesheet.dart
packages/flutter_sprites/lib/src/spritesheet.dart
+7
-7
virtual_joystick.dart
packages/flutter_sprites/lib/src/virtual_joystick.dart
+1
-1
instrumentation.dart
packages/flutter_test/lib/src/instrumentation.dart
+4
-1
.analysis_options
packages/flutter_tools/.analysis_options
+1
-0
executable.dart
packages/flutter_tools/lib/executable.dart
+2
-2
analyze.dart
packages/flutter_tools/lib/src/commands/analyze.dart
+6
-0
newton_test.dart
packages/newton/test/newton_test.dart
+22
-22
No files found.
dev/manual_tests/card_collection.dart
View file @
6795efac
...
...
@@ -26,9 +26,9 @@ class CardCollectionState extends State<CardCollection> {
const
TextStyle
(
color:
Colors
.
white
,
fontSize:
18.0
,
fontWeight:
FontWeight
.
bold
);
// TODO(hansmuller): need a local image asset
static
const
_sunshineURL
=
"http://www.walltor.com/images/wallpaper/good-morning-sunshine-58540.jpg"
;
static
const
String
_sunshineURL
=
"http://www.walltor.com/images/wallpaper/good-morning-sunshine-58540.jpg"
;
static
const
kCardMargins
=
8.0
;
static
const
double
kCardMargins
=
8.0
;
final
TextStyle
backgroundTextStyle
=
Typography
.
white
.
title
.
copyWith
(
textAlign:
TextAlign
.
center
);
...
...
dev/manual_tests/pageable_list.dart
View file @
6795efac
...
...
@@ -23,7 +23,7 @@ class PageableListAppState extends State<PageableListApp> {
List
<
Size
>
cardSizes
=
[
[
100.0
,
300.0
],
[
300.0
,
100.0
],
[
200.0
,
400.0
],
[
400.0
,
400.0
],
[
300.0
,
400.0
]
]
.
map
((
args
)
=>
new
Size
(
args
[
0
],
args
[
1
]))
.
map
((
List
<
double
>
args
)
=>
new
Size
(
args
[
0
],
args
[
1
]))
.
toList
();
cardModels
=
new
List
<
CardModel
>.
generate
(
cardSizes
.
length
,
(
int
i
)
{
...
...
examples/layers/services/media_service.dart
View file @
6795efac
...
...
@@ -39,7 +39,7 @@ class PianoKey {
player
.
ptr
.
pause
();
}
Future
load
(
MediaServiceProxy
mediaService
)
async
{
Future
<
Null
>
load
(
MediaServiceProxy
mediaService
)
async
{
try
{
mediaService
.
ptr
.
createPlayer
(
player
);
UrlResponse
response
=
await
fetchUrl
(
soundUrl
);
...
...
@@ -61,11 +61,11 @@ class PianoApp extends StatelessComponent {
new
PianoKey
(
Colors
.
purple
[
500
],
iLoveYou
),
];
Future
loadSounds
()
async
{
Future
<
Null
>
loadSounds
()
async
{
MediaServiceProxy
mediaService
=
new
MediaServiceProxy
.
unbound
();
try
{
shell
.
connectToService
(
"mojo:media_service"
,
mediaService
);
List
<
Future
<
MediaPlayerPrepareResponseParams
>>
pending
=
<
Future
<
MediaPlayerPrepareResponseParams
>>[];
List
<
Future
<
Null
>>
pending
=
<
Future
<
Null
>>[];
for
(
PianoKey
key
in
keys
)
pending
.
add
(
key
.
load
(
mediaService
));
await
Future
.
wait
(
pending
);
...
...
@@ -93,8 +93,8 @@ class PianoApp extends StatelessComponent {
}
Widget
statusBox
(
Widget
child
)
{
const
mediumGray
=
const
Color
(
0xff555555
);
const
darkGray
=
const
Color
(
0xff222222
);
const
Color
mediumGray
=
const
Color
(
0xff555555
);
const
Color
darkGray
=
const
Color
(
0xff222222
);
return
new
Center
(
child:
new
Container
(
decoration:
const
BoxDecoration
(
...
...
@@ -121,7 +121,7 @@ Widget splashScreen() {
);
}
Future
main
(
)
async
{
Future
<
Null
>
main
()
async
{
runApp
(
splashScreen
());
PianoApp
app
=
new
PianoApp
();
...
...
examples/material_gallery/lib/demo/buttons_demo.dart
View file @
6795efac
...
...
@@ -80,7 +80,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
tooltip:
'Open FAB demos'
,
child:
new
Icon
(
icon:
Icons
.
add
),
onPressed:
()
{
Navigator
.
push
(
context
,
new
MaterialPageRoute
(
Navigator
.
push
(
context
,
new
MaterialPageRoute
<
Null
>
(
builder:
(
BuildContext
context
)
=>
new
TabsFabDemo
()
));
}
...
...
@@ -97,7 +97,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
new
RaisedButton
(
child:
new
Text
(
"Launch Demo"
),
onPressed:
()
{
Navigator
.
push
(
context
,
new
MaterialPageRoute
(
Navigator
.
push
(
context
,
new
MaterialPageRoute
<
Null
>
(
builder:
(
BuildContext
context
)
=>
new
SnackBarDemo
()
));
}
...
...
@@ -127,7 +127,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
new
FlatButton
(
child:
new
Text
(
"Launch Demo"
),
onPressed:
()
{
Navigator
.
push
(
context
,
new
MaterialPageRoute
(
Navigator
.
push
(
context
,
new
MaterialPageRoute
<
Null
>
(
builder:
(
_
)
=>
new
DialogDemo
()
));
}
...
...
@@ -200,10 +200,10 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
center:
new
Text
(
"Buttons"
),
tabBar:
new
TabBar
<
_ButtonDemo
>(
isScrollable:
true
,
labels:
new
Map
.
fromIterable
(
demos
,
value:
(
_ButtonDemo
demo
)
=>
demo
.
tabLabel
)
labels:
new
Map
<
_ButtonDemo
,
TabLabel
>
.
fromIterable
(
demos
,
value:
(
_ButtonDemo
demo
)
=>
demo
.
tabLabel
)
)
),
body:
new
TabBarView
(
body:
new
TabBarView
<
_ButtonDemo
>
(
children:
demos
.
map
(
buildTabView
).
toList
()
)
)
...
...
examples/material_gallery/lib/demo/colors_demo.dart
View file @
6795efac
...
...
@@ -77,8 +77,8 @@ class ColorSwatchTabView extends StatelessComponent {
}
final
ColorSwatch
swatch
;
final
blackTextStyle
=
Typography
.
black
.
body1
;
final
whiteTextStyle
=
Typography
.
white
.
body1
;
final
TextStyle
blackTextStyle
=
Typography
.
black
.
body1
;
final
TextStyle
whiteTextStyle
=
Typography
.
white
.
body1
;
Widget
build
(
BuildContext
context
)
{
List
<
Widget
>
colorItems
=
swatch
.
colors
.
keys
.
map
((
int
index
)
{
...
...
@@ -116,12 +116,12 @@ class ColorsDemo extends StatelessComponent {
center:
new
Text
(
"Colors"
),
tabBar:
new
TabBar
<
ColorSwatch
>(
isScrollable:
true
,
labels:
new
Map
.
fromIterable
(
colorSwatches
,
value:
(
ColorSwatch
swatch
)
{
labels:
new
Map
<
ColorSwatch
,
TabLabel
>
.
fromIterable
(
colorSwatches
,
value:
(
ColorSwatch
swatch
)
{
return
new
TabLabel
(
text:
swatch
.
name
);
})
)
),
body:
new
TabBarView
(
body:
new
TabBarView
<
ColorSwatch
>
(
children:
colorSwatches
.
map
((
ColorSwatch
swatch
)
{
return
new
ColorSwatchTabView
(
swatch:
swatch
);
})
...
...
examples/material_gallery/lib/demo/date_picker_demo.dart
View file @
6795efac
...
...
@@ -14,7 +14,7 @@ class DatePickerDemo extends StatefulComponent {
class
_DatePickerDemoState
extends
State
<
DatePickerDemo
>
{
DateTime
_selectedDate
=
new
DateTime
.
now
();
Future
_handleSelectDate
()
async
{
Future
<
Null
>
_handleSelectDate
()
async
{
DateTime
picked
=
await
showDatePicker
(
context:
context
,
initialDate:
_selectedDate
,
...
...
examples/material_gallery/lib/demo/dialog_demo.dart
View file @
6795efac
...
...
@@ -60,12 +60,12 @@ class DialogDemo extends StatefulComponent {
class
DialogDemoState
extends
State
<
DialogDemo
>
{
final
GlobalKey
<
ScaffoldState
>
scaffoldKey
=
new
GlobalKey
<
ScaffoldState
>();
void
showDemoDialog
({
BuildContext
context
,
Dialog
dialog
})
{
showDialog
(
void
showDemoDialog
/*<T>*/
({
BuildContext
context
,
Dialog
dialog
})
{
showDialog
/*<T>*/
(
context:
context
,
child:
dialog
)
.
then
((
dynamic
value
)
{
// The value passed to Navigator.pop() or null.
.
then
((
dynamic
/*=T*/
value
)
{
// The value passed to Navigator.pop() or null.
if
(
value
!=
null
)
{
scaffoldKey
.
currentState
.
showSnackBar
(
new
SnackBar
(
content:
new
Text
(
'You selected:
$value
'
)
...
...
@@ -89,7 +89,7 @@ class DialogDemoState extends State<DialogDemo> {
new
RaisedButton
(
child:
new
Text
(
'ALERT'
),
onPressed:
()
{
showDemoDialog
(
showDemoDialog
/*<DialogDemoAction>*/
(
context:
context
,
dialog:
new
Dialog
(
content:
new
Text
(
...
...
@@ -113,7 +113,7 @@ class DialogDemoState extends State<DialogDemo> {
new
RaisedButton
(
child:
new
Text
(
'ALERT WITH TITLE'
),
onPressed:
()
{
showDemoDialog
(
showDemoDialog
/*<DialogDemoAction>*/
(
context:
context
,
dialog:
new
Dialog
(
title:
new
Text
(
"Use Google's location service?"
),
...
...
@@ -138,7 +138,7 @@ class DialogDemoState extends State<DialogDemo> {
new
RaisedButton
(
child:
new
Text
(
'SIMPLE'
),
onPressed:
()
{
showDemoDialog
(
showDemoDialog
/*<String>*/
(
context:
context
,
dialog:
new
Dialog
(
title:
new
Text
(
'Set backup account'
),
...
...
@@ -174,7 +174,7 @@ class DialogDemoState extends State<DialogDemo> {
context:
context
,
initialTime:
const
TimeOfDay
(
hour:
15
,
minute:
30
)
)
.
then
((
value
)
{
// The value passed to Navigator.pop() or null.
.
then
((
TimeOfDay
value
)
{
// The value passed to Navigator.pop() or null.
if
(
value
!=
null
)
{
scaffoldKey
.
currentState
.
showSnackBar
(
new
SnackBar
(
content:
new
Text
(
'You selected:
$value
'
)
...
...
@@ -186,7 +186,7 @@ class DialogDemoState extends State<DialogDemo> {
new
RaisedButton
(
child:
new
Text
(
'FULLSCREEN'
),
onPressed:
()
{
Navigator
.
push
(
context
,
new
MaterialPageRoute
(
Navigator
.
push
(
context
,
new
MaterialPageRoute
<
Null
>
(
builder:
(
BuildContext
context
)
=>
new
FullScreenDialogDemo
()
));
}
...
...
examples/material_gallery/lib/demo/fitness_demo.dart
View file @
6795efac
...
...
@@ -33,7 +33,7 @@ class _FitnessDemoContents extends StatefulComponent {
class
_FitnessDemoContentsState
extends
State
<
_FitnessDemoContents
>
{
Future
_loadAssets
(
AssetBundle
bundle
)
async
{
Future
<
Null
>
_loadAssets
(
AssetBundle
bundle
)
async
{
_images
=
new
ImageMap
(
bundle
);
await
_images
.
load
(<
String
>[
'packages/flutter_gallery_assets/jumpingjack.png'
,
...
...
@@ -267,9 +267,9 @@ class _WorkoutAnimationNode extends NodeWithSize {
class
_ProgressCircle
extends
NodeWithSize
{
_ProgressCircle
(
Size
size
,
[
this
.
value
=
0.0
])
:
super
(
size
);
static
const
_kTwoPI
=
math
.
PI
*
2.0
;
static
const
_kEpsilon
=
.
0000001
;
static
const
_kSweep
=
_kTwoPI
-
_kEpsilon
;
static
const
double
_kTwoPI
=
math
.
PI
*
2.0
;
static
const
double
_kEpsilon
=
.
0000001
;
static
const
double
_kSweep
=
_kTwoPI
-
_kEpsilon
;
double
value
;
...
...
examples/material_gallery/lib/demo/grid_list_demo.dart
View file @
6795efac
...
...
@@ -38,7 +38,7 @@ class GridDemoPhotoItem extends StatelessComponent {
final
GridDemoTileStyle
tileStyle
;
void
showPhoto
(
BuildContext
context
)
{
Navigator
.
push
(
context
,
new
MaterialPageRoute
(
Navigator
.
push
(
context
,
new
MaterialPageRoute
<
Null
>
(
builder:
(
BuildContext
context
)
{
return
new
Scaffold
(
toolBar:
new
ToolBar
(
...
...
@@ -138,7 +138,7 @@ class GridListDemoState extends State<GridListDemo> {
GridDemoTileStyle
tileStyle
=
GridDemoTileStyle
.
twoLine
;
void
showTileStyleMenu
(
BuildContext
context
)
{
final
List
<
PopupMenuItem
>
items
=
<
PopupMenuItem
<
GridDemoTileStyle
>>[
final
List
<
PopupMenuItem
<
GridDemoTileStyle
>
>
items
=
<
PopupMenuItem
<
GridDemoTileStyle
>>[
new
PopupMenuItem
<
GridDemoTileStyle
>(
value:
GridDemoTileStyle
.
imageOnly
,
child:
new
Text
(
'Image only'
)
...
...
examples/material_gallery/lib/demo/leave_behind_demo.dart
View file @
6795efac
...
...
@@ -37,7 +37,7 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
List
<
LeaveBehindItem
>
leaveBehindItems
;
void
initListItems
()
{
leaveBehindItems
=
new
List
.
generate
(
16
,
(
int
index
)
{
leaveBehindItems
=
new
List
<
LeaveBehindItem
>
.
generate
(
16
,
(
int
index
)
{
return
new
LeaveBehindItem
(
index:
index
,
name:
'Item
$index
Sender'
,
...
...
@@ -130,7 +130,7 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
right:
<
Widget
>[
new
PopupMenuButton
<
LeaveBehindDemoAction
>(
onSelected:
handleDemoAction
,
items:
<
PopupMenuEntry
>[
items:
<
PopupMenuEntry
<
LeaveBehindDemoAction
>
>[
new
PopupMenuItem
<
LeaveBehindDemoAction
>(
value:
LeaveBehindDemoAction
.
reset
,
child:
new
Text
(
'Reset the list'
)
...
...
examples/material_gallery/lib/demo/list_demo.dart
View file @
6795efac
...
...
@@ -19,7 +19,7 @@ class ListDemo extends StatefulComponent {
class
ListDemoState
extends
State
<
ListDemo
>
{
final
GlobalKey
<
ScaffoldState
>
scaffoldKey
=
new
GlobalKey
<
ScaffoldState
>();
ScaffoldFeatureController
_bottomSheet
;
PersistentBottomSheetController
<
Null
>
_bottomSheet
;
ListDemoItemSize
_itemSize
=
ListDemoItemSize
.
threeLine
;
bool
_dense
=
false
;
bool
_showAvatars
=
true
;
...
...
examples/material_gallery/lib/demo/menu_demo.dart
View file @
6795efac
...
...
@@ -176,7 +176,7 @@ class MenuDemoState extends State<MenuDemo> {
right:
new
PopupMenuButton
<
String
>(
onSelected:
showCheckedMenuSelections
,
items:
<
PopupMenuItem
<
String
>>[
new
CheckedPopupMenuItem
(
new
CheckedPopupMenuItem
<
String
>
(
value:
_checkedValue1
,
checked:
isChecked
(
_checkedValue1
),
child:
new
Text
(
_checkedValue1
)
...
...
examples/material_gallery/lib/demo/modal_bottom_sheet_demo.dart
View file @
6795efac
...
...
@@ -21,7 +21,7 @@ class ModalBottomSheetDemo extends StatelessComponent {
child:
new
RaisedButton
(
child:
new
Text
(
'Show the modal bottom sheet'
,
style:
textStyle
),
onPressed:
()
{
showModalBottomSheet
(
context:
context
,
builder:
(
_
)
{
showModalBottomSheet
/*<Null>*/
(
context:
context
,
builder:
(
BuildContext
context
)
{
return
new
Container
(
child:
new
Padding
(
padding:
const
EdgeDims
.
all
(
32.0
),
...
...
examples/material_gallery/lib/demo/page_selector_demo.dart
View file @
6795efac
...
...
@@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
class
PageSelectorDemo
extends
StatelessComponent
{
void
_handleArrowButtonPress
(
BuildContext
context
,
int
delta
)
{
final
TabBarSelectionState
selection
=
TabBarSelection
.
of
(
context
);
final
TabBarSelectionState
<
IconData
>
selection
=
TabBarSelection
.
of
/*<IconData>*/
(
context
);
if
(!
selection
.
valueIsChanging
)
selection
.
value
=
selection
.
values
[(
selection
.
index
+
delta
).
clamp
(
0
,
selection
.
values
.
length
-
1
)];
}
...
...
@@ -53,7 +53,7 @@ class PageSelectorDemo extends StatelessComponent {
)
),
new
Flexible
(
child:
new
TabBarView
(
child:
new
TabBarView
<
IconData
>
(
children:
icons
.
map
((
IconData
icon
)
{
return
new
Container
(
key:
new
ObjectKey
(
icon
),
...
...
examples/material_gallery/lib/demo/scrolling_techniques_demo.dart
View file @
6795efac
...
...
@@ -82,7 +82,7 @@ class _TechniqueItem extends StatelessComponent {
final
WidgetBuilder
builder
;
void
showDemo
(
BuildContext
context
)
{
Navigator
.
push
(
context
,
new
MaterialPageRoute
(
builder:
builder
));
Navigator
.
push
(
context
,
new
MaterialPageRoute
<
Null
>
(
builder:
builder
));
}
Widget
build
(
BuildContext
context
)
{
...
...
examples/material_gallery/lib/demo/tabs_demo.dart
View file @
6795efac
...
...
@@ -25,20 +25,20 @@ class TabsDemo extends StatelessComponent {
Widget
build
(
BuildContext
context
)
{
final
Color
iconColor
=
Theme
.
of
(
context
).
accentColor
;
return
new
TabBarSelection
(
return
new
TabBarSelection
<
IconData
>
(
values:
icons
,
child:
new
Scaffold
(
toolBar:
new
ToolBar
(
center:
new
Text
(
"Scrollable Tabs"
),
tabBar:
new
TabBar
<
String
>(
tabBar:
new
TabBar
<
IconData
>(
isScrollable:
true
,
labels:
new
Map
.
fromIterable
(
labels:
new
Map
<
IconData
,
TabLabel
>
.
fromIterable
(
icons
,
value:
(
IconData
icon
)
=>
new
TabLabel
(
text:
labels
[
icon
],
icon:
icon
)
)
)
),
body:
new
TabBarView
(
body:
new
TabBarView
<
IconData
>
(
children:
icons
.
map
((
IconData
icon
)
{
return
new
Container
(
key:
new
ObjectKey
(
icon
),
...
...
examples/material_gallery/lib/demo/tabs_fab_demo.dart
View file @
6795efac
...
...
@@ -97,7 +97,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> {
toolBar:
new
ToolBar
(
center:
new
Text
(
"FAB per Tab"
),
tabBar:
new
TabBar
<
_Page
>(
labels:
new
Map
.
fromIterable
(
pages
,
value:
(
_Page
page
)
=>
page
.
tabLabel
)
labels:
new
Map
<
_Page
,
TabLabel
>
.
fromIterable
(
pages
,
value:
(
_Page
page
)
=>
page
.
tabLabel
)
)
),
floatingActionButton:
!
selectedPage
.
fabDefined
?
null
:
new
FloatingActionButton
(
...
...
@@ -107,7 +107,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> {
child:
selectedPage
.
fabIcon
,
onPressed:
_showExplanatoryText
),
body:
new
TabBarView
(
children:
pages
.
map
(
buildTabView
).
toList
())
body:
new
TabBarView
<
_Page
>
(
children:
pages
.
map
(
buildTabView
).
toList
())
)
);
}
...
...
examples/material_gallery/lib/demo/time_picker_demo.dart
View file @
6795efac
...
...
@@ -13,7 +13,7 @@ class TimePickerDemo extends StatefulComponent {
class
_TimePickerDemoState
extends
State
<
TimePickerDemo
>
{
TimeOfDay
_selectedTime
=
const
TimeOfDay
(
hour:
7
,
minute:
28
);
Future
_handleSelectTime
()
async
{
Future
<
Null
>
_handleSelectTime
()
async
{
TimeOfDay
picked
=
await
showTimePicker
(
context:
context
,
initialTime:
_selectedTime
...
...
examples/material_gallery/lib/demo/weather_demo.dart
View file @
6795efac
...
...
@@ -24,7 +24,7 @@ class WeatherDemo extends StatefulComponent {
class
_WeatherDemoState
extends
State
<
WeatherDemo
>
{
Future
_loadAssets
(
AssetBundle
bundle
)
async
{
Future
<
Null
>
_loadAssets
(
AssetBundle
bundle
)
async
{
_images
=
new
ImageMap
(
bundle
);
await
_images
.
load
(<
String
>[
'packages/flutter_gallery_assets/clouds-0.png'
,
...
...
examples/material_gallery/lib/gallery/section.dart
View file @
6795efac
...
...
@@ -16,7 +16,7 @@ class GallerySection extends StatelessComponent {
final
List
<
GalleryDemo
>
demos
;
void
showDemo
(
GalleryDemo
demo
,
BuildContext
context
,
ThemeData
theme
)
{
Navigator
.
push
(
context
,
new
MaterialPageRoute
(
Navigator
.
push
(
context
,
new
MaterialPageRoute
<
Null
>
(
builder:
(
BuildContext
context
)
{
Widget
child
=
(
demo
.
builder
==
null
)
?
null
:
demo
.
builder
();
return
new
Theme
(
data:
theme
,
child:
child
);
...
...
@@ -31,7 +31,7 @@ class GallerySection extends StatelessComponent {
);
final
double
appBarHeight
=
200.0
;
final
Key
scrollableKey
=
new
ValueKey
<
String
>(
title
);
// assume section titles differ
Navigator
.
push
(
context
,
new
MaterialPageRoute
(
Navigator
.
push
(
context
,
new
MaterialPageRoute
<
Null
>
(
builder:
(
BuildContext
context
)
{
return
new
Theme
(
data:
theme
,
...
...
examples/stocks/lib/main.dart
View file @
6795efac
...
...
@@ -75,7 +75,7 @@ class StocksAppState extends State<StocksApp> {
}
}
Route
_getRoute
(
RouteSettings
settings
)
{
Route
<
Null
>
_getRoute
(
RouteSettings
settings
)
{
List
<
String
>
path
=
settings
.
name
.
split
(
'/'
);
if
(
path
[
0
]
!=
''
)
return
null
;
...
...
@@ -83,7 +83,7 @@ class StocksAppState extends State<StocksApp> {
if
(
path
.
length
!=
3
)
return
null
;
if
(
_stocks
.
containsKey
(
path
[
2
]))
{
return
new
MaterialPageRoute
(
return
new
MaterialPageRoute
<
Null
>
(
settings:
settings
,
builder:
(
BuildContext
context
)
=>
new
StockSymbolPage
(
stock:
_stocks
[
path
[
2
]])
);
...
...
examples/stocks/lib/stock_data.dart
View file @
6795efac
...
...
@@ -53,7 +53,7 @@ class StockData {
}
typedef
void
StockDataCallback
(
StockData
data
);
const
_kChunkCount
=
30
;
const
int
_kChunkCount
=
30
;
String
_urlToFetch
(
int
chunk
)
{
return
'https://domokit.github.io/examples/stocks/data/stock_data_
$chunk
.json'
;
...
...
examples/stocks/lib/stock_home.dart
View file @
6795efac
...
...
@@ -321,7 +321,7 @@ class StockHomeState extends State<StockHome> {
}
void
_handleCreateCompany
()
{
showModalBottomSheet
(
showModalBottomSheet
/*<Null>*/
(
context:
context
,
builder:
(
BuildContext
context
)
=>
new
_CreateCompanySheet
()
);
...
...
@@ -344,7 +344,7 @@ class StockHomeState extends State<StockHome> {
toolBar:
_isSearching
?
buildSearchBar
()
:
buildToolBar
(),
floatingActionButton:
buildFloatingActionButton
(),
drawer:
_buildDrawer
(
context
),
body:
new
TabBarView
(
body:
new
TabBarView
<
StockHomeTab
>
(
children:
<
Widget
>[
_buildStockTab
(
context
,
StockHomeTab
.
market
,
config
.
symbols
),
_buildStockTab
(
context
,
StockHomeTab
.
portfolio
,
portfolioSymbols
),
...
...
examples/stocks/lib/stock_list.dart
View file @
6795efac
...
...
@@ -18,7 +18,7 @@ class StockList extends StatelessComponent {
Widget
build
(
BuildContext
context
)
{
return
new
ScrollableList
(
key:
const
ValueKey
(
'stock-list'
),
key:
const
ValueKey
<
String
>
(
'stock-list'
),
itemExtent:
StockRow
.
kHeight
,
children:
stocks
.
map
((
Stock
stock
)
{
return
new
StockRow
(
...
...
examples/stocks/test/locale_test.dart
View file @
6795efac
...
...
@@ -17,11 +17,12 @@ void main() {
tester
.
async
.
flushMicrotasks
();
// see https://github.com/flutter/flutter/issues/1865
tester
.
pump
();
Element
<
Text
>
tab
=
tester
.
findText
(
'MARKET'
);
Element
tab
=
tester
.
findText
(
'MARKET'
);
expect
(
tab
,
isNotNull
);
tester
.
setLocale
(
"es"
,
"US"
);
tester
.
pump
();
expect
(
tab
.
widget
.
data
,
equals
(
"MERCADO"
));
Text
text
=
tab
.
widget
;
expect
(
text
.
data
,
equals
(
"MERCADO"
));
// TODO(abarth): We're leaking an animation. We should track down the leak
// and plug it rather than waiting for the animation to end here.
...
...
examples/stocks/test_driver/scroll_perf_test.dart
View file @
6795efac
...
...
@@ -27,13 +27,13 @@ void main() {
// Scroll down 5 times
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
await
driver
.
scroll
(
stockList
,
0.0
,
-
300.0
,
new
Duration
(
milliseconds:
300
));
await
new
Future
.
delayed
(
new
Duration
(
milliseconds:
500
));
await
new
Future
<
Null
>
.
delayed
(
new
Duration
(
milliseconds:
500
));
}
// Scroll up 5 times
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
await
driver
.
scroll
(
stockList
,
0.0
,
300.0
,
new
Duration
(
milliseconds:
300
));
await
new
Future
.
delayed
(
new
Duration
(
milliseconds:
500
));
await
new
Future
<
Null
>
.
delayed
(
new
Duration
(
milliseconds:
500
));
}
});
});
...
...
packages/cassowary/lib/expression.dart
View file @
6795efac
...
...
@@ -18,108 +18,121 @@ class Expression extends _EquationMember {
bool
get
isConstant
=>
terms
.
length
==
0
;
@override
double
get
value
=>
terms
.
fold
(
constant
,
(
value
,
term
)
=>
value
+
term
.
value
);
double
get
value
=>
terms
.
fold
(
constant
,
(
double
value
,
Term
term
)
=>
value
+
term
.
value
);
@override
Expression
asExpression
()
=>
this
;
Constraint
_createConstraint
(
_EquationMember
/* rhs */
value
,
Relation
relation
)
{
Constraint
_createConstraint
(
_EquationMember
/* rhs */
value
,
Relation
relation
)
{
if
(
value
is
ConstantMember
)
{
return
new
Constraint
(
new
Expression
(
new
List
.
from
(
terms
),
constant
-
value
.
value
),
relation
);
new
Expression
(
new
List
<
Term
>.
from
(
terms
),
constant
-
value
.
value
),
relation
);
}
if
(
value
is
Param
)
{
var
newTerms
=
new
List
<
Term
>.
from
(
terms
)
List
<
Term
>
newTerms
=
new
List
<
Term
>.
from
(
terms
)
..
add
(
new
Term
(
value
.
variable
,
-
1.0
));
return
new
Constraint
(
new
Expression
(
newTerms
,
constant
),
relation
);
}
if
(
value
is
Term
)
{
var
newTerms
=
new
List
<
Term
>.
from
(
terms
)
List
<
Term
>
newTerms
=
new
List
<
Term
>.
from
(
terms
)
..
add
(
new
Term
(
value
.
variable
,
-
value
.
coefficient
));
return
new
Constraint
(
new
Expression
(
newTerms
,
constant
),
relation
);
}
if
(
value
is
Expression
)
{
var
newTerms
=
value
.
terms
.
fold
(
new
List
<
Term
>.
from
(
terms
),
(
list
,
t
)
=>
list
..
add
(
new
Term
(
t
.
variable
,
-
t
.
coefficient
)));
List
<
Term
>
newTerms
=
value
.
terms
.
fold
(
new
List
<
Term
>.
from
(
terms
),
(
List
<
Term
>
list
,
Term
t
)
{
return
list
..
add
(
new
Term
(
t
.
variable
,
-
t
.
coefficient
));
}
);
return
new
Constraint
(
new
Expression
(
newTerms
,
constant
-
value
.
constant
),
relation
);
new
Expression
(
newTerms
,
constant
-
value
.
constant
),
relation
);
}
assert
(
false
);
return
null
;
}
@override
Constraint
operator
>=(
_EquationMember
value
)
=>
_createConstraint
(
value
,
Relation
.
greaterThanOrEqualTo
);
Constraint
operator
>=(
_EquationMember
value
)
{
return
_createConstraint
(
value
,
Relation
.
greaterThanOrEqualTo
);
}
@override
Constraint
operator
<=(
_EquationMember
value
)
=>
_createConstraint
(
value
,
Relation
.
lessThanOrEqualTo
);
Constraint
operator
<=(
_EquationMember
value
)
{
return
_createConstraint
(
value
,
Relation
.
lessThanOrEqualTo
);
}
@override
Constraint
equals
(
_EquationMember
value
)
=>
_createConstraint
(
value
,
Relation
.
equalTo
);
Constraint
equals
(
_EquationMember
value
)
{
return
_createConstraint
(
value
,
Relation
.
equalTo
);
}
@override
Expression
operator
+(
_EquationMember
m
)
{
if
(
m
is
ConstantMember
)
{
return
new
Expression
(
new
List
.
from
(
terms
),
constant
+
m
.
value
);
}
if
(
m
is
ConstantMember
)
return
new
Expression
(
new
List
<
Term
>.
from
(
terms
),
constant
+
m
.
value
);
if
(
m
is
Param
)
{
return
new
Expression
(
new
List
.
from
(
terms
)..
add
(
new
Term
(
m
.
variable
,
1.0
)),
constant
);
new
List
<
Term
>.
from
(
terms
)..
add
(
new
Term
(
m
.
variable
,
1.0
)),
constant
);
}
if
(
m
is
Term
)
{
return
new
Expression
(
new
List
.
from
(
terms
)..
add
(
m
),
constant
);
}
if
(
m
is
Term
)
return
new
Expression
(
new
List
<
Term
>.
from
(
terms
)..
add
(
m
),
constant
);
if
(
m
is
Expression
)
{
return
new
Expression
(
new
List
.
from
(
terms
)..
addAll
(
m
.
terms
),
constant
+
m
.
constant
);
new
List
<
Term
>.
from
(
terms
)..
addAll
(
m
.
terms
),
constant
+
m
.
constant
);
}
assert
(
false
);
return
null
;
}
@override
Expression
operator
-(
_EquationMember
m
)
{
if
(
m
is
ConstantMember
)
{
return
new
Expression
(
new
List
.
from
(
terms
),
constant
-
m
.
value
);
}
if
(
m
is
ConstantMember
)
return
new
Expression
(
new
List
<
Term
>.
from
(
terms
),
constant
-
m
.
value
);
if
(
m
is
Param
)
{
return
new
Expression
(
new
List
.
from
(
terms
)..
add
(
new
Term
(
m
.
variable
,
-
1.0
)),
constant
);
new
List
<
Term
>.
from
(
terms
)..
add
(
new
Term
(
m
.
variable
,
-
1.0
)),
constant
);
}
if
(
m
is
Term
)
{
return
new
Expression
(
new
List
.
from
(
terms
)
return
new
Expression
(
new
List
<
Term
>
.
from
(
terms
)
..
add
(
new
Term
(
m
.
variable
,
-
m
.
coefficient
)),
constant
);
}
if
(
m
is
Expression
)
{
var
copiedTerms
=
new
List
<
Term
>.
from
(
terms
);
m
.
terms
.
forEach
(
(
t
)
=>
copiedTerms
.
add
(
new
Term
(
t
.
variable
,
-
t
.
coefficient
)
));
List
<
Term
>
copiedTerms
=
new
List
<
Term
>.
from
(
terms
);
for
(
Term
t
in
m
.
terms
)
copiedTerms
.
add
(
new
Term
(
t
.
variable
,
-
t
.
coefficient
));
return
new
Expression
(
copiedTerms
,
constant
-
m
.
constant
);
}
assert
(
false
);
return
null
;
}
_EquationMember
_applyMultiplicand
(
double
m
)
{
var
newTerms
=
terms
.
fold
(
new
List
<
Term
>(),
(
list
,
term
)
=>
list
..
add
(
new
Term
(
term
.
variable
,
term
.
coefficient
*
m
)));
List
<
Term
>
newTerms
=
terms
.
fold
(
new
List
<
Term
>(),
(
List
<
Term
>
list
,
Term
term
)
{
return
list
..
add
(
new
Term
(
term
.
variable
,
term
.
coefficient
*
m
));
}
);
return
new
Expression
(
newTerms
,
constant
*
m
);
}
...
...
@@ -127,17 +140,14 @@ class Expression extends _EquationMember {
// At least on of the the two members must be constant for the resulting
// expression to be linear
if
(!
this
.
isConstant
&&
!
m
.
isConstant
)
{
if
(!
this
.
isConstant
&&
!
m
.
isConstant
)
return
null
;
}
if
(
this
.
isConstant
)
{
return
new
_Pair
(
m
.
asExpression
(),
this
.
value
);
}
if
(
this
.
isConstant
)
return
new
_Pair
<
Expression
,
double
>(
m
.
asExpression
(),
this
.
value
);
if
(
m
.
isConstant
)
{
return
new
_Pair
(
this
.
asExpression
(),
m
.
value
);
}
if
(
m
.
isConstant
)
return
new
_Pair
<
Expression
,
double
>(
this
.
asExpression
(),
m
.
value
);
assert
(
false
);
return
null
;
...
...
@@ -148,8 +158,9 @@ class Expression extends _EquationMember {
if
(
args
==
null
)
{
throw
new
ParserException
(
'Could not find constant multiplicand or multiplier'
,
[
this
,
m
]);
return
null
;
'Could not find constant multiplicand or multiplier'
,
<
_EquationMember
>[
this
,
m
]
);
}
return
args
.
first
.
_applyMultiplicand
(
args
.
second
);
...
...
@@ -168,7 +179,7 @@ class Expression extends _EquationMember {
String
toString
()
{
StringBuffer
buffer
=
new
StringBuffer
();
terms
.
forEach
((
t
)
=>
buffer
.
write
(
'
$t
'
));
terms
.
forEach
((
Term
t
)
=>
buffer
.
write
(
'
$t
'
));
if
(
constant
!=
0.0
)
{
buffer
.
write
(
constant
.
sign
>
0.0
?
'+'
:
'-'
);
...
...
packages/cassowary/lib/param.dart
View file @
6795efac
...
...
@@ -5,19 +5,19 @@
part of
cassowary
;
class
Param
extends
_EquationMember
{
final
Variable
variable
;
dynamic
context
;
Param
([
double
value
=
0.0
])
:
variable
=
new
Variable
(
value
)
{
variable
.
_owner
=
this
;
}
Param
.
withContext
(
ctx
,
[
double
value
=
0.0
])
Param
.
withContext
(
dynamic
context
,
[
double
value
=
0.0
])
:
variable
=
new
Variable
(
value
),
context
=
ctx
{
context
=
context
{
variable
.
_owner
=
this
;
}
final
Variable
variable
;
dynamic
context
;
bool
get
isConstant
=>
false
;
double
get
value
=>
variable
.
value
;
...
...
@@ -25,5 +25,5 @@ class Param extends _EquationMember {
String
get
name
=>
variable
.
name
;
void
set
name
(
String
name
)
{
variable
.
name
=
name
;
}
Expression
asExpression
()
=>
new
Expression
([
new
Term
(
variable
,
1.0
)],
0.0
);
Expression
asExpression
()
=>
new
Expression
(
<
Term
>
[
new
Term
(
variable
,
1.0
)],
0.0
);
}
packages/cassowary/lib/row.dart
View file @
6795efac
...
...
@@ -27,7 +27,7 @@ class _Row {
void
insertRow
(
_Row
other
,
[
double
coefficient
=
1.0
])
{
constant
+=
other
.
constant
*
coefficient
;
other
.
cells
.
forEach
((
s
,
v
)
=>
insertSymbol
(
s
,
v
*
coefficient
));
other
.
cells
.
forEach
((
_Symbol
s
,
double
v
)
=>
insertSymbol
(
s
,
v
*
coefficient
));
}
void
removeSymbol
(
_Symbol
symbol
)
{
...
...
@@ -36,7 +36,7 @@ class _Row {
void
reverseSign
()
{
constant
=
-
constant
;
cells
.
forEach
((
s
,
v
)
=>
cells
[
s
]
=
-
v
);
cells
.
forEach
((
_Symbol
s
,
double
v
)
=>
cells
[
s
]
=
-
v
);
}
void
solveForSymbol
(
_Symbol
symbol
)
{
...
...
@@ -44,7 +44,7 @@ class _Row {
double
coefficient
=
-
1.0
/
cells
[
symbol
];
cells
.
remove
(
symbol
);
constant
*=
coefficient
;
cells
.
forEach
((
s
,
v
)
=>
cells
[
s
]
=
v
*
coefficient
);
cells
.
forEach
((
_Symbol
s
,
double
v
)
=>
cells
[
s
]
=
v
*
coefficient
);
}
void
solveForSymbols
(
_Symbol
lhs
,
_Symbol
rhs
)
{
...
...
@@ -70,8 +70,9 @@ class _Row {
buffer
.
write
(
constant
);
cells
.
forEach
((
symbol
,
value
)
=>
buffer
.
write
(
" + "
+
value
.
toString
()
+
" * "
+
symbol
.
toString
()));
cells
.
forEach
((
_Symbol
symbol
,
double
value
)
{
buffer
.
write
(
" + "
+
value
.
toString
()
+
" * "
+
symbol
.
toString
());
});
return
buffer
.
toString
();
}
...
...
packages/cassowary/lib/solver.dart
View file @
6795efac
...
...
@@ -89,7 +89,7 @@ class Solver {
_Symbol
leaving
=
rowPair
.
first
;
row
=
rowPair
.
second
;
var
removed
=
_rows
.
remove
(
rowPair
.
first
);
_Row
removed
=
_rows
.
remove
(
rowPair
.
first
);
assert
(
removed
!=
null
);
row
.
solveForSymbols
(
leaving
,
tag
.
marker
);
_substitute
(
tag
.
marker
,
row
);
...
...
@@ -170,8 +170,8 @@ class Solver {
return
_dualOptimize
();
}
Set
flushUpdates
()
{
Set
updates
=
new
HashSet
<
dynamic
>();
Set
<
dynamic
>
flushUpdates
()
{
Set
<
dynamic
>
updates
=
new
HashSet
<
dynamic
>();
for
(
Variable
variable
in
_vars
.
keys
)
{
_Symbol
symbol
=
_vars
[
variable
];
...
...
@@ -189,10 +189,12 @@ class Solver {
return
updates
;
}
Result
_bulkEdit
(
Iterable
items
,
Result
_bulkEdit
(
Iterable
<
dynamic
>
items
,
_SolverBulkUpdate
applier
,
_SolverBulkUpdate
undoer
)
{
List
applied
=
new
List
();
_SolverBulkUpdate
undoer
)
{
List
<
dynamic
>
applied
=
<
dynamic
>[];
bool
needsCleanup
=
false
;
Result
result
=
Result
.
success
;
...
...
@@ -231,7 +233,7 @@ class Solver {
Expression
expr
=
new
Expression
.
fromExpression
(
constraint
.
expression
);
_Row
row
=
new
_Row
(
expr
.
constant
);
expr
.
terms
.
forEach
((
term
)
{
expr
.
terms
.
forEach
((
Term
term
)
{
if
(!
_nearZero
(
term
.
coefficient
))
{
_Symbol
symbol
=
_symbolForVariable
(
term
.
variable
);
...
...
@@ -397,9 +399,9 @@ class Solver {
_Pair
<
_Symbol
,
_Row
>
_leavingRowForEnteringSymbol
(
_Symbol
entering
)
{
double
ratio
=
double
.
MAX_FINITE
;
_Pair
<
_Symbol
,
_Row
>
result
=
new
_Pair
(
null
,
null
);
_Pair
<
_Symbol
,
_Row
>
result
=
new
_Pair
<
_Symbol
,
_Row
>
(
null
,
null
);
_rows
.
forEach
((
symbol
,
row
)
{
_rows
.
forEach
((
_Symbol
symbol
,
_Row
row
)
{
if
(
symbol
.
type
!=
_SymbolType
.
external
)
{
double
temp
=
row
.
coefficientForSymbol
(
entering
);
...
...
@@ -423,7 +425,7 @@ class Solver {
}
void
_substitute
(
_Symbol
symbol
,
_Row
row
)
{
_rows
.
forEach
((
first
,
second
)
{
_rows
.
forEach
((
_Symbol
first
,
_Row
second
)
{
second
.
substitute
(
symbol
,
row
);
if
(
first
.
type
!=
_SymbolType
.
external
&&
second
.
constant
<
0.0
)
{
_infeasibleRows
.
add
(
first
);
...
...
@@ -470,7 +472,7 @@ class Solver {
_Pair
<
_Symbol
,
_Row
>
first
,
second
,
third
;
_rows
.
forEach
((
symbol
,
row
)
{
_rows
.
forEach
((
_Symbol
symbol
,
_Row
row
)
{
double
c
=
row
.
coefficientForSymbol
(
marker
);
if
(
c
==
0.0
)
{
...
...
@@ -478,18 +480,18 @@ class Solver {
}
if
(
symbol
.
type
==
_SymbolType
.
external
)
{
third
=
new
_Pair
(
symbol
,
row
);
third
=
new
_Pair
<
_Symbol
,
_Row
>
(
symbol
,
row
);
}
else
if
(
c
<
0.0
)
{
double
r
=
-
row
.
constant
/
c
;
if
(
r
<
r1
)
{
r1
=
r
;
first
=
new
_Pair
(
symbol
,
row
);
first
=
new
_Pair
<
_Symbol
,
_Row
>
(
symbol
,
row
);
}
}
else
{
double
r
=
row
.
constant
/
c
;
if
(
r
<
r2
)
{
r2
=
r
;
second
=
new
_Pair
(
symbol
,
row
);
second
=
new
_Pair
<
_Symbol
,
_Row
>
(
symbol
,
row
);
}
}
});
...
...
@@ -596,28 +598,33 @@ class Solver {
// Tableau
buffer
.
writeln
(
separator
+
" Tableau"
);
_rows
.
forEach
((
symbol
,
row
)
{
buffer
.
write
(
symbol
.
toString
());
buffer
.
write
(
" | "
);
buffer
.
writeln
(
row
.
toString
());
_rows
.
forEach
((
_Symbol
symbol
,
_Row
row
)
{
buffer
.
writeln
(
'
$symbol
|
$row
'
);
});
// Infeasible
buffer
.
writeln
(
separator
+
" Infeasible"
);
_infeasibleRows
.
forEach
((
symbol
)
=>
buffer
.
writeln
(
symbol
.
toString
()));
_infeasibleRows
.
forEach
((
_Symbol
symbol
)
{
buffer
.
writeln
(
symbol
);
});
// Variables
buffer
.
writeln
(
separator
+
" Variables"
);
_vars
.
forEach
((
variable
,
symbol
)
=>
buffer
.
writeln
(
"
${variable.toString()}
=
${symbol.toString()}
"
));
_vars
.
forEach
((
Variable
variable
,
_Symbol
symbol
)
{
buffer
.
writeln
(
'
$variable
=
$symbol
'
);
});
// Edit Variables
buffer
.
writeln
(
separator
+
" Edit Variables"
);
_edits
.
forEach
((
variable
,
editinfo
)
=>
buffer
.
writeln
(
variable
));
_edits
.
forEach
((
Variable
variable
,
_EditInfo
editinfo
)
{
buffer
.
writeln
(
variable
);
});
// Constraints
buffer
.
writeln
(
separator
+
" Constraints"
);
_constraints
.
forEach
((
constraint
,
_
)
=>
buffer
.
writeln
(
constraint
));
_constraints
.
forEach
((
Constraint
constraint
,
_Tag
tag
)
{
buffer
.
writeln
(
constraint
);
});
return
buffer
.
toString
();
}
...
...
packages/cassowary/test/cassowary_test.dart
View file @
6795efac
...
...
@@ -10,34 +10,34 @@ import 'package:cassowary/cassowary.dart';
void
main
(
)
{
test
(
'variable'
,
()
{
var
v
=
new
Param
(
22.0
);
Param
v
=
new
Param
(
22.0
);
expect
(
v
.
value
,
22
);
});
test
(
'variable1'
,
()
{
var
v
=
new
Param
(
22.0
);
Param
v
=
new
Param
(
22.0
);
expect
((
v
+
cm
(
22.0
)).
value
,
44.0
);
expect
((
v
-
cm
(
20.0
)).
value
,
2.0
);
});
test
(
'term'
,
()
{
var
t
=
new
Term
(
new
Variable
(
22.0
),
2.0
);
Term
t
=
new
Term
(
new
Variable
(
22.0
),
2.0
);
expect
(
t
.
value
,
44
);
});
test
(
'expression'
,
()
{
var
terms
=
[
List
<
Term
>
terms
=
<
Term
>
[
new
Term
(
new
Variable
(
22.0
),
2.0
),
new
Term
(
new
Variable
(
1.0
),
1.0
),
];
var
e
=
new
Expression
(
terms
,
40.0
);
Expression
e
=
new
Expression
(
terms
,
40.0
);
expect
(
e
.
value
,
85.0
);
});
test
(
'expression1'
,
()
{
var
v1
=
new
Param
(
10.0
);
var
v2
=
new
Param
(
10.0
);
var
v3
=
new
Param
(
22.0
);
Param
v1
=
new
Param
(
10.0
);
Param
v2
=
new
Param
(
10.0
);
Param
v3
=
new
Param
(
22.0
);
expect
(
v1
is
Param
,
true
);
expect
(
v1
+
cm
(
20.0
)
is
Expression
,
true
);
...
...
@@ -51,7 +51,7 @@ void main() {
});
test
(
'expression2'
,
()
{
var
e
=
new
Param
(
10.0
)
+
cm
(
5.0
);
Expression
e
=
new
Param
(
10.0
)
+
cm
(
5.0
);
expect
(
e
.
value
,
15.0
);
expect
(
e
is
Expression
,
true
);
...
...
@@ -64,7 +64,7 @@ void main() {
expect
(
e
.
value
,
15.0
);
// Param
var
v
=
new
Param
(
2.0
);
Param
v
=
new
Param
(
2.0
);
expect
((
e
+
v
)
is
Expression
,
true
);
expect
((
e
+
v
).
value
,
17.0
);
expect
((
e
-
v
)
is
Expression
,
true
);
...
...
@@ -73,7 +73,7 @@ void main() {
expect
(
e
.
value
,
15.0
);
// Term
var
t
=
new
Term
(
v
.
variable
,
2.0
);
Term
t
=
new
Term
(
v
.
variable
,
2.0
);
expect
((
e
+
t
)
is
Expression
,
true
);
expect
((
e
+
t
).
value
,
19.0
);
expect
((
e
-
t
)
is
Expression
,
true
);
...
...
@@ -82,7 +82,7 @@ void main() {
expect
(
e
.
value
,
15.0
);
// Expression
var
e2
=
new
Param
(
7.0
)
+
new
Param
(
3.0
);
Expression
e2
=
new
Param
(
7.0
)
+
new
Param
(
3.0
);
expect
((
e
+
e2
)
is
Expression
,
true
);
expect
((
e
+
e2
).
value
,
25.0
);
expect
((
e
-
e2
)
is
Expression
,
true
);
...
...
@@ -92,31 +92,31 @@ void main() {
});
test
(
'term2'
,
()
{
var
t
=
new
Term
(
new
Variable
(
12.0
),
1.0
);
Term
t
=
new
Term
(
new
Variable
(
12.0
),
1.0
);
// Constant
va
r
c
=
cm
(
2.0
);
ConstantMembe
r
c
=
cm
(
2.0
);
expect
((
t
+
c
)
is
Expression
,
true
);
expect
((
t
+
c
).
value
,
14.0
);
expect
((
t
-
c
)
is
Expression
,
true
);
expect
((
t
-
c
).
value
,
10.0
);
// Variable
var
v
=
new
Param
(
2.0
);
Param
v
=
new
Param
(
2.0
);
expect
((
t
+
v
)
is
Expression
,
true
);
expect
((
t
+
v
).
value
,
14.0
);
expect
((
t
-
v
)
is
Expression
,
true
);
expect
((
t
-
v
).
value
,
10.0
);
// Term
var
t2
=
new
Term
(
new
Variable
(
1.0
),
2.0
);
Term
t2
=
new
Term
(
new
Variable
(
1.0
),
2.0
);
expect
((
t
+
t2
)
is
Expression
,
true
);
expect
((
t
+
t2
).
value
,
14.0
);
expect
((
t
-
t2
)
is
Expression
,
true
);
expect
((
t
-
t2
).
value
,
10.0
);
// Expression
var
exp
=
new
Param
(
1.0
)
+
cm
(
1.0
);
Expression
exp
=
new
Param
(
1.0
)
+
cm
(
1.0
);
expect
((
t
+
exp
)
is
Expression
,
true
);
expect
((
t
+
exp
).
value
,
14.0
);
expect
((
t
-
exp
)
is
Expression
,
true
);
...
...
@@ -124,31 +124,31 @@ void main() {
});
test
(
'variable3'
,
()
{
var
v
=
new
Param
(
3.0
);
Param
v
=
new
Param
(
3.0
);
// Constant
va
r
c
=
cm
(
2.0
);
ConstantMembe
r
c
=
cm
(
2.0
);
expect
((
v
+
c
)
is
Expression
,
true
);
expect
((
v
+
c
).
value
,
5.0
);
expect
((
v
-
c
)
is
Expression
,
true
);
expect
((
v
-
c
).
value
,
1.0
);
// Variable
var
v2
=
new
Param
(
2.0
);
Param
v2
=
new
Param
(
2.0
);
expect
((
v
+
v2
)
is
Expression
,
true
);
expect
((
v
+
v2
).
value
,
5.0
);
expect
((
v
-
v2
)
is
Expression
,
true
);
expect
((
v
-
v2
).
value
,
1.0
);
// Term
var
t2
=
new
Term
(
new
Variable
(
1.0
),
2.0
);
Term
t2
=
new
Term
(
new
Variable
(
1.0
),
2.0
);
expect
((
v
+
t2
)
is
Expression
,
true
);
expect
((
v
+
t2
).
value
,
5.0
);
expect
((
v
-
t2
)
is
Expression
,
true
);
expect
((
v
-
t2
).
value
,
1.0
);
// Expression
var
exp
=
new
Param
(
1.0
)
+
cm
(
1.0
);
Expression
exp
=
new
Param
(
1.0
)
+
cm
(
1.0
);
expect
(
exp
.
terms
.
length
,
1
);
expect
((
v
+
exp
)
is
Expression
,
true
);
...
...
@@ -158,31 +158,31 @@ void main() {
});
test
(
'constantmember'
,
()
{
va
r
c
=
cm
(
3.0
);
ConstantMembe
r
c
=
cm
(
3.0
);
// Constant
va
r
c2
=
cm
(
2.0
);
ConstantMembe
r
c2
=
cm
(
2.0
);
expect
((
c
+
c2
)
is
Expression
,
true
);
expect
((
c
+
c2
).
value
,
5.0
);
expect
((
c
-
c2
)
is
Expression
,
true
);
expect
((
c
-
c2
).
value
,
1.0
);
// Variable
var
v2
=
new
Param
(
2.0
);
Param
v2
=
new
Param
(
2.0
);
expect
((
c
+
v2
)
is
Expression
,
true
);
expect
((
c
+
v2
).
value
,
5.0
);
expect
((
c
-
v2
)
is
Expression
,
true
);
expect
((
c
-
v2
).
value
,
1.0
);
// Term
var
t2
=
new
Term
(
new
Variable
(
1.0
),
2.0
);
Term
t2
=
new
Term
(
new
Variable
(
1.0
),
2.0
);
expect
((
c
+
t2
)
is
Expression
,
true
);
expect
((
c
+
t2
).
value
,
5.0
);
expect
((
c
-
t2
)
is
Expression
,
true
);
expect
((
c
-
t2
).
value
,
1.0
);
// Expression
var
exp
=
new
Param
(
1.0
)
+
cm
(
1.0
);
Expression
exp
=
new
Param
(
1.0
)
+
cm
(
1.0
);
expect
((
c
+
exp
)
is
Expression
,
true
);
expect
((
c
+
exp
).
value
,
5.0
);
...
...
@@ -191,74 +191,74 @@ void main() {
});
test
(
'constraint2'
,
()
{
var
left
=
new
Param
(
10.0
);
var
right
=
new
Param
(
100.0
);
Param
left
=
new
Param
(
10.0
);
Param
right
=
new
Param
(
100.0
);
var
c
=
right
-
left
>=
cm
(
25.0
);
Constraint
c
=
right
-
left
>=
cm
(
25.0
);
expect
(
c
is
Constraint
,
true
);
});
test
(
'simple_multiplication'
,
()
{
// Constant
va
r
c
=
cm
(
20.0
);
ConstantMembe
r
c
=
cm
(
20.0
);
expect
((
c
*
cm
(
2.0
)).
value
,
40.0
);
// Variable
var
v
=
new
Param
(
20.0
);
Param
v
=
new
Param
(
20.0
);
expect
((
v
*
cm
(
2.0
)).
value
,
40.0
);
// Term
var
t
=
new
Term
(
v
.
variable
,
1.0
);
Term
t
=
new
Term
(
v
.
variable
,
1.0
);
expect
((
t
*
cm
(
2.0
)).
value
,
40.0
);
// Expression
var
e
=
new
Expression
([
t
],
0.0
);
Expression
e
=
new
Expression
([
t
],
0.0
);
expect
((
e
*
cm
(
2.0
)).
value
,
40.0
);
});
test
(
'simple_division'
,
()
{
// Constant
va
r
c
=
cm
(
20.0
);
ConstantMembe
r
c
=
cm
(
20.0
);
expect
((
c
/
cm
(
2.0
)).
value
,
10.0
);
// Variable
var
v
=
new
Param
(
20.0
);
Param
v
=
new
Param
(
20.0
);
expect
((
v
/
cm
(
2.0
)).
value
,
10.0
);
// Term
var
t
=
new
Term
(
v
.
variable
,
1.0
);
Term
t
=
new
Term
(
v
.
variable
,
1.0
);
expect
((
t
/
cm
(
2.0
)).
value
,
10.0
);
// Expression
var
e
=
new
Expression
([
t
],
0.0
);
Expression
e
=
new
Expression
([
t
],
0.0
);
expect
((
e
/
cm
(
2.0
)).
value
,
10.0
);
});
test
(
'full_constraints_setup'
,
()
{
var
left
=
new
Param
(
2.0
);
var
right
=
new
Param
(
10.0
);
Param
left
=
new
Param
(
2.0
);
Param
right
=
new
Param
(
10.0
);
var
c1
=
right
-
left
>=
cm
(
20.0
);
Constraint
c1
=
right
-
left
>=
cm
(
20.0
);
expect
(
c1
is
Constraint
,
true
);
expect
(
c1
.
expression
.
constant
,
-
20.0
);
expect
(
c1
.
relation
,
Relation
.
greaterThanOrEqualTo
);
var
c2
=
(
right
-
left
).
equals
(
cm
(
30.0
));
Constraint
c2
=
(
right
-
left
).
equals
(
cm
(
30.0
));
expect
(
c2
is
Constraint
,
true
);
expect
(
c2
.
expression
.
constant
,
-
30.0
);
expect
(
c2
.
relation
,
Relation
.
equalTo
);
var
c3
=
right
-
left
<=
cm
(
30.0
);
Constraint
c3
=
right
-
left
<=
cm
(
30.0
);
expect
(
c3
is
Constraint
,
true
);
expect
(
c3
.
expression
.
constant
,
-
30.0
);
expect
(
c3
.
relation
,
Relation
.
lessThanOrEqualTo
);
});
test
(
'constraint_strength_update'
,
()
{
var
left
=
new
Param
(
2.0
);
var
right
=
new
Param
(
10.0
);
Param
left
=
new
Param
(
2.0
);
Param
right
=
new
Param
(
10.0
);
var
c
=
(
right
-
left
>=
cm
(
200.0
))
|
750.0
;
Constraint
c
=
(
right
-
left
>=
cm
(
200.0
))
|
750.0
;
expect
(
c
is
Constraint
,
true
);
expect
(
c
.
expression
.
terms
.
length
,
2
);
expect
(
c
.
expression
.
constant
,
-
200.0
);
...
...
@@ -266,12 +266,12 @@ void main() {
});
test
(
'solver'
,
()
{
va
r
s
=
new
Solver
();
Solve
r
s
=
new
Solver
();
var
left
=
new
Param
(
2.0
);
var
right
=
new
Param
(
100.0
);
Param
left
=
new
Param
(
2.0
);
Param
right
=
new
Param
(
100.0
);
var
c1
=
right
-
left
>=
cm
(
200.0
);
Constraint
c1
=
right
-
left
>=
cm
(
200.0
);
expect
((
right
>=
left
)
is
Constraint
,
true
);
...
...
@@ -279,28 +279,28 @@ void main() {
});
test
(
'constraint_complex'
,
()
{
var
e
=
new
Param
(
200.0
)
-
new
Param
(
100.0
);
Expression
e
=
new
Param
(
200.0
)
-
new
Param
(
100.0
);
// Constant
var
c1
=
e
>=
cm
(
50.0
);
Constraint
c1
=
e
>=
cm
(
50.0
);
expect
(
c1
is
Constraint
,
true
);
expect
(
c1
.
expression
.
terms
.
length
,
2
);
expect
(
c1
.
expression
.
constant
,
-
50.0
);
// Variable
var
c2
=
e
>=
new
Param
(
2.0
);
Constraint
c2
=
e
>=
new
Param
(
2.0
);
expect
(
c2
is
Constraint
,
true
);
expect
(
c2
.
expression
.
terms
.
length
,
3
);
expect
(
c2
.
expression
.
constant
,
0.0
);
// Term
var
c3
=
e
>=
new
Term
(
new
Variable
(
2.0
),
1.0
);
Constraint
c3
=
e
>=
new
Term
(
new
Variable
(
2.0
),
1.0
);
expect
(
c3
is
Constraint
,
true
);
expect
(
c3
.
expression
.
terms
.
length
,
3
);
expect
(
c3
.
expression
.
constant
,
0.0
);
// Expression
var
c4
=
e
>=
new
Expression
([
new
Term
(
new
Variable
(
2.0
),
1.0
)],
20.0
);
Constraint
c4
=
e
>=
new
Expression
([
new
Term
(
new
Variable
(
2.0
),
1.0
)],
20.0
);
expect
(
c4
is
Constraint
,
true
);
expect
(
c4
.
expression
.
terms
.
length
,
3
);
expect
(
c4
.
expression
.
constant
,
-
20.0
);
...
...
@@ -308,40 +308,40 @@ void main() {
test
(
'constraint_complex_non_exprs'
,
()
{
// Constant
var
c1
=
cm
(
100.0
)
>=
cm
(
50.0
);
Constraint
c1
=
cm
(
100.0
)
>=
cm
(
50.0
);
expect
(
c1
is
Constraint
,
true
);
expect
(
c1
.
expression
.
terms
.
length
,
0
);
expect
(
c1
.
expression
.
constant
,
50.0
);
// Variable
var
c2
=
new
Param
(
100.0
)
>=
new
Param
(
2.0
);
Constraint
c2
=
new
Param
(
100.0
)
>=
new
Param
(
2.0
);
expect
(
c2
is
Constraint
,
true
);
expect
(
c2
.
expression
.
terms
.
length
,
2
);
expect
(
c2
.
expression
.
constant
,
0.0
);
// Term
var
t
=
new
Term
(
new
Variable
(
100.0
),
1.0
);
var
c3
=
t
>=
new
Term
(
new
Variable
(
2.0
),
1.0
);
Term
t
=
new
Term
(
new
Variable
(
100.0
),
1.0
);
Constraint
c3
=
t
>=
new
Term
(
new
Variable
(
2.0
),
1.0
);
expect
(
c3
is
Constraint
,
true
);
expect
(
c3
.
expression
.
terms
.
length
,
2
);
expect
(
c3
.
expression
.
constant
,
0.0
);
// Expression
var
e
=
new
Expression
([
t
],
0.0
);
var
c4
=
e
>=
new
Expression
([
new
Term
(
new
Variable
(
2.0
),
1.0
)],
20.0
);
Expression
e
=
new
Expression
([
t
],
0.0
);
Constraint
c4
=
e
>=
new
Expression
([
new
Term
(
new
Variable
(
2.0
),
1.0
)],
20.0
);
expect
(
c4
is
Constraint
,
true
);
expect
(
c4
.
expression
.
terms
.
length
,
2
);
expect
(
c4
.
expression
.
constant
,
-
20.0
);
});
test
(
'constraint_update_in_solver'
,
()
{
va
r
s
=
new
Solver
();
Solve
r
s
=
new
Solver
();
var
left
=
new
Param
(
2.0
);
var
right
=
new
Param
(
100.0
);
Param
left
=
new
Param
(
2.0
);
Param
right
=
new
Param
(
100.0
);
var
c1
=
right
-
left
>=
cm
(
200.0
);
var
c2
=
right
>=
right
;
Constraint
c1
=
right
-
left
>=
cm
(
200.0
);
Constraint
c2
=
right
>=
right
;
expect
(
s
.
addConstraint
(
c1
),
Result
.
success
);
expect
(
s
.
addConstraint
(
c1
),
Result
.
duplicateConstraint
);
...
...
@@ -351,10 +351,10 @@ void main() {
});
test
(
'test_multiplication_division_override'
,
()
{
va
r
c
=
cm
(
10.0
);
var
v
=
new
Param
(
c
.
value
);
var
t
=
new
Term
(
v
.
variable
,
1.0
);
var
e
=
new
Expression
([
t
],
0.0
);
ConstantMembe
r
c
=
cm
(
10.0
);
Param
v
=
new
Param
(
c
.
value
);
Term
t
=
new
Term
(
v
.
variable
,
1.0
);
Expression
e
=
new
Expression
([
t
],
0.0
);
// Constant
expect
((
c
*
cm
(
10.0
)).
value
,
100
);
...
...
@@ -382,10 +382,10 @@ void main() {
});
test
(
'test_multiplication_division_exceptions'
,
()
{
va
r
c
=
cm
(
10.0
);
var
v
=
new
Param
(
c
.
value
);
var
t
=
new
Term
(
v
.
variable
,
1.0
);
var
e
=
new
Expression
([
t
],
0.0
);
ConstantMembe
r
c
=
cm
(
10.0
);
Param
v
=
new
Param
(
c
.
value
);
Term
t
=
new
Term
(
v
.
variable
,
1.0
);
Expression
e
=
new
Expression
([
t
],
0.0
);
expect
((
c
*
c
).
value
,
100
);
expect
(()
=>
v
*
v
,
throwsA
(
new
isInstanceOf
<
ParserException
>()));
...
...
@@ -401,9 +401,9 @@ void main() {
test
(
'edit_updates'
,
()
{
Solver
s
=
new
Solver
();
var
left
=
new
Param
(
0.0
);
var
right
=
new
Param
(
100.0
);
var
mid
=
new
Param
(
0.0
);
Param
left
=
new
Param
(
0.0
);
Param
right
=
new
Param
(
100.0
);
Param
mid
=
new
Param
(
0.0
);
Constraint
c
=
left
+
right
>=
cm
(
2.0
)
*
mid
;
expect
(
s
.
addConstraint
(
c
),
Result
.
success
);
...
...
@@ -416,15 +416,15 @@ void main() {
});
test
(
'bug1'
,
()
{
var
left
=
new
Param
(
0.0
);
var
right
=
new
Param
(
100.0
);
var
mid
=
new
Param
(
0.0
);
Param
left
=
new
Param
(
0.0
);
Param
right
=
new
Param
(
100.0
);
Param
mid
=
new
Param
(
0.0
);
expect
(((
left
+
right
)
>=
(
cm
(
2.0
)
*
mid
))
is
Constraint
,
true
);
});
test
(
'single_item'
,
()
{
var
left
=
new
Param
(-
20.0
);
Param
left
=
new
Param
(-
20.0
);
Solver
s
=
new
Solver
();
s
.
addConstraint
(
left
>=
cm
(
0.0
));
s
.
flushUpdates
();
...
...
@@ -432,9 +432,9 @@ void main() {
});
test
(
'midpoints'
,
()
{
var
left
=
new
Param
(
0.0
)..
name
=
"left"
;
var
right
=
new
Param
(
0.0
)..
name
=
"right"
;
var
mid
=
new
Param
(
0.0
)..
name
=
"mid"
;
Param
left
=
new
Param
(
0.0
)..
name
=
"left"
;
Param
right
=
new
Param
(
0.0
)..
name
=
"right"
;
Param
mid
=
new
Param
(
0.0
)..
name
=
"mid"
;
Solver
s
=
new
Solver
();
...
...
@@ -451,13 +451,13 @@ void main() {
});
test
(
'addition_of_multiple'
,
()
{
var
left
=
new
Param
(
0.0
);
var
right
=
new
Param
(
0.0
);
var
mid
=
new
Param
(
0.0
);
Param
left
=
new
Param
(
0.0
);
Param
right
=
new
Param
(
0.0
);
Param
mid
=
new
Param
(
0.0
);
Solver
s
=
new
Solver
();
var
c
=
(
left
>=
cm
(
0.0
));
Constraint
c
=
(
left
>=
cm
(
0.0
));
expect
(
s
.
addConstraints
([
(
left
+
right
).
equals
(
cm
(
2.0
)
*
mid
),
...
...
@@ -470,9 +470,9 @@ void main() {
});
test
(
'edit_constraints'
,
()
{
var
left
=
new
Param
(
0.0
)..
name
=
"left"
;
var
right
=
new
Param
(
0.0
)..
name
=
"right"
;
var
mid
=
new
Param
(
0.0
)..
name
=
"mid"
;
Param
left
=
new
Param
(
0.0
)..
name
=
"left"
;
Param
right
=
new
Param
(
0.0
)..
name
=
"right"
;
Param
mid
=
new
Param
(
0.0
)..
name
=
"mid"
;
Solver
s
=
new
Solver
();
...
...
@@ -492,11 +492,11 @@ void main() {
});
test
(
'test_description'
,
()
{
var
left
=
new
Param
(
0.0
);
var
right
=
new
Param
(
100.0
);
var
c1
=
right
>=
left
;
var
c2
=
right
<=
left
;
var
c3
=
right
.
equals
(
left
);
Param
left
=
new
Param
(
0.0
);
Param
right
=
new
Param
(
100.0
);
Constraint
c1
=
right
>=
left
;
Constraint
c2
=
right
<=
left
;
Constraint
c3
=
right
.
equals
(
left
);
Solver
s
=
new
Solver
();
expect
(
s
.
addConstraint
(
c1
),
Result
.
success
);
...
...
@@ -547,7 +547,7 @@ void main() {
expect
(
s
.
suggestValueForVariable
(
mid
.
variable
,
50.0
),
Result
.
success
);
var
updates
=
s
.
flushUpdates
();
Set
<
dynamic
>
updates
=
s
.
flushUpdates
();
expect
(
updates
.
length
,
2
);
...
...
@@ -571,7 +571,7 @@ void main() {
expect
(
s
.
suggestValueForVariable
(
mid
.
variable
,
50.0
),
Result
.
success
);
var
updates
=
s
.
flushUpdates
();
Set
<
dynamic
>
updates
=
s
.
flushUpdates
();
expect
(
updates
.
length
,
1
);
...
...
@@ -581,7 +581,7 @@ void main() {
});
test
(
'param_context_non_final'
,
()
{
var
p
=
new
Param
.
withContext
(
"a"
);
Param
p
=
new
Param
.
withContext
(
"a"
);
p
.
context
=
"b"
;
expect
(
p
.
context
,
"b"
);
});
...
...
@@ -596,9 +596,9 @@ void main() {
test
(
'bulk_add_edit_variables'
,
()
{
Solver
s
=
new
Solver
();
var
left
=
new
Param
(
0.0
);
var
right
=
new
Param
(
100.0
);
var
mid
=
new
Param
(
0.0
);
Param
left
=
new
Param
(
0.0
);
Param
right
=
new
Param
(
100.0
);
Param
mid
=
new
Param
(
0.0
);
expect
(
s
.
addEditVariables
(
[
left
.
variable
,
right
.
variable
,
mid
.
variable
],
999.0
),
Result
.
success
);
...
...
@@ -607,15 +607,15 @@ void main() {
test
(
'bulk_remove_constraints_and_variables'
,
()
{
Solver
s
=
new
Solver
();
var
left
=
new
Param
(
0.0
);
var
right
=
new
Param
(
100.0
);
var
mid
=
new
Param
(
0.0
);
Param
left
=
new
Param
(
0.0
);
Param
right
=
new
Param
(
100.0
);
Param
mid
=
new
Param
(
0.0
);
expect
(
s
.
addEditVariables
(
[
left
.
variable
,
right
.
variable
,
mid
.
variable
],
999.0
),
Result
.
success
);
var
c1
=
left
<=
mid
;
var
c2
=
mid
<=
right
;
Constraint
c1
=
left
<=
mid
;
Constraint
c2
=
mid
<=
right
;
expect
(
s
.
addConstraints
([
c1
,
c2
]),
Result
.
success
);
...
...
packages/flutter/lib/src/animation/animation_controller.dart
View file @
6795efac
...
...
@@ -125,7 +125,7 @@ class AnimationController extends Animation<double>
}
/// Starts running this animation forwards (towards the end).
Future
forward
({
double
from
})
{
Future
<
Null
>
forward
({
double
from
})
{
if
(
from
!=
null
)
value
=
from
;
_direction
=
_AnimationDirection
.
forward
;
...
...
@@ -133,7 +133,7 @@ class AnimationController extends Animation<double>
}
/// Starts running this animation in reverse (towards the beginning).
Future
reverse
({
double
from
})
{
Future
<
Null
>
reverse
({
double
from
})
{
if
(
from
!=
null
)
value
=
from
;
_direction
=
_AnimationDirection
.
reverse
;
...
...
@@ -141,7 +141,7 @@ class AnimationController extends Animation<double>
}
/// Drives the animation from its current value to target.
Future
animateTo
(
double
target
,
{
Duration
duration
,
Curve
curve:
Curves
.
linear
})
{
Future
<
Null
>
animateTo
(
double
target
,
{
Duration
duration
,
Curve
curve:
Curves
.
linear
})
{
Duration
simulationDuration
=
duration
;
if
(
simulationDuration
==
null
)
{
double
range
=
upperBound
-
lowerBound
;
...
...
@@ -152,7 +152,7 @@ class AnimationController extends Animation<double>
if
(
simulationDuration
==
Duration
.
ZERO
)
{
assert
(
value
==
target
);
_checkStatusChanged
();
return
new
Future
.
value
();
return
new
Future
<
Null
>
.
value
();
}
assert
(
simulationDuration
>
Duration
.
ZERO
);
assert
(!
isAnimating
);
...
...
@@ -163,7 +163,7 @@ class AnimationController extends Animation<double>
/// restarts the animation when it completes.
///
/// Defaults to repeating between the lower and upper bounds.
Future
repeat
({
double
min
,
double
max
,
Duration
period
})
{
Future
<
Null
>
repeat
({
double
min
,
double
max
,
Duration
period
})
{
min
??=
lowerBound
;
max
??=
upperBound
;
period
??=
duration
;
...
...
@@ -173,24 +173,24 @@ class AnimationController extends Animation<double>
/// Flings the timeline with an optional force (defaults to a critically
/// damped spring) and initial velocity. If velocity is positive, the
/// animation will complete, otherwise it will dismiss.
Future
fling
({
double
velocity:
1.0
,
Force
force
})
{
Future
<
Null
>
fling
({
double
velocity:
1.0
,
Force
force
})
{
force
??=
kDefaultSpringForce
;
_direction
=
velocity
<
0.0
?
_AnimationDirection
.
reverse
:
_AnimationDirection
.
forward
;
return
animateWith
(
force
.
release
(
value
,
velocity
));
}
/// Drives the animation according to the given simulation.
Future
animateWith
(
Simulation
simulation
)
{
Future
<
Null
>
animateWith
(
Simulation
simulation
)
{
stop
();
return
_startSimulation
(
simulation
);
}
Future
_startSimulation
(
Simulation
simulation
)
{
Future
<
Null
>
_startSimulation
(
Simulation
simulation
)
{
assert
(
simulation
!=
null
);
assert
(!
isAnimating
);
_simulation
=
simulation
;
_value
=
simulation
.
x
(
0.0
).
clamp
(
lowerBound
,
upperBound
);
Future
result
=
_ticker
.
start
();
Future
<
Null
>
result
=
_ticker
.
start
();
_checkStatusChanged
();
return
result
;
}
...
...
packages/flutter/lib/src/http/http.dart
View file @
6795efac
...
...
@@ -145,6 +145,6 @@ Future<Uint8List> readBytes(dynamic url, { Map<String, String> headers }) {
return
_withClient
/*<Uint8List>*/
((
MojoClient
client
)
=>
client
.
readBytes
(
url
,
headers:
headers
));
}
Future
/*<T>*/
_withClient
/*<T>*/
(
Future
/*<T>*/
fn
(
MojoClient
client
))
{
Future
<
dynamic
/*=T*/
>
_withClient
/*<T>*/
(
Future
<
dynamic
/*=T*/
>
fn
(
MojoClient
client
))
{
return
fn
(
new
MojoClient
());
}
packages/flutter/lib/src/material/app.dart
View file @
6795efac
...
...
@@ -45,7 +45,7 @@ class MaterialApp extends WidgetsApp {
onGenerateRoute:
(
RouteSettings
settings
)
{
RouteBuilder
builder
=
routes
[
settings
.
name
];
if
(
builder
!=
null
)
{
return
new
MaterialPageRoute
(
return
new
MaterialPageRoute
<
Null
>
(
builder:
(
BuildContext
context
)
{
return
builder
(
new
RouteArguments
(
context:
context
));
},
...
...
packages/flutter/lib/src/material/bottom_sheet.dart
View file @
6795efac
...
...
@@ -44,7 +44,7 @@ class BottomSheet extends StatefulComponent {
class
_BottomSheetState
extends
State
<
BottomSheet
>
{
final
_childKey
=
new
GlobalKey
(
debugLabel:
'BottomSheet child'
);
final
GlobalKey
_childKey
=
new
GlobalKey
(
debugLabel:
'BottomSheet child'
);
double
get
_childHeight
{
final
RenderBox
renderBox
=
_childKey
.
currentContext
.
findRenderObject
();
...
...
@@ -117,15 +117,15 @@ class _ModalBottomSheetLayout extends OneChildLayoutDelegate {
}
}
class
_ModalBottomSheet
extends
StatefulComponent
{
class
_ModalBottomSheet
<
T
>
extends
StatefulComponent
{
_ModalBottomSheet
({
Key
key
,
this
.
route
})
:
super
(
key:
key
);
final
_ModalBottomSheetRoute
route
;
final
_ModalBottomSheetRoute
<
T
>
route
;
_ModalBottomSheetState
createState
()
=>
new
_ModalBottomSheetState
();
_ModalBottomSheetState
<
T
>
createState
()
=>
new
_ModalBottomSheetState
<
T
>
();
}
class
_ModalBottomSheetState
extends
State
<
_ModalBottomSheet
>
{
class
_ModalBottomSheetState
<
T
>
extends
State
<
_ModalBottomSheet
<
T
>
>
{
Widget
build
(
BuildContext
context
)
{
return
new
GestureDetector
(
onTap:
()
=>
Navigator
.
pop
(
context
),
...
...
@@ -165,15 +165,15 @@ class _ModalBottomSheetRoute<T> extends PopupRoute<T> {
}
Widget
buildPage
(
BuildContext
context
,
Animation
<
double
>
animation
,
Animation
<
double
>
forwardAnimation
)
{
return
new
_ModalBottomSheet
(
route:
this
);
return
new
_ModalBottomSheet
<
T
>
(
route:
this
);
}
}
Future
showModalBottomSheet
(
{
BuildContext
context
,
WidgetBuilder
builder
})
{
Future
<
dynamic
/*=T*/
>
showModalBottomSheet
/*<T>*/
({
BuildContext
context
,
WidgetBuilder
builder
})
{
assert
(
context
!=
null
);
assert
(
builder
!=
null
);
final
Completer
completer
=
new
Completer
();
Navigator
.
push
(
context
,
new
_ModalBottomSheetRoute
(
final
Completer
<
dynamic
/*=T*/
>
completer
=
new
Completer
<
dynamic
/*=T*/
>
();
Navigator
.
push
(
context
,
new
_ModalBottomSheetRoute
<
dynamic
/*=T*/
>
(
completer:
completer
,
builder:
builder
));
...
...
packages/flutter/lib/src/material/colors.dart
View file @
6795efac
...
...
@@ -9,20 +9,20 @@ import 'dart:ui' show Color;
class
Colors
{
Colors
.
_
();
static
const
transparent
=
const
Color
(
0x00000000
);
static
const
black
=
const
Color
(
0xFF000000
);
static
const
black87
=
const
Color
(
0xDD000000
);
static
const
black54
=
const
Color
(
0x8A000000
);
static
const
black45
=
const
Color
(
0x73000000
);
// mask color
static
const
black26
=
const
Color
(
0x42000000
);
// disabled radio buttons and text of disabled flat buttons in light theme
static
const
black12
=
const
Color
(
0x1F000000
);
// background of disabled raised buttons in light theme
static
const
white
=
const
Color
(
0xFFFFFFFF
);
static
const
white70
=
const
Color
(
0xB3FFFFFF
);
static
const
white30
=
const
Color
(
0x4DFFFFFF
);
// disabled radio buttons and text of disabled flat buttons in dark theme
static
const
white12
=
const
Color
(
0x1FFFFFFF
);
// background of disabled raised buttons in dark theme
static
const
white10
=
const
Color
(
0x1AFFFFFF
);
static
const
Color
transparent
=
const
Color
(
0x00000000
);
static
const
Color
black
=
const
Color
(
0xFF000000
);
static
const
Color
black87
=
const
Color
(
0xDD000000
);
static
const
Color
black54
=
const
Color
(
0x8A000000
);
static
const
Color
black45
=
const
Color
(
0x73000000
);
// mask color
static
const
Color
black26
=
const
Color
(
0x42000000
);
// disabled radio buttons and text of disabled flat buttons in light theme
static
const
Color
black12
=
const
Color
(
0x1F000000
);
// background of disabled raised buttons in light theme
static
const
Color
white
=
const
Color
(
0xFFFFFFFF
);
static
const
Color
white70
=
const
Color
(
0xB3FFFFFF
);
static
const
Color
white30
=
const
Color
(
0x4DFFFFFF
);
// disabled radio buttons and text of disabled flat buttons in dark theme
static
const
Color
white12
=
const
Color
(
0x1FFFFFFF
);
// background of disabled raised buttons in dark theme
static
const
Color
white10
=
const
Color
(
0x1AFFFFFF
);
static
const
Map
<
int
,
Color
>
red
=
const
<
int
,
Color
>{
50
:
const
Color
(
0xFFFFEBEE
),
...
...
packages/flutter/lib/src/material/dialog.dart
View file @
6795efac
...
...
@@ -142,8 +142,8 @@ class _DialogRoute<T> extends PopupRoute<T> {
}
}
Future
showDialog
(
{
BuildContext
context
,
Widget
child
})
{
Completer
completer
=
new
Completer
();
Navigator
.
push
(
context
,
new
_DialogRoute
(
completer:
completer
,
child:
child
));
Future
<
dynamic
/*=T*/
>
showDialog
/*<T>*/
({
BuildContext
context
,
Widget
child
})
{
Completer
<
dynamic
/*=T*/
>
completer
=
new
Completer
<
dynamic
/*=T*/
>
();
Navigator
.
push
(
context
,
new
_DialogRoute
<
dynamic
/*=T*/
>
(
completer:
completer
,
child:
child
));
return
completer
.
future
;
}
packages/flutter/lib/src/material/drawer.dart
View file @
6795efac
...
...
@@ -86,7 +86,7 @@ class DrawerControllerState extends State<DrawerController> {
void
_ensureHistoryEntry
()
{
if
(
_historyEntry
==
null
)
{
ModalRoute
route
=
ModalRoute
.
of
(
context
);
ModalRoute
<
dynamic
>
route
=
ModalRoute
.
of
(
context
);
if
(
route
!=
null
)
{
_historyEntry
=
new
LocalHistoryEntry
(
onRemove:
_handleHistoryEntryRemoved
);
route
.
addLocalHistoryEntry
(
_historyEntry
);
...
...
packages/flutter/lib/src/material/dropdown.dart
View file @
6795efac
...
...
@@ -154,7 +154,7 @@ class _DropDownRouteResult<T> {
const
_DropDownRouteResult
(
this
.
result
);
final
T
result
;
bool
operator
==(
dynamic
other
)
{
if
(
other
is
!
_DropDownRouteResult
)
if
(
other
is
!
_DropDownRouteResult
<
T
>
)
return
false
;
final
_DropDownRouteResult
<
T
>
typedOther
=
other
;
return
result
==
typedOther
.
result
;
...
...
@@ -193,7 +193,7 @@ class _DropDownRoute<T> extends PopupRoute<_DropDownRouteResult<T>> {
}
Widget
buildPage
(
BuildContext
context
,
Animation
<
double
>
animation
,
Animation
<
double
>
forwardAnimation
)
{
return
new
_DropDownMenu
(
route:
this
);
return
new
_DropDownMenu
<
T
>
(
route:
this
);
}
}
...
...
@@ -269,7 +269,7 @@ class _DropDownButtonState<T> extends State<DropDownButton<T>> {
void
_handleTap
()
{
final
RenderBox
renderBox
=
indexedStackKey
.
currentContext
.
findRenderObject
();
final
Rect
rect
=
renderBox
.
localToGlobal
(
Point
.
origin
)
&
renderBox
.
size
;
final
Completer
completer
=
new
Completer
<
_DropDownRouteResult
<
T
>>();
final
Completer
<
_DropDownRouteResult
<
T
>>
completer
=
new
Completer
<
_DropDownRouteResult
<
T
>>();
Navigator
.
push
(
context
,
new
_DropDownRoute
<
T
>(
completer:
completer
,
items:
config
.
items
,
...
...
packages/flutter/lib/src/material/ink_well.dart
View file @
6795efac
...
...
@@ -44,7 +44,7 @@ class InkResponse extends StatefulComponent {
final
bool
containedInWell
;
final
BoxShape
highlightShape
;
_InkResponseState
createState
()
=>
new
_InkResponseState
<
InkResponse
>();
_InkResponseState
<
InkResponse
>
createState
()
=>
new
_InkResponseState
<
InkResponse
>();
}
class
_InkResponseState
<
T
extends
InkResponse
>
extends
State
<
T
>
{
...
...
packages/flutter/lib/src/material/material.dart
View file @
6795efac
...
...
@@ -477,7 +477,7 @@ class _InkHighlight extends InkFeature implements InkHighlight {
super
.
dispose
();
}
void
_paintHighlight
(
Canvas
canvas
,
Rect
rect
,
paint
)
{
void
_paintHighlight
(
Canvas
canvas
,
Rect
rect
,
Paint
paint
)
{
if
(
shape
==
BoxShape
.
rectangle
)
canvas
.
drawRect
(
rect
,
paint
);
else
...
...
packages/flutter/lib/src/material/page.dart
View file @
6795efac
...
...
@@ -54,7 +54,7 @@ class MaterialPageRoute<T> extends PageRoute<T> {
Duration
get
transitionDuration
=>
kMaterialPageRouteTransitionDuration
;
Color
get
barrierColor
=>
null
;
bool
canTransitionFrom
(
TransitionRoute
nextRoute
)
=>
false
;
bool
canTransitionFrom
(
TransitionRoute
<
dynamic
>
nextRoute
)
=>
false
;
Widget
buildPage
(
BuildContext
context
,
Animation
<
double
>
animation
,
Animation
<
double
>
forwardAnimation
)
{
Widget
result
=
builder
(
context
);
...
...
packages/flutter/lib/src/material/popup_menu.dart
View file @
6795efac
...
...
@@ -65,7 +65,7 @@ class PopupMenuItem<T> extends PopupMenuEntry<T> {
_PopupMenuItemState
<
PopupMenuItem
<
T
>>
createState
()
=>
new
_PopupMenuItemState
<
PopupMenuItem
<
T
>>();
}
class
_PopupMenuItemState
<
T
extends
PopupMenuItem
>
extends
State
<
T
>
{
class
_PopupMenuItemState
<
T
extends
PopupMenuItem
<
dynamic
>
>
extends
State
<
T
>
{
// Override this to put something else in the menu entry.
Widget
buildChild
()
=>
config
.
child
;
...
...
@@ -318,7 +318,7 @@ class _PopupMenuRoute<T> extends PopupRoute<T> {
constraints:
new
BoxConstraints
(
maxWidth:
screenSize
.
width
,
maxHeight:
screenSize
.
height
),
child:
new
CustomOneChildLayout
(
delegate:
new
_PopupMenuRouteLayout
(
position
,
selectedItemOffset
),
child:
new
_PopupMenu
(
route:
this
)
child:
new
_PopupMenu
<
T
>
(
route:
this
)
)
);
}
...
...
@@ -329,17 +329,17 @@ class _PopupMenuRoute<T> extends PopupRoute<T> {
/// and the value of [position] implies where the left, center point of the
/// highlighted item should appear. If [initialValue] is not specified then position
/// implies the menu's origin.
Future
/*<T>*/
showMenu
/*<T>*/
({
Future
<
dynamic
/*=T*/
>
showMenu
/*<T>*/
({
BuildContext
context
,
ModalPosition
position
,
List
<
PopupMenuEntry
/*<T>*/
>
items
,
List
<
PopupMenuEntry
<
dynamic
/*=T*/
>
>
items
,
dynamic
/*=T*/
initialValue
,
int
elevation:
8
})
{
assert
(
context
!=
null
);
assert
(
items
!=
null
&&
items
.
length
>
0
);
Completer
completer
=
new
Completer
/*<T>*/
();
Navigator
.
push
(
context
,
new
_PopupMenuRoute
/*<T>*/
(
Completer
<
dynamic
/*=T*/
>
completer
=
new
Completer
<
dynamic
/*=T*/
>
();
Navigator
.
push
(
context
,
new
_PopupMenuRoute
<
dynamic
/*=T*/
>
(
completer:
completer
,
position:
position
,
items:
items
,
...
...
packages/flutter/lib/src/material/progress_indicator.dart
View file @
6795efac
...
...
@@ -128,11 +128,11 @@ class _LinearProgressIndicatorState extends State<LinearProgressIndicator> {
}
class
_CircularProgressIndicatorPainter
extends
CustomPainter
{
static
const
_kTwoPI
=
math
.
PI
*
2.0
;
static
const
_kEpsilon
=
.
001
;
static
const
double
_kTwoPI
=
math
.
PI
*
2.0
;
static
const
double
_kEpsilon
=
.
001
;
// Canavs.drawArc(r, 0, 2*PI) doesn't draw anything, so just get close.
static
const
_kSweep
=
_kTwoPI
-
_kEpsilon
;
static
const
_kStartAngle
=
-
math
.
PI
/
2.0
;
static
const
double
_kSweep
=
_kTwoPI
-
_kEpsilon
;
static
const
double
_kStartAngle
=
-
math
.
PI
/
2.0
;
const
_CircularProgressIndicatorPainter
({
this
.
valueColor
,
...
...
packages/flutter/lib/src/material/scaffold.dart
View file @
6795efac
...
...
@@ -229,24 +229,24 @@ class ScaffoldState extends State<Scaffold> {
// SNACKBAR API
Queue
<
ScaffoldFeatureController
<
SnackBar
>>
_snackBars
=
new
Queue
<
ScaffoldFeatureController
<
SnackBar
>>();
Queue
<
ScaffoldFeatureController
<
SnackBar
,
Null
>>
_snackBars
=
new
Queue
<
ScaffoldFeatureController
<
SnackBar
,
Null
>>();
AnimationController
_snackBarController
;
Timer
_snackBarTimer
;
ScaffoldFeatureController
showSnackBar
(
SnackBar
snackbar
)
{
ScaffoldFeatureController
<
SnackBar
,
Null
>
showSnackBar
(
SnackBar
snackbar
)
{
_snackBarController
??=
SnackBar
.
createAnimationController
()
..
addStatusListener
(
_handleSnackBarStatusChange
);
if
(
_snackBars
.
isEmpty
)
{
assert
(
_snackBarController
.
isDismissed
);
_snackBarController
.
forward
();
}
ScaffoldFeatureController
<
SnackBar
>
controller
;
controller
=
new
ScaffoldFeatureController
<
SnackBar
>.
_
(
ScaffoldFeatureController
<
SnackBar
,
Null
>
controller
;
controller
=
new
ScaffoldFeatureController
<
SnackBar
,
Null
>.
_
(
// We provide a fallback key so that if back-to-back snackbars happen to
// match in structure, material ink splashes and highlights don't survive
// from one to the next.
snackbar
.
withAnimation
(
_snackBarController
,
fallbackKey:
new
UniqueKey
()),
new
Completer
(),
new
Completer
<
Null
>
(),
()
{
assert
(
_snackBars
.
first
==
controller
);
_hideSnackBar
();
...
...
@@ -294,14 +294,14 @@ class ScaffoldState extends State<Scaffold> {
// PERSISTENT BOTTOM SHEET API
List
<
Widget
>
_dismissedBottomSheets
;
ScaffoldFeatureController
_currentBottomSheet
;
PersistentBottomSheetController
<
dynamic
>
_currentBottomSheet
;
ScaffoldFeatureController
showBottomSheet
(
WidgetBuilder
builder
)
{
PersistentBottomSheetController
<
dynamic
/*=T*/
>
showBottomSheet
/*<T>*/
(
WidgetBuilder
builder
)
{
if
(
_currentBottomSheet
!=
null
)
{
_currentBottomSheet
.
close
();
assert
(
_currentBottomSheet
==
null
);
}
Completer
completer
=
new
Completer
();
Completer
<
dynamic
/*=T*/
>
completer
=
new
Completer
<
dynamic
/*=T*/
>
();
GlobalKey
<
_PersistentBottomSheetState
>
bottomSheetKey
=
new
GlobalKey
<
_PersistentBottomSheetState
>();
AnimationController
controller
=
BottomSheet
.
createAnimationController
()
..
forward
();
...
...
@@ -334,7 +334,7 @@ class ScaffoldState extends State<Scaffold> {
);
ModalRoute
.
of
(
context
).
addLocalHistoryEntry
(
entry
);
setState
(()
{
_currentBottomSheet
=
new
ScaffoldFeatureController
.
_
(
_currentBottomSheet
=
new
PersistentBottomSheetController
<
dynamic
/*=T*/
>
.
_
(
bottomSheet
,
completer
,
()
=>
entry
.
remove
(),
...
...
@@ -447,7 +447,7 @@ class ScaffoldState extends State<Scaffold> {
}
else
if
(
_scrollOffset
>
appBarHeight
)
{
// scrolled down, show the "floating" toolbar
_floatingAppBarHeight
=
(
_floatingAppBarHeight
+
_scrollOffsetDelta
).
clamp
(
0.0
,
toolBarHeight
);
final
toolBarOpacity
=
_toolBarOpacity
(
_floatingAppBarHeight
/
toolBarHeight
);
final
double
toolBarOpacity
=
_toolBarOpacity
(
_floatingAppBarHeight
/
toolBarHeight
);
_appBarController
.
value
=
(
appBarHeight
-
_floatingAppBarHeight
)
/
appBarHeight
;
appBar
=
new
SizedBox
(
height:
_floatingAppBarHeight
,
...
...
@@ -471,7 +471,7 @@ class ScaffoldState extends State<Scaffold> {
EdgeDims
padding
=
MediaQuery
.
of
(
context
)?.
padding
??
EdgeDims
.
zero
;
if
(
_snackBars
.
length
>
0
)
{
ModalRoute
route
=
ModalRoute
.
of
(
context
);
ModalRoute
<
dynamic
>
route
=
ModalRoute
.
of
(
context
);
if
(
route
==
null
||
route
.
isCurrent
)
{
if
(
_snackBarController
.
isCompleted
&&
_snackBarTimer
==
null
)
_snackBarTimer
=
new
Timer
(
_snackBars
.
first
.
_widget
.
duration
,
_hideSnackBar
);
...
...
@@ -563,11 +563,11 @@ class ScaffoldState extends State<Scaffold> {
}
}
class
ScaffoldFeatureController
<
T
extends
Widget
>
{
class
ScaffoldFeatureController
<
T
extends
Widget
,
U
>
{
const
ScaffoldFeatureController
.
_
(
this
.
_widget
,
this
.
_completer
,
this
.
close
,
this
.
setState
);
final
T
_widget
;
final
Completer
_completer
;
Future
get
closed
=>
_completer
.
future
;
final
Completer
<
U
>
_completer
;
Future
<
U
>
get
closed
=>
_completer
.
future
;
final
VoidCallback
close
;
// call this to close the bottom sheet or snack bar
final
StateSetter
setState
;
}
...
...
@@ -641,3 +641,15 @@ class _PersistentBottomSheetState extends State<_PersistentBottomSheet> {
}
}
/// A [ScaffoldFeatureController] for persistent bottom sheets.
///
/// This is the type of objects returned by [Scaffold.showBottomSheet].
class
PersistentBottomSheetController
<
T
>
extends
ScaffoldFeatureController
<
_PersistentBottomSheet
,
T
>
{
const
PersistentBottomSheetController
.
_
(
_PersistentBottomSheet
widget
,
Completer
<
T
>
completer
,
VoidCallback
close
,
StateSetter
setState
)
:
super
.
_
(
widget
,
completer
,
close
,
setState
);
}
packages/flutter/lib/src/material/scrollbar_painter.dart
View file @
6795efac
...
...
@@ -60,7 +60,7 @@ class ScrollbarPainter extends ScrollableListPainter {
AnimationController
_fade
;
Future
scrollStarted
()
{
Future
<
Null
>
scrollStarted
()
{
if
(
_fade
==
null
)
{
_fade
=
new
AnimationController
(
duration:
_kScrollbarThumbFadeDuration
);
CurvedAnimation
curve
=
new
CurvedAnimation
(
parent:
_fade
,
curve:
Curves
.
ease
);
...
...
@@ -72,7 +72,7 @@ class ScrollbarPainter extends ScrollableListPainter {
return
_fade
.
forward
();
}
Future
scrollEnded
()
{
Future
<
Null
>
scrollEnded
()
{
return
_fade
.
reverse
();
}
...
...
packages/flutter/lib/src/material/switch.dart
View file @
6795efac
...
...
@@ -24,7 +24,7 @@ class Switch extends StatelessComponent {
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterial
(
context
));
ThemeData
themeData
=
Theme
.
of
(
context
);
final
isDark
=
themeData
.
brightness
==
ThemeBrightness
.
dark
;
final
bool
isDark
=
themeData
.
brightness
==
ThemeBrightness
.
dark
;
Color
activeThumbColor
=
activeColor
??
themeData
.
accentColor
;
Color
activeTrackColor
=
activeThumbColor
.
withAlpha
(
0x80
);
...
...
packages/flutter/lib/src/material/tabs.dart
View file @
6795efac
...
...
@@ -416,8 +416,8 @@ class TabBarSelection<T> extends StatefulComponent {
TabBarSelectionState
<
T
>
createState
()
=>
new
TabBarSelectionState
<
T
>();
static
TabBarSelectionState
of
(
BuildContext
context
)
{
return
context
.
ancestorStateOfType
(
const
TypeMatcher
<
TabBarSelectionState
>());
static
TabBarSelectionState
<
dynamic
/*=T*/
>
of
/*<T>*/
(
BuildContext
context
)
{
return
context
.
ancestorStateOfType
(
new
TypeMatcher
<
TabBarSelectionState
<
dynamic
/*=T*/
>
>());
}
}
...
...
@@ -449,7 +449,7 @@ class TabBarSelectionState<T> extends State<TabBarSelection<T>> {
_initValueToIndex
();
}
void
didUpdateConfig
(
TabBarSelection
oldConfig
)
{
void
didUpdateConfig
(
TabBarSelection
<
T
>
oldConfig
)
{
super
.
didUpdateConfig
(
oldConfig
);
if
(
values
!=
oldConfig
.
values
)
_initValueToIndex
();
...
...
@@ -564,12 +564,12 @@ class TabBar<T> extends Scrollable {
final
Map
<
T
,
TabLabel
>
labels
;
final
bool
isScrollable
;
_TabBarState
createState
()
=>
new
_TabBarState
();
_TabBarState
<
T
>
createState
()
=>
new
_TabBarState
<
T
>
();
}
class
_TabBarState
<
T
>
extends
ScrollableState
<
TabBar
<
T
>>
implements
TabBarSelectionAnimationListener
{
TabBarSelectionState
_selection
;
TabBarSelectionState
<
T
>
_selection
;
bool
_valueIsChanging
=
false
;
void
_initSelection
(
TabBarSelectionState
<
T
>
selection
)
{
...
...
@@ -584,7 +584,7 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
_initSelection
(
TabBarSelection
.
of
(
context
));
}
void
didUpdateConfig
(
TabBar
oldConfig
)
{
void
didUpdateConfig
(
TabBar
<
T
>
oldConfig
)
{
super
.
didUpdateConfig
(
oldConfig
);
if
(!
config
.
isScrollable
)
scrollTo
(
0.0
);
...
...
@@ -666,7 +666,7 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
return
new
Rect
.
fromLTRB
(
r
.
left
,
r
.
bottom
,
r
.
right
,
r
.
bottom
+
_kTabIndicatorHeight
);
}
ScrollBehavior
createScrollBehavior
()
=>
new
_TabsScrollBehavior
();
ScrollBehavior
<
double
,
double
>
createScrollBehavior
()
=>
new
_TabsScrollBehavior
();
_TabsScrollBehavior
get
scrollBehavior
=>
super
.
scrollBehavior
;
double
_centeredTabScrollOffset
(
int
tabIndex
)
{
...
...
@@ -795,7 +795,7 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
}
}
class
TabBarView
extends
PageableList
{
class
TabBarView
<
T
>
extends
PageableList
{
TabBarView
({
Key
key
,
List
<
Widget
>
children
...
...
@@ -808,12 +808,12 @@ class TabBarView extends PageableList {
assert
(
children
.
length
>
1
);
}
_TabBarViewState
createState
()
=>
new
_TabBarViewState
();
_TabBarViewState
<
T
>
createState
()
=>
new
_TabBarViewState
<
T
>
();
}
class
_TabBarViewState
extends
PageableListState
<
TabBarView
>
implements
TabBarSelectionAnimationListener
{
class
_TabBarViewState
<
T
>
extends
PageableListState
<
TabBarView
<
T
>
>
implements
TabBarSelectionAnimationListener
{
TabBarSelectionState
_selection
;
TabBarSelectionState
<
T
>
_selection
;
List
<
Widget
>
_items
;
int
get
_tabCount
=>
config
.
children
.
length
;
...
...
@@ -825,7 +825,7 @@ class _TabBarViewState extends PageableListState<TabBarView> implements TabBarSe
return
_boundedBehavior
;
}
void
_initSelection
(
TabBarSelectionState
selection
)
{
void
_initSelection
(
TabBarSelectionState
<
T
>
selection
)
{
_selection
=
selection
;
if
(
_selection
!=
null
)
{
_selection
.
registerAnimationListener
(
this
);
...
...
@@ -838,7 +838,7 @@ class _TabBarViewState extends PageableListState<TabBarView> implements TabBarSe
_initSelection
(
TabBarSelection
.
of
(
context
));
}
void
didUpdateConfig
(
TabBarView
oldConfig
)
{
void
didUpdateConfig
(
TabBarView
<
T
>
oldConfig
)
{
super
.
didUpdateConfig
(
oldConfig
);
if
(
_selection
!=
null
&&
config
.
children
!=
oldConfig
.
children
)
_updateItemsForSelectedIndex
(
_selection
.
index
);
...
...
@@ -931,15 +931,15 @@ class _TabBarViewState extends PageableListState<TabBarView> implements TabBarSe
controller
.
value
=
scrollOffset
/
2.0
;
}
Future
fling
(
double
scrollVelocity
)
{
Future
<
Null
>
fling
(
double
scrollVelocity
)
{
if
(
_selection
==
null
||
_selection
.
valueIsChanging
)
return
new
Future
.
value
();
return
new
Future
<
Null
>
.
value
();
if
(
scrollVelocity
.
abs
()
>
_kMinFlingVelocity
)
{
final
int
selectionDelta
=
scrollVelocity
.
sign
.
truncate
();
final
int
targetIndex
=
(
_selection
.
index
+
selectionDelta
).
clamp
(
0
,
_tabCount
-
1
);
_selection
.
value
=
_selection
.
values
[
targetIndex
];
return
new
Future
.
value
();
return
new
Future
<
Null
>
.
value
();
}
final
int
selectionIndex
=
_selection
.
index
;
...
...
@@ -947,16 +947,16 @@ class _TabBarViewState extends PageableListState<TabBarView> implements TabBarSe
if
(
selectionIndex
>
0
&&
settleIndex
!=
1
)
{
final
int
targetIndex
=
(
selectionIndex
+
(
settleIndex
==
2
?
1
:
-
1
)).
clamp
(
0
,
_tabCount
-
1
);
_selection
.
value
=
_selection
.
values
[
targetIndex
];
return
new
Future
.
value
();
return
new
Future
<
Null
>
.
value
();
}
else
if
(
selectionIndex
==
0
&&
settleIndex
==
1
)
{
_selection
.
value
=
_selection
.
values
[
1
];
return
new
Future
.
value
();
return
new
Future
<
Null
>
.
value
();
}
return
settleScrollOffset
();
}
Widget
buildContent
(
BuildContext
context
)
{
TabBarSelectionState
newSelection
=
TabBarSelection
.
of
(
context
);
TabBarSelectionState
<
T
>
newSelection
=
TabBarSelection
.
of
(
context
);
if
(
_selection
!=
newSelection
)
_initSelection
(
newSelection
);
return
new
PageViewport
(
...
...
@@ -972,7 +972,7 @@ class _TabBarViewState extends PageableListState<TabBarView> implements TabBarSe
class
TabPageSelector
<
T
>
extends
StatelessComponent
{
const
TabPageSelector
({
Key
key
})
:
super
(
key:
key
);
Widget
_buildTabIndicator
(
TabBarSelectionState
<
T
>
selection
,
T
tab
,
Animation
animation
,
ColorTween
selectedColor
,
ColorTween
previousColor
)
{
Widget
_buildTabIndicator
(
TabBarSelectionState
<
T
>
selection
,
T
tab
,
Animation
<
double
>
animation
,
ColorTween
selectedColor
,
ColorTween
previousColor
)
{
Color
background
;
if
(
selection
.
valueIsChanging
)
{
// The selection's animation is animating from previousValue to value.
...
...
@@ -998,7 +998,7 @@ class TabPageSelector<T> extends StatelessComponent {
}
Widget
build
(
BuildContext
context
)
{
final
TabBarSelectionState
selection
=
TabBarSelection
.
of
(
context
);
final
TabBarSelectionState
<
T
>
selection
=
TabBarSelection
.
of
(
context
);
final
Color
color
=
Theme
.
of
(
context
).
accentColor
;
final
ColorTween
selectedColor
=
new
ColorTween
(
begin:
Colors
.
transparent
,
end:
color
);
final
ColorTween
previousColor
=
new
ColorTween
(
begin:
color
,
end:
Colors
.
transparent
);
...
...
packages/flutter/lib/src/material/theme.dart
View file @
6795efac
...
...
@@ -8,7 +8,7 @@ import 'theme_data.dart';
export
'theme_data.dart'
show
ThemeData
,
ThemeBrightness
;
const
kThemeAnimationDuration
=
const
Duration
(
milliseconds:
200
);
const
Duration
kThemeAnimationDuration
=
const
Duration
(
milliseconds:
200
);
/// Applies a theme to descendant widgets.
class
Theme
extends
InheritedWidget
{
...
...
@@ -73,7 +73,7 @@ class AnimatedTheme extends AnimatedWidgetBase {
class
_AnimatedThemeState
extends
AnimatedWidgetBaseState
<
AnimatedTheme
>
{
ThemeDataTween
_data
;
void
forEachTween
(
TweenVisitor
visitor
)
{
void
forEachTween
(
TweenVisitor
<
dynamic
>
visitor
)
{
// TODO(ianh): Use constructor tear-offs when it becomes possible
_data
=
visitor
(
_data
,
config
.
data
,
(
dynamic
value
)
=>
new
ThemeDataTween
(
begin:
value
));
assert
(
_data
!=
null
);
...
...
packages/flutter/lib/src/painting/box_painter.dart
View file @
6795efac
...
...
@@ -27,7 +27,7 @@ class BorderSide {
final
double
width
;
/// A black border side of zero width.
static
const
none
=
const
BorderSide
(
width:
0.0
);
static
const
BorderSide
none
=
const
BorderSide
(
width:
0.0
);
BorderSide
copyWith
({
Color
color
,
...
...
packages/flutter/lib/src/painting/text_painter.dart
View file @
6795efac
...
...
@@ -197,7 +197,7 @@ class TextPainter {
/// The minimum width at which to layout the text.
double
get
minWidth
=>
_paragraph
.
minWidth
;
void
set
minWidth
(
value
)
{
void
set
minWidth
(
double
value
)
{
if
(
_paragraph
.
minWidth
==
value
)
return
;
_paragraph
.
minWidth
=
value
;
...
...
@@ -206,7 +206,7 @@ class TextPainter {
/// The maximum width at which to layout the text.
double
get
maxWidth
=>
_paragraph
.
maxWidth
;
void
set
maxWidth
(
value
)
{
void
set
maxWidth
(
double
value
)
{
if
(
_paragraph
.
maxWidth
==
value
)
return
;
_paragraph
.
maxWidth
=
value
;
...
...
@@ -215,7 +215,7 @@ class TextPainter {
/// The minimum height at which to layout the text.
double
get
minHeight
=>
_paragraph
.
minHeight
;
void
set
minHeight
(
value
)
{
void
set
minHeight
(
double
value
)
{
if
(
_paragraph
.
minHeight
==
value
)
return
;
_paragraph
.
minHeight
=
value
;
...
...
@@ -224,7 +224,7 @@ class TextPainter {
/// The maximum height at which to layout the text.
double
get
maxHeight
=>
_paragraph
.
maxHeight
;
void
set
maxHeight
(
value
)
{
void
set
maxHeight
(
double
value
)
{
if
(
_paragraph
.
maxHeight
==
value
)
return
;
_paragraph
.
maxHeight
=
value
;
...
...
packages/flutter/lib/src/rendering/basic_types.dart
View file @
6795efac
...
...
@@ -7,9 +7,9 @@ typedef void ValueChanged<T>(T value);
/// A BitField over an enum (or other class whose values implement "index").
/// Only the first 63 values of the enum can be used as indices.
class
BitField
<
T
extends
dynamic
>
{
static
const
_kSMIBits
=
63
;
// see https://www.dartlang.org/articles/numeric-computation/#smis-and-mints
static
const
_kAllZeros
=
0
;
static
const
_kAllOnes
=
0x7FFFFFFFFFFFFFFF
;
// 2^(_kSMIBits+1)-1
static
const
int
_kSMIBits
=
63
;
// see https://www.dartlang.org/articles/numeric-computation/#smis-and-mints
static
const
int
_kAllZeros
=
0
;
static
const
int
_kAllOnes
=
0x7FFFFFFFFFFFFFFF
;
// 2^(_kSMIBits+1)-1
BitField
(
this
.
_length
)
:
_bits
=
_kAllZeros
{
assert
(
_length
<=
_kSMIBits
);
}
...
...
packages/flutter/lib/src/rendering/editable_line.dart
View file @
6795efac
...
...
@@ -11,9 +11,9 @@ import 'box.dart';
import
'object.dart'
;
import
'viewport.dart'
;
const
_kCaretGap
=
1.0
;
// pixels
const
_kCaretHeightOffset
=
2.0
;
// pixels
const
_kCaretWidth
=
1.0
;
// pixels
const
double
_kCaretGap
=
1.0
;
// pixels
const
double
_kCaretHeightOffset
=
2.0
;
// pixels
const
double
_kCaretWidth
=
1.0
;
// pixels
final
String
_kZeroWidthSpace
=
new
String
.
fromCharCode
(
0x200B
);
...
...
packages/flutter/lib/src/rendering/flex.dart
View file @
6795efac
...
...
@@ -561,7 +561,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
Paint
markerPaint
=
new
Paint
()..
color
=
const
Color
(
0xE0FF0000
);
Paint
highlightPaint
=
new
Paint
()..
color
=
const
Color
(
0x7FFF0000
);
const
kMarkerSize
=
0.1
;
const
double
kMarkerSize
=
0.1
;
Rect
markerRect
,
overflowRect
;
switch
(
direction
)
{
case
FlexDirection
.
horizontal
:
...
...
packages/flutter/lib/src/rendering/proxy_box.dart
View file @
6795efac
...
...
@@ -756,7 +756,7 @@ abstract class CustomClipper<T> {
Rect
getApproximateClipRect
(
Size
size
)
=>
Point
.
origin
&
size
;
/// Returns true if the new instance will result in a different clip
/// than the oldClipper instance.
bool
shouldRepaint
(
CustomClipper
oldClipper
);
bool
shouldRepaint
(
CustomClipper
<
T
>
oldClipper
);
}
abstract
class
_RenderCustomClip
<
T
>
extends
RenderProxyBox
{
...
...
@@ -1100,13 +1100,13 @@ class RenderTransform extends RenderProxyBox {
}
/// Concatenates a translation by (x, y, z) into the transform.
void
translate
(
x
,
[
double
y
=
0.0
,
double
z
=
0.0
])
{
void
translate
(
double
x
,
[
double
y
=
0.0
,
double
z
=
0.0
])
{
_transform
.
translate
(
x
,
y
,
z
);
markNeedsPaint
();
}
/// Concatenates a scale into the transform.
void
scale
(
x
,
[
double
y
,
double
z
])
{
void
scale
(
double
x
,
[
double
y
,
double
z
])
{
_transform
.
scale
(
x
,
y
,
z
);
markNeedsPaint
();
}
...
...
packages/flutter/lib/src/rendering/shifted_box.dart
View file @
6795efac
...
...
@@ -176,7 +176,7 @@ class RenderPadding extends RenderShiftedBox {
context
.
canvas
.
drawPath
(
path
,
paint
);
paint
=
new
Paint
()
..
color
=
debugPaintPaddingInnerEdgeColor
;
const
kOutline
=
2.0
;
const
double
kOutline
=
2.0
;
path
=
new
Path
()
..
moveTo
(
offset
.
dx
+
math
.
max
(
padding
.
left
-
kOutline
,
0.0
),
offset
.
dy
+
math
.
max
(
padding
.
top
-
kOutline
,
0.0
))
..
lineTo
(
offset
.
dx
+
math
.
min
(
size
.
width
-
padding
.
right
+
kOutline
,
size
.
width
),
offset
.
dy
+
math
.
max
(
padding
.
top
-
kOutline
,
0.0
))
...
...
packages/flutter/lib/src/rendering/stack.dart
View file @
6795efac
...
...
@@ -198,7 +198,7 @@ abstract class RenderStackBase extends RenderBox
RenderBoxContainerDefaultsMixin
<
RenderBox
,
StackParentData
>
{
RenderStackBase
({
List
<
RenderBox
>
children
,
alignment:
const
FractionalOffset
(
0.0
,
0.0
)
FractionalOffset
alignment:
const
FractionalOffset
(
0.0
,
0.0
)
})
:
_alignment
=
alignment
{
addAll
(
children
);
}
...
...
@@ -425,7 +425,7 @@ abstract class RenderStackBase extends RenderBox
class
RenderStack
extends
RenderStackBase
{
RenderStack
({
List
<
RenderBox
>
children
,
alignment:
const
FractionalOffset
(
0.0
,
0.0
)
FractionalOffset
alignment:
const
FractionalOffset
(
0.0
,
0.0
)
})
:
super
(
children:
children
,
alignment:
alignment
...
...
@@ -444,7 +444,7 @@ class RenderStack extends RenderStackBase {
class
RenderIndexedStack
extends
RenderStackBase
{
RenderIndexedStack
({
List
<
RenderBox
>
children
,
alignment:
const
FractionalOffset
(
0.0
,
0.0
),
FractionalOffset
alignment:
const
FractionalOffset
(
0.0
,
0.0
),
int
index:
0
})
:
_index
=
index
,
super
(
children:
children
,
...
...
packages/flutter/lib/src/scheduler/scheduler.dart
View file @
6795efac
...
...
@@ -106,7 +106,7 @@ abstract class Scheduler extends BindingBase {
// Note that we inverse the priority.
return
-
e1
.
priority
.
compareTo
(
e2
.
priority
);
}
final
PriorityQueue
_taskQueue
=
new
HeapPriorityQueue
<
_TaskEntry
>(
_taskSorter
);
final
PriorityQueue
<
_TaskEntry
>
_taskQueue
=
new
HeapPriorityQueue
<
_TaskEntry
>(
_taskSorter
);
/// Whether this scheduler already requested to be called from the event loop.
bool
_hasRequestedAnEventLoopCallback
=
false
;
...
...
packages/flutter/lib/src/scheduler/ticker.dart
View file @
6795efac
...
...
@@ -16,17 +16,17 @@ class Ticker {
final
TickerCallback
_onTick
;
Completer
_completer
;
Completer
<
Null
>
_completer
;
int
_animationId
;
Duration
_startTime
;
/// Starts calling onTick once per animation frame.
///
/// The returned future resolves once the ticker stops ticking.
Future
start
()
{
Future
<
Null
>
start
()
{
assert
(!
isTicking
);
assert
(
_startTime
==
null
);
_completer
=
new
Completer
();
_completer
=
new
Completer
<
Null
>
();
_scheduleTick
();
return
_completer
.
future
;
}
...
...
@@ -48,7 +48,7 @@ class Ticker {
// We take the _completer into a local variable so that isTicking is false
// when we actually complete the future (isTicking uses _completer
// to determine its state).
Completer
localCompleter
=
_completer
;
Completer
<
Null
>
localCompleter
=
_completer
;
_completer
=
null
;
assert
(!
isTicking
);
localCompleter
.
complete
();
...
...
packages/flutter/lib/src/services/asset_bundle.dart
View file @
6795efac
...
...
@@ -80,7 +80,7 @@ class MojoAssetBundle extends CachingAssetBundle {
return
new
MojoAssetBundle
(
bundle
);
}
static
Future
_fetchAndUnpackBundle
(
String
relativeUrl
,
AssetBundleProxy
bundle
)
async
{
static
Future
<
Null
>
_fetchAndUnpackBundle
(
String
relativeUrl
,
AssetBundleProxy
bundle
)
async
{
core
.
MojoDataPipeConsumer
bundleData
=
(
await
fetchUrl
(
relativeUrl
)).
body
;
AssetUnpackerProxy
unpacker
=
new
AssetUnpackerProxy
.
unbound
();
shell
.
connectToService
(
"mojo:asset_bundle"
,
unpacker
);
...
...
packages/flutter/lib/src/services/image_cache.dart
View file @
6795efac
...
...
@@ -36,8 +36,11 @@ class _UrlFetcher implements ImageProvider {
);
}
bool
operator
==(
other
)
{
return
other
is
_UrlFetcher
&&
_url
==
other
.
_url
&&
_scale
==
other
.
_scale
;
bool
operator
==(
dynamic
other
)
{
if
(
other
is
!
_UrlFetcher
)
return
false
;
final
_UrlFetcher
typedOther
=
other
;
return
_url
==
typedOther
.
_url
&&
_scale
==
typedOther
.
_scale
;
}
int
get
hashCode
=>
hashValues
(
_url
,
_scale
);
...
...
packages/flutter/lib/src/services/image_resource.dart
View file @
6795efac
...
...
@@ -24,7 +24,12 @@ typedef void ImageListener(ImageInfo image);
/// or because the underlying image resource was mutated.
class
ImageResource
{
ImageResource
(
this
.
_futureImage
)
{
_futureImage
.
then
(
_handleImageLoaded
,
onError:
(
exception
,
stack
)
=>
_handleImageError
(
'Failed to load image:'
,
exception
,
stack
));
_futureImage
.
then
(
_handleImageLoaded
,
onError:
(
dynamic
exception
,
dynamic
stack
)
{
_handleImageError
(
'Failed to load image:'
,
exception
,
stack
);
}
);
}
bool
_resolved
=
false
;
...
...
packages/flutter/lib/src/widgets/asset_vendor.dart
View file @
6795efac
...
...
@@ -86,9 +86,9 @@ abstract class _VariantAssetResolver extends _AssetResolver {
// one.
Map
<
String
,
List
<
String
>>
_assetManifest
;
Future
_initializer
;
Future
<
Null
>
_initializer
;
Future
_loadManifest
()
async
{
Future
<
Null
>
_loadManifest
()
async
{
String
json
=
await
bundle
.
loadString
(
"AssetManifest.json"
);
_assetManifest
=
JSON
.
decode
(
json
);
}
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
6795efac
...
...
@@ -419,7 +419,7 @@ class Align extends OneChildRenderObjectWidget {
/// Centers its child within itself.
class
Center
extends
Align
{
Center
({
Key
key
,
widthFactor
,
heightFactor
,
Widget
child
})
Center
({
Key
key
,
double
widthFactor
,
double
heightFactor
,
Widget
child
})
:
super
(
key:
key
,
widthFactor:
widthFactor
,
heightFactor:
heightFactor
,
child:
child
);
}
...
...
@@ -453,7 +453,7 @@ class LayoutId extends ParentDataWidget<CustomMultiChildLayout> {
Key
key
,
Widget
child
,
Object
id
})
:
id
=
id
,
super
(
key:
key
??
new
ValueKey
(
id
),
child:
child
)
{
})
:
id
=
id
,
super
(
key:
key
??
new
ValueKey
<
Object
>
(
id
),
child:
child
)
{
assert
(
child
!=
null
);
assert
(
id
!=
null
);
}
...
...
@@ -1388,9 +1388,9 @@ class Row extends Flex {
Row
({
Key
key
,
List
<
Widget
>
children:
_emptyWidgetList
,
justifyContent:
FlexJustifyContent
.
start
,
alignItems:
FlexAlignItems
.
center
,
textBaseline
FlexJustifyContent
justifyContent:
FlexJustifyContent
.
start
,
FlexAlignItems
alignItems:
FlexAlignItems
.
center
,
TextBaseline
textBaseline
})
:
super
(
children:
children
,
key:
key
,
...
...
@@ -1409,9 +1409,9 @@ class Column extends Flex {
Column
({
Key
key
,
List
<
Widget
>
children:
_emptyWidgetList
,
justifyContent:
FlexJustifyContent
.
start
,
alignItems:
FlexAlignItems
.
center
,
textBaseline
FlexJustifyContent
justifyContent:
FlexJustifyContent
.
start
,
FlexAlignItems
alignItems:
FlexAlignItems
.
center
,
TextBaseline
textBaseline
})
:
super
(
children:
children
,
key:
key
,
...
...
packages/flutter/lib/src/widgets/binding.dart
View file @
6795efac
...
...
@@ -222,9 +222,11 @@ class RenderObjectToWidgetAdapter<T extends RenderObject> extends RenderObjectWi
class
RenderObjectToWidgetElement
<
T
extends
RenderObject
>
extends
RenderObjectElement
{
RenderObjectToWidgetElement
(
RenderObjectToWidgetAdapter
<
T
>
widget
)
:
super
(
widget
);
RenderObjectToWidgetAdapter
<
T
>
get
widget
=>
super
.
widget
;
Element
_child
;
static
const
_rootChildSlot
=
const
Object
();
static
const
Object
_rootChildSlot
=
const
Object
();
void
visitChildren
(
ElementVisitor
visitor
)
{
if
(
_child
!=
null
)
...
...
packages/flutter/lib/src/widgets/checked_mode_banner.dart
View file @
6795efac
...
...
@@ -10,12 +10,12 @@ import 'framework.dart';
class
_CheckedModeBannerPainter
extends
CustomPainter
{
const
_CheckedModeBannerPainter
();
static
const
kColor
=
const
Color
(
0xA0B71C1C
);
static
const
kOffset
=
40.0
;
// distance to bottom of banner, at a 45 degree angle inwards from the top right corner
static
const
kHeight
=
12.0
;
// height of banner
static
const
kTextAlign
=
const
Offset
(
0.0
,
-
3.0
);
// offset to move text up
static
const
kFontSize
=
kHeight
*
0.85
;
static
const
kShadowBlur
=
4.0
;
// shadow blur sigma
static
const
Color
kColor
=
const
Color
(
0xA0B71C1C
);
static
const
double
kOffset
=
40.0
;
// distance to bottom of banner, at a 45 degree angle inwards from the top right corner
static
const
double
kHeight
=
12.0
;
// height of banner
static
const
Offset
kTextAlign
=
const
Offset
(
0.0
,
-
3.0
);
// offset to move text up
static
const
double
kFontSize
=
kHeight
*
0.85
;
static
const
double
kShadowBlur
=
4.0
;
// shadow blur sigma
static
final
Rect
kRect
=
new
Rect
.
fromLTWH
(-
kOffset
,
kOffset
-
kHeight
,
kOffset
*
2.0
,
kHeight
);
static
const
TextStyle
kTextStyles
=
const
TextStyle
(
color:
const
Color
(
0xFFFFFFFF
),
...
...
packages/flutter/lib/src/widgets/drag_target.dart
View file @
6795efac
...
...
@@ -80,7 +80,7 @@ abstract class DraggableBase<T> extends StatefulComponent {
/// Should return a new MultiDragGestureRecognizer instance
/// constructed with the given arguments.
MultiDragGestureRecognizer
createRecognizer
(
GestureMultiDragStartCallback
onStart
);
MultiDragGestureRecognizer
<
dynamic
>
createRecognizer
(
GestureMultiDragStartCallback
onStart
);
_DraggableState
<
T
>
createState
()
=>
new
_DraggableState
<
T
>();
}
...
...
@@ -107,7 +107,7 @@ class Draggable<T> extends DraggableBase<T> {
maxSimultaneousDrags:
maxSimultaneousDrags
);
MultiDragGestureRecognizer
createRecognizer
(
GestureMultiDragStartCallback
onStart
)
{
Immediate
MultiDragGestureRecognizer
createRecognizer
(
GestureMultiDragStartCallback
onStart
)
{
return
new
ImmediateMultiDragGestureRecognizer
()..
onStart
=
onStart
;
}
}
...
...
@@ -135,7 +135,7 @@ class HorizontalDraggable<T> extends DraggableBase<T> {
maxSimultaneousDrags:
maxSimultaneousDrags
);
MultiDragGestureRecognizer
createRecognizer
(
GestureMultiDragStartCallback
onStart
)
{
Horizontal
MultiDragGestureRecognizer
createRecognizer
(
GestureMultiDragStartCallback
onStart
)
{
return
new
HorizontalMultiDragGestureRecognizer
()..
onStart
=
onStart
;
}
}
...
...
@@ -163,7 +163,7 @@ class VerticalDraggable<T> extends DraggableBase<T> {
maxSimultaneousDrags:
maxSimultaneousDrags
);
MultiDragGestureRecognizer
createRecognizer
(
GestureMultiDragStartCallback
onStart
)
{
Vertical
MultiDragGestureRecognizer
createRecognizer
(
GestureMultiDragStartCallback
onStart
)
{
return
new
VerticalMultiDragGestureRecognizer
()..
onStart
=
onStart
;
}
}
...
...
@@ -190,7 +190,7 @@ class LongPressDraggable<T> extends DraggableBase<T> {
maxSimultaneousDrags:
maxSimultaneousDrags
);
MultiDragGestureRecognizer
createRecognizer
(
GestureMultiDragStartCallback
onStart
)
{
Delayed
MultiDragGestureRecognizer
createRecognizer
(
GestureMultiDragStartCallback
onStart
)
{
return
new
DelayedMultiDragGestureRecognizer
()
..
onStart
=
(
Point
position
)
{
Drag
result
=
onStart
(
position
);
...
...
@@ -217,7 +217,7 @@ class _DraggableState<T> extends State<DraggableBase<T>> {
_recognizer
.
addPointer
(
event
);
}
_DragAvatar
_startDrag
(
Point
position
)
{
_DragAvatar
<
T
>
_startDrag
(
Point
position
)
{
if
(
config
.
maxSimultaneousDrags
!=
null
&&
_activeCount
>=
config
.
maxSimultaneousDrags
)
return
null
;
Point
dragStartPoint
;
...
...
@@ -361,7 +361,7 @@ class _DragAvatar<T> extends Drag {
final
Offset
feedbackOffset
;
final
VoidCallback
onDragEnd
;
_DragTargetState
_activeTarget
;
_DragTargetState
<
T
>
_activeTarget
;
bool
_activeTargetWillAcceptDrop
=
false
;
Point
_position
;
Offset
_lastOffset
;
...
...
@@ -384,7 +384,7 @@ class _DragAvatar<T> extends Drag {
_entry
.
markNeedsBuild
();
HitTestResult
result
=
new
HitTestResult
();
WidgetFlutterBinding
.
instance
.
hitTest
(
result
,
globalPosition
+
feedbackOffset
);
_DragTargetState
target
=
_getDragTarget
(
result
.
path
);
_DragTargetState
<
T
>
target
=
_getDragTarget
(
result
.
path
);
if
(
target
==
_activeTarget
)
return
;
if
(
_activeTarget
!=
null
)
...
...
@@ -393,13 +393,13 @@ class _DragAvatar<T> extends Drag {
_activeTargetWillAcceptDrop
=
_activeTarget
!=
null
&&
_activeTarget
.
didEnter
(
data
);
}
_DragTargetState
_getDragTarget
(
List
<
HitTestEntry
>
path
)
{
_DragTargetState
<
T
>
_getDragTarget
(
List
<
HitTestEntry
>
path
)
{
// Look for the RenderBox that corresponds to the hit target (the hit target
// widget builds a RenderMetadata box for us for this purpose).
for
(
HitTestEntry
entry
in
path
)
{
if
(
entry
.
target
is
RenderMetaData
)
{
RenderMetaData
renderMetaData
=
entry
.
target
;
if
(
renderMetaData
.
metaData
is
_DragTargetState
)
if
(
renderMetaData
.
metaData
is
_DragTargetState
<
T
>
)
return
renderMetaData
.
metaData
;
}
}
...
...
packages/flutter/lib/src/widgets/editable.dart
View file @
6795efac
...
...
@@ -192,7 +192,7 @@ class RawInputLineState extends ScrollableState<RawInputLine> {
_KeyboardClientImpl
_keyboardClient
;
KeyboardHandle
_keyboardHandle
;
ScrollBehavior
createScrollBehavior
()
=>
new
BoundedBehavior
();
ScrollBehavior
<
double
,
double
>
createScrollBehavior
()
=>
new
BoundedBehavior
();
BoundedBehavior
get
scrollBehavior
=>
super
.
scrollBehavior
;
void
initState
()
{
...
...
packages/flutter/lib/src/widgets/framework.dart
View file @
6795efac
...
...
@@ -119,8 +119,8 @@ abstract class GlobalKey<T extends State<StatefulComponent>> extends Key {
Widget
get
currentWidget
=>
_currentElement
?.
widget
;
T
get
currentState
{
Element
element
=
_currentElement
;
if
(
element
is
StatefulComponentElement
<
StatefulComponent
,
T
>
)
{
StatefulComponentElement
<
StatefulComponent
,
T
>
statefulElement
=
element
;
if
(
element
is
StatefulComponentElement
)
{
StatefulComponentElement
statefulElement
=
element
;
return
statefulElement
.
state
;
}
return
null
;
...
...
@@ -304,7 +304,7 @@ abstract class State<T extends StatefulComponent> {
/// Verifies that the State that was created is one that expects to be created
/// for that particular Widget.
bool
_debugTypesAreRight
(
widget
)
=>
widget
is
T
;
bool
_debugTypesAreRight
(
Widget
widget
)
=>
widget
is
T
;
/// Pointer to the owner Element object
StatefulComponentElement
_element
;
...
...
@@ -420,7 +420,7 @@ abstract class ParentDataWidget<T extends RenderObjectWidget> extends _ProxyComp
const
ParentDataWidget
({
Key
key
,
Widget
child
})
:
super
(
key:
key
,
child:
child
);
ParentDataElement
createElement
()
=>
new
ParentDataElement
(
this
);
ParentDataElement
<
T
>
createElement
()
=>
new
ParentDataElement
<
T
>
(
this
);
/// Subclasses should override this function to return true if the given
/// ancestor is a RenderObjectWidget that wraps a RenderObject that can handle
...
...
@@ -612,8 +612,8 @@ abstract class BuildContext {
///
/// Elements can, in principle, have children. Only subclasses of
/// RenderObjectElement are allowed to have more than one child.
abstract
class
Element
<
T
extends
Widget
>
implements
BuildContext
{
Element
(
T
widget
)
:
_widget
=
widget
{
abstract
class
Element
implements
BuildContext
{
Element
(
Widget
widget
)
:
_widget
=
widget
{
assert
(
widget
!=
null
);
}
...
...
@@ -633,8 +633,8 @@ abstract class Element<T extends Widget> implements BuildContext {
int
_depth
;
/// The configuration for this element.
T
get
widget
=>
_widget
;
T
_widget
;
Widget
get
widget
=>
_widget
;
Widget
_widget
;
bool
_active
=
false
;
...
...
@@ -744,7 +744,7 @@ abstract class Element<T extends Widget> implements BuildContext {
}
/// Called when an Element receives a new configuration widget.
void
update
(
T
newWidget
)
{
void
update
(
Widget
newWidget
)
{
assert
(
_debugLifecycleState
==
_ElementLifecycle
.
active
);
assert
(
widget
!=
null
);
assert
(
newWidget
!=
null
);
...
...
@@ -1040,8 +1040,8 @@ typedef void BuildScheduler(BuildableElement element);
/// Base class for instantiations of widgets that have builders and can be
/// marked dirty.
abstract
class
BuildableElement
<
T
extends
Widget
>
extends
Element
<
T
>
{
BuildableElement
(
T
widget
)
:
super
(
widget
);
abstract
class
BuildableElement
extends
Element
{
BuildableElement
(
Widget
widget
)
:
super
(
widget
);
/// Returns true if the element has been marked as needing rebuilding.
bool
get
dirty
=>
_dirty
;
...
...
@@ -1197,8 +1197,8 @@ typedef Widget WidgetBuilder(BuildContext context);
/// Base class for the instantiation of StatelessComponent, StatefulComponent,
/// and ProxyComponent widgets.
abstract
class
ComponentElement
<
T
extends
Widget
>
extends
BuildableElement
<
T
>
{
ComponentElement
(
T
widget
)
:
super
(
widget
);
abstract
class
ComponentElement
extends
BuildableElement
{
ComponentElement
(
Widget
widget
)
:
super
(
widget
);
WidgetBuilder
_builder
;
Element
_child
;
...
...
@@ -1271,12 +1271,14 @@ abstract class ComponentElement<T extends Widget> extends BuildableElement<T> {
}
/// Instantiation of StatelessComponent widgets.
class
StatelessComponentElement
<
T
extends
StatelessComponent
>
extends
ComponentElement
<
T
>
{
StatelessComponentElement
(
T
widget
)
:
super
(
widget
)
{
class
StatelessComponentElement
extends
ComponentElement
{
StatelessComponentElement
(
StatelessComponent
widget
)
:
super
(
widget
)
{
_builder
=
widget
.
build
;
}
void
update
(
T
newWidget
)
{
StatelessComponent
get
widget
=>
super
.
widget
;
void
update
(
StatelessComponent
newWidget
)
{
super
.
update
(
newWidget
);
assert
(
widget
==
newWidget
);
_builder
=
widget
.
build
;
...
...
@@ -1286,10 +1288,10 @@ class StatelessComponentElement<T extends StatelessComponent> extends ComponentE
}
/// Instantiation of StatefulComponent widgets.
class
StatefulComponentElement
<
T
extends
StatefulComponent
,
U
extends
State
<
T
>>
extends
ComponentElement
<
T
>
{
StatefulComponentElement
(
T
widget
)
class
StatefulComponentElement
extends
ComponentElement
{
StatefulComponentElement
(
StatefulComponent
widget
)
:
_state
=
widget
.
createState
(),
super
(
widget
)
{
assert
(
_state
.
_debugTypesAreRight
(
widget
));
// can't use T and U, since normally we don't actually set those
assert
(
_state
.
_debugTypesAreRight
(
widget
));
assert
(
_state
.
_element
==
null
);
_state
.
_element
=
this
;
assert
(
_builder
==
null
);
...
...
@@ -1299,8 +1301,8 @@ class StatefulComponentElement<T extends StatefulComponent, U extends State<T>>
assert
(
_state
.
_debugLifecycleState
==
_StateLifecycle
.
created
);
}
U
get
state
=>
_state
;
U
_state
;
State
<
StatefulComponent
>
get
state
=>
_state
;
State
<
StatefulComponent
>
_state
;
void
_firstBuild
()
{
assert
(
_state
.
_debugLifecycleState
==
_StateLifecycle
.
created
);
...
...
@@ -1323,7 +1325,7 @@ class StatefulComponentElement<T extends StatefulComponent, U extends State<T>>
super
.
_firstBuild
();
}
void
update
(
T
newWidget
)
{
void
update
(
StatefulComponent
newWidget
)
{
super
.
update
(
newWidget
);
assert
(
widget
==
newWidget
);
StatefulComponent
oldConfig
=
_state
.
_config
;
...
...
@@ -1375,15 +1377,17 @@ class StatefulComponentElement<T extends StatefulComponent, U extends State<T>>
}
}
abstract
class
_ProxyElement
<
T
extends
_ProxyComponent
>
extends
ComponentElement
<
T
>
{
_ProxyElement
(
T
widget
)
:
super
(
widget
)
{
abstract
class
_ProxyElement
extends
ComponentElement
{
_ProxyElement
(
_ProxyComponent
widget
)
:
super
(
widget
)
{
_builder
=
_build
;
}
_ProxyComponent
get
widget
=>
super
.
widget
;
Widget
_build
(
BuildContext
context
)
=>
widget
.
child
;
void
update
(
T
newWidget
)
{
T
oldWidget
=
widget
;
void
update
(
_ProxyComponent
newWidget
)
{
_ProxyComponent
oldWidget
=
widget
;
assert
(
widget
!=
null
);
assert
(
widget
!=
newWidget
);
super
.
update
(
newWidget
);
...
...
@@ -1393,18 +1397,20 @@ abstract class _ProxyElement<T extends _ProxyComponent> extends ComponentElement
rebuild
();
}
void
notifyDescendants
(
T
oldWidget
);
void
notifyDescendants
(
_ProxyComponent
oldWidget
);
}
class
ParentDataElement
extends
_ProxyElement
<
ParentDataWidget
>
{
ParentDataElement
(
ParentDataWidget
widget
)
:
super
(
widget
);
class
ParentDataElement
<
T
extends
RenderObjectWidget
>
extends
_ProxyElement
{
ParentDataElement
(
ParentDataWidget
<
T
>
widget
)
:
super
(
widget
);
ParentDataWidget
<
T
>
get
widget
=>
super
.
widget
;
void
mount
(
Element
parent
,
dynamic
slot
)
{
assert
(()
{
List
<
Widget
>
badAncestors
=
<
Widget
>[];
Element
ancestor
=
parent
;
while
(
ancestor
!=
null
)
{
if
(
ancestor
is
ParentDataElement
)
{
if
(
ancestor
is
ParentDataElement
<
dynamic
>
)
{
badAncestors
.
add
(
ancestor
.
widget
);
}
else
if
(
ancestor
is
RenderObjectElement
)
{
if
(
widget
.
debugIsValidAncestor
(
ancestor
.
widget
))
...
...
@@ -1428,22 +1434,26 @@ class ParentDataElement extends _ProxyElement<ParentDataWidget> {
super
.
mount
(
parent
,
slot
);
}
void
notifyDescendants
(
ParentDataWidget
oldWidget
)
{
void
notifyDescendants
(
ParentDataWidget
<
T
>
oldWidget
)
{
void
notifyChildren
(
Element
child
)
{
if
(
child
is
RenderObjectElement
)
if
(
child
is
RenderObjectElement
)
{
child
.
updateParentData
(
widget
);
else
if
(
child
is
!
ParentDataElement
)
}
else
{
assert
(
child
is
!
ParentDataElement
<
dynamic
>);
child
.
visitChildren
(
notifyChildren
);
}
}
visitChildren
(
notifyChildren
);
}
}
class
InheritedElement
extends
_ProxyElement
<
InheritedWidget
>
{
class
InheritedElement
extends
_ProxyElement
{
InheritedElement
(
InheritedWidget
widget
)
:
super
(
widget
);
InheritedWidget
get
widget
=>
super
.
widget
;
final
Set
<
Element
>
_dependants
=
new
HashSet
<
Element
>();
void
_updateInheritance
()
{
...
...
@@ -1481,8 +1491,10 @@ class InheritedElement extends _ProxyElement<InheritedWidget> {
}
/// Base class for instantiations of RenderObjectWidget subclasses
abstract
class
RenderObjectElement
<
T
extends
RenderObjectWidget
>
extends
BuildableElement
<
T
>
{
RenderObjectElement
(
T
widget
)
:
super
(
widget
);
abstract
class
RenderObjectElement
extends
BuildableElement
{
RenderObjectElement
(
RenderObjectWidget
widget
)
:
super
(
widget
);
RenderObjectWidget
get
widget
=>
super
.
widget
;
/// The underlying [RenderObject] for this element
RenderObject
get
renderObject
=>
_renderObject
;
...
...
@@ -1497,10 +1509,10 @@ abstract class RenderObjectElement<T extends RenderObjectWidget> extends Buildab
return
ancestor
;
}
ParentDataElement
_findAncestorParentDataElement
()
{
ParentDataElement
<
dynamic
>
_findAncestorParentDataElement
()
{
Element
ancestor
=
_parent
;
while
(
ancestor
!=
null
&&
ancestor
is
!
RenderObjectElement
)
{
if
(
ancestor
is
ParentDataElement
)
if
(
ancestor
is
ParentDataElement
<
dynamic
>
)
return
ancestor
;
ancestor
=
ancestor
.
_parent
;
}
...
...
@@ -1516,7 +1528,7 @@ abstract class RenderObjectElement<T extends RenderObjectWidget> extends Buildab
_dirty
=
false
;
}
void
update
(
T
newWidget
)
{
void
update
(
RenderObjectWidget
newWidget
)
{
super
.
update
(
newWidget
);
assert
(
widget
==
newWidget
);
assert
(()
{
debugUpdateRenderObjectOwner
();
return
true
;
});
...
...
@@ -1702,7 +1714,7 @@ abstract class RenderObjectElement<T extends RenderObjectWidget> extends Buildab
widget
.
didUnmountRenderObject
(
renderObject
);
}
void
updateParentData
(
ParentDataWidget
parentData
)
{
void
updateParentData
(
ParentDataWidget
<
dynamic
>
parentData
)
{
parentData
.
applyParentData
(
renderObject
);
}
...
...
@@ -1718,7 +1730,7 @@ abstract class RenderObjectElement<T extends RenderObjectWidget> extends Buildab
_slot
=
newSlot
;
_ancestorRenderObjectElement
=
_findAncestorRenderObjectElement
();
_ancestorRenderObjectElement
?.
insertChildRenderObject
(
renderObject
,
newSlot
);
ParentDataElement
parentDataElement
=
_findAncestorParentDataElement
();
ParentDataElement
<
dynamic
>
parentDataElement
=
_findAncestorParentDataElement
();
if
(
parentDataElement
!=
null
)
updateParentData
(
parentDataElement
.
widget
);
}
...
...
@@ -1743,8 +1755,8 @@ abstract class RenderObjectElement<T extends RenderObjectWidget> extends Buildab
}
/// Instantiation of RenderObjectWidgets that have no children
class
LeafRenderObjectElement
<
T
extends
RenderObjectWidget
>
extends
RenderObjectElement
<
T
>
{
LeafRenderObjectElement
(
T
widget
):
super
(
widget
);
class
LeafRenderObjectElement
extends
RenderObjectElement
{
LeafRenderObjectElement
(
LeafRenderObjectWidget
widget
):
super
(
widget
);
void
insertChildRenderObject
(
RenderObject
child
,
dynamic
slot
)
{
assert
(
false
);
...
...
@@ -1760,8 +1772,10 @@ class LeafRenderObjectElement<T extends RenderObjectWidget> extends RenderObject
}
/// Instantiation of RenderObjectWidgets that have up to one child
class
OneChildRenderObjectElement
<
T
extends
OneChildRenderObjectWidget
>
extends
RenderObjectElement
<
T
>
{
OneChildRenderObjectElement
(
T
widget
)
:
super
(
widget
);
class
OneChildRenderObjectElement
extends
RenderObjectElement
{
OneChildRenderObjectElement
(
OneChildRenderObjectWidget
widget
)
:
super
(
widget
);
OneChildRenderObjectWidget
get
widget
=>
super
.
widget
;
Element
_child
;
...
...
@@ -1782,14 +1796,14 @@ class OneChildRenderObjectElement<T extends OneChildRenderObjectWidget> extends
_child
=
updateChild
(
_child
,
widget
.
child
,
null
);
}
void
update
(
T
newWidget
)
{
void
update
(
OneChildRenderObjectWidget
newWidget
)
{
super
.
update
(
newWidget
);
assert
(
widget
==
newWidget
);
_child
=
updateChild
(
_child
,
widget
.
child
,
null
);
}
void
insertChildRenderObject
(
RenderObject
child
,
dynamic
slot
)
{
final
RenderObjectWithChildMixin
renderObject
=
this
.
renderObject
;
final
RenderObjectWithChildMixin
<
dynamic
>
renderObject
=
this
.
renderObject
;
assert
(
slot
==
null
);
renderObject
.
child
=
child
;
assert
(
renderObject
==
this
.
renderObject
);
...
...
@@ -1800,7 +1814,7 @@ class OneChildRenderObjectElement<T extends OneChildRenderObjectWidget> extends
}
void
removeChildRenderObject
(
RenderObject
child
)
{
final
RenderObjectWithChildMixin
renderObject
=
this
.
renderObject
;
final
RenderObjectWithChildMixin
<
dynamic
>
renderObject
=
this
.
renderObject
;
assert
(
renderObject
.
child
==
child
);
renderObject
.
child
=
null
;
assert
(
renderObject
==
this
.
renderObject
);
...
...
@@ -1808,37 +1822,39 @@ class OneChildRenderObjectElement<T extends OneChildRenderObjectWidget> extends
}
/// Instantiation of RenderObjectWidgets that can have a list of children
class
MultiChildRenderObjectElement
<
T
extends
MultiChildRenderObjectWidget
>
extends
RenderObjectElement
<
T
>
{
MultiChildRenderObjectElement
(
T
widget
)
:
super
(
widget
)
{
class
MultiChildRenderObjectElement
extends
RenderObjectElement
{
MultiChildRenderObjectElement
(
MultiChildRenderObjectWidget
widget
)
:
super
(
widget
)
{
assert
(!
_debugHasDuplicateIds
());
}
MultiChildRenderObjectWidget
get
widget
=>
super
.
widget
;
List
<
Element
>
_children
;
// We keep a set of detached children to avoid O(n^2) work walking _children
// repeatedly to remove children.
final
Set
<
Element
>
_detachedChildren
=
new
HashSet
<
Element
>();
void
insertChildRenderObject
(
RenderObject
child
,
Element
slot
)
{
final
ContainerRenderObjectMixin
renderObject
=
this
.
renderObject
;
final
ContainerRenderObjectMixin
<
dynamic
,
dynamic
>
renderObject
=
this
.
renderObject
;
renderObject
.
insert
(
child
,
after:
slot
?.
renderObject
);
assert
(
renderObject
==
this
.
renderObject
);
}
void
moveChildRenderObject
(
RenderObject
child
,
dynamic
slot
)
{
final
ContainerRenderObjectMixin
renderObject
=
this
.
renderObject
;
final
ContainerRenderObjectMixin
<
dynamic
,
dynamic
>
renderObject
=
this
.
renderObject
;
renderObject
.
move
(
child
,
after:
slot
?.
renderObject
);
assert
(
renderObject
==
this
.
renderObject
);
}
void
removeChildRenderObject
(
RenderObject
child
)
{
final
ContainerRenderObjectMixin
renderObject
=
this
.
renderObject
;
final
ContainerRenderObjectMixin
<
dynamic
,
dynamic
>
renderObject
=
this
.
renderObject
;
assert
(
child
.
parent
==
renderObject
);
renderObject
.
remove
(
child
);
assert
(
renderObject
==
this
.
renderObject
);
}
bool
_debugHasDuplicateIds
()
{
var
idSet
=
new
HashSet
<
Key
>();
Set
<
Key
>
idSet
=
new
HashSet
<
Key
>();
for
(
Widget
child
in
widget
.
children
)
{
assert
(
child
!=
null
);
if
(
child
.
key
==
null
)
...
...
@@ -1879,7 +1895,7 @@ class MultiChildRenderObjectElement<T extends MultiChildRenderObjectWidget> exte
}
}
void
update
(
T
newWidget
)
{
void
update
(
MultiChildRenderObjectWidget
newWidget
)
{
super
.
update
(
newWidget
);
assert
(
widget
==
newWidget
);
_children
=
updateChildren
(
_children
,
widget
.
children
,
detachedChildren:
_detachedChildren
);
...
...
packages/flutter/lib/src/widgets/heroes.dart
View file @
6795efac
...
...
@@ -104,10 +104,11 @@ class Hero extends StatefulComponent {
Map
<
Object
,
Map
<
Key
,
HeroState
>>
heroes
=
<
Object
,
Map
<
Key
,
HeroState
>>{};
void
visitor
(
Element
element
)
{
if
(
element
.
widget
is
Hero
)
{
StatefulComponentElement
<
Hero
,
HeroState
>
hero
=
element
;
Object
tag
=
hero
.
widget
.
tag
;
StatefulComponentElement
hero
=
element
;
Hero
heroWidget
=
element
.
widget
;
Object
tag
=
heroWidget
.
tag
;
assert
(
tag
!=
null
);
Key
key
=
hero
.
w
idget
.
key
;
Key
key
=
hero
W
idget
.
key
;
final
Map
<
Key
,
HeroState
>
tagHeroes
=
heroes
.
putIfAbsent
(
tag
,
()
=>
<
Key
,
HeroState
>{});
assert
(()
{
if
(
tagHeroes
.
containsKey
(
key
))
{
...
...
@@ -395,17 +396,17 @@ class HeroController extends NavigatorObserver {
HeroParty
_party
;
Animation
<
double
>
_animation
;
PageRoute
_from
;
PageRoute
_to
;
PageRoute
<
dynamic
>
_from
;
PageRoute
<
dynamic
>
_to
;
final
List
<
OverlayEntry
>
_overlayEntries
=
new
List
<
OverlayEntry
>();
void
didPush
(
Route
route
,
Route
previousRoute
)
{
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
assert
(
navigator
!=
null
);
assert
(
route
!=
null
);
if
(
route
is
PageRoute
)
{
if
(
route
is
PageRoute
<
dynamic
>
)
{
assert
(
route
.
animation
!=
null
);
if
(
previousRoute
is
PageRoute
)
// could be null
if
(
previousRoute
is
PageRoute
<
dynamic
>
)
// could be null
_from
=
previousRoute
;
_to
=
route
;
_animation
=
route
.
animation
;
...
...
@@ -413,12 +414,12 @@ class HeroController extends NavigatorObserver {
}
}
void
didPop
(
Route
route
,
Route
previousRoute
)
{
void
didPop
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
assert
(
navigator
!=
null
);
assert
(
route
!=
null
);
if
(
route
is
PageRoute
)
{
if
(
route
is
PageRoute
<
dynamic
>
)
{
assert
(
route
.
animation
!=
null
);
if
(
previousRoute
is
PageRoute
)
{
if
(
previousRoute
is
PageRoute
<
dynamic
>
)
{
_to
=
previousRoute
;
_from
=
route
;
_animation
=
route
.
animation
;
...
...
packages/flutter/lib/src/widgets/implicit_animations.dart
View file @
6795efac
...
...
@@ -68,7 +68,7 @@ abstract class AnimatedWidgetBase extends StatefulComponent {
/// The duration over which to animate the parameters of this container.
final
Duration
duration
;
AnimatedWidgetBaseState
createState
();
AnimatedWidgetBaseState
<
AnimatedWidgetBase
>
createState
();
void
debugFillDescription
(
List
<
String
>
description
)
{
super
.
debugFillDescription
(
description
);
...
...
@@ -105,7 +105,7 @@ abstract class AnimatedWidgetBaseState<T extends AnimatedWidgetBase> extends Sta
_updateCurve
();
_controller
.
duration
=
config
.
duration
;
if
(
_constructTweens
())
{
forEachTween
((
Tween
tween
,
dynamic
targetValue
,
TweenConstructor
<
T
>
constructor
)
{
forEachTween
((
Tween
<
dynamic
>
tween
,
dynamic
targetValue
,
TweenConstructor
<
dynamic
>
constructor
)
{
_updateTween
(
tween
,
targetValue
);
return
tween
;
});
...
...
@@ -131,11 +131,11 @@ abstract class AnimatedWidgetBaseState<T extends AnimatedWidgetBase> extends Sta
setState
(()
{
});
}
bool
_shouldAnimateTween
(
Tween
tween
,
dynamic
targetValue
)
{
bool
_shouldAnimateTween
(
Tween
<
dynamic
>
tween
,
dynamic
targetValue
)
{
return
targetValue
!=
(
tween
.
end
??
tween
.
begin
);
}
void
_updateTween
(
Tween
tween
,
dynamic
targetValue
)
{
void
_updateTween
(
Tween
<
dynamic
>
tween
,
dynamic
targetValue
)
{
if
(
tween
==
null
)
return
;
tween
...
...
@@ -145,7 +145,7 @@ abstract class AnimatedWidgetBaseState<T extends AnimatedWidgetBase> extends Sta
bool
_constructTweens
()
{
bool
shouldStartAnimation
=
false
;
forEachTween
((
Tween
tween
,
dynamic
targetValue
,
TweenConstructor
<
T
>
constructor
)
{
forEachTween
((
Tween
<
dynamic
>
tween
,
dynamic
targetValue
,
TweenConstructor
<
T
>
constructor
)
{
if
(
targetValue
!=
null
)
{
tween
??=
constructor
(
targetValue
);
if
(
_shouldAnimateTween
(
tween
,
targetValue
))
...
...
@@ -173,7 +173,7 @@ abstract class AnimatedWidgetBaseState<T extends AnimatedWidgetBase> extends Sta
/// 2. Take the value returned from the callback, and store it. This is the
/// value to use as the current value the next time that the forEachTween()
/// method is called.
void
forEachTween
(
TweenVisitor
visitor
);
void
forEachTween
(
TweenVisitor
<
dynamic
>
visitor
);
}
/// A container that gradually changes its values over a period of time.
...
...
@@ -262,7 +262,7 @@ class _AnimatedContainerState extends AnimatedWidgetBaseState<AnimatedContainer>
Tween
<
double
>
_width
;
Tween
<
double
>
_height
;
void
forEachTween
(
TweenVisitor
visitor
)
{
void
forEachTween
(
TweenVisitor
<
dynamic
>
visitor
)
{
// TODO(ianh): Use constructor tear-offs when it becomes possible
_constraints
=
visitor
(
_constraints
,
config
.
constraints
,
(
dynamic
value
)
=>
new
BoxConstraintsTween
(
begin:
value
));
_decoration
=
visitor
(
_decoration
,
config
.
decoration
,
(
dynamic
value
)
=>
new
DecorationTween
(
begin:
value
));
...
...
@@ -381,7 +381,7 @@ class _AnimatedPositionedState extends AnimatedWidgetBaseState<AnimatedPositione
Tween
<
double
>
_width
;
Tween
<
double
>
_height
;
void
forEachTween
(
TweenVisitor
visitor
)
{
void
forEachTween
(
TweenVisitor
<
dynamic
>
visitor
)
{
// TODO(ianh): Use constructor tear-offs when it becomes possible
_left
=
visitor
(
_left
,
config
.
left
,
(
dynamic
value
)
=>
new
Tween
<
double
>(
begin:
value
));
_top
=
visitor
(
_top
,
config
.
top
,
(
dynamic
value
)
=>
new
Tween
<
double
>(
begin:
value
));
...
...
packages/flutter/lib/src/widgets/locale_query.dart
View file @
6795efac
...
...
@@ -5,10 +5,10 @@
import
'framework.dart'
;
/// Superclass for locale-specific data provided by the application.
class
LocaleQueryData
{
}
class
LocaleQueryData
{
}
// TODO(ianh): We need a better type here. This doesn't really make sense.
/// Establishes a subtree in which locale queries resolve to the given data.
class
LocaleQuery
<
T
extends
LocaleQueryData
>
extends
InheritedWidget
{
class
LocaleQuery
extends
InheritedWidget
{
LocaleQuery
({
Key
key
,
this
.
data
,
...
...
@@ -18,7 +18,7 @@ class LocaleQuery<T extends LocaleQueryData> extends InheritedWidget {
}
/// The locale data for this subtree.
final
T
data
;
final
LocaleQueryData
data
;
/// The data from the closest instance of this class that encloses the given context.
static
LocaleQueryData
of
(
BuildContext
context
)
{
...
...
packages/flutter/lib/src/widgets/mimic.dart
View file @
6795efac
...
...
@@ -48,7 +48,7 @@ class MimicOverlayEntry {
/// given curve.
///
/// This function can only be called once per overlay entry.
Future
animateTo
({
Future
<
Null
>
animateTo
({
GlobalKey
targetKey
,
Duration
duration
,
Curve
curve:
Curves
.
linear
...
...
packages/flutter/lib/src/widgets/mixed_viewport.dart
View file @
6795efac
...
...
@@ -68,12 +68,14 @@ class _ChildKey {
String
toString
()
=>
"_ChildKey(type:
$type
, key:
$key
)"
;
}
class
_MixedViewportElement
extends
RenderObjectElement
<
MixedViewport
>
{
class
_MixedViewportElement
extends
RenderObjectElement
{
_MixedViewportElement
(
MixedViewport
widget
)
:
super
(
widget
)
{
if
(
widget
.
onInvalidatorAvailable
!=
null
)
widget
.
onInvalidatorAvailable
(
invalidate
);
}
MixedViewport
get
widget
=>
super
.
widget
;
/// _childExtents contains the extents of each child from the top of the list
/// up to the last one we've ever created.
final
List
<
double
>
_childExtents
=
<
double
>[];
...
...
packages/flutter/lib/src/widgets/navigator.dart
View file @
6795efac
...
...
@@ -33,7 +33,7 @@ abstract class Route<T> {
void
didPush
()
{
}
/// Called after install() when the route replaced another in the navigator.
void
didReplace
(
Route
oldRoute
)
{
}
void
didReplace
(
Route
<
dynamic
>
oldRoute
)
{
}
/// A request was made to pop this route. If the route can handle it
/// internally (e.g. because it has its own stack of internal state) then
...
...
@@ -49,13 +49,13 @@ abstract class Route<T> {
/// The given route, which came after this one, has been popped off the
/// navigator.
void
didPopNext
(
Route
nextRoute
)
{
}
void
didPopNext
(
Route
<
dynamic
>
nextRoute
)
{
}
/// This route's next route has changed to the given new route. This is called
/// on a route whenever the next route changes for any reason, except for
/// cases when didPopNext() would be called, so long as it is in the history.
/// nextRoute will be null if there's no next route.
void
didChangeNext
(
Route
nextRoute
)
{
}
void
didChangeNext
(
Route
<
dynamic
>
nextRoute
)
{
}
/// The route should remove its overlays and free any other resources.
///
...
...
@@ -109,7 +109,7 @@ class RouteSettings {
}
/// Creates a route for the given route settings.
typedef
Route
RouteFactory
(
RouteSettings
settings
);
typedef
Route
<
dynamic
>
RouteFactory
(
RouteSettings
settings
);
/// A callback in during which you can perform a number of navigator operations (e.g., pop, push) that happen atomically.
typedef
void
NavigatorTransactionCallback
(
NavigatorTransaction
transaction
);
...
...
@@ -121,10 +121,10 @@ class NavigatorObserver {
NavigatorState
_navigator
;
/// The [Navigator] pushed the given route.
void
didPush
(
Route
route
,
Route
previousRoute
)
{
}
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
}
/// THe [Navigator] popped the given route.
void
didPop
(
Route
route
,
Route
previousRoute
)
{
}
void
didPop
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
}
}
/// Manages a set of child widgets with a stack discipline.
...
...
@@ -189,7 +189,7 @@ class Navigator extends StatefulComponent {
/// Navigator observer, if any, will have didPush() called on it.
///
/// Uses [openTransaction()]. Only one transaction will be executed per frame.
static
void
push
(
BuildContext
context
,
Route
route
)
{
static
void
push
(
BuildContext
context
,
Route
<
dynamic
>
route
)
{
openTransaction
(
context
,
(
NavigatorTransaction
transaction
)
{
transaction
.
push
(
route
);
});
...
...
@@ -224,7 +224,7 @@ class Navigator extends StatefulComponent {
/// If it is already the current route, nothing happens.
///
/// Uses [openTransaction()]. Only one transaction will be executed per frame.
static
void
popUntil
(
BuildContext
context
,
Route
targetRoute
)
{
static
void
popUntil
(
BuildContext
context
,
Route
<
dynamic
>
targetRoute
)
{
openTransaction
(
context
,
(
NavigatorTransaction
transaction
)
{
transaction
.
popUntil
(
targetRoute
);
});
...
...
@@ -277,7 +277,7 @@ class Navigator extends StatefulComponent {
/// The state for a [Navigator] widget.
class
NavigatorState
extends
State
<
Navigator
>
{
final
GlobalKey
<
OverlayState
>
_overlayKey
=
new
GlobalKey
<
OverlayState
>();
final
List
<
Route
>
_history
=
new
List
<
Route
>();
final
List
<
Route
<
dynamic
>>
_history
=
new
List
<
Route
<
dynamic
>
>();
void
initState
()
{
super
.
initState
();
...
...
@@ -301,7 +301,7 @@ class NavigatorState extends State<Navigator> {
assert
(!
_debugLocked
);
assert
(()
{
_debugLocked
=
true
;
return
true
;
});
config
.
observer
?.
_navigator
=
null
;
for
(
Route
route
in
_history
)
{
for
(
Route
<
dynamic
>
route
in
_history
)
{
route
.
dispose
();
route
.
_navigator
=
null
;
}
...
...
@@ -313,7 +313,7 @@ class NavigatorState extends State<Navigator> {
OverlayState
get
overlay
=>
_overlayKey
.
currentState
;
OverlayEntry
get
_currentOverlayEntry
{
for
(
Route
route
in
_history
.
reversed
)
{
for
(
Route
<
dynamic
>
route
in
_history
.
reversed
)
{
if
(
route
.
overlayEntries
.
isNotEmpty
)
return
route
.
overlayEntries
.
last
;
}
...
...
@@ -329,7 +329,7 @@ class NavigatorState extends State<Navigator> {
name:
name
,
mostValuableKeys:
mostValuableKeys
);
Route
route
=
config
.
onGenerateRoute
(
settings
);
Route
<
dynamic
>
route
=
config
.
onGenerateRoute
(
settings
);
if
(
route
==
null
)
{
assert
(
config
.
onUnknownRoute
!=
null
);
route
=
config
.
onUnknownRoute
(
settings
);
...
...
@@ -338,13 +338,13 @@ class NavigatorState extends State<Navigator> {
_push
(
route
);
}
void
_push
(
Route
route
)
{
void
_push
(
Route
<
dynamic
>
route
)
{
assert
(!
_debugLocked
);
assert
(()
{
_debugLocked
=
true
;
return
true
;
});
assert
(
route
!=
null
);
assert
(
route
.
_navigator
==
null
);
setState
(()
{
Route
oldRoute
=
_history
.
isNotEmpty
?
_history
.
last
:
null
;
Route
<
dynamic
>
oldRoute
=
_history
.
isNotEmpty
?
_history
.
last
:
null
;
route
.
_navigator
=
this
;
route
.
install
(
_currentOverlayEntry
);
_history
.
add
(
route
);
...
...
@@ -357,7 +357,7 @@ class NavigatorState extends State<Navigator> {
assert
(()
{
_debugLocked
=
false
;
return
true
;
});
}
void
_replace
({
Route
oldRoute
,
Route
newRoute
})
{
void
_replace
({
Route
<
dynamic
>
oldRoute
,
Route
<
dynamic
>
newRoute
})
{
assert
(!
_debugLocked
);
assert
(
oldRoute
!=
null
);
assert
(
newRoute
!=
null
);
...
...
@@ -388,25 +388,25 @@ class NavigatorState extends State<Navigator> {
assert
(()
{
_debugLocked
=
false
;
return
true
;
});
}
void
_replaceRouteBefore
({
Route
anchorRoute
,
Route
newRoute
})
{
void
_replaceRouteBefore
({
Route
<
dynamic
>
anchorRoute
,
Route
<
dynamic
>
newRoute
})
{
assert
(
anchorRoute
!=
null
);
assert
(
anchorRoute
.
_navigator
==
this
);
assert
(
_history
.
indexOf
(
anchorRoute
)
>
0
);
_replace
(
oldRoute:
_history
[
_history
.
indexOf
(
anchorRoute
)-
1
],
newRoute:
newRoute
);
}
void
_removeRouteBefore
(
Route
anchorRoute
)
{
void
_removeRouteBefore
(
Route
<
dynamic
>
anchorRoute
)
{
assert
(!
_debugLocked
);
assert
(()
{
_debugLocked
=
true
;
return
true
;
});
assert
(
anchorRoute
.
_navigator
==
this
);
int
index
=
_history
.
indexOf
(
anchorRoute
)
-
1
;
assert
(
index
>=
0
);
Route
targetRoute
=
_history
[
index
];
Route
<
dynamic
>
targetRoute
=
_history
[
index
];
assert
(
targetRoute
.
_navigator
==
this
);
assert
(
targetRoute
.
overlayEntries
.
isEmpty
||
!
overlay
.
debugIsVisible
(
targetRoute
.
overlayEntries
.
last
));
setState
(()
{
_history
.
removeAt
(
index
);
Route
newRoute
=
index
<
_history
.
length
?
_history
[
index
]
:
null
;
Route
<
dynamic
>
newRoute
=
index
<
_history
.
length
?
_history
[
index
]
:
null
;
if
(
index
>
0
)
_history
[
index
-
1
].
didChangeNext
(
newRoute
);
targetRoute
.
dispose
();
...
...
@@ -418,7 +418,7 @@ class NavigatorState extends State<Navigator> {
bool
_pop
([
dynamic
result
])
{
assert
(!
_debugLocked
);
assert
(()
{
_debugLocked
=
true
;
return
true
;
});
Route
route
=
_history
.
last
;
Route
<
dynamic
>
route
=
_history
.
last
;
assert
(
route
.
_navigator
==
this
);
bool
debugPredictedWouldPop
;
assert
(()
{
debugPredictedWouldPop
=
!
route
.
willHandlePopInternally
;
return
true
;
});
...
...
@@ -445,7 +445,7 @@ class NavigatorState extends State<Navigator> {
return
true
;
}
void
_popUntil
(
Route
targetRoute
)
{
void
_popUntil
(
Route
<
dynamic
>
targetRoute
)
{
assert
(
_history
.
contains
(
targetRoute
));
while
(!
targetRoute
.
isCurrent
)
_pop
();
...
...
@@ -512,7 +512,7 @@ class NavigatorTransaction {
/// The route will have didPush() and didChangeNext() called on it; the
/// previous route, if any, will have didChangeNext() called on it; and the
/// Navigator observer, if any, will have didPush() called on it.
void
push
(
Route
route
)
{
void
push
(
Route
<
dynamic
>
route
)
{
assert
(
_debugOpen
);
_navigator
.
_push
(
route
);
}
...
...
@@ -528,7 +528,7 @@ class NavigatorTransaction {
///
/// It is safe to call this redundantly (replacing a route with itself). Such
/// calls are ignored.
void
replace
({
Route
oldRoute
,
Route
newRoute
})
{
void
replace
({
Route
<
dynamic
>
oldRoute
,
Route
<
dynamic
>
newRoute
})
{
assert
(
_debugOpen
);
_navigator
.
_replace
(
oldRoute:
oldRoute
,
newRoute:
newRoute
);
}
...
...
@@ -541,14 +541,14 @@ class NavigatorTransaction {
///
/// The conditions described for [replace()] apply; for instance, the route
/// before anchorRoute must have overlay entries.
void
replaceRouteBefore
({
Route
anchorRoute
,
Route
newRoute
})
{
void
replaceRouteBefore
({
Route
<
dynamic
>
anchorRoute
,
Route
<
dynamic
>
newRoute
})
{
assert
(
_debugOpen
);
_navigator
.
_replaceRouteBefore
(
anchorRoute:
anchorRoute
,
newRoute:
newRoute
);
}
/// Removes the route prior to the given anchorRoute, and calls didChangeNext
/// on the route prior to that one, if any. The observer is not notified.
void
removeRouteBefore
(
Route
anchorRoute
)
{
void
removeRouteBefore
(
Route
<
dynamic
>
anchorRoute
)
{
assert
(
_debugOpen
);
_navigator
.
_removeRouteBefore
(
anchorRoute
);
}
...
...
@@ -573,7 +573,7 @@ class NavigatorTransaction {
/// Calls pop() repeatedly until the given route is the current route.
/// If it is already the current route, nothing happens.
void
popUntil
(
Route
targetRoute
)
{
void
popUntil
(
Route
<
dynamic
>
targetRoute
)
{
assert
(
_debugOpen
);
_navigator
.
_popUntil
(
targetRoute
);
}
...
...
packages/flutter/lib/src/widgets/notification_listener.dart
View file @
6795efac
...
...
@@ -13,9 +13,9 @@ abstract class Notification {
void
dispatch
(
BuildContext
target
)
{
target
.
visitAncestorElements
((
Element
element
)
{
if
(
element
is
StatelessComponentElement
&&
element
.
widget
is
NotificationListener
)
{
final
NotificationListener
widget
=
element
.
widget
;
if
(
widget
.
_dispatch
(
this
))
element
.
widget
is
NotificationListener
<
dynamic
>
)
{
final
NotificationListener
<
dynamic
>
widget
=
element
.
widget
;
if
(
widget
.
_dispatch
(
this
))
// that function checks the type dynamically
return
false
;
}
return
true
;
...
...
packages/flutter/lib/src/widgets/pageable_list.dart
View file @
6795efac
...
...
@@ -71,7 +71,7 @@ class PageableList extends Scrollable {
/// The list of pages themselves.
final
Iterable
<
Widget
>
children
;
PageableListState
createState
()
=>
new
PageableListState
();
PageableListState
<
PageableList
>
createState
()
=>
new
PageableListState
<
PageableList
>
();
}
/// State for a [PageableList] widget.
...
...
@@ -185,7 +185,7 @@ class PageableListState<T extends PageableList> extends ScrollableState<T> {
return
_overscrollBehavior
;
}
ScrollBehavior
createScrollBehavior
()
=>
scrollBehavior
;
ScrollBehavior
<
double
,
double
>
createScrollBehavior
()
=>
scrollBehavior
;
bool
get
shouldSnapScrollOffset
=>
config
.
itemsSnapAlignment
==
ItemsSnapAlignment
.
item
;
...
...
@@ -196,14 +196,14 @@ class PageableListState<T extends PageableList> extends ScrollableState<T> {
.
clamp
(
scrollBehavior
.
minScrollOffset
,
scrollBehavior
.
maxScrollOffset
);
}
Future
_flingToAdjacentItem
(
double
scrollVelocity
)
{
Future
<
Null
>
_flingToAdjacentItem
(
double
scrollVelocity
)
{
final
double
newScrollOffset
=
snapScrollOffset
(
scrollOffset
+
scrollVelocity
.
sign
)
.
clamp
(
snapScrollOffset
(
scrollOffset
-
0.5
),
snapScrollOffset
(
scrollOffset
+
0.5
));
return
scrollTo
(
newScrollOffset
,
duration:
config
.
duration
,
curve:
config
.
curve
)
.
then
(
_notifyPageChanged
);
}
Future
fling
(
double
scrollVelocity
)
{
Future
<
Null
>
fling
(
double
scrollVelocity
)
{
switch
(
config
.
itemsSnapAlignment
)
{
case
ItemsSnapAlignment
.
adjacentItem
:
return
_flingToAdjacentItem
(
scrollVelocity
);
...
...
@@ -212,7 +212,7 @@ class PageableListState<T extends PageableList> extends ScrollableState<T> {
}
}
Future
settleScrollOffset
()
{
Future
<
Null
>
settleScrollOffset
()
{
return
scrollTo
(
snapScrollOffset
(
scrollOffset
),
duration:
config
.
duration
,
curve:
config
.
curve
)
.
then
(
_notifyPageChanged
);
}
...
...
@@ -247,9 +247,11 @@ class PageViewport extends VirtualViewportFromIterable {
_PageViewportElement
createElement
()
=>
new
_PageViewportElement
(
this
);
}
class
_PageViewportElement
extends
VirtualViewportElement
<
PageViewport
>
{
class
_PageViewportElement
extends
VirtualViewportElement
{
_PageViewportElement
(
PageViewport
widget
)
:
super
(
widget
);
PageViewport
get
widget
=>
super
.
widget
;
RenderList
get
renderObject
=>
super
.
renderObject
;
int
get
materializedChildBase
=>
_materializedChildBase
;
...
...
packages/flutter/lib/src/widgets/pages.dart
View file @
6795efac
...
...
@@ -17,8 +17,8 @@ abstract class PageRoute<T> extends ModalRoute<T> {
})
:
super
(
completer:
completer
,
settings:
settings
);
bool
get
opaque
=>
true
;
bool
get
barrierDismissable
=>
false
;
bool
canTransitionTo
(
TransitionRoute
nextRoute
)
=>
nextRoute
is
PageRoute
;
bool
canTransitionFrom
(
TransitionRoute
nextRoute
)
=>
nextRoute
is
PageRoute
;
bool
canTransitionTo
(
TransitionRoute
<
dynamic
>
nextRoute
)
=>
nextRoute
is
PageRoute
<
dynamic
>
;
bool
canTransitionFrom
(
TransitionRoute
<
dynamic
>
nextRoute
)
=>
nextRoute
is
PageRoute
<
dynamic
>
;
AnimationController
createAnimationController
()
{
AnimationController
controller
=
super
.
createAnimationController
();
...
...
packages/flutter/lib/src/widgets/routes.dart
View file @
6795efac
...
...
@@ -13,7 +13,7 @@ import 'overlay.dart';
import
'page_storage.dart'
;
import
'pages.dart'
;
const
_kTransparent
=
const
Color
(
0x00000000
);
const
Color
_kTransparent
=
const
Color
(
0x00000000
);
/// A route that displays widgets in the [Navigator]'s [Overlay].
abstract
class
OverlayRoute
<
T
>
extends
Route
<
T
>
{
...
...
@@ -159,8 +159,8 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
super
.
didPush
();
}
void
didReplace
(
Route
oldRoute
)
{
if
(
oldRoute
is
TransitionRoute
)
void
didReplace
(
Route
<
dynamic
>
oldRoute
)
{
if
(
oldRoute
is
TransitionRoute
<
dynamic
>
)
_controller
.
value
=
oldRoute
.
_controller
.
value
;
_animation
.
addStatusListener
(
_handleStatusChanged
);
super
.
didReplace
(
oldRoute
);
...
...
@@ -173,18 +173,18 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
return
true
;
}
void
didPopNext
(
Route
nextRoute
)
{
void
didPopNext
(
Route
<
dynamic
>
nextRoute
)
{
_updateForwardAnimation
(
nextRoute
);
super
.
didPopNext
(
nextRoute
);
}
void
didChangeNext
(
Route
nextRoute
)
{
void
didChangeNext
(
Route
<
dynamic
>
nextRoute
)
{
_updateForwardAnimation
(
nextRoute
);
super
.
didChangeNext
(
nextRoute
);
}
void
_updateForwardAnimation
(
Route
nextRoute
)
{
if
(
nextRoute
is
TransitionRoute
&&
canTransitionTo
(
nextRoute
)
&&
nextRoute
.
canTransitionFrom
(
this
))
{
void
_updateForwardAnimation
(
Route
<
dynamic
>
nextRoute
)
{
if
(
nextRoute
is
TransitionRoute
<
dynamic
>
&&
canTransitionTo
(
nextRoute
)
&&
nextRoute
.
canTransitionFrom
(
this
))
{
Animation
<
double
>
current
=
_forwardAnimation
.
parent
;
if
(
current
!=
null
)
{
if
(
current
is
TrainHoppingAnimation
)
{
...
...
@@ -216,13 +216,13 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
///
/// Subclasses can override this function to restrict the set of routes they
/// need to coordinate transitions with.
bool
canTransitionTo
(
TransitionRoute
nextRoute
)
=>
true
;
bool
canTransitionTo
(
TransitionRoute
<
dynamic
>
nextRoute
)
=>
true
;
/// Whether this route can perform a transition from the given route.
///
/// Subclasses can override this function to restrict the set of routes they
/// need to coordinate transitions with.
bool
canTransitionFrom
(
TransitionRoute
nextRoute
)
=>
true
;
bool
canTransitionFrom
(
TransitionRoute
<
dynamic
>
nextRoute
)
=>
true
;
void
finished
()
{
super
.
finished
();
...
...
@@ -245,7 +245,7 @@ class LocalHistoryEntry {
/// Called when this entry is removed from the history of its associated [LocalHistoryRoute].
final
VoidCallback
onRemove
;
LocalHistoryRoute
_owner
;
LocalHistoryRoute
<
dynamic
>
_owner
;
/// Remove this entry from the history of its associated [LocalHistoryRoute].
void
remove
()
{
...
...
@@ -323,7 +323,7 @@ class _ModalScopeStatus extends InheritedWidget {
}
final
bool
isCurrent
;
final
Route
route
;
final
Route
<
dynamic
>
route
;
bool
updateShouldNotify
(
_ModalScopeStatus
old
)
{
return
isCurrent
!=
old
.
isCurrent
||
...
...
@@ -342,7 +342,7 @@ class _ModalScope extends StatefulComponent {
this
.
route
})
:
super
(
key:
key
);
final
ModalRoute
route
;
final
ModalRoute
<
dynamic
>
route
;
_ModalScopeState
createState
()
=>
new
_ModalScopeState
();
}
...
...
@@ -444,7 +444,7 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
/// Returns the modal route most closely associated with the given context.
///
/// Returns null if the given context is not associated with a modal route.
static
ModalRoute
of
(
BuildContext
context
)
{
static
ModalRoute
<
dynamic
>
of
(
BuildContext
context
)
{
_ModalScopeStatus
widget
=
context
.
inheritFromWidgetOfExactType
(
_ModalScopeStatus
);
return
widget
?.
route
;
}
...
...
@@ -581,8 +581,8 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
abstract
class
PopupRoute
<
T
>
extends
ModalRoute
<
T
>
{
PopupRoute
({
Completer
<
T
>
completer
})
:
super
(
completer:
completer
);
bool
get
opaque
=>
false
;
void
didChangeNext
(
Route
nextRoute
)
{
assert
(
nextRoute
is
!
PageRoute
);
void
didChangeNext
(
Route
<
dynamic
>
nextRoute
)
{
assert
(
nextRoute
is
!
PageRoute
<
dynamic
>
);
super
.
didChangeNext
(
nextRoute
);
}
}
packages/flutter/lib/src/widgets/scrollable.dart
View file @
6795efac
...
...
@@ -112,13 +112,13 @@ abstract class Scrollable extends StatefulComponent {
}
/// Scrolls the closest enclosing scrollable to make the given context visible.
static
Future
ensureVisible
(
BuildContext
context
,
{
Duration
duration
,
Curve
curve:
Curves
.
ease
})
{
static
Future
<
Null
>
ensureVisible
(
BuildContext
context
,
{
Duration
duration
,
Curve
curve:
Curves
.
ease
})
{
assert
(
context
.
findRenderObject
()
is
RenderBox
);
// TODO(abarth): This function doesn't handle nested scrollable widgets.
ScrollableState
scrollable
=
Scrollable
.
of
(
context
);
if
(
scrollable
==
null
)
return
new
Future
.
value
();
return
new
Future
<
Null
>
.
value
();
RenderBox
targetBox
=
context
.
findRenderObject
();
assert
(
targetBox
.
attached
);
...
...
@@ -162,7 +162,7 @@ abstract class Scrollable extends StatefulComponent {
}
else
if
(
targetMax
>
scrollableMax
)
{
scrollOffsetDelta
=
targetMax
-
scrollableMax
;
}
else
{
return
new
Future
.
value
();
return
new
Future
<
Null
>
.
value
();
}
ExtentScrollBehavior
scrollBehavior
=
scrollable
.
scrollBehavior
;
...
...
@@ -172,13 +172,14 @@ abstract class Scrollable extends StatefulComponent {
if
(
scrollOffset
!=
scrollable
.
scrollOffset
)
return
scrollable
.
scrollTo
(
scrollOffset
,
duration:
duration
,
curve:
curve
);
return
new
Future
.
value
();
return
new
Future
<
Null
>
.
value
();
}
ScrollableState
createState
();
}
/// Contains the state for common scrolling widgets.
/// Contains the state for common scrolling widgets that scroll only
/// along one axis.
///
/// Widgets that subclass [Scrollable] typically use state objects
/// that subclass [ScrollableState].
...
...
@@ -299,14 +300,14 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
/// Scroll behaviors control where the boundaries of the scrollable are placed
/// and how the scrolling physics should behave near those boundaries and
/// after the user stops directly manipulating the scrollable.
ScrollBehavior
get
scrollBehavior
{
ScrollBehavior
<
double
,
double
>
get
scrollBehavior
{
return
_scrollBehavior
??=
createScrollBehavior
();
}
ScrollBehavior
_scrollBehavior
;
ScrollBehavior
<
double
,
double
>
_scrollBehavior
;
/// Subclasses should override this function to create the [ScrollBehavior]
/// they desire.
ScrollBehavior
createScrollBehavior
();
ScrollBehavior
<
double
,
double
>
createScrollBehavior
();
bool
_scrollOffsetIsInBounds
(
double
scrollOffset
)
{
if
(
scrollBehavior
is
!
ExtentScrollBehavior
)
...
...
@@ -336,7 +337,7 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
///
/// If a non-null [duration] is provided, the widget will animate to the new
/// scroll offset over the given duration with the given curve.
Future
scrollBy
(
double
scrollDelta
,
{
Duration
duration
,
Curve
curve:
Curves
.
ease
})
{
Future
<
Null
>
scrollBy
(
double
scrollDelta
,
{
Duration
duration
,
Curve
curve:
Curves
.
ease
})
{
double
newScrollOffset
=
scrollBehavior
.
applyCurve
(
_scrollOffset
,
scrollDelta
);
return
scrollTo
(
newScrollOffset
,
duration:
duration
,
curve:
curve
);
}
...
...
@@ -349,21 +350,21 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
/// This function does not accept a zero duration. To jump-scroll to
/// the new offset, do not provide a duration, rather than providing
/// a zero duration.
Future
scrollTo
(
double
newScrollOffset
,
{
Duration
duration
,
Curve
curve:
Curves
.
ease
})
{
Future
<
Null
>
scrollTo
(
double
newScrollOffset
,
{
Duration
duration
,
Curve
curve:
Curves
.
ease
})
{
if
(
newScrollOffset
==
_scrollOffset
)
return
new
Future
.
value
();
return
new
Future
<
Null
>
.
value
();
if
(
duration
==
null
)
{
_controller
.
stop
();
_setScrollOffset
(
newScrollOffset
);
return
new
Future
.
value
();
return
new
Future
<
Null
>
.
value
();
}
assert
(
duration
>
Duration
.
ZERO
);
return
_animateTo
(
newScrollOffset
,
duration
,
curve
);
}
Future
_animateTo
(
double
newScrollOffset
,
Duration
duration
,
Curve
curve
)
{
Future
<
Null
>
_animateTo
(
double
newScrollOffset
,
Duration
duration
,
Curve
curve
)
{
_controller
.
stop
();
_controller
.
value
=
scrollOffset
;
_startScroll
();
...
...
@@ -375,10 +376,10 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
/// Calling this function starts a physics-based animation of the scroll
/// offset with the given value as the initial velocity. The physics
/// simulation used is determined by the scroll behavior.
Future
fling
(
double
scrollVelocity
)
{
Future
<
Null
>
fling
(
double
scrollVelocity
)
{
if
(
scrollVelocity
!=
0.0
||
!
_controller
.
isAnimating
)
return
_startToEndAnimation
(
scrollVelocity
);
return
new
Future
.
value
();
return
new
Future
<
Null
>
.
value
();
}
/// Animate the scroll offset to a value with a local minima of energy.
...
...
@@ -386,15 +387,15 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
/// Calling this function starts a physics-based animation of the scroll
/// offset either to a snap point or to within the scrolling bounds. The
/// physics simulation used is determined by the scroll behavior.
Future
settleScrollOffset
()
{
Future
<
Null
>
settleScrollOffset
()
{
return
_startToEndAnimation
(
0.0
);
}
Future
_startToEndAnimation
(
double
scrollVelocity
)
{
Future
<
Null
>
_startToEndAnimation
(
double
scrollVelocity
)
{
_controller
.
stop
();
Simulation
simulation
=
_createSnapSimulation
(
scrollVelocity
)
??
_createFlingSimulation
(
scrollVelocity
);
if
(
simulation
==
null
)
return
new
Future
.
value
();
return
new
Future
<
Null
>
.
value
();
_startScroll
();
return
_controller
.
animateWith
(
simulation
).
then
(
_endScroll
);
}
...
...
@@ -493,7 +494,7 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
scrollBy
(
pixelOffsetToScrollOffset
(
delta
));
}
Future
_handleDragEnd
(
Velocity
velocity
)
{
Future
<
Null
>
_handleDragEnd
(
Velocity
velocity
)
{
double
scrollVelocity
=
pixelDeltaToScrollOffset
(
velocity
.
pixelsPerSecond
)
/
Duration
.
MILLISECONDS_PER_SECOND
;
// The gesture velocity properties are pixels/second, config min,max limits are pixels/ms
return
fling
(
scrollVelocity
.
clamp
(-
kMaxFlingVelocity
,
kMaxFlingVelocity
)).
then
(
_endScroll
);
...
...
@@ -631,7 +632,7 @@ class ScrollableViewport extends Scrollable {
}
class
_ScrollableViewportState
extends
ScrollableState
<
ScrollableViewport
>
{
ScrollBehavior
createScrollBehavior
()
=>
new
OverscrollWhenScrollableBehavior
();
ScrollBehavior
<
double
,
double
>
createScrollBehavior
()
=>
new
OverscrollWhenScrollableBehavior
();
OverscrollWhenScrollableBehavior
get
scrollBehavior
=>
super
.
scrollBehavior
;
double
_viewportSize
=
0.0
;
...
...
@@ -745,13 +746,13 @@ abstract class ScrollableListPainter extends Painter {
/// Called when a scroll starts. Subclasses may override this method to
/// initialize some state or to play an animation. The returned Future should
/// complete when the computation triggered by this method has finished.
Future
scrollStarted
()
=>
new
Future
.
value
();
Future
<
Null
>
scrollStarted
()
=>
new
Future
<
Null
>
.
value
();
/// Similar to scrollStarted(). Called when a scroll ends. For fling scrolls
/// "ended" means that the scroll animation either stopped of its own accord
/// or was canceled by the user.
Future
scrollEnded
()
=>
new
Future
.
value
();
Future
<
Null
>
scrollEnded
()
=>
new
Future
<
Null
>
.
value
();
}
/// A general scrollable list for a large number of children that might not all
...
...
@@ -793,7 +794,7 @@ class ScrollableMixedWidgetListState extends ScrollableState<ScrollableMixedWidg
);
}
ScrollBehavior
createScrollBehavior
()
=>
new
OverscrollBehavior
();
ScrollBehavior
<
double
,
double
>
createScrollBehavior
()
=>
new
OverscrollBehavior
();
OverscrollBehavior
get
scrollBehavior
=>
super
.
scrollBehavior
;
Offset
_handlePaintOffsetUpdateNeeded
(
ViewportDimensions
dimensions
)
{
...
...
packages/flutter/lib/src/widgets/scrollable_grid.dart
View file @
6795efac
...
...
@@ -41,7 +41,7 @@ class ScrollableGrid extends Scrollable {
}
class
_ScrollableGridState
extends
ScrollableState
<
ScrollableGrid
>
{
ScrollBehavior
createScrollBehavior
()
=>
new
OverscrollBehavior
();
ScrollBehavior
<
double
,
double
>
createScrollBehavior
()
=>
new
OverscrollBehavior
();
ExtentScrollBehavior
get
scrollBehavior
=>
super
.
scrollBehavior
;
void
_handleExtentsChanged
(
double
contentExtent
,
double
containerExtent
)
{
...
...
@@ -85,9 +85,11 @@ class GridViewport extends VirtualViewportFromIterable {
_GridViewportElement
createElement
()
=>
new
_GridViewportElement
(
this
);
}
class
_GridViewportElement
extends
VirtualViewportElement
<
GridViewport
>
{
class
_GridViewportElement
extends
VirtualViewportElement
{
_GridViewportElement
(
GridViewport
widget
)
:
super
(
widget
);
GridViewport
get
widget
=>
super
.
widget
;
RenderGrid
get
renderObject
=>
super
.
renderObject
;
int
get
materializedChildBase
=>
_materializedChildBase
;
...
...
packages/flutter/lib/src/widgets/scrollable_list.dart
View file @
6795efac
...
...
@@ -45,7 +45,7 @@ class ScrollableList extends Scrollable {
}
class
_ScrollableListState
extends
ScrollableState
<
ScrollableList
>
{
ScrollBehavior
createScrollBehavior
()
=>
new
OverscrollBehavior
();
ScrollBehavior
<
double
,
double
>
createScrollBehavior
()
=>
new
OverscrollBehavior
();
ExtentScrollBehavior
get
scrollBehavior
=>
super
.
scrollBehavior
;
void
_handleExtentsChanged
(
double
contentExtent
,
double
containerExtent
)
{
...
...
@@ -145,9 +145,11 @@ class _VirtualListViewport extends VirtualViewport {
_VirtualListViewportElement
createElement
()
=>
new
_VirtualListViewportElement
(
this
);
}
class
_VirtualListViewportElement
extends
VirtualViewportElement
<
_VirtualListViewport
>
{
class
_VirtualListViewportElement
extends
VirtualViewportElement
{
_VirtualListViewportElement
(
VirtualViewport
widget
)
:
super
(
widget
);
_VirtualListViewport
get
widget
=>
super
.
widget
;
RenderList
get
renderObject
=>
super
.
renderObject
;
int
get
materializedChildBase
=>
_materializedChildBase
;
...
...
@@ -306,7 +308,7 @@ class ScrollableLazyList extends Scrollable {
}
class
_ScrollableLazyListState
extends
ScrollableState
<
ScrollableLazyList
>
{
ScrollBehavior
createScrollBehavior
()
=>
new
OverscrollBehavior
();
ScrollBehavior
<
double
,
double
>
createScrollBehavior
()
=>
new
OverscrollBehavior
();
ExtentScrollBehavior
get
scrollBehavior
=>
super
.
scrollBehavior
;
void
_handleExtentsChanged
(
double
contentExtent
,
double
containerExtent
)
{
...
...
packages/flutter/lib/src/widgets/semantics_debugger.dart
View file @
6795efac
...
...
@@ -296,12 +296,12 @@ class _SemanticsDebuggerListener implements mojom.SemanticsListener {
}
entry
.
updateMessage
();
if
(
node
.
children
!=
null
)
{
Set
oldChildren
=
new
Set
<
_SemanticsDebuggerEntry
>.
from
(
entry
.
children
??
const
<
_SemanticsDebuggerEntry
>[]);
Set
<
_SemanticsDebuggerEntry
>
oldChildren
=
new
Set
<
_SemanticsDebuggerEntry
>.
from
(
entry
.
children
??
const
<
_SemanticsDebuggerEntry
>[]);
entry
.
children
?.
clear
();
entry
.
children
??=
new
List
<
_SemanticsDebuggerEntry
>();
for
(
mojom
.
SemanticsNode
child
in
node
.
children
)
entry
.
children
.
add
(
_updateNode
(
child
));
Set
newChildren
=
new
Set
<
_SemanticsDebuggerEntry
>.
from
(
entry
.
children
);
Set
<
_SemanticsDebuggerEntry
>
newChildren
=
new
Set
<
_SemanticsDebuggerEntry
>.
from
(
entry
.
children
);
Set
<
_SemanticsDebuggerEntry
>
removedChildren
=
oldChildren
.
difference
(
newChildren
);
for
(
_SemanticsDebuggerEntry
oldChild
in
removedChildren
)
nodes
.
remove
(
oldChild
.
id
);
...
...
packages/flutter/lib/src/widgets/virtual_viewport.dart
View file @
6795efac
...
...
@@ -31,8 +31,10 @@ abstract class _WidgetProvider {
/// This class is a building block for building a widget that has more children
/// than it wishes to display at any given time. For example, [ScrollableList]
/// uses this element to materialize only those children that are visible.
abstract
class
VirtualViewportElement
<
T
extends
VirtualViewport
>
extends
RenderObjectElement
<
T
>
{
VirtualViewportElement
(
T
widget
)
:
super
(
widget
);
abstract
class
VirtualViewportElement
extends
RenderObjectElement
{
VirtualViewportElement
(
VirtualViewport
widget
)
:
super
(
widget
);
VirtualViewport
get
widget
=>
super
.
widget
;
/// The index of the first child to materialize.
int
get
materializedChildBase
;
...
...
@@ -70,7 +72,7 @@ abstract class VirtualViewportElement<T extends VirtualViewport> extends RenderO
List
<
Element
>
_materializedChildren
=
const
<
Element
>[];
RenderVirtualViewport
get
renderObject
=>
super
.
renderObject
;
RenderVirtualViewport
<
dynamic
>
get
renderObject
=>
super
.
renderObject
;
void
visitChildren
(
ElementVisitor
visitor
)
{
if
(
_materializedChildren
==
null
)
...
...
@@ -94,8 +96,8 @@ abstract class VirtualViewportElement<T extends VirtualViewport> extends RenderO
super
.
unmount
();
}
void
update
(
T
newWidget
)
{
T
oldWidget
=
widget
;
void
update
(
VirtualViewport
newWidget
)
{
VirtualViewport
oldWidget
=
widget
;
_widgetProvider
.
didUpdateWidget
(
oldWidget
,
newWidget
);
super
.
update
(
newWidget
);
updateRenderObject
(
oldWidget
);
...
...
@@ -107,7 +109,7 @@ abstract class VirtualViewportElement<T extends VirtualViewport> extends RenderO
renderObject
.
paintOffset
=
scrollOffsetToPixelDelta
(
widget
.
startOffset
-
startOffsetBase
);
}
void
updateRenderObject
(
T
oldWidget
)
{
void
updateRenderObject
(
VirtualViewport
oldWidget
)
{
renderObject
.
virtualChildCount
=
_widgetProvider
.
virtualChildCount
;
if
(
startOffsetBase
!=
null
)
{
...
...
@@ -161,7 +163,7 @@ abstract class VirtualViewportElement<T extends VirtualViewport> extends RenderO
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
int
childIndex
=
base
+
i
;
Widget
child
=
_widgetProvider
.
getChild
(
childIndex
);
Key
key
=
new
ValueKey
(
child
.
key
??
childIndex
);
Key
key
=
new
ValueKey
<
Key
>(
child
.
key
)
??
new
ValueKey
<
int
>(
childIndex
);
newWidgets
[
i
]
=
new
RepaintBoundary
(
key:
key
,
child:
child
);
}
_materializedChildren
=
updateChildren
(
_materializedChildren
,
newWidgets
);
...
...
packages/flutter/test/rendering/box_test.dart
View file @
6795efac
...
...
@@ -64,10 +64,10 @@ void main() {
});
test
(
"should not have a 0 sized colored Box"
,
()
{
var
coloredBox
=
new
RenderDecoratedBox
(
RenderBox
coloredBox
=
new
RenderDecoratedBox
(
decoration:
new
BoxDecoration
()
);
var
paddingBox
=
new
RenderPadding
(
padding:
const
EdgeDims
.
all
(
10.0
),
RenderBox
paddingBox
=
new
RenderPadding
(
padding:
const
EdgeDims
.
all
(
10.0
),
child:
coloredBox
);
RenderBox
root
=
new
RenderDecoratedBox
(
decoration:
new
BoxDecoration
(),
...
...
packages/flutter/test/widget/asset_vendor_test.dart
View file @
6795efac
...
...
@@ -107,11 +107,11 @@ Widget buildImageAtRatio(String image, Key key, double ratio, bool inferSize) {
);
}
RenderImage
getRenderImage
(
tester
,
Key
key
)
{
RenderImage
getRenderImage
(
WidgetTester
tester
,
Key
key
)
{
return
tester
.
findElementByKey
(
key
).
renderObject
;
}
TestImage
getTestImage
(
tester
,
Key
key
)
{
TestImage
getTestImage
(
WidgetTester
tester
,
Key
key
)
{
return
getRenderImage
(
tester
,
key
).
image
;
}
...
...
packages/flutter/test/widget/bottom_sheet_rebuild_test.dart
View file @
6795efac
...
...
@@ -10,7 +10,7 @@ void main() {
test
(
'Verify that a BottomSheet can be rebuilt with ScaffoldFeatureController.setState()'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
final
GlobalKey
<
ScaffoldState
>
scaffoldKey
=
new
GlobalKey
<
ScaffoldState
>();
ScaffoldFeatureController
bottomSheet
;
PersistentBottomSheetController
<
Null
>
bottomSheet
;
int
buildCount
=
0
;
tester
.
pumpWidget
(
new
MaterialApp
(
...
...
@@ -24,7 +24,7 @@ void main() {
}
));
bottomSheet
=
scaffoldKey
.
currentState
.
showBottomSheet
((
_
)
{
bottomSheet
=
scaffoldKey
.
currentState
.
showBottomSheet
/*<Null>*/
((
_
)
{
return
new
Builder
(
builder:
(
_
)
{
buildCount
+=
1
;
...
...
packages/flutter/test/widget/bottom_sheet_test.dart
View file @
6795efac
...
...
@@ -25,10 +25,11 @@ void main() {
tester
.
pump
();
expect
(
tester
.
findText
(
'BottomSheet'
),
isNull
);
showModalBottomSheet
(
showModalBottomSheet
/*<Null>*/
(
context:
context
,
builder:
(
BuildContext
context
)
=>
new
Text
(
'BottomSheet'
)
).
then
((
_
)
{
).
then
((
Null
result
)
{
expect
(
result
,
isNull
);
showBottomSheetThenCalled
=
true
;
});
...
...
@@ -45,7 +46,7 @@ void main() {
tester
.
pump
(
new
Duration
(
seconds:
1
));
// frame after the animation (sheet has been removed)
expect
(
tester
.
findText
(
'BottomSheet'
),
isNull
);
showModalBottomSheet
(
context:
context
,
builder:
(
BuildContext
context
)
=>
new
Text
(
'BottomSheet'
));
showModalBottomSheet
/*<Null>*/
(
context:
context
,
builder:
(
BuildContext
context
)
=>
new
Text
(
'BottomSheet'
));
tester
.
pump
();
// bottom sheet show animation starts
tester
.
pump
(
new
Duration
(
seconds:
1
));
// animation done
expect
(
tester
.
findText
(
'BottomSheet'
),
isNotNull
);
...
...
packages/flutter/test/widget/custom_one_child_layout_test.dart
View file @
6795efac
...
...
@@ -46,7 +46,7 @@ class TestOneChildLayoutDelegate extends OneChildLayoutDelegate {
}
}
Widget
buildFrame
(
delegate
)
{
Widget
buildFrame
(
OneChildLayoutDelegate
delegate
)
{
return
new
Center
(
child:
new
CustomOneChildLayout
(
delegate:
delegate
,
child:
new
Container
()));
}
...
...
packages/flutter/test/widget/draggable_test.dart
View file @
6795efac
...
...
@@ -15,19 +15,19 @@ void main() {
routes:
<
String
,
RouteBuilder
>{
'/'
:
(
RouteArguments
args
)
{
return
new
Column
(
children:
<
Widget
>[
new
Draggable
(
new
Draggable
<
int
>
(
data:
1
,
child:
new
Text
(
'Source'
),
feedback:
new
Text
(
'Dragging'
)
),
new
DragTarget
(
builder:
(
context
,
data
,
rejects
)
{
new
DragTarget
<
int
>
(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
return
new
Container
(
height:
100.0
,
child:
new
Text
(
'Target'
)
);
},
onAccept:
(
data
)
{
onAccept:
(
int
data
)
{
accepted
.
add
(
data
);
}
),
...
...
@@ -78,7 +78,7 @@ void main() {
routes:
<
String
,
RouteBuilder
>{
'/'
:
(
RouteArguments
args
)
{
return
new
Column
(
children:
<
Widget
>[
new
Draggable
(
new
Draggable
<
int
>
(
data:
1
,
child:
new
Text
(
'Source'
),
feedback:
new
Text
(
'Dragging'
)
...
...
@@ -94,15 +94,15 @@ void main() {
child:
new
Text
(
'Button'
)
)
),
new
DragTarget
(
builder:
(
context
,
data
,
rejects
)
{
new
DragTarget
<
int
>
(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
return
new
IgnorePointer
(
child:
new
Container
(
child:
new
Text
(
'Target'
)
)
);
},
onAccept:
(
data
)
{
onAccept:
(
int
data
)
{
events
.
add
(
'drop'
);
}
),
...
...
@@ -176,7 +176,7 @@ void main() {
routes:
<
String
,
RouteBuilder
>{
'/'
:
(
RouteArguments
args
)
{
return
new
Column
(
children:
<
Widget
>[
new
Draggable
(
new
Draggable
<
int
>
(
data:
1
,
child:
new
GestureDetector
(
behavior:
HitTestBehavior
.
opaque
,
...
...
@@ -189,11 +189,11 @@ void main() {
),
feedback:
new
Text
(
'Dragging'
)
),
new
DragTarget
(
builder:
(
context
,
data
,
rejects
)
{
new
DragTarget
<
int
>
(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
return
new
Text
(
'Target'
);
},
onAccept:
(
data
)
{
onAccept:
(
int
data
)
{
events
.
add
(
'drop'
);
}
),
...
...
@@ -237,16 +237,16 @@ void main() {
routes:
<
String
,
RouteBuilder
>{
'/'
:
(
RouteArguments
args
)
{
return
new
Column
(
children:
<
Widget
>[
new
LongPressDraggable
(
new
LongPressDraggable
<
int
>
(
data:
1
,
child:
new
Text
(
'Source'
),
feedback:
new
Text
(
'Dragging'
)
),
new
DragTarget
(
builder:
(
context
,
data
,
rejects
)
{
new
DragTarget
<
int
>
(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
return
new
Text
(
'Target'
);
},
onAccept:
(
data
)
{
onAccept:
(
int
data
)
{
events
.
add
(
'drop'
);
}
),
...
...
@@ -288,16 +288,16 @@ void main() {
routes:
<
String
,
RouteBuilder
>{
'/'
:
(
RouteArguments
args
)
{
return
new
Column
(
children:
<
Widget
>[
new
Draggable
(
new
Draggable
<
int
>
(
data:
1
,
child:
new
Text
(
'Source'
),
feedback:
new
Text
(
'Dragging'
)
),
new
DragTarget
(
builder:
(
context
,
data
,
rejects
)
{
new
DragTarget
<
int
>
(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
return
new
Text
(
'Target'
);
},
onAccept:
(
data
)
{
onAccept:
(
int
data
)
{
events
.
add
(
'drop'
);
}
),
...
...
@@ -341,21 +341,21 @@ void main() {
'/'
:
(
RouteArguments
args
)
{
return
new
Block
(
children:
<
Widget
>[
new
DragTarget
(
builder:
(
context
,
data
,
rejects
)
{
new
DragTarget
<
int
>
(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
return
new
Text
(
'Target'
);
},
onAccept:
(
data
)
{
onAccept:
(
int
data
)
{
events
.
add
(
'drop
$data
'
);
}
),
new
Container
(
height:
400.0
),
new
HorizontalDraggable
(
new
HorizontalDraggable
<
int
>
(
data:
1
,
child:
new
Text
(
'H'
),
feedback:
new
Text
(
'Dragging'
)
),
new
VerticalDraggable
(
new
VerticalDraggable
<
int
>
(
data:
2
,
child:
new
Text
(
'V'
),
feedback:
new
Text
(
'Dragging'
)
...
...
@@ -453,21 +453,21 @@ void main() {
return
new
Block
(
scrollDirection:
Axis
.
horizontal
,
children:
<
Widget
>[
new
DragTarget
(
builder:
(
context
,
data
,
rejects
)
{
new
DragTarget
<
int
>
(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
return
new
Text
(
'Target'
);
},
onAccept:
(
data
)
{
onAccept:
(
int
data
)
{
events
.
add
(
'drop
$data
'
);
}
),
new
Container
(
width:
400.0
),
new
HorizontalDraggable
(
new
HorizontalDraggable
<
int
>
(
data:
1
,
child:
new
Text
(
'H'
),
feedback:
new
Text
(
'Dragging'
)
),
new
VerticalDraggable
(
new
VerticalDraggable
<
int
>
(
data:
2
,
child:
new
Text
(
'V'
),
feedback:
new
Text
(
'Dragging'
)
...
...
packages/flutter/test/widget/heroes_test.dart
View file @
6795efac
...
...
@@ -31,7 +31,7 @@ final Map<String, RouteBuilder> routes = <String, RouteBuilder>{
),
};
class
ThreeRoute
extends
MaterialPageRoute
{
class
ThreeRoute
extends
MaterialPageRoute
<
Null
>
{
ThreeRoute
()
:
super
(
builder:
(
BuildContext
context
)
{
return
new
Material
(
child:
new
Block
(
children:
<
Widget
>[
...
...
packages/flutter/test/widget/modal_barrier_test.dart
View file @
6795efac
...
...
@@ -69,7 +69,7 @@ void main() {
tester
.
pumpWidget
(
new
MaterialApp
(
routes:
routes
));
// Initially the barrier is not visible
expect
(
tester
.
findElementByKey
(
const
ValueKey
(
'barrier'
)),
isNull
);
expect
(
tester
.
findElementByKey
(
const
ValueKey
<
String
>
(
'barrier'
)),
isNull
);
// Tapping on X routes to the barrier
tester
.
tap
(
tester
.
findText
(
'X'
));
...
...
@@ -77,11 +77,11 @@ void main() {
tester
.
pump
(
const
Duration
(
seconds:
1
));
// end transition
// Tap on the barrier to dismiss it
tester
.
tap
(
tester
.
findElementByKey
(
const
ValueKey
(
'barrier'
)));
tester
.
tap
(
tester
.
findElementByKey
(
const
ValueKey
<
String
>
(
'barrier'
)));
tester
.
pump
();
// begin transition
tester
.
pump
(
const
Duration
(
seconds:
1
));
// end transition
expect
(
tester
.
findElementByKey
(
const
ValueKey
(
'barrier'
)),
isNull
,
expect
(
tester
.
findElementByKey
(
const
ValueKey
<
String
>
(
'barrier'
)),
isNull
,
reason:
'because the barrier was dismissed'
);
});
});
...
...
@@ -103,7 +103,7 @@ class FirstComponent extends StatelessComponent {
class
SecondComponent
extends
StatelessComponent
{
Widget
build
(
BuildContext
context
)
{
return
new
ModalBarrier
(
key:
const
ValueKey
(
'barrier'
),
key:
const
ValueKey
<
String
>
(
'barrier'
),
dismissable:
true
);
}
...
...
packages/flutter/test/widget/navigator_test.dart
View file @
6795efac
...
...
@@ -40,7 +40,7 @@ class SecondComponentState extends State<SecondComponent> {
}
}
typedef
void
ExceptionCallback
(
exception
);
typedef
void
ExceptionCallback
(
dynamic
exception
);
class
ThirdComponent
extends
StatelessComponent
{
ThirdComponent
({
this
.
targetKey
,
this
.
onException
});
...
...
@@ -103,7 +103,7 @@ void main() {
dynamic
exception
;
Widget
widget
=
new
ThirdComponent
(
targetKey:
targetKey
,
onException:
(
e
)
{
onException:
(
dynamic
e
)
{
exception
=
e
;
}
);
...
...
packages/flutter/test/widget/page_forward_transitions_test.dart
View file @
6795efac
...
...
@@ -70,12 +70,12 @@ void main() {
onGenerateRoute:
(
RouteSettings
settings
)
{
switch
(
settings
.
name
)
{
case
'/'
:
return
new
TestRoute
(
return
new
TestRoute
<
Null
>
(
settings:
settings
,
child:
new
Builder
(
key:
insideKey
,
builder:
(
BuildContext
context
)
{
PageRoute
route
=
ModalRoute
.
of
(
context
);
PageRoute
<
Null
>
route
=
ModalRoute
.
of
(
context
);
return
new
Column
(
children:
<
Widget
>[
new
TestTransition
(
...
...
@@ -93,9 +93,9 @@ void main() {
}
)
);
case
'/2'
:
return
new
TestRoute
(
settings:
settings
,
child:
new
Text
(
'E'
));
case
'/3'
:
return
new
TestRoute
(
settings:
settings
,
child:
new
Text
(
'F'
));
case
'/4'
:
return
new
TestRoute
(
settings:
settings
,
child:
new
Text
(
'G'
));
case
'/2'
:
return
new
TestRoute
<
Null
>
(
settings:
settings
,
child:
new
Text
(
'E'
));
case
'/3'
:
return
new
TestRoute
<
Null
>
(
settings:
settings
,
child:
new
Text
(
'F'
));
case
'/4'
:
return
new
TestRoute
<
Null
>
(
settings:
settings
,
child:
new
Text
(
'G'
));
}
}
)
...
...
packages/flutter/test/widget/page_transitions_test.dart
View file @
6795efac
...
...
@@ -8,7 +8,7 @@ import 'package:test/test.dart';
import
'test_matchers.dart'
;
class
TestOverlayRoute
extends
OverlayRoute
{
class
TestOverlayRoute
extends
OverlayRoute
<
Null
>
{
List
<
WidgetBuilder
>
get
builders
=>
<
WidgetBuilder
>[
_build
];
Widget
_build
(
BuildContext
context
)
=>
new
Text
(
'Overlay'
);
}
...
...
packages/flutter/test/widget/remember_scroll_position_test.dart
View file @
6795efac
...
...
@@ -28,9 +28,9 @@ void main() {
key:
navigatorKey
,
onGenerateRoute:
(
RouteSettings
settings
)
{
if
(
settings
.
name
==
'/'
)
return
new
MaterialPageRoute
(
builder:
(
_
)
=>
new
Container
(
child:
new
ThePositiveNumbers
()));
return
new
MaterialPageRoute
<
Null
>
(
builder:
(
_
)
=>
new
Container
(
child:
new
ThePositiveNumbers
()));
else
if
(
settings
.
name
==
'/second'
)
return
new
MaterialPageRoute
(
builder:
(
_
)
=>
new
Container
(
child:
new
ThePositiveNumbers
()));
return
new
MaterialPageRoute
<
Null
>
(
builder:
(
_
)
=>
new
Container
(
child:
new
ThePositiveNumbers
()));
return
null
;
}
));
...
...
@@ -47,9 +47,10 @@ void main() {
expect
(
tester
.
findText
(
'10'
),
isNull
);
expect
(
tester
.
findText
(
'100'
),
isNull
);
StatefulComponentElement
<
ScrollableLazyList
,
ScrollableState
<
ScrollableLazyList
>>
target
=
StatefulComponentElement
target
=
tester
.
findElement
((
Element
element
)
=>
element
.
widget
is
ScrollableLazyList
);
target
.
state
.
scrollTo
(
1000.0
);
ScrollableState
targetState
=
target
.
state
;
targetState
.
scrollTo
(
1000.0
);
tester
.
pump
(
new
Duration
(
seconds:
1
));
// we're 600 pixels high, each item is 100 pixels high, scroll position is
...
...
packages/flutter/test/widget/snack_bar_test.dart
View file @
6795efac
...
...
@@ -144,7 +144,7 @@ void main() {
int
snackBarCount
=
0
;
Key
tapTarget
=
new
Key
(
'tap-target'
);
int
time
;
ScaffoldFeatureController
<
SnackBar
>
lastController
;
ScaffoldFeatureController
<
SnackBar
,
Null
>
lastController
;
tester
.
pumpWidget
(
new
MaterialApp
(
routes:
<
String
,
RouteBuilder
>{
'/'
:
(
RouteArguments
args
)
{
...
...
@@ -176,7 +176,7 @@ void main() {
expect
(
tester
.
findText
(
'bar2'
),
isNull
);
time
=
1000
;
tester
.
tap
(
tester
.
findElementByKey
(
tapTarget
));
// queue bar1
ScaffoldFeatureController
<
SnackBar
>
firstController
=
lastController
;
ScaffoldFeatureController
<
SnackBar
,
Null
>
firstController
=
lastController
;
time
=
2
;
tester
.
tap
(
tester
.
findElementByKey
(
tapTarget
));
// queue bar2
expect
(
tester
.
findText
(
'bar1'
),
isNull
);
...
...
packages/flutter/test/widget/snap_scrolling_test.dart
View file @
6795efac
...
...
@@ -47,7 +47,7 @@ void set scrollOffset(double value) {
scrollableState
.
scrollTo
(
value
);
}
Future
fling
(
double
velocity
)
{
Future
<
Null
>
fling
(
double
velocity
)
{
return
scrollableState
.
fling
(
velocity
);
}
...
...
packages/flutter/test/widget/stack_test.dart
View file @
6795efac
...
...
@@ -155,7 +155,7 @@ void main() {
Widget
buildFrame
(
int
index
)
{
itemsPainted
=
<
int
>[];
List
<
Widget
>
items
=
new
List
<
Widget
>.
generate
(
itemCount
,
(
i
)
{
List
<
Widget
>
items
=
new
List
<
Widget
>.
generate
(
itemCount
,
(
i
nt
i
)
{
return
new
CustomPaint
(
child:
new
Text
(
'
$i
'
),
painter:
new
TestCallbackPainter
(
...
...
@@ -188,7 +188,7 @@ void main() {
Widget
buildFrame
(
int
index
)
{
itemsTapped
=
<
int
>[];
List
<
Widget
>
items
=
new
List
<
Widget
>.
generate
(
itemCount
,
(
i
)
{
List
<
Widget
>
items
=
new
List
<
Widget
>.
generate
(
itemCount
,
(
i
nt
i
)
{
return
new
GestureDetector
(
child:
new
Text
(
'
$i
'
),
onTap:
()
{
itemsTapped
.
add
(
i
);
});
});
return
new
Center
(
child:
new
IndexedStack
(
children:
items
,
key:
key
,
index:
index
));
...
...
packages/flutter/test/widget/test_matchers.dart
View file @
6795efac
...
...
@@ -20,25 +20,25 @@ bool _hasAncestorOfType(Element element, Type targetType) {
class
_IsOnStage
extends
Matcher
{
const
_IsOnStage
();
bool
matches
(
item
,
Map
matchState
)
=>
!
_hasAncestorOfType
(
item
,
OffStage
);
bool
matches
(
Element
item
,
Map
<
dynamic
,
dynamic
>
matchState
)
=>
!
_hasAncestorOfType
(
item
,
OffStage
);
Description
describe
(
Description
description
)
=>
description
.
add
(
'onstage'
);
}
class
_IsOffStage
extends
Matcher
{
const
_IsOffStage
();
bool
matches
(
item
,
Map
matchState
)
=>
_hasAncestorOfType
(
item
,
OffStage
);
bool
matches
(
Element
item
,
Map
<
dynamic
,
dynamic
>
matchState
)
=>
_hasAncestorOfType
(
item
,
OffStage
);
Description
describe
(
Description
description
)
=>
description
.
add
(
'offstage'
);
}
class
_IsInCard
extends
Matcher
{
const
_IsInCard
();
bool
matches
(
item
,
Map
matchState
)
=>
_hasAncestorOfType
(
item
,
Card
);
bool
matches
(
Element
item
,
Map
<
dynamic
,
dynamic
>
matchState
)
=>
_hasAncestorOfType
(
item
,
Card
);
Description
describe
(
Description
description
)
=>
description
.
add
(
'in card'
);
}
class
_IsNotInCard
extends
Matcher
{
const
_IsNotInCard
();
bool
matches
(
item
,
Map
matchState
)
=>
!
_hasAncestorOfType
(
item
,
Card
);
bool
matches
(
Element
item
,
Map
<
dynamic
,
dynamic
>
matchState
)
=>
!
_hasAncestorOfType
(
item
,
Card
);
Description
describe
(
Description
description
)
=>
description
.
add
(
'not in card'
);
}
...
...
packages/flutter_driver/lib/src/driver.dart
View file @
6795efac
...
...
@@ -55,7 +55,7 @@ class FlutterDriver {
//
// See: https://github.com/dart-lang/sdk/issues/25902
if
(
isolate
.
pauseEvent
is
VMResumeEvent
)
{
await
new
Future
.
delayed
(
new
Duration
(
milliseconds:
300
));
await
new
Future
<
Null
>
.
delayed
(
new
Duration
(
milliseconds:
300
));
isolate
=
await
vm
.
isolates
.
first
.
loadRunnable
();
}
...
...
@@ -64,10 +64,10 @@ class FlutterDriver {
// Attempts to resume the isolate, but does not crash if it fails because
// the isolate is already resumed. There could be a race with other tools,
// such as a debugger, any of which could have resumed the isolate.
Future
resumeLeniently
()
{
Future
<
Null
>
resumeLeniently
()
{
_log
.
trace
(
'Attempting to resume isolate'
);
return
isolate
.
resume
().
catchError
((
e
)
{
const
vmMustBePausedCode
=
101
;
return
isolate
.
resume
().
catchError
((
dynamic
e
)
{
const
int
vmMustBePausedCode
=
101
;
if
(
e
is
rpc
.
RpcException
&&
e
.
code
==
vmMustBePausedCode
)
{
// No biggie; something else must have resumed the isolate
_log
.
warning
(
...
...
@@ -87,7 +87,7 @@ class FlutterDriver {
_log
.
trace
(
'Isolate is paused at start.'
);
// Waits for a signal from the VM service that the extension is registered
Future
waitForServiceExtension
()
{
Future
<
Null
>
waitForServiceExtension
()
{
return
isolate
.
onExtensionAdded
.
firstWhere
((
String
extension
)
{
return
extension
==
_kFlutterExtensionMethod
;
});
...
...
@@ -96,8 +96,8 @@ class FlutterDriver {
// If the isolate is paused at the start, e.g. via the --start-paused
// option, then the VM service extension is not registered yet. Wait for
// it to be registered.
Future
whenResumed
=
resumeLeniently
();
Future
whenServiceExtensionReady
=
Future
.
any
(<
Future
>[
Future
<
Null
>
whenResumed
=
resumeLeniently
();
Future
<
Null
>
whenServiceExtensionReady
=
Future
.
any
(<
Future
<
dynamic
>
>[
waitForServiceExtension
(),
// We will never receive the extension event if the user does not
// register it. If that happens time out.
...
...
@@ -150,7 +150,7 @@ class FlutterDriver {
Map
<
String
,
String
>
parameters
=
<
String
,
String
>{
'command'
:
command
.
kind
}
..
addAll
(
command
.
serialize
());
return
_appIsolate
.
invokeExtension
(
_kFlutterExtensionMethod
,
parameters
)
.
then
((
Map
<
String
,
dynamic
>
result
)
=>
result
,
onError:
(
error
,
stackTrace
)
{
.
then
((
Map
<
String
,
dynamic
>
result
)
=>
result
,
onError:
(
dynamic
error
,
dynamic
stackTrace
)
{
throw
new
DriverError
(
'Failed to fulfill
${command.runtimeType}
due to remote error'
,
error
,
...
...
@@ -217,7 +217,7 @@ class FlutterDriver {
dynamic
value
=
await
evaluator
();
MatchResult
matchResult
=
match
(
value
,
matcher
);
if
(!
matchResult
.
hasMatched
)
{
return
new
Future
.
error
(
matchResult
.
mismatchDescription
);
return
new
Future
<
Null
>
.
error
(
matchResult
.
mismatchDescription
);
}
return
value
;
},
timeout
,
pauseBetweenRetries
);
...
...
@@ -227,7 +227,7 @@ class FlutterDriver {
///
/// Returns a [Future] that fires once the connection has been closed.
// TODO(yjbanov): cleanup object references
Future
close
()
=>
_serviceClient
.
close
().
then
((
_
)
{
Future
<
Null
>
close
()
=>
_serviceClient
.
close
().
then
((
_
)
{
// Don't leak vm_service_client-specific objects, if any
return
null
;
});
...
...
@@ -255,10 +255,10 @@ Future<VMServiceClient> _waitAndConnect(String url) async {
Stopwatch
timer
=
new
Stopwatch
();
Future
<
VMServiceClient
>
attemptConnection
()
{
return
VMServiceClient
.
connect
(
url
)
.
catchError
((
e
)
async
{
.
catchError
((
dynamic
e
)
async
{
if
(
timer
.
elapsed
<
const
Duration
(
seconds:
30
))
{
_log
.
info
(
'Waiting for application to start'
);
await
new
Future
.
delayed
(
const
Duration
(
seconds:
1
));
await
new
Future
<
Null
>
.
delayed
(
const
Duration
(
seconds:
1
));
return
attemptConnection
();
}
else
{
_log
.
critical
(
...
...
packages/flutter_driver/lib/src/matcher_util.dart
View file @
6795efac
...
...
@@ -49,7 +49,7 @@ class _TextDescription implements Description {
return
this
;
}
Description
addDescriptionOf
(
value
)
{
Description
addDescriptionOf
(
dynamic
value
)
{
if
(
value
is
Matcher
)
{
value
.
describe
(
this
);
return
this
;
...
...
@@ -58,7 +58,7 @@ class _TextDescription implements Description {
}
}
Description
addAll
(
String
start
,
String
separator
,
String
end
,
Iterable
list
)
{
Description
addAll
(
String
start
,
String
separator
,
String
end
,
Iterable
<
dynamic
>
list
)
{
add
(
start
);
if
(
list
.
isNotEmpty
)
{
addDescriptionOf
(
list
.
first
);
...
...
packages/flutter_driver/lib/src/retry.dart
View file @
6795efac
...
...
@@ -48,9 +48,9 @@ Future<dynamic> retry(Action action, Duration timeout,
if
(
success
)
return
result
;
else
if
(
lastError
!=
null
)
return
new
Future
.
error
(
lastError
,
lastStackTrace
);
return
new
Future
<
Null
>
.
error
(
lastError
,
lastStackTrace
);
else
return
new
Future
.
error
(
'Retry timed out'
);
return
new
Future
<
Null
>
.
error
(
'Retry timed out'
);
}
/// A function that produces a [Stopwatch].
...
...
packages/flutter_sprites/lib/src/action.dart
View file @
6795efac
...
...
@@ -424,7 +424,7 @@ class ActionTween extends ActionInterval {
}
void
update
(
double
t
)
{
var
newVal
;
dynamic
newVal
;
if
(
startVal
is
Point
)
{
// Point
...
...
packages/flutter_sprites/lib/src/physics_body.dart
View file @
6795efac
...
...
@@ -35,8 +35,8 @@ class PhysicsBody {
bool
bullet:
false
,
bool
active:
true
,
this
.
gravityScale
:
1.0
,
collisionCategory:
"Default"
,
collisionMask:
null
String
collisionCategory:
"Default"
,
List
<
Object
>
collisionMask
})
{
this
.
density
=
density
;
this
.
friction
=
friction
;
...
...
packages/flutter_sprites/lib/src/physics_world.dart
View file @
6795efac
...
...
@@ -314,7 +314,7 @@ class PhysicsContact {
final
PhysicsShape
shapeB
;
/// True if the two nodes are touching.
final
isTouching
;
final
bool
isTouching
;
/// To ignore the collision to take place, you can set isEnabled to false
/// during the preSolve phase.
...
...
packages/flutter_sprites/lib/src/sprite_box.dart
View file @
6795efac
...
...
@@ -164,7 +164,7 @@ class SpriteBox extends RenderBox {
// Event handling
void
_addEventTargets
(
Node
node
,
List
<
Node
>
eventTargets
)
{
List
children
=
node
.
children
;
List
<
Node
>
children
=
node
.
children
;
int
i
=
0
;
// Add childrens that are behind this node
...
...
packages/flutter_sprites/lib/src/spritesheet.dart
View file @
6795efac
...
...
@@ -19,12 +19,12 @@ class SpriteSheet {
assert
(
jsonDefinition
!=
null
);
JsonDecoder
decoder
=
new
JsonDecoder
();
Map
file
=
decoder
.
convert
(
jsonDefinition
);
Map
<
dynamic
,
dynamic
>
file
=
decoder
.
convert
(
jsonDefinition
);
assert
(
file
!=
null
);
List
frames
=
file
[
"frames"
];
List
<
dynamic
>
frames
=
file
[
"frames"
];
for
(
Map
frameInfo
in
frames
)
{
for
(
Map
<
dynamic
,
dynamic
>
frameInfo
in
frames
)
{
String
fileName
=
frameInfo
[
"filename"
];
Rect
frame
=
_readJsonRect
(
frameInfo
[
"frame"
]);
bool
rotated
=
frameInfo
[
"rotated"
];
...
...
@@ -33,13 +33,13 @@ class SpriteSheet {
Size
sourceSize
=
_readJsonSize
(
frameInfo
[
"sourceSize"
]);
Point
pivot
=
_readJsonPoint
(
frameInfo
[
"pivot"
]);
var
texture
=
new
Texture
.
_fromSpriteFrame
(
_image
,
fileName
,
sourceSize
,
rotated
,
trimmed
,
frame
,
Texture
texture
=
new
Texture
.
_fromSpriteFrame
(
_image
,
fileName
,
sourceSize
,
rotated
,
trimmed
,
frame
,
spriteSourceSize
,
pivot
);
_textures
[
fileName
]
=
texture
;
}
}
Rect
_readJsonRect
(
Map
data
)
{
Rect
_readJsonRect
(
Map
<
dynamic
,
dynamic
>
data
)
{
num
x
=
data
[
"x"
];
num
y
=
data
[
"y"
];
num
w
=
data
[
"w"
];
...
...
@@ -48,14 +48,14 @@ class SpriteSheet {
return
new
Rect
.
fromLTRB
(
x
.
toDouble
(),
y
.
toDouble
(),
(
x
+
w
).
toDouble
(),
(
y
+
h
).
toDouble
());
}
Size
_readJsonSize
(
Map
data
)
{
Size
_readJsonSize
(
Map
<
dynamic
,
dynamic
>
data
)
{
num
w
=
data
[
"w"
];
num
h
=
data
[
"h"
];
return
new
Size
(
w
.
toDouble
(),
h
.
toDouble
());
}
Point
_readJsonPoint
(
Map
data
)
{
Point
_readJsonPoint
(
Map
<
dynamic
,
dynamic
>
data
)
{
num
x
=
data
[
"x"
];
num
y
=
data
[
"y"
];
...
...
packages/flutter_sprites/lib/src/virtual_joystick.dart
View file @
6795efac
...
...
@@ -39,7 +39,7 @@ class VirtualJoystick extends NodeWithSize {
else
if
(
event
.
type
==
PointerUpEvent
||
event
.
type
==
PointerCancelEvent
)
{
_pointerDownAt
=
null
;
_value
=
Point
.
origin
;
ActionTween
moveToCenter
=
new
ActionTween
((
a
)
=>
_handlePos
=
a
,
_handlePos
,
_center
,
0.4
,
Curves
.
elasticOut
);
ActionTween
moveToCenter
=
new
ActionTween
((
Point
a
)
=>
_handlePos
=
a
,
_handlePos
,
_center
,
0.4
,
Curves
.
elasticOut
);
actions
.
run
(
moveToCenter
);
_isDown
=
false
;
}
else
if
(
event
.
type
==
PointerMoveEvent
)
{
...
...
packages/flutter_test/lib/src/instrumentation.dart
View file @
6795efac
...
...
@@ -72,7 +72,10 @@ class Instrumentation {
/// element.
Element
findText
(
String
text
)
{
return
findElement
((
Element
element
)
{
return
element
.
widget
is
Text
&&
element
.
widget
.
data
==
text
;
if
(
element
.
widget
is
!
Text
)
return
false
;
Text
textWidget
=
element
.
widget
;
return
textWidget
.
data
==
text
;
});
}
...
...
packages/flutter_tools/.analysis_options
View file @
6795efac
...
...
@@ -16,6 +16,7 @@ analyzer:
strong_mode_static_type_error: ignore
strong_mode_down_cast_composite: ignore
type_argument_not_matching_bounds: ignore
argument_type_not_assignable: ignore
# we allow having TODOs in the code
todo: ignore
linter:
...
...
packages/flutter_tools/lib/executable.dart
View file @
6795efac
...
...
@@ -37,7 +37,7 @@ import 'src/runner/flutter_command_runner.dart';
/// Main entry point for commands.
///
/// This function is intended to be used from the [flutter] command line tool.
Future
main
(
List
<
String
>
args
)
async
{
Future
<
Null
>
main
(
List
<
String
>
args
)
async
{
bool
help
=
args
.
contains
(
'-h'
)
||
args
.
contains
(
'--help'
);
bool
verbose
=
args
.
contains
(
'-v'
)
||
args
.
contains
(
'--verbose'
);
bool
verboseHelp
=
help
&&
verbose
;
...
...
@@ -73,7 +73,7 @@ Future main(List<String> args) async {
if
(
result
is
int
)
exit
(
result
);
},
onError:
(
error
,
Chain
chain
)
{
},
onError:
(
dynamic
error
,
Chain
chain
)
{
if
(
error
is
UsageException
)
{
stderr
.
writeln
(
error
);
// Argument error exit code.
...
...
packages/flutter_tools/lib/src/commands/analyze.dart
View file @
6795efac
...
...
@@ -336,6 +336,7 @@ class AnalyzeCommand extends FlutterCommand {
RegExp
generalPattern
=
new
RegExp
(
r'^\[(error|warning|hint|lint)\] (.+) \(([^(),]+), line ([0-9]+), col ([0-9]+)\)$'
);
RegExp
allowedIdentifiersPattern
=
new
RegExp
(
r'_?([A-Z]|_+)\b'
);
RegExp
classesWithOptionalTypeArgumentsPattern
=
new
RegExp
(
r'\b(GlobalKey|State|ScrollableState|Element|StatelessComponentElement|TypeMatcher)\b'
);
RegExp
constructorTearOffsPattern
=
new
RegExp
(
'.+#.+// analyzer doesn
\'
t like constructor tear-offs'
);
RegExp
conflictingNamesPattern
=
new
RegExp
(
'^The imported libraries
\'
([^
\'
]+)
\'
and
\'
([^
\'
]+)
\'
cannot have the same name
\'
([^
\'
]+)
\'
\$
'
);
RegExp
missingFilePattern
=
new
RegExp
(
'^Target of URI does not exist:
\'
([^
\'
)]+)
\'
\$
'
);
...
...
@@ -388,6 +389,11 @@ class AnalyzeCommand extends FlutterCommand {
}
else
if
(
level
==
'lint'
&&
errorMessage
==
'Name non-constant identifiers using lowerCamelCase.'
)
{
if
(
allowedIdentifiersPattern
.
matchAsPrefix
(
sourceLine
,
colNumber
-
1
)
!=
null
)
shouldIgnore
=
true
;
}
else
if
(
level
==
'lint'
&&
errorMessage
==
'Specify type annotations.'
)
{
// we want the type annotations on certain classes to be optional.
// see https://github.com/dart-lang/linter/issues/196
if
(
classesWithOptionalTypeArgumentsPattern
.
matchAsPrefix
(
sourceLine
,
colNumber
-
1
)
!=
null
)
shouldIgnore
=
true
;
}
else
if
(
constructorTearOffsPattern
.
allMatches
(
sourceLine
).
isNotEmpty
)
{
shouldIgnore
=
true
;
}
...
...
packages/newton/test/newton_test.dart
View file @
6795efac
...
...
@@ -10,7 +10,7 @@ import 'package:newton/newton.dart';
void
main
(
)
{
test
(
'test_friction'
,
()
{
var
friction
=
new
FrictionSimulation
(
0.3
,
100.0
,
400.0
);
FrictionSimulation
friction
=
new
FrictionSimulation
(
0.3
,
100.0
,
400.0
);
friction
.
tolerance
=
const
Tolerance
(
velocity:
1.0
);
...
...
@@ -32,18 +32,18 @@ void main() {
test
(
'test_friction_through'
,
()
{
// Use a normal FrictionSimulation to generate start and end
// velocity and positions with drag = 0.025.
var
startPosition
=
10.0
;
var
startVelocity
=
600.0
;
var
f
=
new
FrictionSimulation
(
0.025
,
startPosition
,
startVelocity
);
var
endPosition
=
f
.
x
(
1.0
);
var
endVelocity
=
f
.
dx
(
1.0
);
double
startPosition
=
10.0
;
double
startVelocity
=
600.0
;
FrictionSimulation
f
=
new
FrictionSimulation
(
0.025
,
startPosition
,
startVelocity
);
double
endPosition
=
f
.
x
(
1.0
);
double
endVelocity
=
f
.
dx
(
1.0
);
expect
(
endPosition
,
greaterThan
(
startPosition
));
expect
(
endVelocity
,
lessThan
(
startVelocity
));
// Verify that that the "through" FrictionSimulation ends up at
// endPosition and endVelocity; implies that it computed the right
// value for _drag.
var
friction
=
new
FrictionSimulation
.
through
(
FrictionSimulation
friction
=
new
FrictionSimulation
.
through
(
startPosition
,
endPosition
,
startVelocity
,
endVelocity
);
expect
(
friction
.
isDone
(
0.0
),
false
);
expect
(
friction
.
x
(
0.0
),
10.0
);
...
...
@@ -72,7 +72,7 @@ void main() {
});
test
(
'test_gravity'
,
()
{
var
gravity
=
new
GravitySimulation
(
200.0
,
100.0
,
600.0
,
0.0
);
GravitySimulation
gravity
=
new
GravitySimulation
(
200.0
,
100.0
,
600.0
,
0.0
);
expect
(
gravity
.
isDone
(
0.0
),
false
);
expect
(
gravity
.
x
(
0.0
),
100.0
);
...
...
@@ -102,7 +102,7 @@ void main() {
});
test
(
'spring_types'
,
()
{
var
crit
=
new
SpringSimulation
(
new
SpringDescription
.
withDampingRatio
(
SpringSimulation
crit
=
new
SpringSimulation
(
new
SpringDescription
.
withDampingRatio
(
mass:
1.0
,
springConstant:
100.0
),
0.0
,
300.0
,
0.0
);
expect
(
crit
.
type
,
SpringType
.
criticallyDamped
);
...
...
@@ -110,23 +110,23 @@ void main() {
mass:
1.0
,
springConstant:
100.0
,
ratio:
1.0
),
0.0
,
300.0
,
0.0
);
expect
(
crit
.
type
,
SpringType
.
criticallyDamped
);
var
under
=
new
SpringSimulation
(
new
SpringDescription
.
withDampingRatio
(
SpringSimulation
under
=
new
SpringSimulation
(
new
SpringDescription
.
withDampingRatio
(
mass:
1.0
,
springConstant:
100.0
,
ratio:
0.75
),
0.0
,
300.0
,
0.0
);
expect
(
under
.
type
,
SpringType
.
underDamped
);
var
over
=
new
SpringSimulation
(
new
SpringDescription
.
withDampingRatio
(
SpringSimulation
over
=
new
SpringSimulation
(
new
SpringDescription
.
withDampingRatio
(
mass:
1.0
,
springConstant:
100.0
,
ratio:
1.25
),
0.0
,
300.0
,
0.0
);
expect
(
over
.
type
,
SpringType
.
overDamped
);
// Just so we don't forget how to create a desc without the ratio.
var
other
=
new
SpringSimulation
(
SpringSimulation
other
=
new
SpringSimulation
(
new
SpringDescription
(
mass:
1.0
,
springConstant:
100.0
,
damping:
20.0
),
0.0
,
20.0
,
20.0
);
expect
(
other
.
type
,
SpringType
.
criticallyDamped
);
});
test
(
'crit_spring'
,
()
{
var
crit
=
new
SpringSimulation
(
new
SpringDescription
.
withDampingRatio
(
SpringSimulation
crit
=
new
SpringSimulation
(
new
SpringDescription
.
withDampingRatio
(
mass:
1.0
,
springConstant:
100.0
,
ratio:
1.0
),
0.0
,
500.0
,
0.0
);
crit
.
tolerance
=
const
Tolerance
(
distance:
0.01
,
velocity:
0.01
);
...
...
@@ -151,7 +151,7 @@ void main() {
});
test
(
'overdamped_spring'
,
()
{
var
over
=
new
SpringSimulation
(
new
SpringDescription
.
withDampingRatio
(
SpringSimulation
over
=
new
SpringSimulation
(
new
SpringDescription
.
withDampingRatio
(
mass:
1.0
,
springConstant:
100.0
,
ratio:
1.25
),
0.0
,
500.0
,
0.0
);
over
.
tolerance
=
const
Tolerance
(
distance:
0.01
,
velocity:
0.01
);
...
...
@@ -173,7 +173,7 @@ void main() {
});
test
(
'underdamped_spring'
,
()
{
var
under
=
new
SpringSimulation
(
new
SpringDescription
.
withDampingRatio
(
SpringSimulation
under
=
new
SpringSimulation
(
new
SpringDescription
.
withDampingRatio
(
mass:
1.0
,
springConstant:
100.0
,
ratio:
0.25
),
0.0
,
300.0
,
0.0
);
expect
(
under
.
type
,
SpringType
.
underDamped
);
...
...
@@ -190,16 +190,16 @@ void main() {
});
test
(
'test_kinetic_scroll'
,
()
{
var
spring
=
new
SpringDescription
.
withDampingRatio
(
SpringDescription
spring
=
new
SpringDescription
.
withDampingRatio
(
mass:
1.0
,
springConstant:
50.0
,
ratio:
0.5
);
var
scroll
=
new
ScrollSimulation
(
100.0
,
800.0
,
0.0
,
300.0
,
spring
,
0.3
);
ScrollSimulation
scroll
=
new
ScrollSimulation
(
100.0
,
800.0
,
0.0
,
300.0
,
spring
,
0.3
);
scroll
.
tolerance
=
const
Tolerance
(
velocity:
0.5
,
distance:
0.1
);
expect
(
scroll
.
isDone
(
0.0
),
false
);
expect
(
scroll
.
isDone
(
0.5
),
false
);
// switch from friction to spring
expect
(
scroll
.
isDone
(
3.5
),
true
);
var
scroll2
=
new
ScrollSimulation
(
100.0
,
-
800.0
,
0.0
,
300.0
,
spring
,
0.3
);
ScrollSimulation
scroll2
=
new
ScrollSimulation
(
100.0
,
-
800.0
,
0.0
,
300.0
,
spring
,
0.3
);
scroll2
.
tolerance
=
const
Tolerance
(
velocity:
0.5
,
distance:
0.1
);
expect
(
scroll2
.
isDone
(
0.0
),
false
);
expect
(
scroll2
.
isDone
(
0.5
),
false
);
// switch from friction to spring
...
...
@@ -207,10 +207,10 @@ void main() {
});
test
(
'scroll_with_inf_edge_ends'
,
()
{
var
spring
=
new
SpringDescription
.
withDampingRatio
(
SpringDescription
spring
=
new
SpringDescription
.
withDampingRatio
(
mass:
1.0
,
springConstant:
50.0
,
ratio:
0.5
);
var
scroll
=
ScrollSimulation
scroll
=
new
ScrollSimulation
(
100.0
,
400.0
,
0.0
,
double
.
INFINITY
,
spring
,
0.3
);
scroll
.
tolerance
=
const
Tolerance
(
velocity:
1.0
);
...
...
@@ -233,8 +233,8 @@ void main() {
});
test
(
'over/under scroll spring'
,
()
{
var
spring
=
new
SpringDescription
.
withDampingRatio
(
mass:
1.0
,
springConstant:
170.0
,
ratio:
1.1
);
var
scroll
=
new
ScrollSimulation
(
500.0
,
-
7500.0
,
0.0
,
1000.0
,
spring
,
0.025
);
SpringDescription
spring
=
new
SpringDescription
.
withDampingRatio
(
mass:
1.0
,
springConstant:
170.0
,
ratio:
1.1
);
ScrollSimulation
scroll
=
new
ScrollSimulation
(
500.0
,
-
7500.0
,
0.0
,
1000.0
,
spring
,
0.025
);
scroll
.
tolerance
=
new
Tolerance
(
velocity:
45.0
,
distance:
1.5
);
expect
(
scroll
.
isDone
(
0.0
),
false
);
...
...
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