diff --git a/example/lib/main.dart b/example/lib/main.dart index 5b3ce9a..e585d7a 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -39,7 +39,6 @@ class HomeState extends State { lineLength: 120, // width of the output colors: true, // Colorful log messages printEmojis: true, // Print an emoji for each log message - printTime: true, ), ); @@ -767,14 +766,8 @@ class HomeState extends State { Future checkIfAppIsActive(BuildContext context) async { try { - await SpotifySdk.isSpotifyAppActive.then((isActive) { - final snackBar = SnackBar( - content: Text(isActive - ? 'Spotify app connection is active (currently playing)' - : 'Spotify app connection is not active (currently not playing)')); - - ScaffoldMessenger.of(context).showSnackBar(snackBar); - }); + final isActive = await SpotifySdk.isSpotifyAppActive; + _showSnackBar(isActive); } on PlatformException catch (e) { setStatus(e.code, message: e.message); } on MissingPluginException { @@ -782,6 +775,16 @@ class HomeState extends State { } } + void _showSnackBar(bool isActive) { + final snackBar = SnackBar( + content: Text(isActive + ? 'Spotify app connection is active (currently playing)' + : 'Spotify app connection is not active (currently not playing)'), + ); + + ScaffoldMessenger.of(context).showSnackBar(snackBar); + } + void setStatus(String code, {String? message}) { var text = message ?? ''; _logger.i('$code$text'); diff --git a/lib/spotify_sdk_web.dart b/lib/spotify_sdk_web.dart index 0d47bc6..44bcb6e 100644 --- a/lib/spotify_sdk_web.dart +++ b/lib/spotify_sdk_web.dart @@ -1,5 +1,5 @@ @JS() -library spotify_sdk_web; +library; import 'dart:async'; import 'dart:convert';