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
50cf609e
Commit
50cf609e
authored
Nov 18, 2015
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #453 from Hixie/yak4-of
Pave the Foo.of() cowpath.
parents
752e341d
65d81451
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
33 additions
and
34 deletions
+33
-34
icon_theme.dart
packages/flutter/lib/src/material/icon_theme.dart
+1
-1
material_button.dart
packages/flutter/lib/src/material/material_button.dart
+1
-1
theme.dart
packages/flutter/lib/src/material/theme.dart
+1
-1
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+2
-2
focus.dart
packages/flutter/lib/src/widgets/focus.dart
+4
-4
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+20
-3
media_query.dart
packages/flutter/lib/src/widgets/media_query.dart
+1
-1
navigator.dart
packages/flutter/lib/src/widgets/navigator.dart
+1
-11
page_storage.dart
packages/flutter/lib/src/widgets/page_storage.dart
+2
-10
No files found.
packages/flutter/lib/src/material/icon_theme.dart
View file @
50cf609e
...
...
@@ -19,7 +19,7 @@ class IconTheme extends InheritedWidget {
final
IconThemeData
data
;
static
IconThemeData
of
(
BuildContext
context
)
{
IconTheme
result
=
context
.
inherit
ed
WidgetOfType
(
IconTheme
);
IconTheme
result
=
context
.
inherit
From
WidgetOfType
(
IconTheme
);
return
result
?.
data
;
}
...
...
packages/flutter/lib/src/material/material_button.dart
View file @
50cf609e
...
...
@@ -23,7 +23,7 @@ class ButtonTheme extends InheritedWidget {
final
ButtonColor
color
;
static
ButtonColor
of
(
BuildContext
context
)
{
ButtonTheme
result
=
context
.
inherit
ed
WidgetOfType
(
ButtonTheme
);
ButtonTheme
result
=
context
.
inherit
From
WidgetOfType
(
ButtonTheme
);
return
result
?.
color
??
ButtonColor
.
normal
;
}
...
...
packages/flutter/lib/src/material/theme.dart
View file @
50cf609e
...
...
@@ -23,7 +23,7 @@ class Theme extends InheritedWidget {
static
final
ThemeData
_kFallbackTheme
=
new
ThemeData
.
fallback
();
static
ThemeData
of
(
BuildContext
context
)
{
Theme
theme
=
context
.
inherit
ed
WidgetOfType
(
Theme
);
Theme
theme
=
context
.
inherit
From
WidgetOfType
(
Theme
);
return
theme
==
null
?
_kFallbackTheme
:
theme
.
data
;
}
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
50cf609e
...
...
@@ -972,7 +972,7 @@ class DefaultTextStyle extends InheritedWidget {
final
TextStyle
style
;
static
TextStyle
of
(
BuildContext
context
)
{
DefaultTextStyle
result
=
context
.
inherit
ed
WidgetOfType
(
DefaultTextStyle
);
DefaultTextStyle
result
=
context
.
inherit
From
WidgetOfType
(
DefaultTextStyle
);
return
result
?.
style
;
}
...
...
@@ -1163,7 +1163,7 @@ class DefaultAssetBundle extends InheritedWidget {
final
AssetBundle
bundle
;
static
AssetBundle
of
(
BuildContext
context
)
{
DefaultAssetBundle
result
=
context
.
inherit
ed
WidgetOfType
(
DefaultAssetBundle
);
DefaultAssetBundle
result
=
context
.
inherit
From
WidgetOfType
(
DefaultAssetBundle
);
return
result
?.
bundle
;
}
...
...
packages/flutter/lib/src/widgets/focus.dart
View file @
50cf609e
...
...
@@ -87,7 +87,7 @@ class Focus extends StatefulComponent {
static
bool
at
(
BuildContext
context
,
Widget
widget
,
{
bool
autofocus:
true
})
{
assert
(
widget
!=
null
);
assert
(
widget
.
key
is
GlobalKey
);
_FocusScope
focusScope
=
context
.
inherit
ed
WidgetOfType
(
_FocusScope
);
_FocusScope
focusScope
=
context
.
inherit
From
WidgetOfType
(
_FocusScope
);
if
(
focusScope
!=
null
)
{
if
(
autofocus
)
focusScope
.
_setFocusedWidgetIfUnset
(
widget
.
key
);
...
...
@@ -100,7 +100,7 @@ class Focus extends StatefulComponent {
static
bool
_atScope
(
BuildContext
context
,
Widget
widget
,
{
bool
autofocus:
true
})
{
assert
(
widget
!=
null
);
_FocusScope
focusScope
=
context
.
inherit
ed
WidgetOfType
(
_FocusScope
);
_FocusScope
focusScope
=
context
.
inherit
From
WidgetOfType
(
_FocusScope
);
if
(
focusScope
!=
null
)
{
if
(
autofocus
)
focusScope
.
_setFocusedScopeIfUnset
(
widget
.
key
);
...
...
@@ -118,7 +118,7 @@ class Focus extends StatefulComponent {
static
void
moveTo
(
BuildContext
context
,
Widget
widget
)
{
assert
(
widget
!=
null
);
assert
(
widget
.
key
is
GlobalKey
);
_FocusScope
focusScope
=
context
.
inherit
ed
WidgetOfType
(
_FocusScope
);
_FocusScope
focusScope
=
context
.
inherit
From
WidgetOfType
(
_FocusScope
);
if
(
focusScope
!=
null
)
focusScope
.
focusState
.
_setFocusedWidget
(
widget
.
key
);
}
...
...
@@ -126,7 +126,7 @@ class Focus extends StatefulComponent {
static
void
moveScopeTo
(
BuildContext
context
,
Focus
component
)
{
assert
(
component
!=
null
);
assert
(
component
.
key
!=
null
);
_FocusScope
focusScope
=
context
.
inherit
ed
WidgetOfType
(
_FocusScope
);
_FocusScope
focusScope
=
context
.
inherit
From
WidgetOfType
(
_FocusScope
);
if
(
focusScope
!=
null
)
focusScope
.
focusState
.
_setFocusedScope
(
component
.
key
);
}
...
...
packages/flutter/lib/src/widgets/framework.dart
View file @
50cf609e
...
...
@@ -534,7 +534,9 @@ typedef void ElementVisitor(Element element);
abstract
class
BuildContext
{
Widget
get
widget
;
RenderObject
findRenderObject
();
InheritedWidget
inheritedWidgetOfType
(
Type
targetType
);
InheritedWidget
inheritFromWidgetOfType
(
Type
targetType
);
Widget
ancestorWidgetOfType
(
Type
targetType
);
State
ancestorStateOfType
(
Type
targetType
);
void
visitAncestorElements
(
bool
visitor
(
Element
element
));
void
visitChildElements
(
void
visitor
(
Element
element
));
}
...
...
@@ -806,18 +808,33 @@ abstract class Element<T extends Widget> implements BuildContext {
assert
(()
{
_debugLifecycleState
=
_ElementLifecycle
.
defunct
;
return
true
;
});
}
RenderObject
findRenderObject
()
=>
renderObject
;
Set
<
Type
>
_dependencies
;
InheritedWidget
inherit
ed
WidgetOfType
(
Type
targetType
)
{
InheritedWidget
inherit
From
WidgetOfType
(
Type
targetType
)
{
if
(
_dependencies
==
null
)
_dependencies
=
new
Set
<
Type
>();
_dependencies
.
add
(
targetType
);
return
ancestorWidgetOfType
(
targetType
);
}
Widget
ancestorWidgetOfType
(
Type
targetType
)
{
Element
ancestor
=
_parent
;
while
(
ancestor
!=
null
&&
ancestor
.
widget
.
runtimeType
!=
targetType
)
ancestor
=
ancestor
.
_parent
;
return
ancestor
?.
widget
;
}
RenderObject
findRenderObject
()
=>
renderObject
;
State
ancestorStateOfType
(
Type
targetType
)
{
Element
ancestor
=
_parent
;
while
(
ancestor
!=
null
)
{
if
(
ancestor
is
StatefulComponentElement
&&
ancestor
.
state
.
runtimeType
==
targetType
)
break
;
ancestor
=
ancestor
.
_parent
;
}
StatefulComponentElement
statefulAncestor
=
ancestor
;
return
statefulAncestor
?.
state
;
}
void
visitAncestorElements
(
bool
visitor
(
Element
element
))
{
Element
ancestor
=
_parent
;
...
...
packages/flutter/lib/src/widgets/media_query.dart
View file @
50cf609e
...
...
@@ -42,7 +42,7 @@ class MediaQuery extends InheritedWidget {
final
MediaQueryData
data
;
static
MediaQueryData
of
(
BuildContext
context
)
{
MediaQuery
query
=
context
.
inherit
ed
WidgetOfType
(
MediaQuery
);
MediaQuery
query
=
context
.
inherit
From
WidgetOfType
(
MediaQuery
);
return
query
==
null
?
null
:
query
.
data
;
}
...
...
packages/flutter/lib/src/widgets/navigator.dart
View file @
50cf609e
...
...
@@ -54,17 +54,7 @@ class Navigator extends StatefulComponent {
static
const
String
defaultRouteName
=
'/'
;
static
NavigatorState
of
(
BuildContext
context
)
{
NavigatorState
result
;
context
.
visitAncestorElements
((
Element
element
)
{
if
(
element
is
StatefulComponentElement
&&
element
.
state
is
NavigatorState
)
{
result
=
element
.
state
;
return
false
;
}
return
true
;
});
return
result
;
}
static
NavigatorState
of
(
BuildContext
context
)
=>
context
.
ancestorStateOfType
(
NavigatorState
);
NavigatorState
createState
()
=>
new
NavigatorState
();
}
...
...
packages/flutter/lib/src/widgets/page_storage.dart
View file @
50cf609e
...
...
@@ -86,16 +86,8 @@ class PageStorage extends StatelessComponent {
/// Might return null if there is no PageStorage in this context.
static
PageStorageBucket
of
(
BuildContext
context
)
{
PageStorageBucket
result
;
context
.
visitAncestorElements
((
Element
element
)
{
Widget
widget
=
element
.
widget
;
if
(
widget
is
PageStorage
)
{
result
=
widget
.
bucket
;
return
false
;
}
return
true
;
});
return
result
;
PageStorage
widget
=
context
.
ancestorWidgetOfType
(
PageStorage
);
return
widget
?.
bucket
;
}
Widget
build
(
BuildContext
context
)
=>
child
;
...
...
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