An image loading and caching library for flutter focused on speed and memory efficiency.
Supports iOS and Android.
Dalí saves the downloaded image in memory in case the same image is requested in the future. Only a resized version with the desired size will be loaded in memory instead of loading the full size in order to preserve RAM memory.
Images are also saved in the cache directory of the app.
The easier way is to use the Dali widget. It will get the dimensions of his container and load a resized image
Container(
height: 200,
width: 200,
child: Dali(
'https://homepages.cae.wisc.edu/~ece533/images/airplane.png',
),
)
You have the option to set a loading widget while the image is being loaded, and also an error widget if it occurs
Dali(
imageUrl: 'https://homepages.cae.wisc.edu/~ece533/images/airplane.png',
fit: BoxFit.cover,
placeholder: Icon(Icons.timer),
errorWidget: Icon(Icons.error),
)
Alternatively you can use the DaliImageProvider in combination with the Image widget
Image(
image: DaliImageProvider(
'https://homepages.cae.wisc.edu/~ece533/images/airplane.png',
width: 90,
height: 90,
),
fit: BoxFit.cover,
)
Remember it is always better to set the width and height of the image
example/example.dart
import 'package:dali/dali.dart';
import 'package:flutter/material.dart';
const images = [
'https://homepages.cae.wisc.edu/~ece533/images/airplane.png',
'https://homepages.cae.wisc.edu/~ece533/images/arctichare.png',
'https://homepages.cae.wisc.edu/~ece533/images/baboon.png',
'https://homepages.cae.wisc.edu/~ece533/images/barbara.bmp',
'https://homepages.cae.wisc.edu/~ece533/images/barbara.png',
'https://homepages.cae.wisc.edu/~ece533/images/boat.png',
'https://homepages.cae.wisc.edu/~ece533/images/cameraman.tif',
'https://homepages.cae.wisc.edu/~ece533/images/cat.png',
'https://homepages.cae.wisc.edu/~ece533/images/fruits.png',
'https://homepages.cae.wisc.edu/~ece533/images/frymire.png',
'https://homepages.cae.wisc.edu/~ece533/images/girl.png',
'https://homepages.cae.wisc.edu/~ece533/images/goldhill.png',
'https://homepages.cae.wisc.edu/~ece533/images/lena.png',
'https://homepages.cae.wisc.edu/~ece533/images/monarch.png',
'https://homepages.cae.wisc.edu/~ece533/images/mountain.png',
'https://homepages.cae.wisc.edu/~ece533/images/peppers.png',
'https://homepages.cae.wisc.edu/~ece533/images/pool.png',
'https://homepages.cae.wisc.edu/~ece533/images/sails.bmp',
'https://homepages.cae.wisc.edu/~ece533/images/serrano.png',
'https://homepages.cae.wisc.edu/~ece533/images/tulips.png',
'https://homepages.cae.wisc.edu/~ece533/images/watch.png',
'https://homepages.cae.wisc.edu/~ece533/images/zelda.png',
];
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Dali Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
body: ListView.builder(
itemCount: images.length,
itemBuilder: (context, index) {
return Container(
height: 200,
child: Dali(
images[index],
placeholder: Icon(Icons.timer),
errorWidget: Icon(Icons.error),
),
);
}),
),
);
}
}
Add this to your package's pubspec.yaml file:
dependencies:
dali: ^0.0.8
You can install packages from the command line:
with Flutter:
$ flutter packages get
Alternatively, your editor might support flutter packages get
.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:dali/dali.dart';
Version | Uploaded | Documentation | Archive |
---|---|---|---|
0.0.10 | Jan 12, 2019 |
|
|
0.0.9 | Jan 12, 2019 |
|
|
0.0.8 | Jan 4, 2019 |
|
|
0.0.7 | Jan 1, 2019 |
|
|
0.0.6 | Dec 24, 2018 |
|
|
0.0.5 | Dec 24, 2018 |
|
|
0.0.4 | Dec 23, 2018 |
|
|
0.0.3 | Dec 23, 2018 |
|
|
0.0.2 | Dec 19, 2018 |
|
|
0.0.1 | Dec 17, 2018 |
|
|
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
64
|
Health:
Code health derived from static analysis.
[more]
|
100
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
90
|
Overall:
Weighted score of the above.
[more]
|
80
|
We analyzed this package on Feb 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: Flutter
References Flutter, and has no conflicting libraries.
Format lib/cached_image.dart
.
Run flutter format
to format lib/cached_image.dart
.
Format lib/cached_image_provider.dart
.
Run flutter format
to format lib/cached_image_provider.dart
.
Format lib/dali.dart
.
Run flutter format
to format lib/dali.dart
.
Format lib/dali_cache_manager.dart
.
Run flutter format
to format lib/dali_cache_manager.dart
.
Format lib/site.dart
.
Run flutter format
to format lib/site.dart
.
Package is pre-v0.1 release. (-10 points)
While nothing is inherently wrong with versions of 0.0.*
, it might mean that the author is still experimenting with the general direction of the API.
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=2.0.0-dev.68.0 <3.0.0 | ||
flutter | 0.0.0 | ||
image | ^2.0.4 | 2.0.7 | |
path_provider | ^0.4.1 | 0.4.1 | 0.5.0+1 |
Transitive dependencies | |||
archive | 2.0.8 | ||
args | 1.5.1 | ||
charcode | 1.1.2 | ||
collection | 1.14.11 | ||
convert | 2.1.1 | ||
crypto | 2.0.6 | ||
meta | 1.1.6 | 1.1.7 | |
path | 1.6.2 | ||
petitparser | 2.1.1 | ||
sky_engine | 0.0.99 | ||
typed_data | 1.1.6 | ||
vector_math | 2.0.8 | ||
xml | 3.3.1 | ||
Dev dependencies | |||
flutter_test |