File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -197,6 +197,21 @@ class ForegroundNotificationWrapper extends StatelessWidget {
197197}
198198
199199class BikePageState extends ConsumerState <BikePage > {
200+ @override
201+ void initState () {
202+ super .initState ();
203+ // Schedule a post-frame callback to ensure providers are initialized
204+ WidgetsBinding .instance.addPostFrameCallback ((_) {
205+ final bikeControl = ref.read (bikeProvider (widget.bikeID).notifier);
206+ final connectionState =
207+ ref.read (connectionHandlerProvider (widget.bikeID));
208+
209+ if (connectionState == SDBluetoothConnectionState .connected) {
210+ bikeControl.updateStateDataNow (force: true );
211+ }
212+ });
213+ }
214+
200215 @override
201216 Widget build (BuildContext context) {
202217 var bike = ref.watch (bikeProvider (widget.bikeID));
@@ -205,7 +220,7 @@ class BikePageState extends ConsumerState<BikePage> {
205220 if (previous != SDBluetoothConnectionState .connected &&
206221 next == SDBluetoothConnectionState .connected) {
207222 // add a delay
208- Future .delayed (const Duration (milliseconds: 200 ), () {
223+ Future .delayed (const Duration (milliseconds: 1000 ), () {
209224 bikeControl.updateStateDataNow (force: true );
210225 });
211226 }
You can’t perform that action at this time.
0 commit comments