美文网首页
Flutter FadeInImage

Flutter FadeInImage

作者: 三只仓鼠 | 来源:发表于2020-03-06 12:49 被阅读0次

    动图录制所以图片有闪动,实际效果正常。


    1.首先需要在目录在创建assets文件夹,用于存放资源文件。(loading.gif)

    2.修改pubspec.yaml

    assets:
        -  assets/loading.gif
    
    import 'package:flutter/material.dart';
    
    void main() => runApp(MyApp());
    
    class MyApp extends StatelessWidget {
      // This widget is the root of your application.
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: MyHomePage(),
        );
      }
    }
    
    class MyHomePage extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Center(
            child: FadeInImage.assetNetwork(
                placeholder: "assets/loading.gif",
                image: "https://tukuimg.bdstatic.com/scrop/6be65a47b2bc49e492385b8ebc486d14.gif"),
          ),
        );
      }
    }
    
    

    相关文章

      网友评论

          本文标题:Flutter FadeInImage

          本文链接:https://www.haomeiwen.com/subject/axpbrhtx.html