Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- class VisibilityPoc extends StatefulWidget {
- @override
- _VisibilityPocState createState() => _VisibilityPocState();
- }
- class _VisibilityPocState extends State<VisibilityPoc> {
- bool show = true;
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: Center(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Visibility(
- visible: show,
- maintainAnimation: true,
- maintainSize: true,
- maintainState: true,
- child: Container(
- width: 100,
- height: 100,
- color: Colors.red,
- ),v
- ),
- ElevatedButton(
- onPressed: () {
- setState(() {
- show = !show;
- });
- },
- child: Text("Show & Hide"))
- ],
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement