From 9da4c98e08d10713664dd8539404aad7949557af Mon Sep 17 00:00:00 2001 From: Briar Bowser Date: Wed, 13 Jun 2018 11:49:16 -0500 Subject: [PATCH] Fixed singleton design to fix issues with async initialization. --- lib/flutter_cache_manager.dart | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/flutter_cache_manager.dart b/lib/flutter_cache_manager.dart index 551d9943..b66a73ce 100644 --- a/lib/flutter_cache_manager.dart +++ b/lib/flutter_cache_manager.dart @@ -24,15 +24,14 @@ class CacheManager { static CacheManager _instance; static Future getInstance() async { - if (_instance == null) { - await synchronized(_lock, () async { - if (_instance == null) { - _instance = new CacheManager._(); - await _instance._init(); - } - }); - } - return _instance; + return await synchronized(_lock, () async { + if (_instance == null) { + _instance = new CacheManager._(); + await _instance._init(); + } + + return _instance; + }); } CacheManager._();