@@ -3,7 +3,8 @@ import 'package:trent/src/logic/mappers.dart';
33import 'package:trent/trent.dart' ;
44
55/// A generic Alerter widget that listens to alert events and state changes from a Trent.
6- class Alerter <TrentType extends Trents <StateType >, StateType > extends StatefulWidget {
6+ class Alerter <TrentType extends Trents <StateType >, StateType >
7+ extends StatefulWidget {
78 /// Called when an alert state is emitted, using a mapper.
89 final void Function (LogicSubTypeMapper <StateType > mapper)? listenAlerts;
910
@@ -28,14 +29,17 @@ class Alerter<TrentType extends Trents<StateType>, StateType> extends StatefulWi
2829 });
2930
3031 @override
31- AlerterState <TrentType , StateType > createState () => AlerterState <TrentType , StateType >();
32+ AlerterState <TrentType , StateType > createState () =>
33+ AlerterState <TrentType , StateType >();
3234}
3335
34- class AlerterState <TrentType extends Trents <StateType >, StateType > extends State <Alerter <TrentType , StateType >> {
36+ class AlerterState <TrentType extends Trents <StateType >, StateType >
37+ extends State <Alerter <TrentType , StateType >> {
3538 late final TrentType sm = get <TrentType >(context);
3639 late StateType _previousAlert; // Tracks the previous alert state
3740 late StateType _previousState; // Tracks the previous normal state
38- bool _hasInitialStateTriggered = false ; // Tracks if the initial state has been emitted
41+ bool _hasInitialStateTriggered =
42+ false ; // Tracks if the initial state has been emitted
3943
4044 @override
4145 void initState () {
@@ -46,7 +50,8 @@ class AlerterState<TrentType extends Trents<StateType>, StateType> extends State
4650 // Listen to the alert stream
4751 sm.alertStream.listen ((alert) {
4852 if (widget.listenAlerts != null ) {
49- final shouldTrigger = widget.listenAlertsIf? .call (_previousAlert, alert) ?? true ;
53+ final shouldTrigger =
54+ widget.listenAlertsIf? .call (_previousAlert, alert) ?? true ;
5055 if (shouldTrigger) {
5156 final mapper = LogicSubTypeMapper <StateType >(alert);
5257 widget.listenAlerts !(mapper);
@@ -63,7 +68,8 @@ class AlerterState<TrentType extends Trents<StateType>, StateType> extends State
6368 }
6469
6570 if (widget.listenStates != null ) {
66- final shouldTrigger = widget.listenStatesIf? .call (_previousState, state) ?? true ;
71+ final shouldTrigger =
72+ widget.listenStatesIf? .call (_previousState, state) ?? true ;
6773 if (shouldTrigger) {
6874 final mapper = LogicSubTypeMapper <StateType >(state);
6975 widget.listenStates !(mapper);
0 commit comments