Created
January 4, 2020 14:13
-
-
Save kishansinhparmar/36a958b5219a2a1c6f68a3c74bd8bc58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Loading indicator for something going to change | |
yield LoadingQuoteState(); | |
if (await repo.networkInfo.isConnected) { | |
if (event is GetNewQuote) { | |
try { | |
var failOrQuoteDetails = await repo.apiProvider.getNewQuote(); | |
yield failOrQuoteDetails.fold( | |
(failure) => | |
ErrorState(errorMsg: (failure as GeneralMsgError).errorMsg), | |
(quoteDetails) => DetailQuoteState(quoteDetails: quoteDetails), | |
); | |
} on Error { | |
yield ErrorState(errorMsg: "Something went wrong"); | |
} | |
} | |
}else{ | |
yield ErrorState(errorMsg: "Connect with working internet..."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment