Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 tasks done
Tracked by #125329
kishan-dhankecha opened this issue May 12, 2023 · 11 comments · Fixed by #135667
Assignees
Labels
f: material design flutter/packages/flutter/material repository. found in release: 3.10 Found to occur in 3.10 found in release: 3.11 Found to occur in 3.11 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list r: fixed Issue is closed as already fixed in a newer version team-design Owned by Design Languages team triaged-design Triaged by Design Languages team

Comments

@kishan-dhankecha
Copy link
Contributor

kishan-dhankecha commented May 12, 2023

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!
@kishan-dhankecha kishan-dhankecha changed the title [RangeSlider] LateInitializationError: Field '_startThumbCenter@280317193' has not been initialized. [RangeSlider] [Flutter 3.10] LateInitializationError: Field '_startThumbCenter@280317193' has not been initialized. May 12, 2023
@kishan-dhankecha
Copy link
Contributor Author

kishan-dhankecha commented May 12, 2023

Additionally, This is the line which causes LateInitializationError.

@danagbemava-nc danagbemava-nc added the in triage Presently being triaged by the triage team label May 12, 2023
@danagbemava-nc
Copy link
Member

Reproducible using the code sample provided above.

flutter doctor -v
[✓] Flutter (Channel stable, 3.10.0, on macOS 13.3.1 22E772610a darwin-arm64, locale en-GB)
    • Flutter version 3.10.0 on channel stable at /Users/nexus/dev/sdks/flutter
    • 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.0)
    • Android SDK at /Users/nexus/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841/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.3)
    • Xcode at /Applications/Xcode-14.3.0.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841/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)

[✓] Android Studio (version 2022.2)
    • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9862592/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)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.1.1)
    • IntelliJ at /Users/nexus/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 73.1.1
    • Dart plugin version 231.8770.15

[✓] IntelliJ IDEA Ultimate Edition (version 2023.1)
    • IntelliJ at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.8109.175/IntelliJ IDEA.app
    • 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

[✓] IntelliJ IDEA Ultimate Edition (version 2023.1.1)
    • IntelliJ at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.8770.65/IntelliJ IDEA.app
    • 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

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

[✓] Connected device (4 available)
    • Pixel 7 (mobile) • 28291FDH2001SA            • android-arm64  • Android 13 (API 33)
    • Nexus (mobile)   • 00008020-001875E83A38002E • ios            • iOS 16.4.1 20E252
    • macOS (desktop)  • macos                     • darwin-arm64   • macOS 13.3.1 22E772610a darwin-arm64
    • Chrome (web)     • chrome                    • web-javascript • Google Chrome 113.0.5672.92

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

• No issues found!
[!] Flutter (Channel master, 3.11.0-5.0.pre.48, on macOS 13.3.1 22E772610a darwin-arm64, locale en-GB)
    • Flutter version 3.11.0-5.0.pre.48 on channel master at /Users/nexus/dev/sdks/flutters
    ! Warning: `flutter` on your path resolves to /Users/nexus/dev/sdks/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutters. Consider adding /Users/nexus/dev/sdks/flutters/bin to the front of your path.
    ! Warning: `dart` on your path resolves to /Users/nexus/dev/sdks/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutters. Consider adding /Users/nexus/dev/sdks/flutters/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5e459380c1 (8 hours ago), 2023-05-11 22:53:01 -0400
    • Engine revision ef5c349f04
    • Dart version 3.1.0 (build 3.1.0-94.0.dev)
    • DevTools version 2.23.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/nexus/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841/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.3)
    • Xcode at /Applications/Xcode-14.3.0.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841/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)

[✓] Android Studio (version 2022.2)
    • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9862592/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)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.1.1)
    • IntelliJ at /Users/nexus/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 73.1.1
    • Dart plugin version 231.8770.15

[✓] IntelliJ IDEA Ultimate Edition (version 2023.1)
    • IntelliJ at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.8109.175/IntelliJ IDEA.app
    • 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

[✓] IntelliJ IDEA Ultimate Edition (version 2023.1.1)
    • IntelliJ at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.8770.65/IntelliJ IDEA.app
    • 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

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

