Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

fade in only animation in flutter

I have a home screen and I want to apply fade in animation in image and text I have a image in center and then two line of text and I just want them to fade in for the one time only I have gone through some various examples but they all contains fade in and fade out i just want to reveal thosse image and text to user and the pause.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Try with this it will fade in from initState also i delayed 1 second you can modify it.

bool _visible = false;
 @override
  void initState() {
    
    Future.delayed(const Duration(seconds: 1), () {
    setState(() {
            _visible = !_visible;
          }); 
    });
     
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: AnimatedOpacity(
          // If the widget is visible, animate to 0.0 (invisible).
          // If the widget is hidden, animate to 1.0 (fully visible).
          opacity: _visible ? 1.0 : 0.0,
          duration: const Duration(milliseconds: 500),
          // The green box must be a child of the AnimatedOpacity widget.
          child:Column(
          children:[
          Image.network("https://cdn0.iconfinder.com/data/icons/business-startup-10/50/5-256.png")
          ,
          const Text("Your text")
          ])
        ),
      ),
     
    );
  }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading