Skip to content

Null-check operator on RangeSlider's _startSemanticsNode #141953

@r-i-c-o

Description

@r-i-c-o

Steps to reproduce

Try to run the sample code. We could not reproduce it on a local machine.

Expected results

No problems with the semantics part of a RangeSlider

Actual results

The issue appears in Sentry in release mode. The _startSemanticsNode field somehow became null. This seems to be related with #91029

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: ElevatedButton(
          onPressed: () {
            showModalBottomSheet(
              context: context,
              builder: (context) {
                return _BottomSheetRangeSlider();
              },
            );
          },
          child: Text("Show range slider"),
        ),
      ),
    );
  }
}

class _BottomSheetRangeSlider extends StatefulWidget {
  const _BottomSheetRangeSlider({super.key});

  @override
  State<_BottomSheetRangeSlider> createState() => _BottomSheetRangeSliderState();
}

class _BottomSheetRangeSliderState extends State<_BottomSheetRangeSlider> {
  double _s = 1;
  double _e = 100;
  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: Column(
        children: [
          Column(
            children: [
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: RangeSlider(
                  values: RangeValues(_s, _e),
                  min: 1,
                  max: 100,
                  divisions: 50,
                  onChanged: (RangeValues values) {
                    setState(() {
                      _s = values.start;
                      _e = values.end;
                    });
                  },
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}

Screenshots or Video

No response

Logs

Logs
_TypeError: Null check operator used on a null value
  File "range_slider.dart", line 1700, in _RenderRangeSlider.assembleSemanticsNode
  File "object.dart", line 4947, in _SwitchableSemanticsFragment.compileChildren
  File "object.dart", line 4871, in _SwitchableSemanticsFragment.compileChildren
  File "object.dart", line 4936, in _SwitchableSemanticsFragment.compileChildren
  File "object.dart", line 3601, in RenderObject._updateSemantics
  File "object.dart", line 1277, in PipelineOwner.flushSemantics
  File "object.dart", line 1282, in PipelineOwner.flushSemantics
  File "binding.dart", line 598, in RendererBinding.drawFrame
  File "binding.dart", line 986, in WidgetsBinding.drawFrame
  File "binding.dart", line 457, in RendererBinding._handlePersistentFrameCallback
  File "binding.dart", line 1325, in SchedulerBinding._invokeFrameCallback
  File "binding.dart", line 1255, in SchedulerBinding.handleDrawFrame
  File "binding.dart", line 1113, in SchedulerBinding._handleDrawFrame
  File "hooks.dart", line 312, in _invoke
  File "platform_dispatcher.dart", line 383, in PlatformDispatcher._drawFrame
  File "hooks.dart", line 283, in _drawFrame

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.16.7, on Microsoft Windows [Version 10.0.19045.3930], locale ru-RU)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.4.4)
[√] Android Studio (version 2023.1)
[√] IntelliJ IDEA Community Edition (version 2022.3)
[√] Connected device (3 available)
[√] Network resources

Metadata

Metadata

Assignees

Labels

a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)a: error messageError messages from the Flutter frameworkf: material designflutter/packages/flutter/material repository.found in release: 3.16Found to occur in 3.16frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages team

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions