Skip to content

[syncfusion_flutter_sliders] range_slider_base.dart in RenderBaseRangeSlider.increasedEndValue type 'int' is not a subtype of type 'double' #1698

@Justus-M

Description

@Justus-M

Hi,

I noticed this error in Sentry here is the stacktrace:

_TypeError
type 'int' is not a subtype of type 'double'

Unfortunately I am not able to reproduce the error and it came from one of my users. I can give you all the information I have though, and perhaps you might know what the issue is

Here is the stacktrace:

range_slider_base.dart in RenderBaseRangeSlider.increasedEndValue at line 290 within syncfusion_flutter_sliders
In App
range_slider.dart in _RenderRangeSlider.assembleSemanticsNode at line 2225 within syncfusion_flutter_sliders
In App
object.dart in _SwitchableSemanticsFragment.compileChildren at line 4947 within flutter
object.dart in _SwitchableSemanticsFragment.compileChildren at line 4871 within flutter
object.dart in _SwitchableSemanticsFragment.compileChildren at line 4936 within flutter
object.dart in RenderObject._updateSemantics at line 3601 within flutter
object.dart in PipelineOwner.flushSemantics at line 1277 within flutter
object.dart in PipelineOwner.flushSemantics at line 1282 within flutter
binding.dart in RendererBinding.drawFrame at line 598 within flutter
binding.dart in WidgetsBinding.drawFrame at line 986 within flutter
binding.dart in RendererBinding._handlePersistentFrameCallback at line 457 within flutter
binding.dart in SchedulerBinding._invokeFrameCallback at line 1325 within flutter
binding.dart in SchedulerBinding.handleDrawFrame at line 1255 within flutter
binding.dart in SchedulerBinding._handleDrawFrame at line 1113 within flutter
hooks.dart in _invoke at line 312
platform_dispatcher.dart in PlatformDispatcher._drawFrame at line 383
hooks.dart in _drawFrame at line 283

Here is my relevant flutter code:


class GraphSliders extends ConsumerWidget {
  BlazeQuery query;
  bool isDashboard;
  DashItem? dashItem;
  GraphSliders(this.query, this.isDashboard, this.dashItem);
  void onChanged(SfRangeValues values, String variable, WidgetRef ref) {
    if (isDashboard) {
      query.sliders = {
        variable: {'min': values.start, 'max': values.end}
      };
    }
    ref
        .read(queriesProvider.notifier)
        .replaceQueryInState(query.copyWith(sliders: {
          variable: {'min': values.start, 'max': values.end}
        }));
  }

  String formatDate(value, suggested) {
    if (value is DateTime &&
        !List<DateTime?>.from(result![query.sliders?.keys.first]!)
            .sublist(0, min(result![query.sliders?.keys.first]!.length, 5))
            .any((element) =>
                (element?.hour ?? 0) > 0 &&
                (element?.minute ?? 0) > 0 &&
                (element?.second ?? 0) > 0)) {
      return DateFormat.yMMMd().format(value);
    }
    return suggested;
  }

  String formatNum(number, _) {
    if (number is num &&
        !List<num?>.from(result![query.sliders?.keys.first]!)
            .sublist(0, min(result![query.sliders?.keys.first]!.length, 5))
            .any((element) =>
                element != null && element.toString().split('.').length > 1)) {
      return (number.toInt()).toString();
    }
    return number.toString();
  }

  num getMinNumericValue(MapEntry<String, Map<String, dynamic>> sliderEntry) {
    return List<num>.from(result![sliderEntry.key]!).reduce(min);
  }

  num getMaxNumericValue(MapEntry<String, Map<String, dynamic>> sliderEntry) {
    return List<num>.from(result![sliderEntry.key]!).reduce(max);
  }

  num getNumericStartValue(MapEntry<String, Map<String, dynamic>> sliderEntry) {
    return sliderEntry.value['min'] == null
        ? getMinNumericValue(sliderEntry)
        : max(sliderEntry.value['min'], getMinNumericValue(sliderEntry));
  }

