Skip to content

Commit

Permalink
Release 1.1.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattreid1 committed Dec 23, 2021
1 parent 97fb1e2 commit 1fd0b9b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [1.1.0] 23/12/2021

- Merged [PR #33](https://github.com/mattreid1/firebase_image/pull/33) for pre-cache function
- Updated example/main.dart file
- Formatted code

## [1.0.2] 23/12/2021

- Merged [PR #55](https://github.com/mattreid1/firebase_image/pull/55) to update dependancies
Expand Down
20 changes: 13 additions & 7 deletions example/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import 'package:flutter/material.dart';
import 'package:firebase_image/firebase_image.dart';
import 'package:firebase_core/firebase_core.dart';

void main() => runApp(const MyApp());
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
Expand Down Expand Up @@ -31,6 +36,7 @@ class _MyHomePageState extends State<MyHomePage> {
@override
void initState() {
super.initState();
FirebaseImage('gs://bucket123/otherUser123.jpg').preCache();
}

@override
Expand All @@ -40,12 +46,12 @@ class _MyHomePageState extends State<MyHomePage> {
title: Text(widget.title),
),
body: Image(
image: FirebaseImage(
'gs://bucket123/userIcon123.jpg',
shouldCache: true, // The image should be cached (default: True)
maxSizeBytes: 3000 * 1000, // 3MB max file size (default: 2.5MB)
cacheRefreshStrategy: CacheRefreshStrategy.NEVER // Switch off update checking
),
image: FirebaseImage('gs://bucket123/userIcon123.jpg',
shouldCache: true, // The image should be cached (default: True)
maxSizeBytes: 3000 * 1000, // 3MB max file size (default: 2.5MB)
cacheRefreshStrategy:
CacheRefreshStrategy.NEVER // Switch off update checking
),
width: 100,
),
);
Expand Down
1 change: 0 additions & 1 deletion lib/src/cache_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'dart:typed_data';

import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_image/firebase_image.dart';
import 'package:firebase_image/src/firebase_image.dart';
import 'package:firebase_image/src/image_object.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:path/path.dart';
Expand Down
12 changes: 6 additions & 6 deletions lib/src/firebase_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ class FirebaseImage extends ImageProvider<FirebaseImage> {

/// Pre-caches an image
Future<void> preCache() async {
if (shouldCache == false) throw "Caching must be enabled to pre-cache an image.";
if (shouldCache == false) {
throw "Caching must be enabled to pre-cache an image.";
}
await _fetchImage();
}

Expand Down Expand Up @@ -90,14 +92,13 @@ class FirebaseImage extends ImageProvider<FirebaseImage> {
if (localObject != null) {
bytes = await cacheManager.localFileBytes(localObject);
bytes ??= await cacheManager.upsertRemoteFileToCache(
_imageObject, maxSizeBytes);
_imageObject, maxSizeBytes);
} else {
bytes = await cacheManager.upsertRemoteFileToCache(
_imageObject, maxSizeBytes);
}
} else {
bytes =
await cacheManager.remoteFileBytes(_imageObject, maxSizeBytes);
bytes = await cacheManager.remoteFileBytes(_imageObject, maxSizeBytes);
}

return bytes!;
Expand Down Expand Up @@ -133,6 +134,5 @@ class FirebaseImage extends ImageProvider<FirebaseImage> {
int get hashCode => hashValues(_imageObject.uri, scale);

@override
String toString() =>
'$runtimeType("${_imageObject.uri}", scale: $scale)';
String toString() => '$runtimeType("${_imageObject.uri}", scale: $scale)';
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: firebase_image
description: A cached Flutter ImageProvider for Firebase Cloud Storage image objects.
version: 1.0.2
version: 1.1.0
homepage: https://github.com/mattreid1/firebase_image

environment:
Expand Down

0 comments on commit 1fd0b9b

Please sign in to comment.