FadeInImage in BoxDecoration

前端 未结 3 669
长情又很酷
长情又很酷 2021-01-25 11:28

I love the FadeInImage

I can do this

child: FadeInImage.assetNetwork(
    image: \'https://placeimg.com/640/480/any\',
    placeholder: \'assets/images/l         


        
3条回答
  •  感动是毒
    2021-01-25 12:00

    Here is the code.

    class _HomePageState extends State {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(),
          body: Center(
              child: FutureBuilder(
            future: _myFuture(),
            builder: (BuildContext context, AsyncSnapshot snapshot) {
              if (snapshot.hasData) return _yourWidget();
              return CircularProgressIndicator();
            },
          )),
        );
      }
    
      Widget _yourWidget() {
        return Stack(
          children: [
            Center(
              child: FadeInImage(
                width: 300,
                height: 300,
                placeholder: AssetImage(chocolateImage),
                image: NetworkImage(poolImageUrl),
                fit: BoxFit.cover,
              ),
            ),
            Center(child: Text('Pool', style: TextStyle(fontSize: 36.0, color: Colors.white, fontWeight: FontWeight.bold))),
          ],
        );
      }
    
      Future _myFuture() async {
        await Future.delayed(Duration(milliseconds: 10500));
        return true;
      }
    }
    

提交回复
热议问题