Navigator.of(context) must be called at MaterialApp or Navigator tree. Check showMessage function is it in the right context.