import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:gps/blocs/bloc_provider.dart'; import 'package:gps/blocs/gps_bloc.dart'; class GpsTitleWidgetBloc extends StatelessWidget { const GpsTitleWidgetBloc({ Key? key, }) : super(key: key); @override Widget build(BuildContext context) { final GpsBloc bloc = BlocProvider.of(context); return StreamBuilder( stream: bloc.stateOut, initialData: GpsBlocState.notRecording, builder: (BuildContext context, AsyncSnapshot snapshot) { String title = AppLocalizations.of(context)!.appName; final state = (snapshot.data == GpsBlocState.recording) ? "- recording" : ""; return Text("$title $state"); }); } }