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:
18
lib/api.dart
18
lib/api.dart
@ -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)),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user