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
d571257a
Unverified
Commit
d571257a
authored
Dec 21, 2021
by
Alberto
Committed by
GitHub
Dec 21, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated Stateless and Stateful widget docstrings (#95407)
parent
c746be66
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
1 deletion
+18
-1
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+18
-1
No files found.
packages/flutter/lib/src/widgets/framework.dart
View file @
d571257a
...
...
@@ -438,6 +438,14 @@ abstract class Widget extends DiagnosticableTree {
/// * Use `const` widgets where possible, and provide a `const` constructor for
/// the widget so that users of the widget can also do so.
///
/// * When trying to create a reusable piece of UI, prefer using a widget
/// rather than a helper method. For example, if there was a function used to
/// build a widget, a [State.setState] call would require Flutter to entirely
/// rebuild the returned wrapping widget. If a [Widget] was used instead,
/// Flutter would be able to efficiently re-render only those parts that
/// really need to be updated. Even better, if the created widget is `const`,
/// Flutter would short-circuit most of the rebuild work.
///
/// * Consider refactoring the stateless widget into a stateful widget so that
/// it can use some of the techniques described at [StatefulWidget], such as
/// caching common parts of subtrees and using [GlobalKey]s when changing the
...
...
@@ -646,11 +654,20 @@ abstract class StatelessWidget extends Widget {
/// efficient for a widget to be re-used than for a new (but
/// identically-configured) widget to be created. Factoring out the stateful
/// part into a widget that takes a child argument is a common way of doing
/// this.
/// this. Another caching strategy consists of assigning a widget to a
/// `final` state variable which can be used in the build method.
///
/// * Use `const` widgets where possible. (This is equivalent to caching a
/// widget and re-using it.)
///
/// * When trying to create a reusable piece of UI, prefer using a widget
/// rather than a helper method. For example, if there was a function used to
/// build a widget, a [State.setState] call would require Flutter to entirely
/// rebuild the returned wrapping widget. If a [Widget] was used instead,
/// Flutter would be able to efficiently re-render only those parts that
/// really need to be updated. Even better, if the created widget is `const`,
/// Flutter would short-circuit most of the rebuild work.
///
/// * Avoid changing the depth of any created subtrees or changing the type of
/// any widgets in the subtree. For example, rather than returning either the
/// child or the child wrapped in an [IgnorePointer], always wrap the 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