preloaded_images 0.0.1 preloaded_images: ^0.0.1 copied to clipboard
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.
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();
}
getImages() async {
allImage = [];
List allImageTemp = await PreloadedImages.getImages(count: 5);
allImage.addAll(allImageTemp);
print(allImage);
setState(() {
loading = false;
});
}
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: loading
? CircularProgressIndicator()
: Container(
alignment: Alignment.center,
child: Image.asset(
// displaying only first image
// but will return you the count
"${allImage.first}",
fit: BoxFit.contain,
),
),
),
);
}
}