Files
notas/lib/models/category.dart
T
Marcos def755e1c5 refactor: Update Note and Category models to use 'id' instead of 'uuid', and adjust related database operations
- Changed 'uuid' to 'id' in Note and Category models for consistency.
- Updated database operations in NoteRepository to reflect the new 'id' field.
- Modified sync models to accommodate changes in Note and Category structures.
- Adjusted the handling of notes and categories during synchronization.
- Refactored the note editor and home screen to use the new 'id' field.
- Ensured that the 'isDirty' flag is properly set and utilized across models.
2026-05-20 11:05:30 +02:00

50 lines
1.0 KiB
Dart

import 'package:uuid/uuid.dart';
class Category {
Category({
String? id,
required this.name,
this.serverVersion = 0,
this.isDeleted = false,
required this.updatedAt,
this.isDirty = true,
}) : id = id ?? Uuid().v4();
final String id;
final String name;
final int serverVersion;
final bool isDeleted;
final DateTime updatedAt;
final bool isDirty;
Category copyWith({
String? id,
String? name,
int? serverVersion,
bool? isDeleted,
DateTime? updatedAt,
bool? isDirty,
}) {
return Category(
id: id ?? this.id,
name: name ?? this.name,
serverVersion: serverVersion ?? this.serverVersion,
isDeleted: isDeleted ?? this.isDeleted,
updatedAt: updatedAt ?? this.updatedAt,
isDirty: isDirty ?? this.isDirty,
);
}
@override
bool operator ==(Object other) {
if (identical(this, other)) {
return true;
}
return other is Category && id == other.id;
}
@override
int get hashCode => id.hashCode;
}