```dart void main() { runApp(MyApp()); } class MyApp extends StatefulWidget { const MyApp({Key? key}) : super(key: key); @override State createState() => _MyAppState(); } class _MyAppState extends State { late StreamSubscription hubSubscription; // Initialize a boolean indicating if the network is up bool networkIsUp = false; // Initialize the libraries ... void observeEvents() { hubSubscription = Amplify.Hub.listen(HubChannel.DataStore, (hubEvent) { if (hubEvent.eventName == 'networkStatus') { final status = hubEvent.payload as NetworkStatusEvent?; setState(() { networkIsUp = status?.active ?? false; }); } }); } // Build function and UI elements ... @override void dispose() { hubSubscription?.cancel(); super.dispose(); } } ``` Setup your Hub Listener or Subscriber before calling Amplify.configure() to avoid missing some DataStore events.