Paint issue after updating Flutter

Viewed 1206

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)
1 Answers

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:

https://github.com/flutter/flutter/blob/2ae34518b8/packages/flutter/lib/src/material/slider_theme.dart#L1006

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.

Related