preloaded_images 1.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 74

preloaded_images #

A new flutter plugin to fetch latest 'X' images from mobile storage. It returns list of asset url's and works both on IOS and Android.

Usage #


Future<void> loadImageList() async {
    List<String> allImage = List<String>();
    List allImageTemp = await PreloadedImages.getImages(count: 5); // your custom count goes here
    allImage.addAll(allImageTemp);
  }
  
  

Note #

IOS: As getting Path URL from PHAsset is asynchronous, the order may not be in sorted form but you will get latest 'X' number of images for sure.

Android: You get images in sorted order.

Preview #

grab-landing-page

grab-landing-page

1.0.2 #

  • In 1.0.1, IOS is giving exact paths and it is not allowing to use this resource (while uploading into any storage buckets).
  • In 1.0.2, It will solve the above issue.

1.0.1 #

  • Added Support for GIF images in IOS (Earlier GIF images are converted to PNG)
  • Updated example in readme file (Check the example tab)

1.0.0 #

  • Updated Permissions message and added Images in ReadMe.md

0.0.2 #

  • Updated Readme.MD in example

0.0.1 #

  • Inital Version

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:preloaded_images/preloaded_images.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  List allImage = List();
  bool loading = true;

  @override
  void initState() {
    super.initState();
    getImages();
  }

  // Call this function at your app start or at any place
  // to fetch the latest images from your phone storage.
  getImages() async {
    allImage = [];
    List allImageTemp = await PreloadedImages.getImages(count: 5);
    allImage.addAll(allImageTemp);
    print(allImage);
    setState(() {
      loading = false;
    });
  }

  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        backgroundColor: Colors.white,
        body: Center(
          child: loading
              ? CircularProgressIndicator()
              : allImage.length == 0
                  ? Text(
                      "Either permission was declined or no images in storage",
                      maxLines: null,
                      textAlign: TextAlign.center,
                      style: TextStyle(
                        color: Colors.black,
                        fontSize: 25,
                      ),
                    )
                  : GridView.builder(
                      shrinkWrap: true,
                      padding: EdgeInsets.all(20),
                      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                        crossAxisCount: 2,
                        childAspectRatio: 1.0,
                        crossAxisSpacing: 5,
                      ),
                      itemBuilder: (context, index) {
                        return Container(
                          margin: EdgeInsets.only(bottom: 5),
                          decoration: BoxDecoration(
                            border: Border.all(color: Colors.red),
                            borderRadius: BorderRadius.circular(5),
                            color: Colors.grey[200],
                          ),
                          child: ClipRRect(
                            borderRadius: BorderRadius.circular(5),
                            child: Image.asset(
                              "${allImage[index]}",
                              fit: BoxFit.cover,
                              height: 100,
                              // width: 100,
                            ),
                          ),
                        );
                      },
                      itemCount: allImage.length,
                    ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  preloaded_images: ^1.0.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support 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:preloaded_images/preloaded_images.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
48
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
74
Learn more about scoring.

We analyzed this package on Apr 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test