Skip to content

[RangeSlider] [Flutter 3.10] LateInitializationError: Field '_startThumbCenter@280317193' has not been initialized. #126648

@kishan-dhankecha

Description

@kishan-dhankecha

Is there an existing issue for this?

Steps to reproduce

  1. Using RangeSlider inside ListView or CustomScrollView.
  2. Add this slider after many widgets (to simulate just use SizedBox with big height). This way the slider is not visible on the screen initially.
  3. Now scroll until the RangeSlider is in viewport.

[Note] It works fine if used in Column with SingleChildScrollView but in my Case I have lots of widgets before slider and I can not use that approach.

Expected results

The RangeSlider should work in scroll view normally.

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: 'Bug',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(
        min: 0,
        max: 500,
      ),
    );
  }
}

class MyHomePage extends StatefulWidget {
  final double min;
  final double max;

  const MyHomePage({
    super.key,
    required this.min,
    required this.max,
  });

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  late final ValueNotifier<(double, double)> rangeNotifier;

  @override
  void initState() {
    super.initState();
    rangeNotifier = ValueNotifier<(double, double)>((widget.min, widget.max));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text('Bug'),
      ),
      body: ListView(
        children: [
          SizedBox(
            height: MediaQuery.of(context).size.height * 1.5,
            child: const Placeholder(),
          ),
          ValueListenableBuilder(
            valueListenable: rangeNotifier,
            builder: (context, range, child) {
              return Padding(
                padding: const EdgeInsets.symmetric(horizontal: 22),
                child: RangeSlider(
                  min: widget.min,
                  max: widget.max,
                  values: RangeValues(range.$1, range.$2),
                  onChanged: (value) {
                    rangeNotifier.value = (value.start, value.end);
                  },
                ),
              );
            },
          ),
        ],
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

No visual sign of crash or error screen.

Simulator.Screen.Recording.-.iPhone.14.Pro.Max.-.2023-05-12.at.14.37.03.mp4

Logs

Logs
Restarted application in 670ms.

════════ Exception caught by scheduler library ═════════════════════════════════
The following LateError was thrown during a scheduler callback:
LateInitializationError: Field '_startThumbCenter@280317193' has not been initialized.

When the exception was thrown, this was the stack
#0      _RenderRangeSlider._startThumbCenter (package:flutter/src/material/range_slider.dart)
#1      _RenderRangeSlider.assembleSemanticsNode
#2      _SwitchableSemanticsFragment.compileChildren
#3      _SwitchableSemanticsFragment.compileChildren
#4      _SwitchableSemanticsFragment.compileChildren
#5      _SwitchableSemanticsFragment.compileChildren
#6      RenderObject._updateSemantics
#7      PipelineOwner.flushSemantics
#8      RendererBinding.drawFrame
#9      WidgetsBinding.drawFrame
#10     RendererBinding._handlePersistentFrameCallback
#11     SchedulerBinding._invokeFrameCallback
#12     SchedulerBinding.handleDrawFrame
#13     SchedulerBinding._handleDrawFrame
#14     _invoke (dart:ui/hooks.dart:142:13)
#15     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:359:5)
#16     _drawFrame (dart:ui/hooks.dart:112:31)
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by scheduler library ═════════════════════════════════
LateInitializationError: Field '_startThumbCenter@280317193' has not been initialized.
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by scheduler library ═════════════════════════════════
LateInitializationError: Field '_startThumbCenter@280317193' has not been initialized.
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by scheduler library ═════════════════════════════════
LateInitializationError: Field '_startThumbCenter@280317193' has not been initialized.
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by scheduler library ═════════════════════════════════
LateInitializationError: Field '_startThumbCenter@280317193' has not been initialized.
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by scheduler library ═════════════════════════════════
LateInitializationError: Field '_startThumbCenter@280317193' has not been initialized.
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by scheduler library ═════════════════════════════════
LateInitializationError: Field '_startThumbCenter@280317193' has not been initialized.
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by scheduler library ═════════════════════════════════
LateInitializationError: Field '_startThumbCenter@280317193' has not been initialized.
════════════════════════════════════════════════════════════════════════════════

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.10.0, on macOS 12.6.5 21G531 darwin-x64, locale en-GB)
    • Flutter version 3.10.0 on channel stable at /Users/os/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 84a1e904f4 (3 days ago), 2023-05-09 07:41:44 -0700
    • Engine revision d44b5a94c9
    • Dart version 3.0.0
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/os/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • ANDROID_HOME = /Users/os/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/os/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14B47b
    • CocoaPods version 1.12.0

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.78.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.64.0

[✓] Connected device (1 available)
    • iPhone 14 Pro Max (mobile) • 3454690B-8535-47DD-A81F-AE7B3E9008CE • ios • com.apple.CoreSimulator.SimRuntime.iOS-16-1
      (simulator)

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listf: material designflutter/packages/flutter/material repository.found in release: 3.10Found to occur in 3.10found in release: 3.11Found to occur in 3.11frameworkflutter/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 teamtriaged-designTriaged 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