initial multi user feature
This commit is contained in:
@@ -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);
|
||||
}
|
||||
@@ -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,
|
||||
};
|
||||
Reference in New Issue
Block a user