The Offstage
widget is to visually hide its child widget.
The default const
constructor creates a widget that visually hides its child.
Offstage(
offstage: // default to true
child:// its child widget
)
It contains many input parameters which can be configured to change its behavior and appearance.
The offstage
parameter is to lay out or include child widget in a tree. If true, the child is laid out as if it was in the tree, but without painting anything, without making the child available for hit testing, and without taking any room in the parent. If false, the child is included in the tree as normal. It's must not be null and its defaults to true.
The child
parameter is to add the child widget below the OffStage
widget in a tree.
The following code snippet shows how to use Offstage
widget.
Offstage(
child: FlutterLogo(),
)
This example shows how to visually Offstage
hides its child.
import 'package:flutter/material.dart';
class OffstageDemo extends StatelessWidget {
Widget build(BuildContext context) {
return Container(
color: Colors.blue[50],
height: 100.0,
width: 100.0,
child: Offstage(
child: FlutterLogo(),
),
);
}
}
// This Widget is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Offstage';
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: Center(
child: Material(child: OffstageDemo()),
),
),
);
}
}
void main() => runApp(MyApp());