added first working prototype of flashcards
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:frontend/model/quote.dart';
|
||||
import 'package:frontend/repository/quote_repository.dart';
|
||||
import 'dart:math';
|
||||
|
||||
class QuoteProvider extends ChangeNotifier {
|
||||
List<Quote> _quotes = [];
|
||||
@@ -44,6 +45,31 @@ class QuoteProvider extends ChangeNotifier {
|
||||
filterController.text = '';
|
||||
}
|
||||
|
||||
Quote randomQuote = Quote(
|
||||
id: 0,
|
||||
body: "quote text",
|
||||
author: "dummy"
|
||||
);
|
||||
bool randomQuoteDeterminator = true;
|
||||
String get randomQuoteText {
|
||||
if (randomQuoteDeterminator) {
|
||||
return randomQuote.body;
|
||||
} else {
|
||||
return randomQuote.author;
|
||||
}
|
||||
}
|
||||
|
||||
void flipRandomQuote() {
|
||||
randomQuoteDeterminator = !randomQuoteDeterminator;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void nextRandomQuote() {
|
||||
final random = Random();
|
||||
randomQuote = filteredQuotes[random.nextInt(filteredQuotes.length)];
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void filterQuotes() {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user