dali 0.0.12

  • Readme
  • Changelog
  • Example
  • Installing
  • 26

Dalí #

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.

Getting Started #

Use the Dali widget

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),
)

Use the DaliImageProvider

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

[0.0.12] - 25/4/2019

  • Fix androidx problem

[0.0.11] - 16/4/2019

  • Formatted files

[0.0.10] - 12/1/2019

  • Scale parameter

[0.0.8] - 4/1/2019

  • Manage non supported format errors

[0.0.7] - 24/12/2018

  • Some classes have been renamed
  • Updated readme file

[0.0.6] - 24/12/2018

  • Bug fixing

[0.0.5] - 24/12/2018

  • Simplified set up of the library

[0.0.4] - 23/12/2018

  • Error detection to show errorWidget
  • Added BoxFit param to Dali class

[0.0.3] - 23/12/2018

  • Bug fixing
  • Unit tests

[0.0.2] - 19/12/2018

  • Bug fixing

[0.0.1] - 16/12/2018

  • Initial release.

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),
                ),
              );
            }),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dali: ^0.0.12

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:dali/dali.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
13
Health:
Code health derived from static analysis. [more]
24
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
60
Overall:
Weighted score of the above. [more]
26
Learn more about scoring.

We analyzed this package on Nov 15, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6

Platforms

Detected platforms:

Low code quality prevents platform classification.

Health issues and suggestions

Fix lib/cached_image.dart. (-57.81 points)

Analysis of lib/cached_image.dart failed with 3 errors:

line 186 col 38: The argument type 'void Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'.

line 187 col 32: The argument type 'void Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'.

line 197 col 34: The argument type 'void Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'.

Fix lib/dali_image_provider.dart. (-25.38 points)

Analysis of lib/dali_image_provider.dart failed with 1 error, 1 hint:

line 49 col 11: The argument type 'Null Function(StringBuffer)' can't be assigned to the parameter type 'Iterable

line 49 col 33: This function has a return type of 'Iterable

Fix lib/dali_cache_manager.dart. (-25 points)

Analysis of lib/dali_cache_manager.dart failed with 1 error:

line 93 col 25: Too many positional arguments: 1 expected, but 2 found.

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Low code quality prevents platform classification.

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (path_provider).

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.

Dependencies

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.1.8
path_provider ^0.5.0+1 0.5.0+1 1.4.2
Transitive dependencies
archive 2.0.11
args 1.5.2
charcode 1.1.2
collection 1.14.11 1.14.12
convert 2.1.1
crypto 2.1.3
meta 1.1.7 1.1.8
path 1.6.4
petitparser 2.4.0
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
xml 3.5.0
Dev dependencies
flutter_test