Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i fade in widgets when the screen loads using Flutter? [closed]

Its a login page and I want that when I load my screen , my all widgets should fade in smoothly

like image 530
Neha Garg Avatar asked Oct 25 '25 02:10

Neha Garg


1 Answers

Hey you take a look at Animated Opacity using this you can achieve the fade in transition

Sample Snippet :

    class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  double widget1Opacity = 0.0;
  

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    Future.delayed(Duration(milliseconds: 300), () {
      widget1Opacity = 1;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: AnimatedOpacity(
            opacity: widget1Opacity,
            duration: Duration(seconds: 3),
            child: FlutterLogo(
              size: 200,
              style: FlutterLogoStyle.markOnly,
            )),
      ),
    );
  }
}
like image 66
Akshay Kumar U Avatar answered Oct 27 '25 18:10

Akshay Kumar U



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!