feat : cashing data in local storage and send it

This commit is contained in:
2025-08-11 12:56:26 +03:30
parent 2669af7a92
commit aa1b9e899a
16 changed files with 635 additions and 32 deletions

View File

@@ -0,0 +1,39 @@
import 'package:rasadyar_core/core.dart';
part 'car.g.dart';
@HiveType(typeId: 50)
class CarsLocal extends HiveObject {
@HiveField(0)
String? name;
@HiveField(1)
String? price;
CarsLocal({this.name, this.price});
factory CarsLocal.fromJson(Map<String, dynamic> json) {
return CarsLocal(name: json['name'] as String?, price: json['price'] as String?);
}
Map<String, dynamic> toJson() {
return {'name': name, 'price': price};
}
}
class Cars {
String? name;
String? price;
Cars({this.name, this.price});
factory Cars.fromJson(Map<String, dynamic> json) {
return Cars(name: json['name'] as String?, price: json['price'] as String?);
}
Map<String, dynamic> toJson() {
return {'name': name, 'price': price};
}
}

View File

@@ -0,0 +1,41 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'car.dart';
// **************************************************************************
// TypeAdapterGenerator
// **************************************************************************
class CarsLocalAdapter extends TypeAdapter<CarsLocal> {
@override
final typeId = 50;
@override
CarsLocal read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields = <int, dynamic>{
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return CarsLocal(name: fields[0] as String?, price: fields[1] as String?);
}
@override
void write(BinaryWriter writer, CarsLocal obj) {
writer
..writeByte(2)
..writeByte(0)
..write(obj.name)
..writeByte(1)
..write(obj.price);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is CarsLocalAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}

View File

@@ -0,0 +1,97 @@
import 'package:rasadyar_core/core.dart';
part 'livestock_local_model.g.dart';
@HiveType(typeId: liveStockDataLocalModelTypeId)
class LivestockLocalModel extends HiveObject {
@HiveField(0)
RancherLocal? rancher;
@HiveField(1)
HerdLocal? herd;
@HiveField(2)
List<LivestockLocal>? livestock;
}
@HiveType(typeId: liveStockDataRancherLocalModelTypeId)
class RancherLocal extends HiveObject {
@HiveField(0)
String? name;
@HiveField(1)
String? phone;
@HiveField(2)
String? image;
}
@HiveType(typeId: liveStockDataHerdLocalModelTypeId)
class HerdLocal extends HiveObject{
@HiveField(0)
LocationLocal? location;
@HiveField(1)
String? address;
@HiveField(2)
String? image;
}
@HiveType(typeId: liveStockDataLocationLocalModelTypeId)
class LocationLocal extends HiveObject {
@HiveField(0)
double? lat;
@HiveField(1)
double? lng;
}
@HiveType(typeId: liveStockDataLivestockLocalModelTypeId)
class LivestockLocal extends HiveObject {
@HiveField(0)
String? species;
@HiveField(1)
String? breed;
@HiveField(2)
String? dateOfBirth;
@HiveField(3)
String? sex;
@HiveField(4)
String? motherTag;
@HiveField(5)
String? fatherTag;
@HiveField(6)
String? tagNumber;
@HiveField(7)
String? tagType;
@HiveField(8)
String? image;
}

View File

@@ -0,0 +1,217 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'livestock_local_model.dart';
// **************************************************************************
// TypeAdapterGenerator
// **************************************************************************
class LivestockLocalModelAdapter extends TypeAdapter<LivestockLocalModel> {
@override
final typeId = 4;
@override
LivestockLocalModel read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields = <int, dynamic>{
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return LivestockLocalModel()
..rancher = fields[0] as RancherLocal?
..herd = fields[1] as HerdLocal?
..livestock = (fields[2] as List?)?.cast<LivestockLocal>();
}
@override
void write(BinaryWriter writer, LivestockLocalModel obj) {
writer
..writeByte(3)
..writeByte(0)
..write(obj.rancher)
..writeByte(1)
..write(obj.herd)
..writeByte(2)
..write(obj.livestock);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is LivestockLocalModelAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
class RancherLocalAdapter extends TypeAdapter<RancherLocal> {
@override
final typeId = 5;
@override
RancherLocal read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields = <int, dynamic>{
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return RancherLocal()
..name = fields[0] as String?
..phone = fields[1] as String?
..image = fields[2] as String?;
}
@override
void write(BinaryWriter writer, RancherLocal obj) {
writer
..writeByte(3)
..writeByte(0)
..write(obj.name)
..writeByte(1)
..write(obj.phone)
..writeByte(2)
..write(obj.image);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is RancherLocalAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
class HerdLocalAdapter extends TypeAdapter<HerdLocal> {
@override
final typeId = 6;
@override
HerdLocal read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields = <int, dynamic>{
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return HerdLocal()
..location = fields[0] as LocationLocal?
..address = fields[1] as String?
..image = fields[2] as String?;
}
@override
void write(BinaryWriter writer, HerdLocal obj) {
writer
..writeByte(3)
..writeByte(0)
..write(obj.location)
..writeByte(1)
..write(obj.address)
..writeByte(2)
..write(obj.image);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is HerdLocalAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
class LocationLocalAdapter extends TypeAdapter<LocationLocal> {
@override
final typeId = 7;
@override
LocationLocal read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields = <int, dynamic>{
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return LocationLocal()
..lat = (fields[0] as num?)?.toDouble()
..lng = (fields[1] as num?)?.toDouble();
}
@override
void write(BinaryWriter writer, LocationLocal obj) {
writer
..writeByte(2)
..writeByte(0)
..write(obj.lat)
..writeByte(1)
..write(obj.lng);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is LocationLocalAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
class LivestockLocalAdapter extends TypeAdapter<LivestockLocal> {
@override
final typeId = 8;
@override
LivestockLocal read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields = <int, dynamic>{
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return LivestockLocal()
..species = fields[0] as String?
..breed = fields[1] as String?
..dateOfBirth = fields[2] as String?
..sex = fields[3] as String?
..motherTag = fields[4] as String?
..fatherTag = fields[5] as String?
..tagNumber = fields[6] as String?
..tagType = fields[7] as String?
..image = fields[8] as String?;
}
@override
void write(BinaryWriter writer, LivestockLocal obj) {
writer
..writeByte(9)
..writeByte(0)
..write(obj.species)
..writeByte(1)
..write(obj.breed)
..writeByte(2)
..write(obj.dateOfBirth)
..writeByte(3)
..write(obj.sex)
..writeByte(4)
..write(obj.motherTag)
..writeByte(5)
..write(obj.fatherTag)
..writeByte(6)
..write(obj.tagNumber)
..writeByte(7)
..write(obj.tagType)
..writeByte(8)
..write(obj.image);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is LivestockLocalAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}