You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Applications will have to store their own data on top of existing Card object. For example, a typical flashcard will need to store "Card Name", "Deck", and so on.
final fsrs =FSRS();
final textCard =TextCard();
final now =DateTime(2022, 11, 29, 12, 30, 0, 0);
final schedulingCards = fsrs.repeat(textCard.card, now);
textCard.card = schedulingCards;
print(textCard.card.due);
It would be simpler if TextCard inherit Card properties instead, removing extra hops it needs to get accessing the Card object using .card. But since Card is constructed with a factory for private class _Card, Card can't be extended by another class.
classTextCardextendsCard {
finalString text;
TextCard({requiredthis.text});
// ^^^^^^^^// The generative constructor 'Card Card()' is expected, but a factory was found.// Try calling a different constructor of the superclass, or making the called // constructor not be a factory constructor.
}
Proposal
From the above description, I suggest changing the Card API to make it extendable/inherited by other classes, this will allow the object to access to Card's properties and further make the API cleaner.
// fsrs/models.dartabstractclassCard {
constCard({
... // implementation of the Card model
});
... // implementation of the Card model
}
// app/model.dartclassTextCardextendsCard {
String text;
...
}
classImageCardextendsCard {
Image image;
...
}
// app/main.dartvar imageCard =ImageCard();
imageCard.due; // get card due
imageCard.image; // get card image
imageCard = fsrs.repeat(imageCard, now); // scheduling a card
This code isn't a final decision, I'm still not sure how it should be for the most part. As for the modifiers, I would refer to this documentation first: Class modifiers for API maintainers | Dart.
The text was updated successfully, but these errors were encountered:
Background
Currently the class
Card
only holds properties as follows:dart-fsrs/lib/src/models.dart
Lines 57 to 67 in eb52cfa
Applications will have to store their own data on top of existing
Card
object. For example, a typical flashcard will need to store "Card Name", "Deck", and so on.Some of applications may also have multiple card types, so inheriting a class containing common properties would makes sense for this.
But doing this, makes a convoluted API design.
It would be simpler if
TextCard
inheritCard
properties instead, removing extra hops it needs to get accessing theCard
object using.card
. But sinceCard
is constructed with a factory for private class_Card
,Card
can't be extended by another class.Proposal
From the above description, I suggest changing the
Card
API to make it extendable/inherited by other classes, this will allow the object to access toCard
's properties and further make the API cleaner.This code isn't a final decision, I'm still not sure how it should be for the most part. As for the modifiers, I would refer to this documentation first: Class modifiers for API maintainers | Dart.
The text was updated successfully, but these errors were encountered: