initial multi user feature

This commit is contained in:
Fabian Freund
2025-11-27 07:51:16 +01:00
parent 6d3c2757c3
commit 00d0599dde
49 changed files with 1341 additions and 258 deletions
+31
View File
@@ -0,0 +1,31 @@
import 'package:copy_with_extension/copy_with_extension.dart';
import 'package:fast_equatable/fast_equatable.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:uuid/uuid_value.dart';
import 'package:weblibre/core/uuid.dart';
part 'profile.g.dart';
@JsonSerializable()
@CopyWith()
class Profile with FastEquatable {
@CopyWithField(immutable: true)
final String id;
final String name;
late final uuidValue = UuidValue.fromString(id);
Profile({required this.id, required this.name});
factory Profile.create({required String name}) {
return Profile(id: uuid.v7(), name: name);
}
@override
List<Object?> get hashParameters => [id, name];
factory Profile.fromJson(Map<String, dynamic> json) =>
_$ProfileFromJson(json);
Map<String, dynamic> toJson() => _$ProfileToJson(this);
}
+68
View File
@@ -0,0 +1,68 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'profile.dart';
// **************************************************************************
// CopyWithGenerator
// **************************************************************************
abstract class _$ProfileCWProxy {
Profile name(String name);
/// Creates a new instance with the provided field values.
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `Profile(...).copyWith.fieldName(value)`.
///
/// Example:
/// ```dart
/// Profile(...).copyWith(id: 12, name: "My name")
/// ```
Profile call({String name});
}
/// Callable proxy for `copyWith` functionality.
/// Use as `instanceOfProfile.copyWith(...)` or call `instanceOfProfile.copyWith.fieldName(value)` for a single field.
class _$ProfileCWProxyImpl implements _$ProfileCWProxy {
const _$ProfileCWProxyImpl(this._value);
final Profile _value;
@override
Profile name(String name) => call(name: name);
@override
/// Creates a new instance with the provided field values.
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `Profile(...).copyWith.fieldName(value)`.
///
/// Example:
/// ```dart
/// Profile(...).copyWith(id: 12, name: "My name")
/// ```
Profile call({Object? name = const $CopyWithPlaceholder()}) {
return Profile(
id: _value.id,
name: name == const $CopyWithPlaceholder() || name == null
? _value.name
// ignore: cast_nullable_to_non_nullable
: name as String,
);
}
}
extension $ProfileCopyWith on Profile {
/// Returns a callable class used to build a new instance with modified fields.
/// Example: `instanceOfProfile.copyWith(...)` or `instanceOfProfile.copyWith.fieldName(...)`.
// ignore: library_private_types_in_public_api
_$ProfileCWProxy get copyWith => _$ProfileCWProxyImpl(this);
}
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Profile _$ProfileFromJson(Map<String, dynamic> json) =>
Profile(id: json['id'] as String, name: json['name'] as String);
Map<String, dynamic> _$ProfileToJson(Profile instance) => <String, dynamic>{
'id': instance.id,
'name': instance.name,
};