PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, July 17, 2022

[FIXED] How to show custom warning when FutureBuilder snapshot data equals to 0 (zero)?

 July 17, 2022     flutter, future, warnings     No comments   

Issue

In my Flutter app body section I use FutureBuilder. If snapshot.hasData then I show the Data in body. My problem is that sometimes the snapshot data is 0 (zero). I need to use stack or similar to show user a warning with stating that “currently data is not available”. How do I do that?

body: new Center(
  child: new FutureBuilder(
      future: getCurrencyJsonData(),
      builder: (context, snaphot) {
        if (snaphot.hasData) {
          return new ListView(

Solution

Just add a if into your builder..

 if (snaphot.data.length == 0) {
     return new Stack(...);
 }


Answered By - Rémi Rousselet
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing