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
0a03d643
Unverified
Commit
0a03d643
authored
Jul 28, 2020
by
songyiYu
Committed by
GitHub
Jul 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add LayoutBuilder example (#61948)
parent
7c942e39
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
+53
-0
layout_builder.dart
packages/flutter/lib/src/widgets/layout_builder.dart
+53
-0
No files found.
packages/flutter/lib/src/widgets/layout_builder.dart
View file @
0a03d643
...
@@ -247,6 +247,59 @@ mixin RenderConstrainedLayoutBuilder<ConstraintType extends Constraints, ChildTy
...
@@ -247,6 +247,59 @@ mixin RenderConstrainedLayoutBuilder<ConstraintType extends Constraints, ChildTy
/// in an [Align] widget. If the child might want to be bigger, consider
/// in an [Align] widget. If the child might want to be bigger, consider
/// wrapping it in a [SingleChildScrollView] or [OverflowBox].
/// wrapping it in a [SingleChildScrollView] or [OverflowBox].
///
///
/// {@tool dartpad --template=stateless_widget_material}
///
/// This example uses a [LayoutBuilder] to build a different widget depending on the available width. Resize the
/// DartPad window to see [LayoutBuilder] in action!
///
/// ```dart
/// Widget build(BuildContext context) {
/// return Scaffold(
/// appBar: AppBar(title: Text("LayoutBuilder Example")),
/// body: LayoutBuilder(
/// builder: (context, constraints) {
/// if (constraints.maxWidth > 600) {
/// return _buildWideContainers();
/// } else {
/// return _buildNormalContainer();
/// }
/// },
/// ),
/// );
/// }
///
/// Widget _buildNormalContainer() {
/// return Center(
/// child: Container(
/// height: 100.0,
/// width: 100.0,
/// color: Colors.red,
/// ),
/// );
/// }
///
/// Widget _buildWideContainers() {
/// return Center(
/// child: Row(
/// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
/// children: <Widget>[
/// Container(
/// height: 100.0,
/// width: 100.0,
/// color: Colors.red,
/// ),
/// Container(
/// height: 100.0,
/// width: 100.0,
/// color: Colors.yellow,
/// ),
/// ],
/// ),
/// );
/// }
/// ```
/// {@end-tool}
///
/// See also:
/// See also:
///
///
/// * [SliverLayoutBuilder], the sliver counterpart of this widget.
/// * [SliverLayoutBuilder], the sliver counterpart of this widget.
...
...
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