feedback_create_state.dart 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import 'package:cs_resources/generated/l10n.dart';
  2. import 'package:domain/entity/id_name_entity.dart';
  3. import 'package:flutter/material.dart';
  4. class FeedbackCreateState {
  5. //表单的校验与数据
  6. final Map<String, Map<String, dynamic>> formData;
  7. //类型选项
  8. List<IdNameEntity>? optionList;
  9. IdNameEntity? selectedOption;
  10. //选择的图片
  11. List<String> imgList;
  12. // =================================== Begin ↓ ===================================
  13. FeedbackCreateState({
  14. Map<String, Map<String, dynamic>>? formData,
  15. required this.imgList,
  16. this.optionList,
  17. this.selectedOption,
  18. }) : formData = formData ??
  19. {
  20. 'title': {
  21. 'value': '',
  22. 'controller': TextEditingController(),
  23. 'focusNode': FocusNode(),
  24. 'obsecure': false,
  25. },
  26. 'desc': {
  27. 'value': '',
  28. 'controller': TextEditingController(),
  29. 'focusNode': FocusNode(),
  30. 'hintText': S.current.type_here,
  31. 'obsecure': false,
  32. },
  33. };
  34. FeedbackCreateState copyWith({
  35. List<IdNameEntity>? optionList,
  36. IdNameEntity? selectedOption,
  37. List<String>? imgList,
  38. }) {
  39. return FeedbackCreateState(
  40. formData: this.formData,
  41. imgList: imgList ?? this.imgList,
  42. optionList: optionList ?? this.optionList,
  43. selectedOption: selectedOption ?? this.selectedOption,
  44. );
  45. }
  46. }