import 'package:widgets/load_state_layout.dart';

class ForyouState {
  //页面 LoadView 状态的展示
  LoadState loadingState;
  String? errorMessage;
  List<Map<String, dynamic>>? list = [];

  ForyouState({
    this.loadingState = LoadState.State_Loading,
    String? errorMessage,
    this.list,
  });

  ForyouState copyWith({
    LoadState? loadingState,
    String? errorMessage,
    List<Map<String, dynamic>>? list,
  }) {
    return ForyouState(
      loadingState: loadingState ?? this.loadingState,
      errorMessage: errorMessage ?? this.errorMessage,
      list: list ?? this.list,
    );
  }

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

  factory ForyouState.fromMap(Map<String, dynamic> map) {
    return ForyouState(
      loadingState: map['loadingState'] as LoadState,
      errorMessage: map['errorMessage'] as String,
      list: map['list'] as List<Map<String, dynamic>>,
    );
  }
}