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
9109bb02
Commit
9109bb02
authored
Sep 15, 2016
by
Adam Barth
Committed by
GitHub
Sep 15, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve docs for ComponentElement (#5829)
Also, make ProxyWidget and ProxyElement public. Fixes #4505
parent
cc1755aa
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
16 deletions
+28
-16
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+28
-16
No files found.
packages/flutter/lib/src/widgets/framework.dart
View file @
9109bb02
...
@@ -973,9 +973,15 @@ abstract class State<T extends StatefulWidget> {
...
@@ -973,9 +973,15 @@ abstract class State<T extends StatefulWidget> {
}
}
}
}
abstract
class
_ProxyWidget
extends
Widget
{
/// A widget that has exactly one child widget.
const
_ProxyWidget
({
Key
key
,
this
.
child
})
:
super
(
key:
key
);
///
/// Useful as a base class for other widgets, such as [InheritedWidget] and
/// [ParentDataWidget].
abstract
class
ProxyWidget
extends
Widget
{
/// Creates a widget that has exactly one child widget.
const
ProxyWidget
({
Key
key
,
this
.
child
})
:
super
(
key:
key
);
/// The widget below this widget in the tree.
final
Widget
child
;
final
Widget
child
;
}
}
...
@@ -989,7 +995,7 @@ abstract class _ProxyWidget extends Widget {
...
@@ -989,7 +995,7 @@ abstract class _ProxyWidget extends Widget {
/// A [ParentDataWidget] is specific to a particular kind of [RenderObject], and
/// A [ParentDataWidget] is specific to a particular kind of [RenderObject], and
/// thus also to a particular [RenderObjectWidget] class. That class is `T`, the
/// thus also to a particular [RenderObjectWidget] class. That class is `T`, the
/// [ParentDataWidget] type argument.
/// [ParentDataWidget] type argument.
abstract
class
ParentDataWidget
<
T
extends
RenderObjectWidget
>
extends
_
ProxyWidget
{
abstract
class
ParentDataWidget
<
T
extends
RenderObjectWidget
>
extends
ProxyWidget
{
const
ParentDataWidget
({
Key
key
,
Widget
child
})
const
ParentDataWidget
({
Key
key
,
Widget
child
})
:
super
(
key:
key
,
child:
child
);
:
super
(
key:
key
,
child:
child
);
...
@@ -1046,7 +1052,7 @@ abstract class ParentDataWidget<T extends RenderObjectWidget> extends _ProxyWidg
...
@@ -1046,7 +1052,7 @@ abstract class ParentDataWidget<T extends RenderObjectWidget> extends _ProxyWidg
///
///
/// Inherited widgets, when referenced in this way, will cause the consumer to
/// Inherited widgets, when referenced in this way, will cause the consumer to
/// rebuild when the inherited widget itself changes state.
/// rebuild when the inherited widget itself changes state.
abstract
class
InheritedWidget
extends
_
ProxyWidget
{
abstract
class
InheritedWidget
extends
ProxyWidget
{
const
InheritedWidget
({
Key
key
,
Widget
child
})
const
InheritedWidget
({
Key
key
,
Widget
child
})
:
super
(
key:
key
,
child:
child
);
:
super
(
key:
key
,
child:
child
);
...
@@ -1647,6 +1653,7 @@ class BuildOwner {
...
@@ -1647,6 +1653,7 @@ class BuildOwner {
/// Elements can, in principle, have children. Only subclasses of
/// Elements can, in principle, have children. Only subclasses of
/// RenderObjectElement are allowed to have more than one child.
/// RenderObjectElement are allowed to have more than one child.
abstract
class
Element
implements
BuildContext
{
abstract
class
Element
implements
BuildContext
{
/// Creates an element that instantiates the given widget.
Element
(
Widget
widget
)
:
_widget
=
widget
{
Element
(
Widget
widget
)
:
_widget
=
widget
{
assert
(
widget
!=
null
);
assert
(
widget
!=
null
);
}
}
...
@@ -2180,9 +2187,9 @@ class ErrorWidget extends LeafRenderObjectWidget {
...
@@ -2180,9 +2187,9 @@ class ErrorWidget extends LeafRenderObjectWidget {
}
}
}
}
/// Base class for instantiations of widgets that have builders and can be
/// An [Element] that can be marked dirty and rebuilt.
/// marked dirty.
abstract
class
BuildableElement
extends
Element
{
abstract
class
BuildableElement
extends
Element
{
/// Creates an element that instantiates the given widget.
BuildableElement
(
Widget
widget
)
:
super
(
widget
);
BuildableElement
(
Widget
widget
)
:
super
(
widget
);
/// Returns true if the element has been marked as needing rebuilding.
/// Returns true if the element has been marked as needing rebuilding.
...
@@ -2342,9 +2349,12 @@ typedef Widget IndexedWidgetBuilder(BuildContext context, int index);
...
@@ -2342,9 +2349,12 @@ typedef Widget IndexedWidgetBuilder(BuildContext context, int index);
// See ComponentElement._builder.
// See ComponentElement._builder.
Widget
_buildNothing
(
BuildContext
context
)
=>
null
;
Widget
_buildNothing
(
BuildContext
context
)
=>
null
;
/// Base class for the instantiation of [StatelessWidget], [StatefulWidget],
/// An [Element] that composes other [Element]s.
/// and [_ProxyWidget] widgets.
///
/// Rather than creating a [RenderObject] directly, a [ComponentElement] creates
/// [RenderObject]s indirectly by creating other [Element]s.
abstract
class
ComponentElement
extends
BuildableElement
{
abstract
class
ComponentElement
extends
BuildableElement
{
/// Creates an element that instantiates the given widget.
ComponentElement
(
Widget
widget
)
:
super
(
widget
);
ComponentElement
(
Widget
widget
)
:
super
(
widget
);
// Initializing this field with _buildNothing helps the compiler prove that
// Initializing this field with _buildNothing helps the compiler prove that
...
@@ -2582,13 +2592,15 @@ class StatefulElement extends ComponentElement {
...
@@ -2582,13 +2592,15 @@ class StatefulElement extends ComponentElement {
}
}
}
}
abstract
class
_ProxyElement
extends
ComponentElement
{
/// A base class for elements that instantiate [ProxyElement]s.
_ProxyElement
(
_ProxyWidget
widget
)
:
super
(
widget
)
{
abstract
class
ProxyElement
extends
ComponentElement
{
/// Creates an element that instantiates the given widget.
ProxyElement
(
ProxyWidget
widget
)
:
super
(
widget
)
{
_builder
=
_build
;
_builder
=
_build
;
}
}
@override
@override
_
ProxyWidget
get
widget
=>
super
.
widget
;
ProxyWidget
get
widget
=>
super
.
widget
;
Widget
_build
(
BuildContext
context
)
=>
widget
.
child
;
Widget
_build
(
BuildContext
context
)
=>
widget
.
child
;
...
@@ -2599,8 +2611,8 @@ abstract class _ProxyElement extends ComponentElement {
...
@@ -2599,8 +2611,8 @@ abstract class _ProxyElement extends ComponentElement {
}
}
@override
@override
void
update
(
_
ProxyWidget
newWidget
)
{
void
update
(
ProxyWidget
newWidget
)
{
_
ProxyWidget
oldWidget
=
widget
;
ProxyWidget
oldWidget
=
widget
;
assert
(
widget
!=
null
);
assert
(
widget
!=
null
);
assert
(
widget
!=
newWidget
);
assert
(
widget
!=
newWidget
);
super
.
update
(
newWidget
);
super
.
update
(
newWidget
);
...
@@ -2611,11 +2623,11 @@ abstract class _ProxyElement extends ComponentElement {
...
@@ -2611,11 +2623,11 @@ abstract class _ProxyElement extends ComponentElement {
}
}
@protected
@protected
void
notifyClients
(
_
ProxyWidget
oldWidget
);
void
notifyClients
(
ProxyWidget
oldWidget
);
}
}
/// Base class for instantiations of [ParentDataWidget] subclasses.
/// Base class for instantiations of [ParentDataWidget] subclasses.
class
ParentDataElement
<
T
extends
RenderObjectWidget
>
extends
_
ProxyElement
{
class
ParentDataElement
<
T
extends
RenderObjectWidget
>
extends
ProxyElement
{
ParentDataElement
(
ParentDataWidget
<
T
>
widget
)
:
super
(
widget
);
ParentDataElement
(
ParentDataWidget
<
T
>
widget
)
:
super
(
widget
);
@override
@override
...
@@ -2666,7 +2678,7 @@ class ParentDataElement<T extends RenderObjectWidget> extends _ProxyElement {
...
@@ -2666,7 +2678,7 @@ class ParentDataElement<T extends RenderObjectWidget> extends _ProxyElement {
}
}
/// Base class for instantiations of [InheritedWidget] subclasses.
/// Base class for instantiations of [InheritedWidget] subclasses.
class
InheritedElement
extends
_
ProxyElement
{
class
InheritedElement
extends
ProxyElement
{
InheritedElement
(
InheritedWidget
widget
)
:
super
(
widget
);
InheritedElement
(
InheritedWidget
widget
)
:
super
(
widget
);
@override
@override
...
...
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