StrokeOrderAnimationController constructor
StrokeOrderAnimationController(
- StrokeOrder _strokeOrder,
- TickerProvider tickerProvider, {
- double strokeAnimationSpeed = 1,
- double hintAnimationSpeed = 3,
- bool showStroke = true,
- bool showOutline = true,
- bool showBackground = false,
- bool showMedian = false,
- bool showUserStroke = false,
- bool highlightRadical = false,
- Color strokeColor = Colors.blue,
- Color outlineColor = Colors.black,
- Color backgroundColor = Colors.grey,
- Color medianColor = Colors.black,
- Color radicalColor = Colors.red,
- Color brushColor = Colors.black,
- double brushWidth = 8.0,
- double outlineWidth = 2.0,
- double medianWidth = 2.0,
- int hintAfterStrokes = 3,
- Color hintColor = Colors.lightBlueAccent,
- void onQuizCompleteCallback()?,
- void onWrongStrokeCallback()?,
- void onCorrectStrokeCallback()?,
Creates a new StrokeOrderAnimationController.
A number of attributes can be set during initialization or via their respective setters:
- Animation speed of stroke animations and hints in quiz mode (try 3 and adjust from there)
- Whether to show/hide strokes
- Whether to show/hide outlines
- Whether to show/hide backgrounds for the strokes
- Whether to show/hide medians
- Whether to show/hide the correct strokes the user writes during a quiz
- Whether to highlight radicals
- Stroke color
- Outline color
- Background color (of the strokes, not the whole widget)
- Median color
- Radical color
- Brush color in quiz mode
- Brush thickness in quiz mode
- Number of wrong strokes before showing a hint in quiz mode
- Hint color in quiz mode
Don't forget to call dispose when the controller is no longer needed.
Implementation
StrokeOrderAnimationController(
this._strokeOrder,
TickerProvider tickerProvider, {
double strokeAnimationSpeed = 1,
double hintAnimationSpeed = 3,
bool showStroke = true,
bool showOutline = true,
bool showBackground = false,
bool showMedian = false,
bool showUserStroke = false,
bool highlightRadical = false,
Color strokeColor = Colors.blue,
Color outlineColor = Colors.black,
Color backgroundColor = Colors.grey,
Color medianColor = Colors.black,
Color radicalColor = Colors.red,
Color brushColor = Colors.black,
double brushWidth = 8.0,
double outlineWidth = 2.0,
double medianWidth = 2.0,
int hintAfterStrokes = 3,
Color hintColor = Colors.lightBlueAccent,
void Function(QuizSummary)? onQuizCompleteCallback,
void Function(int)? onWrongStrokeCallback,
void Function(int)? onCorrectStrokeCallback,
}) : _strokeColor = strokeColor,
_showStroke = showStroke,
_showOutline = showOutline,
_showBackground = showBackground,
_showMedian = showMedian,
_showUserStroke = showUserStroke,
_highlightRadical = highlightRadical,
_outlineColor = outlineColor,
_backgroundColor = backgroundColor,
_medianColor = medianColor,
_radicalColor = radicalColor,
_brushColor = brushColor,
_brushWidth = brushWidth,
_outlineWidth = outlineWidth,
_medianWidth = medianWidth,
_hintAfterStrokes = hintAfterStrokes,
_hintColor = hintColor,
_strokeAnimationSpeed = strokeAnimationSpeed,
_hintAnimationSpeed = hintAnimationSpeed,
_strokeAnimationController = AnimationController(
vsync: tickerProvider,
),
_hintAnimationController = AnimationController(
vsync: tickerProvider,
) {
_strokeAnimationController.addStatusListener(_strokeCompleted);
_hintAnimationController.addStatusListener((status) {
if (status == AnimationStatus.completed) {
_hintAnimationController.reset();
}
});
_setCurrentStroke(0);
_summary = QuizSummary(strokeOrder.nStrokes);
if (onQuizCompleteCallback != null) {
addOnQuizCompleteCallback(onQuizCompleteCallback);
}
if (onWrongStrokeCallback != null) {
addOnWrongStrokeCallback(onWrongStrokeCallback);
}
if (onCorrectStrokeCallback != null) {
addOnCorrectStrokeCallback(onCorrectStrokeCallback);
}
notifyListeners();
}