feedback_create_state.dart 1.5 KB

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