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
d25039df
Commit
d25039df
authored
Oct 22, 2015
by
Hans Muller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a type parameter for Dropdown value
parent
bd9036cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
10 deletions
+11
-10
dropdown.dart
examples/widgets/dropdown.dart
+4
-4
dropdown.dart
packages/flutter/lib/src/material/dropdown.dart
+7
-6
No files found.
examples/widgets/dropdown.dart
View file @
d25039df
...
@@ -11,17 +11,17 @@ class DropdownDemo extends StatefulComponent {
...
@@ -11,17 +11,17 @@ class DropdownDemo extends StatefulComponent {
}
}
class
DropdownDemoState
extends
State
<
DropdownDemo
>
{
class
DropdownDemoState
extends
State
<
DropdownDemo
>
{
dynamic
_value
=
0
;
String
_value
=
"Free"
;
List
<
DropdownMenuItem
>
_buildItems
()
{
List
<
DropdownMenuItem
>
_buildItems
()
{
return
[
"One"
,
"Two"
,
"Free"
,
"Four"
].
map
((
String
label
)
{
return
[
"One"
,
"Two"
,
"Free"
,
"Four"
].
map
((
String
value
)
{
return
new
DropdownMenuItem
(
value:
label
,
child:
new
Text
(
label
));
return
new
DropdownMenuItem
<
String
>(
value:
value
,
child:
new
Text
(
value
));
})
})
.
toList
();
.
toList
();
}
}
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
Widget
dropdown
=
new
DropdownButton
(
Widget
dropdown
=
new
DropdownButton
<
String
>
(
items:
_buildItems
(),
items:
_buildItems
(),
value:
_value
,
value:
_value
,
onChanged:
(
dynamic
newValue
)
{
onChanged:
(
dynamic
newValue
)
{
...
...
packages/flutter/lib/src/material/dropdown.dart
View file @
d25039df
...
@@ -139,7 +139,8 @@ class _MenuRoute extends PerformanceRoute {
...
@@ -139,7 +139,8 @@ class _MenuRoute extends PerformanceRoute {
Duration
get
transitionDuration
=>
_kMenuDuration
;
Duration
get
transitionDuration
=>
_kMenuDuration
;
Widget
build
(
RouteArguments
args
)
{
Widget
build
(
RouteArguments
args
)
{
final
Size
navigatorSize
=
navigator
.
context
.
findRenderObject
().
size
;
final
RenderBox
renderBox
=
navigator
.
context
.
findRenderObject
();
final
Size
navigatorSize
=
renderBox
.
size
;
final
RelativeRect
menuRect
=
new
RelativeRect
.
fromSize
(
rect
,
navigatorSize
);
final
RelativeRect
menuRect
=
new
RelativeRect
.
fromSize
(
rect
,
navigatorSize
);
return
new
Positioned
(
return
new
Positioned
(
...
@@ -166,7 +167,7 @@ class _MenuRoute extends PerformanceRoute {
...
@@ -166,7 +167,7 @@ class _MenuRoute extends PerformanceRoute {
}
}
}
}
class
DropdownMenuItem
extends
StatelessComponent
{
class
DropdownMenuItem
<
T
>
extends
StatelessComponent
{
DropdownMenuItem
({
DropdownMenuItem
({
Key
key
,
Key
key
,
this
.
value
,
this
.
value
,
...
@@ -174,7 +175,7 @@ class DropdownMenuItem extends StatelessComponent {
...
@@ -174,7 +175,7 @@ class DropdownMenuItem extends StatelessComponent {
})
:
super
(
key:
key
);
})
:
super
(
key:
key
);
final
Widget
child
;
final
Widget
child
;
final
dynamic
value
;
final
T
value
;
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
new
Container
(
return
new
Container
(
...
@@ -191,7 +192,7 @@ class DropdownMenuItem extends StatelessComponent {
...
@@ -191,7 +192,7 @@ class DropdownMenuItem extends StatelessComponent {
}
}
}
}
class
DropdownButton
extends
StatelessComponent
{
class
DropdownButton
<
T
>
extends
StatelessComponent
{
DropdownButton
({
DropdownButton
({
Key
key
,
Key
key
,
this
.
items
,
this
.
items
,
...
@@ -200,8 +201,8 @@ class DropdownButton extends StatelessComponent {
...
@@ -200,8 +201,8 @@ class DropdownButton extends StatelessComponent {
this
.
level
:
4
this
.
level
:
4
})
:
super
(
key:
key
);
})
:
super
(
key:
key
);
final
List
<
DropdownMenuItem
>
items
;
final
List
<
DropdownMenuItem
<
T
>
>
items
;
final
dynamic
value
;
final
T
value
;
final
ValueChanged
onChanged
;
final
ValueChanged
onChanged
;
final
int
level
;
final
int
level
;
...
...
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