  num getNumericEndValue(MapEntry<String, Map<String, dynamic>> sliderEntry) {
    return sliderEntry.value['max'] == null
        ? getMaxNumericValue(sliderEntry)
        : min(sliderEntry.value['max'], getMaxNumericValue(sliderEntry));
  }

  DateTime getDateStartValue(
      MapEntry<String, Map<String, dynamic>> sliderEntry) {
    return sliderEntry.value['min'] == null
        ? getMinDateValue(sliderEntry)
        : (getMinDateValue(sliderEntry).isAfter(sliderEntry.value['min'])
            ? getMinDateValue(sliderEntry)
            : sliderEntry.value['min']);
  }

  DateTime getDateEndValue(MapEntry<String, Map<String, dynamic>> sliderEntry) {
    return sliderEntry.value['max'] == null
        ? getMinDateValue(sliderEntry)
        : (getMaxDateValue(sliderEntry).isBefore(sliderEntry.value['max'])
            ? getMaxDateValue(sliderEntry)
            : sliderEntry.value['max']);
  }

  DateTime getMinDateValue(MapEntry<String, Map<String, dynamic>> sliderEntry) {
    return List<DateTime>.from(result![sliderEntry.key]!)
        .reduce((a, b) => a.isBefore(b) ? a : b);
  }

  DateTime getMaxDateValue(MapEntry<String, Map<String, dynamic>> sliderEntry) {
    return List<DateTime>.from(result![sliderEntry.key]!)
        .reduce((a, b) => a.isAfter(b) ? a : b);
  }

  Map<String, List<dynamic>>? result;
  @override
  Widget build(BuildContext context, WidgetRef ref) {
    var request = ref.watch(queryRequestProvider(query.id));
    result = request.result;

    return result?.isNotEmpty == true &&
            query.sliders?.isNotEmpty == true &&
            request.safeSliderVariable(query.sliders!.keys.first) != null
        ? Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              if (!ref.read(reorderingProvider))
                ...query.sliders!.entries.map((sliderEntry) {
                  return LayoutBuilder(builder: (context, constraints) {
                    return Container(
                        height: 64,
                        width: dashItem == null ? null : dashItem!.width - 100,
                        padding:
                            EdgeInsets.symmetric(horizontal: 32, vertical: 8)
                                .copyWith(left: 40),
                        child: result![sliderEntry.key]!
                                .any((v) => v is DateTime)
                            ? SfRangeSlider(
                                tooltipTextFormatterCallback: formatDate,
                                labelFormatterCallback: formatDate,
                                key: Key(
                                    '${sliderEntry.key}rs${isDashboard.toString()}'),
                                enableTooltip: true,
                                showLabels: true,
                                values: SfRangeValues(
                                    getDateStartValue(sliderEntry),
                                    getDateEndValue(sliderEntry)),
                                activeColor: Theme.of(context).primaryColor,
                                min: getMinDateValue(sliderEntry),
                                max: getMaxDateValue(sliderEntry),
                                onChanged: (values) =>
                                    onChanged(values, sliderEntry.key, ref))
                            : SfRangeSlider(
                                tooltipTextFormatterCallback: formatNum,
                                key: Key(
                                    '${sliderEntry.key}rs${isDashboard.toString()}'),
                                enableTooltip: true,
                                showLabels: true,
                                values: SfRangeValues(
                                    getNumericStartValue(sliderEntry),
                                    getNumericEndValue(sliderEntry)),
                                activeColor: Theme.of(context).primaryColor,
                                min: getMinNumericValue(sliderEntry),
                                max: getMaxNumericValue(sliderEntry),
                                onChanged: (values) =>
                                    onChanged(values, sliderEntry.key, ref),
                              ));
                  });
                }),
              if (query.sliders?.keys.isNotEmpty == true)
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Padding(
                      padding: const EdgeInsets.only(left: 48, bottom: 8),
                      child: Text('Filter ' + query.sliders!.keys.first),
                    )
                  ],
                )
            ],
          )
        : Container();
  }
}


Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedFixed and delivered updateslidersSliders component

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions