StrokeOrderAnimationController class
A ChangeNotifier that controls the behavior of a stroke order diagram.
It must be passed as an argument to a StrokeOrderAnimator that handles the actual presentation of the diagram. It can additionally be consumed by an app to allow for synchronization of control buttons with the animations. In order to control animations, a TickerProvider must be passed to the controller, for example using a TickerProviderStateMixin.
To better integrate quizzes, three callbacks can be either passed to the StrokeOrderAnimationController during instantiation or afterwards using the following methods:
- StrokeOrderAnimationController.addOnWrongStrokeCallback
- StrokeOrderAnimationController.addOnCorrectStrokeCallback
- StrokeOrderAnimationController.addOnQuizCompleteCallback
The onQuizCompleteCallback
receives a QuizSummary.
The other two callbacks receive the index of the stroke that was written
(in-)correctly. All indices are zero-based.
Check out StrokeOrderAnimationController.new for a list of attributes that control how the stroke order diagram is displayed and behaves.
A number of methods control the animation state:
- Start/stop animation
- Start/stop quiz
- Show next/previous stroke
- Show full character
- Reset animation/quiz
- Inheritance
-
- Object
- ChangeNotifier
- StrokeOrderAnimationController
Constructors
- StrokeOrderAnimationController(StrokeOrder _strokeOrder, TickerProvider tickerProvider, {double strokeAnimationSpeed = 1, double hintAnimationSpeed = 3, bool showStroke = true, bool showOutline = true, bool showMedian = false, bool showUserStroke = false, bool highlightRadical = false, Color strokeColor = Colors.blue, Color outlineColor = Colors.black, Color medianColor = Colors.black, Color radicalColor = Colors.red, Color brushColor = Colors.black, double brushWidth = 8.0, int hintAfterStrokes = 3, Color hintColor = Colors.lightBlueAccent, void onQuizCompleteCallback(QuizSummary)?, void onWrongStrokeCallback(int)?, void onCorrectStrokeCallback(int)?})
- Creates a new StrokeOrderAnimationController.
Properties
- brushColor → Color
-
no setter
- brushWidth → double
-
no setter
- currentStroke → int
-
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- highlightRadical → bool
-
no setter
- hintAfterStrokes → int
-
no setter
- hintAnimationController → AnimationController
-
no setter
- hintColor → Color
-
no setter
- isAnimating → bool
-
no setter
- isQuizzing → bool
-
no setter
- medianColor → Color
-
no setter
- outlineColor → Color
-
no setter
- radicalColor → Color
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showMedian → bool
-
no setter
- showOutline → bool
-
no setter
- showStroke → bool
-
no setter
- showUserStroke → bool
-
no setter
- strokeAnimationController → AnimationController
-
no setter
- strokeColor → Color
-
no setter
- strokeOrder ↔ StrokeOrder
-
getter/setter pair
- summary → QuizSummary
-
no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
addOnCorrectStrokeCallback(
void callback(int)) → void -
addOnQuizCompleteCallback(
void callback(QuizSummary)) → void -
addOnWrongStrokeCallback(
void callback(int)) → void -
animateHint(
) → void -
checkStroke(
List< Offset?> rawStroke) → void -
convertOffsetsToPath(
List< Offset> points) → Path -
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
override
-
getAllowedLengthRange(
double medianLength) → List< double> -
getLength(
List< Offset> points) → double -
getNonNullPointsFrom(
List< Offset?> rawPoints) → List<Offset> -
getStartEndMargin(
double medianLength) → double -
nextStroke(
) → void -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyCorrectStrokeCallbacks(
) → void -
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
notifyQuizCompleteCallbacks(
) → void -
notifyWrongStrokeCallbacks(
) → void -
previousStroke(
) → void -
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
reset(
) → void -
setBrushColor(
Color value) → void -
setBrushWidth(
double value) → void -
setHighlightRadical(
bool value) → void -
setHintAfterStrokes(
int value) → void -
setHintAnimationSpeed(
double value) → void -
setHintColor(
Color value) → void -
setMedianColor(
Color value) → void -
setOutlineColor(
Color value) → void -
setRadicalColor(
Color value) → void -
setShowMedian(
bool value) → void -
setShowOutline(
bool value) → void -
setShowStroke(
bool value) → void -
setShowUserStroke(
bool value) → void -
setStrokeAnimationSpeed(
double value) → void -
setStrokeColor(
Color value) → void -
showFullCharacter(
) → void -
startAnimation(
) → void -
startQuiz(
) → void -
stopAnimation(
) → void -
stopQuiz(
) → void -
strokeEndIsWithinMargin(
List< Offset> points, List<Offset> currentMedian, double startEndMargin) → bool -
strokeHasRightDirection(
List< Offset> points, List<Offset> currentMedian) → bool -
strokeIsCorrect(
double strokeLength, List< Offset> stroke) → bool -
strokeLengthWithinBounds(
double strokeLength, List< double> lengthRange) → bool -
strokeStartIsWithinMargin(
List< Offset> points, List<Offset> currentMedian, double startEndMargin) → bool -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited