/// YApi QuickType插件生成，具体参考文档:https://plugins.jetbrains.com/plugin/18847-yapi-quicktype/documentation

import 'dart:convert';

import 'package:domain/entity/rewards_search_entity.dart';
import 'package:widgets/load_state_layout.dart';

class RewardsSearchState {
  //页面 LoadView 状态的展示
  LoadState loadingState;
  String? errorMessage;
  RewardsSearchEntity? detailInfo;
  String? keyword = '';
  bool? searchIs = true;
  List<Map<String, dynamic>>? list;

  RewardsSearchState({
    this.loadingState = LoadState.State_Loading,
    String? errorMessage,
    RewardsSearchEntity? detailInfo,
    this.keyword = '',
    this.searchIs = true,
    required this.list,
  }) : detailInfo = detailInfo ?? RewardsSearchEntity();

  RewardsSearchState copyWith({
    LoadState? loadingState,
    String? errorMessage,
    String? keyword,
    bool? searchIs,
    RewardsSearchEntity? detailInfo,
    List<Map<String, dynamic>>? list,
  }) {
    return RewardsSearchState(
      loadingState: loadingState ?? this.loadingState,
      errorMessage: errorMessage ?? this.errorMessage,
      detailInfo: detailInfo ?? this.detailInfo,
      keyword: keyword ?? this.keyword,
      searchIs: searchIs ?? this.searchIs,
      list: list ?? this.list,
    );
  }

  Map<String, dynamic> toMap() {
    return {
      'loadingState': this.loadingState,
      'errorMessage': this.errorMessage,
      'keyword': this.keyword,
      'searchIs': this.searchIs,
      'detailInfo': this.detailInfo,
      'list': this.list,
    };
  }

  factory RewardsSearchState.fromMap(Map<String, dynamic> map) {
    return RewardsSearchState(
      loadingState: map['loadingState'] as LoadState,
      errorMessage: map['errorMessage'] as String,
      keyword: map['keyword'] as String,
      searchIs: map['searchIs'] as bool,
      detailInfo: map['detailInfo'] as RewardsSearchEntity,
      list: map['list'] as List<Map<String, dynamic>>,
    );
  }
}
