diff --git a/lib/main.dart b/lib/main.dart index ac1cc7a2..555639b3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -151,6 +151,13 @@ class _MyHomePageState extends State { _serverAddress = prefs.getString("server"); + // Reset the connection status variables + _serverStatus = "Connecting to server"; + _serverMessage = ""; + _serverConnection = false; + _serverIcon = new FaIcon(FontAwesomeIcons.spinner); + _serverStatusColor = Color.fromARGB(255, 50, 50, 250); + InvenTreeAPI().connect().then((bool result) { if (result) { @@ -176,6 +183,9 @@ class _MyHomePageState extends State { onConnectFailure(fault); }); + + // Update widget state + setState(() {}); } void _search() { @@ -358,6 +368,11 @@ class _MyHomePageState extends State { style: TextStyle(color: _serverStatusColor), ), leading: _serverIcon, + onTap: () { + if (!_serverConnection) { + _checkServerConnection(); + } + }, ), ), ],