Reputation: 276
Today when I updated Flutter I began to get an error with my paint method which had never caused any problems before:
@override
void paint(
PaintingContext context,
Offset center, {
Animation<double> activationAnimation,
Animation<double> enableAnimation,
bool isDiscrete,
TextPainter labelPainter,
RenderBox parentBox,
SliderThemeData sliderTheme,
TextDirection textDirection,
double value,
}) {
This is the error:
error: 'CustomSlider.paint' ('void Function(PaintingContext, Offset, {Animation<double> activationAnimation, Animation<double> enableAnimation, bool isDiscrete, TextPainter labelPainter, RenderBox parentBox, SliderThemeData sliderTheme, TextDirection textDirection, double value})')
isn't a valid override of 'SliderComponentShape.paint' ('void Function(PaintingContext, Offset, {Animation<double> activationAnimation, Animation<double> enableAnimation, bool isDiscrete, TextPainter labelPainter, RenderBox parentBox, Size sizeWithOverflow, SliderThemeData sliderTheme, TextDirection textDirection, double textScaleFactor, double value})').
(invalid_override at [app_name] lib/Home/path_to_file:20)
Upvotes: 2
Views: 3033
Reputation: 1109
If your class happens to be like this,
class YourClass extends SliderTrackShape
with BaseSliderTrackShape
And you're experiencing this error, you're most liking one more parameter which is
Offset? secondaryOffset
And the full structure would be like this
@override
void paint(
PaintingContext context,
Offset offset, {
@required RenderBox? parentBox,
@required SliderThemeData? sliderTheme,
@required Animation<double>? enableAnimation,
@required TextDirection? textDirection,
@required Offset? thumbCenter,
bool isDiscrete = false,
bool isEnabled = false,
double additionalActiveTrackHeight = 2,
Offset? secondaryOffset,
})
Upvotes: 2
Reputation: 663
Looks like you now need to now specify the sizeWithOverflow in your override: https://api.flutter.dev/flutter/material/SliderComponentShape/paint.html I'm not familiar with that field, but there seems to be a description of that parameter in the Github code:
So you would need to change the above to:
@override
void paint(
PaintingContext context,
Offset center, {
Animation<double> activationAnimation,
Animation<double> enableAnimation,
bool isDiscrete,
TextPainter labelPainter,
RenderBox parentBox,
Size sizeWithOverflow, /*The missing link*/
double textScaleFactor, /*And the missing link I missed*/
SliderThemeData sliderTheme,
TextDirection textDirection,
double value,
}) {
Hope that helps.
P.S. I recommend using text-comparison tools in the future to more easily troubleshoot this sort of problem. I like using BeyondCompare, but that's me.
Upvotes: 6