当前位置:网站首页>[shutter] image component (the placeholder | transparent_image transparent image plug-in is loaded into the memory)
[shutter] image component (the placeholder | transparent_image transparent image plug-in is loaded into the memory)
2022-07-03 00:34:00 【Programmer community】
List of articles
- One 、transparent_image Transparent image plugin
- Two 、 Memory load Placeholder
- 3、 ... and 、 Complete code example
- Four 、 Related resources
One 、transparent_image Transparent image plugin
install transparent_image plug-in unit :
- Search plug-ins : stay https://pub.dev/packages Mid search transparent_image plug-in unit ;
- Plug-in address : https://pub.dev/packages/transparent_image
- Configuration plug-ins : stay pubspec.yaml Configure plug-ins in ;
dependencies: transparent_image: ^2.0.0- Get plug-ins : Click on pubspec.yaml In the upper right corner of the middle Pub get Button , Get plug-ins ;
- Import header file :
import 'package:transparent_image/transparent_image.dart';Two 、 Memory load Placeholder
Placeholder Is a placeholder control , When the picture is not ready , Such as getting pictures from the Internet , First use Placeholder Occupy the position of the picture component ;
Code example :
Stack( children: [ // Progress bar Center(child: CircularProgressIndicator(),), Center( // The gradient appears when the network is loaded child: FadeInImage.memoryNetwork( // Placeholder placeholder: kTransparentImage, image: "/img/77/2697601bd73b0330cda8b8835a2857.jpg", ), ) ],),Running effect : The progress bar is always , At the beginning of the FadeInImage Components are transparent , Show progress bar , Then it becomes opaque , Progress bar is overwritten , But keep turning in the back ;

Displayed network pictures : ( Learn the lesson of the last blog , Use landscape pictures )

3、 ... and 、 Complete code example
Complete code example :
import 'package:flutter/material.dart';import 'dart:io';import 'package:path_provider/path_provider.dart';import 'package:transparent_image/transparent_image.dart';import 'package:cached_network_image/cached_network_image.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(title: 'Flutter Demo Home Page'), ); }}class MyHomePage extends StatefulWidget {
MyHomePage({
Key key, this.title}) : super(key: key); final String title; @override _MyHomePageState createState() => _MyHomePageState();}class _MyHomePageState extends State<MyHomePage> {
int _counter = 0; void _incrementCounter() {
setState(() {
_counter++; }); } /// SD Card path String sdPath; @override void initState() {
// obtain SD Card path getSdPath(); } void getSdPath() async {
String path = (await getExternalStorageDirectory()).path; setState(() {
sdPath = path; }); } @override Widget build(BuildContext context) {
print("sdPath : $sdPath"); return Scaffold( appBar: AppBar( title: Text(widget.title), ), body: Center( child: ListView( children: [ Stack( children: [ // Progress bar Center(child: CircularProgressIndicator(),), Center( // The gradient appears when the network is loaded child: FadeInImage.memoryNetwork( // Placeholder placeholder: kTransparentImage, image: "/img/77/2697601bd73b0330cda8b8835a2857.jpg", ), ) ], ), // Picture components , Load a picture from the network /*Image.network( // Picture address "https://img-blog.csdnimg.cn/2021032313493741.png", ),*/ /*Image( image: AssetImage("images/sidalin.png"), ),*/ //Image.asset('images/sidalin2.png', ), /// from SD Card loading picture /*if(sdPath != null) Image.file( File('$sdPath/sidalin3.png'), width: 200, ),*/ ], ) ), floatingActionButton: FloatingActionButton( onPressed: _incrementCounter, tooltip: 'Increment', child: Icon(Icons.add), ), // This trailing comma makes auto-formatting nicer for build methods. ); }}pubspec.yaml The configuration file :
name: flutter_image_widgetdescription: A new Flutter application.version: 1.0.0+1environment: sdk: ">=2.1.0 <3.0.0"dependencies: flutter: sdk: flutter cupertino_icons: ^0.1.2 path_provider: ^2.0.1 transparent_image: ^2.0.0 cached_network_image: ^2.5.1dev_dependencies: flutter_test: sdk: flutterflutter: uses-material-design: true assets: - images/sidalin.png - images/sidalin2.png - images/waiting.gifRunning effect :

Four 、 Related resources
Reference material :
- Flutter Official website : https://flutter.dev/
- Flutter Plug in download address : https://pub.dev/packages
- Flutter Developing documents : https://flutter.cn/docs ( Strongly recommend )
- official GitHub Address : https://github.com/flutter
- Flutter The Chinese community : https://flutter.cn/
- Flutter Practical tutorial : https://flutter.cn/docs/cookbook
- Flutter CodeLab : https://codelabs.flutter-io.cn/
- Dart Chinese document : https://dart.cn/
- Dart Developer website : https://api.dart.dev/
- Flutter Chinese net ( unofficial , The translation is very good ) : https://flutterchina.club/ , http://flutter.axuer.com/docs/
- Flutter Related issues : https://flutterchina.club/faq/ ( It is recommended to watch it at the introductory stage )
- GitHub Upper Flutter Open source examples : https://download.csdn.net/download/han1202012/15989510
Blog source download :
GitHub Address : https://github.com/han1202012/flutter_image_widget ( Keep updating with the progress of the blog , There may not be the source code of this blog )
Blog source snapshot : https://download.csdn.net/download/han1202012/16073006 ( The source code snapshot of this blog , You can find the source code of this blog )

边栏推荐
- 写论文可以去哪些网站搜索参考文献?
- 关于XML一些介绍和注意事项
- Angled detection frame | calibrated depth feature for target detection (with implementation source code)
- Andorid 获取系统标题栏高度
- 百数不断创新,打造自由的低代码办公工具
- NC50965 Largest Rectangle in a Histogram
- 大学生课堂作业2000~3000字的小论文,标准格式是什么?
- FRP reverse proxy +msf get shell
- Luogu_ P1149 [noip2008 improvement group] matchstick equation_ Enumeration and tabulation
- maya渔屋建模
猜你喜欢

setInterval定时器在ie不生效原因之一:回调的是箭头函数

Logback configuration file
![[shutter] Introduction to the official example of shutter Gallery (project introduction | engineering construction)](/img/f7/a8eb8e40b9ea25021751d7150936ac.jpg)
[shutter] Introduction to the official example of shutter Gallery (project introduction | engineering construction)

pod生命周期详解
![[IELTS reading] Wang Xiwei reading P1 (reading judgment question)](/img/ee/540661fcb2cf1cf1eb15e2026c997a.png)
[IELTS reading] Wang Xiwei reading P1 (reading judgment question)

Hundreds of continuous innovation to create free low code office tools

Shell脚本基本使用

pageoffice-之bug修改之旅

Linux Software: how to install redis service

为什么网站打开速度慢?
随机推荐
Automated defect analysis in electron microscopic images-论文阅读笔记
Briefly talk about other uses of operation and maintenance monitoring
简单聊聊运维监控的其他用途
使用jenkins之二Job
哪些软件可以整篇翻译英文论文?
[golang syntax] map common errors golang panic: assignment to entry in nil map
The "2022 China Digital Office Market Research Report" can be downloaded to explain the 176.8 billion yuan market in detail
Feature Engineering: summary of common feature transformation methods
collections. What is the purpose of chainmap- What is the purpose of collections. ChainMap?
antv x6节点拖拽到画布上后的回调事件(踩大坑记录)
Don't want teachers to see themselves with cameras in online classes? Virtual camera you deserve!
Automated defect analysis in electronic microscopic images
[target detection] r-cnn, fast r-cnn, fast r-cnn learning
奥斯陆大学:Li Meng | 基于Swin-Transformer的深度强化学习
How SQLSEVER removes data with duplicate IDS
v8
Maya fishing house modeling
Where can I check the foreign literature of economics?
NC50528 滑动窗口
[shutter] Introduction to the official example of shutter Gallery (project introduction | engineering construction)