|
@@ -6,6 +6,7 @@ import 'package:sqflite/sqflite.dart';
|
|
|
import '../data/api_response.dart';
|
|
|
import '../models/models.dart';
|
|
|
import 'services.dart';
|
|
|
+import '../views/producto/producto_imagen.dart';
|
|
|
|
|
|
class RepoService<T> {
|
|
|
static int dbVersion = 19;
|
|
@@ -580,6 +581,8 @@ class RepoService<T> {
|
|
|
|
|
|
case 18:
|
|
|
await db.execute('''
|
|
|
+
|
|
|
+
|
|
|
ALTER TABLE Usuario ADD COLUMN clave TEXT;
|
|
|
''');
|
|
|
|
|
@@ -1278,11 +1281,31 @@ class RepoService<T> {
|
|
|
"claveSucursal": claveSucursal!,
|
|
|
"expand": "media"
|
|
|
};
|
|
|
+
|
|
|
final response = ApiResponse(
|
|
|
await BaseService().get('/pos/producto', queryParameters: parametros));
|
|
|
- return response.isOk && response.resultados != null
|
|
|
- ? response.resultados!.map((json) => Producto.fromApi(json)).toList()
|
|
|
- : [];
|
|
|
+
|
|
|
+ if (response.isOk && response.resultados != null) {
|
|
|
+ List<Producto> productosApi =
|
|
|
+ response.resultados!.map((json) => Producto.fromApi(json)).toList();
|
|
|
+
|
|
|
+ // Descargar y almacenar cada imagen de producto
|
|
|
+ for (var productoApi in productosApi) {
|
|
|
+ if (productoApi.media != null && productoApi.media!.isNotEmpty) {
|
|
|
+ for (var media in productoApi.media!) {
|
|
|
+ // Descargar y guardar la imagen localmente
|
|
|
+ String? localImagePath = await downloadAndStoreImage(
|
|
|
+ media.ruta!, productoApi.id!, media.nombre!);
|
|
|
+
|
|
|
+ if (localImagePath != null) {
|
|
|
+ productoApi.imagen = localImagePath;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return productosApi;
|
|
|
+ }
|
|
|
+ return [];
|
|
|
}
|
|
|
|
|
|
Future<List<ProductoTopping>> fetchProductoToppingApi(
|