How To Use Offstage Widget Using Flutter Android App

admin_img Posted By Bajarangi soft , Posted On 06-11-2020

A widget that lays the child 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.Offstage children are still active: they can receive focus and have keyboard input directed to them.Animations continue to run in offstage children, and therefore use battery and CPU time, regardless of whether the animations end up being visible.

How To Use Offstage Widget Using Flutter Android App

Offstage Widget
Complete Code For Offstage Widget In Flutter
main.dart

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: HomeScreen(),
    );
  }
}

class HomeScreen extends StatefulWidget {
  @override
  _HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.black,
      appBar: AppBar(
        backgroundColor: Colors.indigo,
          title: Text("Offstage Widget")),
      body: Offstage(
        child: Container(
          child: Text('Bajarangisoft.com',style: TextStyle(
            color: Colors.white
          ),),
         ),
      ),
    );
  }
}

Related Post