import 'package:flutter/material.dart'; import 'package:gps/blocs/bloc_provider.dart'; import 'package:gps/blocs/gps_bloc.dart'; class GpsButtonsWidgetBloc extends StatelessWidget { const GpsButtonsWidgetBloc({ Key? key, }) : super(key: key); @override Widget build(BuildContext context) { final GpsBloc bloc = BlocProvider.of(context); return Row( children: [ StreamBuilder( stream: bloc.stateOut, initialData: GpsBlocState.notRecording, builder: (BuildContext context, AsyncSnapshot snapshot) { return IconButton( onPressed: () => bloc.actionIn.add(GpsBlocAction.toggleRecording), icon: Icon(snapshot.data == GpsBlocState.recording ? Icons.stop : Icons.fiber_manual_record), ); }), IconButton( onPressed: () => bloc.actionIn.add(GpsBlocAction.save), icon: const Icon(Icons.save), ) ], ); } }