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
dc907830
Commit
dc907830
authored
Dec 04, 2015
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #718 from Hixie/core-basics
Introduce some basic utility classes.
parents
1d4693fc
c5a26615
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
91 additions
and
19 deletions
+91
-19
stock_menu.dart
examples/stocks/lib/stock_menu.dart
+16
-8
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+16
-0
page_forward_transitions_test.dart
packages/unit/test/widget/page_forward_transitions_test.dart
+0
-2
set_state_2_test.dart
packages/unit/test/widget/set_state_2_test.dart
+59
-0
snack_bar_test.dart
packages/unit/test/widget/snack_bar_test.dart
+0
-2
test_widgets.dart
packages/unit/test/widget/test_widgets.dart
+0
-7
No files found.
examples/stocks/lib/stock_menu.dart
View file @
dc907830
...
...
@@ -9,6 +9,7 @@ enum _MenuItems { autorefresh, autorefreshCheckbox, refresh, speedUp, speedDown
const
double
_kMenuMargin
=
16.0
;
// 24.0 on tablet
Future
showStockMenu
(
{
BuildContext
context
,
bool
autorefresh
,
ValueChanged
<
bool
>
onAutorefreshChanged
})
async
{
StateSetter
autorefreshStateSetter
;
switch
(
await
showMenu
(
context:
context
,
position:
new
ModalPosition
(
...
...
@@ -20,12 +21,18 @@ Future showStockMenu({BuildContext context, bool autorefresh, ValueChanged<bool>
value:
_MenuItems
.
autorefresh
,
child:
new
Row
(<
Widget
>[
new
Flexible
(
child:
new
Text
(
'Autorefresh'
)),
new
Checkbox
(
value:
autorefresh
,
onChanged:
(
bool
value
)
{
// TODO(ianh): https://github.com/flutter/flutter/issues/187
autorefresh
=
value
;
Navigator
.
pop
(
context
,
_MenuItems
.
autorefreshCheckbox
);
new
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
autorefreshStateSetter
=
setState
;
return
new
Checkbox
(
value:
autorefresh
,
onChanged:
(
bool
value
)
{
setState
(()
{
autorefresh
=
value
;
});
Navigator
.
pop
(
context
,
_MenuItems
.
autorefreshCheckbox
);
}
);
}
)
]
...
...
@@ -46,8 +53,9 @@ Future showStockMenu({BuildContext context, bool autorefresh, ValueChanged<bool>
]
))
{
case
_MenuItems
.
autorefresh
:
// TODO(ianh): https://github.com/flutter/flutter/issues/187
autorefresh
=
!
autorefresh
;
autorefreshStateSetter
(()
{
autorefresh
=
!
autorefresh
;
});
continue
autorefreshNotify
;
autorefreshNotify:
case
_MenuItems
.
autorefreshCheckbox
:
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
dc907830
...
...
@@ -1367,3 +1367,19 @@ class KeyedSubtree extends StatelessComponent {
Widget
build
(
BuildContext
context
)
=>
child
;
}
class
Builder
extends
StatelessComponent
{
Builder
({
Key
key
,
this
.
builder
})
:
super
(
key:
key
);
final
WidgetBuilder
builder
;
Widget
build
(
BuildContext
context
)
=>
builder
(
context
);
}
typedef
Widget
StatefulWidgetBuilder
(
BuildContext
context
,
StateSetter
setState
);
class
StatefulBuilder
extends
StatefulComponent
{
StatefulBuilder
({
Key
key
,
this
.
builder
})
:
super
(
key:
key
);
final
StatefulWidgetBuilder
builder
;
_StatefulBuilderState
createState
()
=>
new
_StatefulBuilderState
();
}
class
_StatefulBuilderState
extends
State
<
StatefulBuilder
>
{
Widget
build
(
BuildContext
context
)
=>
config
.
builder
(
context
,
setState
);
}
\ No newline at end of file
packages/unit/test/widget/page_forward_transitions_test.dart
View file @
dc907830
...
...
@@ -7,8 +7,6 @@ import 'package:flutter/animation.dart';
import
'package:flutter/material.dart'
;
import
'package:test/test.dart'
;
import
'test_widgets.dart'
;
class
TestTransition
extends
TransitionComponent
{
TestTransition
({
Key
key
,
...
...
packages/unit/test/widget/set_state_2_test.dart
0 → 100644
View file @
dc907830
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:test/test.dart'
;
void
main
(
)
{
test
(
'setState() overbuild test'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
List
<
String
>
log
=
<
String
>[];
Builder
inner
=
new
Builder
(
builder:
(
BuildContext
context
)
{
log
.
add
(
'inner'
);
return
new
Text
(
'inner'
);
}
);
int
value
=
0
;
tester
.
pumpWidget
(
new
Builder
(
builder:
(
BuildContext
context
)
{
log
.
add
(
'outer'
);
return
new
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
log
.
add
(
'stateful'
);
return
new
GestureDetector
(
onTap:
()
{
setState
(()
{
value
+=
1
;
});
},
child:
new
Builder
(
builder:
(
BuildContext
context
)
{
log
.
add
(
'middle
$value
'
);
return
inner
;
}
)
);
}
);
}
));
log
.
add
(
'---'
);
tester
.
tap
(
tester
.
findText
(
'inner'
));;
tester
.
pump
();
log
.
add
(
'---'
);
expect
(
log
,
equals
(<
String
>[
'outer'
,
'stateful'
,
'middle 0'
,
'inner'
,
'---'
,
'stateful'
,
'middle 1'
,
'---'
,
]));
});
});
}
packages/unit/test/widget/snack_bar_test.dart
View file @
dc907830
...
...
@@ -6,8 +6,6 @@ import 'package:flutter_test/flutter_test.dart';
import
'package:flutter/material.dart'
;
import
'package:test/test.dart'
;
import
'test_widgets.dart'
;
void
main
(
)
{
test
(
'SnackBar control test'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
...
...
packages/unit/test/widget/test_widgets.dart
View file @
dc907830
...
...
@@ -59,10 +59,3 @@ void flipStatefulComponent(WidgetTester tester) {
FlipComponentState
state
=
stateElement
.
state
;
state
.
flip
();
}
class
Builder
extends
StatelessComponent
{
Builder
({
Key
key
,
this
.
builder
})
:
super
(
key:
key
);
final
WidgetBuilder
builder
;
Widget
build
(
BuildContext
context
)
=>
builder
(
context
);
}
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