当前位置:网站首页>[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 )

边栏推荐
- Program analysis and Optimization - 9 appendix XLA buffer assignment
- 【雅思阅读】王希伟阅读P2(阅读填空)
- DotNet圈里一个优秀的ORM——FreeSql
- Free we media essential tools sharing
- Multiprocess programming (4): shared memory
- 多进程编程(三):消息队列
- Where can I check the foreign literature of economics?
- Attributeerror: 'tuple' object has no attribute 'layer' problem solving
- LeedCode1480. Dynamic sum of one-dimensional array
- Is there a specific format for English papers?
猜你喜欢

Two common methods and steps of character device registration

antv x6节点拖拽到画布上后的回调事件(踩大坑记录)

多进程编程(一):基本概念
![[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)

Maya fishing house modeling

FAQ | FAQ for building applications for large screen devices

Automated defect analysis in electron microscopic images-论文阅读笔记

ftrace工具的介绍及使用

Seckill system design

pod生命周期详解
随机推荐
[shutter] image component (image component introduction | image constructor | image.network constructor | image.asset constructor)
AcWing_ 188. Warrior cattle_ bfs
Architecture: database architecture design
antv x6节点拖拽到画布上后的回调事件(踩大坑记录)
kubernetes编写yml简单入门
MySQL 23 classic interview hanging interviewer
Slf4j + logback logging framework
奥斯陆大学:Li Meng | 基于Swin-Transformer的深度强化学习
Introduction of UART, RS232, RS485, I2C and SPI
简单聊聊运维监控的其他用途
redis21道经典面试题,极限拉扯面试官
[IELTS reading] Wang Xiwei reading P1 (reading judgment question)
How SQLSEVER removes data with duplicate IDS
logback配置文件
微信小程序获取某个元素的信息(高、宽等),并将px转换为rpx。
Where can I find foreign papers?
Hundreds of continuous innovation to create free low code office tools
【Pulsar文档】概念和架构/Concepts and Architecture
NC50528 滑动窗口
form表单实例化