profile_edit_state.dart 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import 'package:cs_resources/generated/l10n.dart';
  2. import 'package:flutter/material.dart';
  3. class ProfileEditState{
  4. //表单的校验与数据
  5. final Map<String, Map<String, dynamic>> formData;
  6. List<String>? defaultAvatars; //默认头像
  7. String? avatarPath; //头像的路径或Uri
  8. // =================================== Begin ↓ ===================================
  9. ProfileEditState({
  10. Map<String, Map<String, dynamic>>? formData,
  11. this.avatarPath,
  12. this.defaultAvatars,
  13. }) : formData = formData ??
  14. {
  15. 'first_name': {
  16. 'value': '',
  17. 'controller': TextEditingController(),
  18. 'hintText': S.current.first_name,
  19. 'focusNode': FocusNode(),
  20. 'obsecure': false,
  21. },
  22. 'last_name': {
  23. 'value': '',
  24. 'controller': TextEditingController(),
  25. 'hintText': S.current.last_name,
  26. 'focusNode': FocusNode(),
  27. 'obsecure': false,
  28. },
  29. 'email': {
  30. 'value': '',
  31. 'controller': TextEditingController(),
  32. 'hintText': S.current.email,
  33. 'focusNode': FocusNode(),
  34. 'obsecure': false,
  35. },
  36. };
  37. ProfileEditState copyWith({
  38. String? avatarPath,
  39. List<String>? defaultAvatars,
  40. }) {
  41. return ProfileEditState(
  42. formData: this.formData,
  43. avatarPath: avatarPath ?? this.avatarPath,
  44. defaultAvatars: defaultAvatars ?? this.defaultAvatars,
  45. );
  46. }
  47. }