Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/3.2' into release/web
Browse files Browse the repository at this point in the history
  • Loading branch information
Arenukvern committed May 15, 2024
2 parents e6d20cf + e10b590 commit e146f74
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:flutter/widgets.dart';
abstract class BaseOnlineStatusService extends ChangeNotifier {
// ignore: avoid_unused_constructor_parameters
BaseOnlineStatusService(final BuildContext context);

Future<void> onLoad();
bool _isConnected = false;

bool get isConnected => _isConnected;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import 'package:web/web.dart' as web;
import 'online_status_service_i.dart';

class OnlineStatusService extends BaseOnlineStatusService {
OnlineStatusService(super.context) {
isConnected = web.window.navigator.onLine;
_startListening();
}
OnlineStatusService(super.context);

void _startListening() => web.window
..addEventListener('online', _onOnline.toJS)
Expand All @@ -24,4 +21,10 @@ class OnlineStatusService extends BaseOnlineStatusService {
..removeEventListener('offline', _onOffline.toJS);
super.dispose();
}

@override
Future<void> onLoad() async {
isConnected = web.window.navigator.onLine;
_startListening();
}
}

0 comments on commit e146f74

Please sign in to comment.