import 'package:bloc/bloc.dart';

abstract class DatePickerEvent{}

class GetCurrentDate extends DatePickerEvent{}

class InitStateDate extends DatePickerEvent{}

class SetDate extends DatePickerEvent{
  DateTime? date;
  SetDate(this.date);
}

class DatePickerTglLahirBloc extends Bloc<DatePickerEvent, DateTime>{
  DateTime? date;
  DatePickerTglLahirBloc(DateTime initialState) : super(initialState);

  @override
  Stream<DateTime> mapEventToState(DatePickerEvent event) async*{
    // TODO: implement mapEventToState
    if(event is GetCurrentDate) date = DateTime.now();
    else if(event is InitStateDate) date = null;
    else if(event is SetDate) date = event.date;
    yield date!;
  }
}