upload_state.dart 508 B

1234567891011121314151617181920212223242526
  1. /// 上传状态
  2. enum UploadState {
  3. /// 上传成功
  4. success("success"),
  5. /// 上传中
  6. uploading("uploading"),
  7. /// 上传失败
  8. fail("fail");
  9. final String state;
  10. const UploadState(this.state);
  11. /// 通过状态字符串,获取对应的状态枚举
  12. static UploadState fromString(String state) {
  13. return values.firstWhere(
  14. (e) => e.state == state,
  15. orElse: () => throw ArgumentError('无效的状态值: $state'),
  16. );
  17. }
  18. @override
  19. String toString() => state;
  20. }