Issue I’ve just stumbled upon a github repo containing an example of flutter application for google_sign_in package. I’m confused about a particular usage of unawaited used inside the example : Future<void> _handleAuthorizeScopes() async { final bool isAuthorized = await _googleSignIn.requestScopes(scopes);
Continue readingTag: dart-async
Dart: `return future` vs `async return future`
Issue I’m running this code: import ‘dart:async’; void main() { final c = Future.value(); // Other constructors and `Completer.future` all yield same results. print(c == sync(c)); print(c == aSync(c)); } Future sync(Future future) { return future; } Future aSync(Future future)
Continue readingDart – how to mock a method that returns a future
Issue I have a class that defines a method that returns a Future. The Future contains a list of class that also return a future. class User{ Future<List<Album>> albums(){ }; } class Album{ Future<List<Photos>> photos(){ } }; What is the
Continue readingCapture all futures in a Zone
Issue In Dart is there any way to capture all Future‘s created inside a Zone? Currently, I’m forced to manually capture them all, but this seems prone to forgetting to do it. So I want to automate this if possible.
Continue readingGeneric Widget for listening Streams in Flutter
Issue I would like to create a StatefulWidget which I’ll use all over the app for listening streams of different types. Since I try to keep all the widgets Stateless I wanted to extract this functionality. I’ve created this: class
Continue readingFlutter, how to return different widget based on future value?
Issue I would like to base on a future bool value, to set different icons pass back to a data card inside a list, I tried .then or FutureBuilder, but still not successful. Scaffold: child: ListView.builder( itemCount: fullList.length, itemBuilder: (BuildContext
Continue readingWhy is the `await` keyword often omitted when using the shared_preferences plugin?
Issue While using shared prefs plugin it’s common to explore code like below void saveList() async { final prefs = await SharedPreferences.getInstance(); prefs.setStringList("listKey", aList); //await isn’t used } where setStringList returns a Future<bool> so that why in this case the
Continue readingThe value of expression of type 'void' can't be used in then()
Issue How to fix this kind of errors when using then? void handleSubmitWrapper() { final future = handleSubmit(); future.then(context.loaderOverlay.hide()); // error } Future<void> handleSubmit() async { … } This expression has a type of ‘void’ so its value can’t be
Continue readingHow to create a matcher that verifies an async callback is doing right thing?
Issue I would like to create a matcher that takes async or non-async callback, sets up some listeners, invokes callback, verifies listeners received expected events, and then clean up listeners. However, I see couple blockers: The method Matcher.matches is sync
Continue readingHow to create a matcher that verifies an async callback is doing right thing?
Issue I would like to create a matcher that takes async or non-async callback, sets up some listeners, invokes callback, verifies listeners received expected events, and then clean up listeners. However, I see couple blockers: The method Matcher.matches is sync
Continue reading