[✓] Connected device (4 available)
    • Pixel 7 (mobile) • 28291FDH2001SA            • android-arm64  • Android 13 (API 33)
    • Nexus (mobile)   • 00008020-001875E83A38002E • ios            • iOS 16.4.1 20E252
    • macOS (desktop)  • macos                     • darwin-arm64   • macOS 13.3.1 22E772610a darwin-arm64
    • Chrome (web)     • chrome                    • web-javascript • Google Chrome 113.0.5672.92

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

! Doctor found issues in 1 category.

@danagbemava-nc danagbemava-nc added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 3.10 Found to occur in 3.10 found in release: 3.11 Found to occur in 3.11 and removed in triage Presently being triaged by the triage team labels May 12, 2023
@TahaTesser TahaTesser self-assigned this May 12, 2023
@ueman
Copy link
Contributor

ueman commented May 24, 2023

We're also seeing a huge amount of errors for this case in production. Is there a known workaround while it's being fixed?

Edit: Using a Column as suggested in the issue description works for us since we have just a small list.

@kishan-dhankecha
Copy link
Contributor Author

Currently, as my prod apps have had this issue, I used syncfusion_flutter_sliders as temporary solution.

I will change back to Material Slider once this issue is fixed and merged in stable.

@TahaTesser
Copy link
Member

I'm working on a rework of Slider and RangeSlider. This should be fixed as part of it.

@ueman
Copy link
Contributor

ueman commented May 26, 2023

Is there already something I can track? I see nothing linked to this issue.

@TahaTesser
Copy link
Member

@ueman
You can track here #125329

@TahaTesser TahaTesser removed their assignment Jun 19, 2023
@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-design Owned by Design Languages team triaged-design Triaged by Design Languages team labels Jul 8, 2023
@flutter-triage-bot flutter-triage-bot bot removed the triaged-design Triaged by Design Languages team label Sep 4, 2023
@flutter-triage-bot
Copy link

This issue is missing a priority label. Please set a priority label when adding the triaged-design label.

@HansMuller HansMuller added P2 Important issues not at the top of the work list triaged-design Triaged by Design Languages team labels Sep 6, 2023
auto-submit bot pushed a commit that referenced this issue Sep 28, 2023
fixes [[RangeSlider] [Flutter 3.10] LateInitializationError: Field '_startThumbCenter@280317193' has not been initialized.](#126648)

### Code sample (Run it on iOS)

<details>
<summary>expand to view the code sample</summary> 

```dart
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

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

  @OverRide
  Widget build(BuildContext context) {
    return const MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Example(),
    );
  }
}

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

  @OverRide
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView(
        children: <Widget>[
          const SizedBox(
            height: 1000,
            child: Placeholder(),
          ),
          RangeSlider(
            values: const RangeValues(0.25, 0.75),
            onChanged: (value) {},
          ),
        ],
      ),
    );
  }
}
```

</details>
@TahaTesser TahaTesser added the r: fixed Issue is closed as already fixed in a newer version label Sep 28, 2023
@manish-wearetechtonic
Copy link

You can try using this
Wrap your children in Column and make column scrollable with SingleChildScrollView.

@kishan-dhankecha
Copy link
Contributor Author

@manish-wearetechtonic Kindly read the initial bug post thoroughly. Specifically the note in Step to reproduce section

Mairramer pushed a commit to Mairramer/flutter that referenced this issue Oct 10, 2023
fixes [[RangeSlider] [Flutter 3.10] LateInitializationError: Field '_startThumbCenter@280317193' has not been initialized.](flutter#126648)

### Code sample (Run it on iOS)

<details>
<summary>expand to view the code sample</summary> 

```dart
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

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

  @OverRide
  Widget build(BuildContext context) {
    return const MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Example(),
    );
  }
}

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

  @OverRide
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView(
        children: <Widget>[
          const SizedBox(
            height: 1000,
            child: Placeholder(),
          ),
          RangeSlider(
            values: const RangeValues(0.25, 0.75),
            onChanged: (value) {},
          ),
        ],
      ),
    );
  }
}
```

</details>
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
f: material design flutter/packages/flutter/material repository. found in release: 3.10 Found to occur in 3.10 found in release: 3.11 Found to occur in 3.11 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list r: fixed Issue is closed as already fixed in a newer version team-design Owned by Design Languages team triaged-design Triaged by Design Languages team
Projects
Status: Done (PR merged)
Development

Successfully merging a pull request may close this issue.

6 participants