import 'package:bloc/bloc.dart';
import 'package:flutter/material.dart';

enum ColorEvent { to_blue, to_yellow }

class ColorBloc extends Bloc<ColorEvent, Color> {
  Color _color = Colors.blue;
  ColorBloc() : super(Colors.blue);

  @override
  Stream<Color> mapEventToState(ColorEvent event) async* {
    switch (event) {
      case ColorEvent.to_blue:
        _color = Colors.blue;
        yield _color;
        break;

      case ColorEvent.to_yellow:
        _color = Colors.yellow;
        yield _color;
        break;
    }
  }
}
