update
This commit is contained in:
parent
27f00e43a7
commit
3572f90b24
24 changed files with 290 additions and 257 deletions
|
|
@ -1,8 +1,4 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
|
@ -60,33 +56,6 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
|
|||
late bool imageUploaded = false;
|
||||
late String imageUrl = '';
|
||||
|
||||
// void _checkResult(List list, String name) {
|
||||
// if (list.isEmpty) {
|
||||
// if (mounted) {
|
||||
// showNotification(context, 'Error: No $name Found', false);
|
||||
|
||||
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// if (mounted) {
|
||||
// context.push('/main');
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// } else {
|
||||
// setState(() => {});
|
||||
// }
|
||||
// }
|
||||
|
||||
// Future<Uint8List> compressFile(XFile file) async {
|
||||
// var result = await FlutterImageCompress.compressWithFile(
|
||||
// file.path,
|
||||
// minWidth: 1020,
|
||||
// minHeight: 765,
|
||||
// quality: 90,
|
||||
// format: CompressFormat.webp,
|
||||
// );
|
||||
// return result;
|
||||
// }
|
||||
|
||||
Future<void> _getGenerics() async {
|
||||
_genericNameList = await _refGenericNames.getList();
|
||||
setState(() {
|
||||
|
|
@ -199,15 +168,16 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
|
|||
|
||||
final imageBytes = await image!.readAsBytes();
|
||||
final webpImage = await _webpConvert(imageBytes);
|
||||
late bool uploaded = false;
|
||||
|
||||
uuid = imageName;
|
||||
|
||||
if (mounted) {
|
||||
imageUrl = await _storage.uploadImage(context, storageName, webpImage, '$imageName.webp');
|
||||
uploaded = await _storage.uploadImage(context, storageName, webpImage, '$imageName.webp');
|
||||
}
|
||||
|
||||
setState(() {
|
||||
if (imageUrl.isEmpty) {
|
||||
if (!uploaded) {
|
||||
if (mounted) {
|
||||
showNotification(context, 'Image Upload failed, try again.', false);
|
||||
}
|
||||
|
|
@ -218,8 +188,6 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
|
|||
Future<Uint8List> _webpConvert(Uint8List file) async {
|
||||
final result = await FlutterImageCompress.compressWithList(
|
||||
file,
|
||||
// minHeight: 1080,
|
||||
// minWidth: 1080,
|
||||
quality: 70,
|
||||
rotate: 0,
|
||||
keepExif: false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue