first commit
This commit is contained in:
28
lib/thermal priting invoices/network_image.dart
Normal file
28
lib/thermal priting invoices/network_image.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:image/image.dart' as img;
|
||||
|
||||
Future<img.Image?> getNetworkImage(
|
||||
String? url, {
|
||||
int width = 250,
|
||||
int height = 250,
|
||||
}) async {
|
||||
if (url == null) return null;
|
||||
|
||||
try {
|
||||
final response = await http.get(Uri.parse(url));
|
||||
if (response.statusCode != 200) return null;
|
||||
|
||||
final _image = img.decodeImage(response.bodyBytes);
|
||||
if (_image == null) return null;
|
||||
return _image;
|
||||
return img.copyResize(
|
||||
_image,
|
||||
width: width,
|
||||
height: height,
|
||||
interpolation: img.Interpolation.average,
|
||||
);
|
||||
// final img.Image grayscaleImage = img.grayscale(resizedImage);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user