Skip to content

Closing bottom sheet and removing FAB cause assertion failure #128562

Description

@utisam

Is there an existing issue for this?

Steps to reproduce

  1. Display bottom sheet using showBottomSheet and FloatingActionButton in stateful scaffold
  2. PersistentBottomSheetController.close() and floatingActionButton: null at the same time

Expected results

Assertion failure should not happen.

Actual results

════════ Exception caught by animation library ═════════════════════════════════
The following assertion was thrown while notifying status listeners for AnimationController:
'package:flutter/src/material/scaffold.dart': Failed assertion: line 1362 pos 16: 'widget.currentController.status == AnimationStatus.dismissed': is not true.

This assertion is not needed when removing FAV (widget.child == null).

Code sample

Code sample

Remove bottom sheet and FAV at the same time with count == 3.

import 'package:flutter/material.dart';

void main() => runApp(const MaterialApp(home: _CounterScaffold()));

class _CounterScaffold extends StatefulWidget {
  const _CounterScaffold();

  @override
  State<_CounterScaffold> createState() => _CounterScaffoldState();
}

class _CounterScaffoldState extends State<_CounterScaffold> {
  int _count = 0;

  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(title: const Text('Sample Code')),
        body: _CounterBody(count: _count),
        floatingActionButton: _count < 3
            ? FloatingActionButton(
                onPressed: () => setState(() => _count++),
                tooltip: 'Increment Counter',
                child: const Icon(Icons.add),
              )
            : null,
      );
}

class _CounterBody extends StatefulWidget {
  final int count;

  const _CounterBody({required this.count});

  @override
  State<_CounterBody> createState() => _CounterBodyState();
}

class _CounterBodyState extends State<_CounterBody> {
  PersistentBottomSheetController? _controller;

  @override
  void didUpdateWidget(_CounterBody oldWidget) {
    super.didUpdateWidget(oldWidget);

    if (oldWidget.count == 0 && widget.count > 0) {
      WidgetsBinding.instance.addPostFrameCallback((_) {
        _controller = showBottomSheet(
          context: context,
          builder: (_) => Container(height: 200, color: Colors.amber),
        );
      });
    }

    if (_controller != null && widget.count >= 3) {
      WidgetsBinding.instance.addPostFrameCallback((_) {
        _controller!.close();
        _controller = null;
      });
    }
  }

  @override
  Widget build(BuildContext context) =>
      Center(child: Text('You have pressed the button ${widget.count} times.'));
}

Screenshots or Video

No response

Logs

Logs
════════ Exception caught by animation library ═════════════════════════════════
The following assertion was thrown while notifying status listeners for AnimationController:
'package:flutter/src/material/scaffold.dart': Failed assertion: line 1362 pos 16: 'widget.currentController.status == AnimationStatus.dismissed': is not true.

Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack
#2      _FloatingActionButtonTransitionState._handlePreviousAnimationStatusChanged.<anonymous closure>
#3      State.setState
#4      _FloatingActionButtonTransitionState._handlePreviousAnimationStatusChanged
#5      AnimationLocalStatusListenersMixin.notifyStatusListeners
#6      AnimationController._checkStatusChanged
#7      AnimationController._tick
#8      Ticker._tick
#9      SchedulerBinding._invokeFrameCallback
#10     SchedulerBinding.handleBeginFrame.<anonymous closure>
#11     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625:13)
#12     SchedulerBinding.handleBeginFrame
#13     SchedulerBinding._handleBeginFrame
#14     _invoke1 (dart:ui/hooks.dart:158:13)
#15     PlatformDispatcher._beginFrame (dart:ui/platform_dispatcher.dart:337:5)
#16     _beginFrame (dart:ui/hooks.dart:101:31)
(elided 2 frames from class _AssertionError)
The AnimationController notifying status listeners was: AnimationController#24868(⏮ 0.000; paused)
════════════════════════════════════════════════════════════════════════════════

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.10.4, on macOS 13.3.1 22E261 darwin-arm64, locale ja-JP)
    • Flutter version 3.10.4 on channel stable at /opt/homebrew/Caskroom/flutter/3.10.0/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 682aa387cf (3 days ago), 2023-06-05 18:04:56 -0500
    • Engine revision 2a3401c9bb
    • Dart version 3.0.3
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/masatoshitsushima/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • 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.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 /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.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.66.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 13.3.1 22E261 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 114.0.5735.106

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

• No issues found!

Activity

  1. added
    in triagePresently being triaged by the triage team
    on Jun 9, 2023
  2. huycozy commented on Jun 9, 2023

    @huycozy
    Member

    Thanks for the report. Reproduced this issue on the latest master channel as well.

    flutter doctor -v (stable and master)
    [✓] Flutter (Channel stable, 3.10.4, on macOS 13.0.1 22A400 darwin-x64, locale en-VN)
        • Flutter version 3.10.4 on channel stable at /Users/huynq/Documents/GitHub/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 682aa387cf (2 days ago), 2023-06-05 18:04:56 -0500
        • Engine revision 2a3401c9bb
        • Dart version 3.0.3
        • DevTools version 2.23.1
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
        • Android SDK at /Users/huynq/Library/Android/sdk
        • Platform android-33, build-tools 32.0.0
        • ANDROID_HOME = /Users/huynq/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.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14E222b
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] 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.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.66.0
    
    [✓] Connected device (3 available)
        • Pixel 3a (mobile) • 964AY0WL20 • android-arm64  • Android 12 (API 32)
        • macOS (desktop)   • macos      • darwin-x64     • macOS 13.0.1 22A400 darwin-x64
        • Chrome (web)      • chrome     • web-javascript • Google Chrome 114.0.5735.106
    
    [✓] Network resources
        • All expected network resources are available.
    
    • No issues found!
    [!] Flutter (Channel master, 3.12.0-2.0.pre.43, on macOS 13.0.1 22A400 darwin-x64, locale en-VN)
        • Flutter version 3.12.0-2.0.pre.43 on channel master at /Users/huynq/Documents/GitHub/flutter_master
        ! Warning: `flutter` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision e25eabd263 (81 minutes ago), 2023-06-08 18:57:25 -0700
        • Engine revision a5f7d5d75f
        • Dart version 3.1.0 (build 3.1.0-171.0.dev)
        • DevTools version 2.24.0
        • 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 32.0.0)
        • Android SDK at /Users/huynq/Library/Android/sdk
        • Platform android-33, build-tools 32.0.0
        • ANDROID_HOME = /Users/huynq/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.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14E222b
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] 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.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.66.0
    
    [✓] Connected device (3 available)
        • Pixel 3a (mobile) • 964AY0WL20 • android-arm64  • Android 12 (API 32)
        • macOS (desktop)   • macos      • darwin-x64     • macOS 13.0.1 22A400 darwin-x64
        • Chrome (web)      • chrome     • web-javascript • Google Chrome 114.0.5735.106
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
  3. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    a: error messageError messages from the Flutter framework
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Jun 9, 2023
  4. added a commit that references this issue on Jun 22, 2023
    0da8012
  5. github-actions commented on Jul 6, 2023

    @github-actions

    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.

  6. locked as resolved and limited conversation to collaborators on Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: error messageError messages from the Flutter frameworkfound in release: 3.10Found to occur in 3.10found in release: 3.12Found to occur in 3.12frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions