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
55a1d0ae
Unverified
Commit
55a1d0ae
authored
Nov 03, 2020
by
Shi-Hao Hong
Committed by
GitHub
Nov 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Offstage Docs Sample (#69567)
* Add a code sample for the [Offstage] widget
parent
88bf732e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+54
-0
No files found.
packages/flutter/lib/src/widgets/basic.dart
View file @
55a1d0ae
...
...
@@ -2758,6 +2758,60 @@ class SizedOverflowBox extends SingleChildRenderObjectWidget {
/// needed, prefer removing the widget from the tree entirely rather than
/// keeping it alive in an [Offstage] subtree.
///
/// {@tool dartpad --template=stateful_widget_scaffold_center}
///
/// This example shows a [FlutterLogo] widget when the `_offstage` member field
/// is false, and hides it without any room in the parent when it is true. When
/// offstage, this app displays a button to get the logo size, which will be
/// displayed in a [SnackBar].
///
/// ```dart
/// GlobalKey _key = GlobalKey();
/// bool _offstage = true;
///
/// Size _getFlutterLogoSize() {
/// final RenderBox renderLogo = _key.currentContext.findRenderObject();
/// return renderLogo.size;
/// }
///
/// @override
/// Widget build(BuildContext context) {
/// return Column(
/// mainAxisAlignment: MainAxisAlignment.center,
/// children: <Widget>[
/// Offstage(
/// offstage: _offstage,
/// child: FlutterLogo(
/// key: _key,
/// size: 150.0,
/// ),
/// ),
/// Text('Flutter logo is offstage: $_offstage'),
/// RaisedButton(
/// child: Text('Toggle Offstage Value'),
/// onPressed: () {
/// setState(() {
/// _offstage = !_offstage;
/// });
/// },
/// ),
/// if (_offstage)
/// RaisedButton(
/// child: Text('Get Flutter Logo size'),
/// onPressed: () {
/// ScaffoldMessenger.of(context).showSnackBar(
/// SnackBar(
/// content: Text('Flutter Logo size is ${_getFlutterLogoSize()}'),
/// ),
/// );
/// }
/// ),
/// ],
/// );
/// }
/// ```
/// {@end-tool}
///
/// See also:
///
/// * [Visibility], which can hide a child more efficiently (albeit less
...
...
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