formattazione testo da e verso json

This commit is contained in:
2026-04-13 10:37:12 +02:00
parent 55b0a0839d
commit d72b329a13
4 changed files with 34 additions and 9 deletions

View File

@@ -1,4 +1,5 @@
import 'package:equatable/equatable.dart';
import 'package:flux/core/utils/string_extensions.dart';
class BrandModel extends Equatable {
final String? id;
@@ -18,7 +19,7 @@ class BrandModel extends Equatable {
factory BrandModel.fromJson(Map<String, dynamic> json) {
return BrandModel(
id: json['id'] as String,
name: json['name'] as String,
name: (json['name'] as String).myFormat(),
companyId: json['company_id'] as String,
isActive: json['is_active'] as bool? ?? true,
createdAt: json['created_at'] != null
@@ -30,7 +31,7 @@ class BrandModel extends Equatable {
Map<String, dynamic> toJson() {
return {
if (id != null) 'id': id,
'name': name,
'name': name.toLowerCase(),
'company_id': companyId,
'is_active': isActive,
};

View File

@@ -1,4 +1,5 @@
import 'package:equatable/equatable.dart';
import 'package:flux/core/utils/string_extensions.dart';
class ModelModel extends Equatable {
final String? id;
@@ -20,8 +21,8 @@ class ModelModel extends Equatable {
factory ModelModel.fromJson(Map<String, dynamic> json) {
return ModelModel(
id: json['id'] as String,
name: json['name'] as String,
nameWithBrand: json['name_with_brand'] as String,
name: (json['name'] as String).myFormat(),
nameWithBrand: (json['name_with_brand'] as String).myFormat(),
brandId: json['brand_id'] as String,
isActive: json['is_active'] as bool? ?? true,
createdAt: json['created_at'] != null
@@ -33,8 +34,8 @@ class ModelModel extends Equatable {
Map<String, dynamic> toJson() {
return {
if (id != null) 'id': id,
'name': name,
'name_with_brand': nameWithBrand,
'name': name.toLowerCase(),
'name_with_brand': nameWithBrand.toLowerCase(),
'brand_id': brandId,
'is_active': isActive,
};