PMU_PIbd32_Kamcharova_K.A/lib/bloc/state.dart

32 lines
798 B
Dart

import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import '../models/character.dart';
enum HomeStatus { initial, loading, loaded, error }
class HomeState extends Equatable {
final HomeStatus status;
final List<CharacterDTO> characters;
final String errorMessage;
const HomeState({
this.status = HomeStatus.initial,
this.characters = const [],
this.errorMessage = '',
});
HomeState copyWith({
HomeStatus? status,
List<CharacterDTO>? characters,
String? errorMessage,
}) {
return HomeState(
status: status ?? this.status,
characters: characters ?? this.characters,
errorMessage: errorMessage ?? this.errorMessage,
);
}
@override
List<Object?> get props => [status, characters, errorMessage];
}