import 'package:flutter/material.dart';
class OpeningHoursSettings extends StatelessWidget {

  final Function(bool?)? onSliderChanged;
  
  const OpeningHoursSettings({
    super.key,required this.onSliderChanged,
  });
 
  ///.....

  RangeSlider _buildSlider(BuildContext context){
    return RangeSlider(divisions: 24,values: 
       RangeValues(
         openingHours.openAt,
         openingHours.closeAt),min: 0, max: 0, 
         **onChanged: onSliderChanged**
  );
  }



I have made the problem part bold.

The error thrown is

The argument type 'dynamic Function(bool?)?' can't be assigned to the parameter type 'void Function(RangeValues)?'.dartargument_type_not_assignable

I read the docs of null safety but in vain

1

There are 1 best solutions below

0
Md. Yeasin Sheikh On

If you check the definition of RangeSlider(onChangedit is

 final ValueChanged<RangeValues>? onChanged;

So you can change the function dataType like,

  final Function(RangeValues)? onSliderChanged;