profile_edit_state.dart 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. String? avatarPath; //头像的路径或Uri
  7. // =================================== Begin ↓ ===================================
  8. ProfileEditState({
  9. Map<String, Map<String, dynamic>>? formData,
  10. this.avatarPath,
  11. }) : formData = formData ??
  12. {
  13. 'first_name': {
  14. 'value': '',
  15. 'controller': TextEditingController(),
  16. 'hintText': S.current.first_name,
  17. 'focusNode': FocusNode(),
  18. 'obsecure': false,
  19. },
  20. 'last_name': {
  21. 'value': '',
  22. 'controller': TextEditingController(),
  23. 'hintText': S.current.last_name,
  24. 'focusNode': FocusNode(),
  25. 'obsecure': false,
  26. },
  27. 'email': {
  28. 'value': '',
  29. 'controller': TextEditingController(),
  30. 'hintText': S.current.email,
  31. 'focusNode': FocusNode(),
  32. 'obsecure': false,
  33. },
  34. };
  35. ProfileEditState copyWith({
  36. String? avatarPath,
  37. }) {
  38. return ProfileEditState(
  39. formData: this.formData,
  40. avatarPath: avatarPath ?? this.avatarPath,
  41. );
  42. }
  43. }