2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-12 10:15:32 +00:00

Driving the refactor tractor

- InvenTreeAPI() object now has a method to return a cache-backed image from the server
This commit is contained in:
Oliver Walters
2020-04-05 00:34:08 +11:00
parent 528215455d
commit cd4731833d
3 changed files with 25 additions and 17 deletions

View File

@ -2,6 +2,8 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_advanced_networkimage/provider.dart';
import 'package:image/image.dart';
import 'package:path/path.dart' as path;
@ -287,4 +289,20 @@ class InvenTreeAPI {
return "Basic " + base64Encode(utf8.encode('$_username:$_password'));
}
}
static String get staticImage => "/static/img/blank_image.png";
static String get staticThumb => "/static/img/blank_image.thumbnail.png";
/*
* Get an image from the server (or, from cache)
*/
AdvancedNetworkImage getImage(String imageUrl) {
return new AdvancedNetworkImage(makeUrl(imageUrl),
header: defaultHeaders(),
useDiskCache: true,
cacheRule: CacheRule(maxAge: const Duration(days: 5)),
);
}
}