fixed issue #5
This commit is contained in:
@@ -64,7 +64,7 @@ class QuoteProvider extends ChangeNotifier {
|
||||
filterController.text = '';
|
||||
}
|
||||
|
||||
Quote randomQuote = Quote(id: 0, author: "dummy", body: "text");
|
||||
late Quote randomQuote;
|
||||
bool randomQuoteDeterminator = true;
|
||||
String get randomQuoteText {
|
||||
if (randomQuoteDeterminator) {
|
||||
@@ -80,6 +80,7 @@ class QuoteProvider extends ChangeNotifier {
|
||||
}
|
||||
|
||||
void nextRandomQuote() {
|
||||
if (filteredQuotes.isEmpty) return;
|
||||
final random = Random();
|
||||
randomQuote = filteredQuotes[random.nextInt(filteredQuotes.length)];
|
||||
notifyListeners();
|
||||
@@ -107,17 +108,20 @@ class QuoteProvider extends ChangeNotifier {
|
||||
|
||||
Future<void> readQuotes() async {
|
||||
_loading = true;
|
||||
_error = null;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
_quotes = await repo.readQuotes();
|
||||
populateAuthors();
|
||||
|
||||
if (_quotes.isNotEmpty) {
|
||||
nextRandomQuote();
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
_error = e.toString();
|
||||
}
|
||||
|
||||
populateAuthors();
|
||||
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user