I'm learning bloc pattern. I could not understand what is the usecase of this toString function in bloc pattern. Ok I did convert the constructor to string and passed it the counter, so what?! why should I even do something like that?!
class CounterState extends Equatable {
final int counter;
const CounterState({
required this.counter,
});
factory CounterState.initial() {
return const CounterState(counter: 0);
}
// THIS FUNCTION
@override
String toString() => 'CounterState(counter: $counter)';
//
CounterState copyWith({
int? counter,
}) {
return CounterState(
counter: counter ?? this.counter,
);
}
@override
List<Object> get props => [counter];
}
Aucun commentaire:
Enregistrer un commentaire