Skip to content

Got An Issue With SliverAppBar 'needsCompositing': is not true. #135486

@AnkitFlutterDev

Description

@AnkitFlutterDev

Is there an existing issue for this?

Steps to reproduce

I have implimanted SliverAppBar with CustomScrollView,in sometime(like once in 30)whenever i tried to navigate that page and tried to scroll i got ERROR:

══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during paint():
'package:flutter/src/material/flexible_space_bar.dart': Failed assertion: line 464 pos 12:
'needsCompositing': 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.yml

The relevant error-causing widget was:
  FlexibleSpaceBar 

Expected results

Got the Expected result,the problem is i got error inside Debug console,UI works smoothly

Actual results

Got the Expected result,the problem is i got error inside Debug console,UI works smoothly

Code sample

Code

@override
  Widget build(BuildContext context) {
    return Consumer<ArticalProvider>(
      builder: (context, articalP, child) {
        return articalP.isLoading || articalP.articalData == null
            ? Scaffold(body: Center(child: CircularProgressIndicator()))
            : Builder(builder: (context) {
                final articalData = articalP.articalData!;
                final category = articalData.category;
                return Scaffold(
                    floatingActionButtonLocation:
                        FloatingActionButtonLocation.centerDocked,
                    floatingActionButton: _floatingButton(context, widget.id),
                    body: CustomScrollView(
                      controller: _scrollController,
                      physics: BouncingScrollPhysics(),
                      slivers: <Widget>[
                        SliverAppBar(
                          shadowColor: color00.withOpacity(.25),
                          pinned: true,
                          snap: false,
                          floating: false,
                          flexibleSpace: FlexibleSpaceBar(
                            background: MyCachedNetworkWidget(
                                imageUrl: articalData.thumbnailImage),
                          ),
                          expandedHeight: 308,
                          backgroundColor: primaryColor,
                          leading: IconButton(
                              onPressed: () {
                                Navigator.pop(context);
                              },
                              icon: Icon(Icons.arrow_back)),
                          title: Transform.translate(
                            offset: Offset(-20, 0),
                            child: Text(articalData.title, style: whiteBold18),
                          ),
                          actions: <Widget>[
                            Transform.translate(
                              offset: Offset(10, 0),
                              child: IconButton(
                                  onPressed: () {},
                                  icon: Icon(
                                    Icons.share_outlined,
                                    color: white,
                                  )),
                            ),
                            Consumer<BookmarkProvider>(
                              builder: (context, bookmarkP, child) =>
                                  IconButton(
                                      onPressed: () => Functionality.bookMark(
                                          context: context, id: widget.id),
                                      icon: Icon(
                                        bookmarkP.isBookmarked(widget.id)
                                            ? Icons.bookmark_outlined
                                            : Icons.bookmark_outline,
                                        color: white,
                                      )),
                            )
                          ],
                        ),
                        SliverList(
                            delegate: SliverChildListDelegate([
                          ListView(
                            shrinkWrap: true,
                            physics: NeverScrollableScrollPhysics(),
                            padding: EdgeInsets.zero,
                            children: [
                              Padding(
                                padding: const EdgeInsets.all(20)
                                    .copyWith(bottom: 0),
                                child: Column(
                                  children: [
                                    IntrinsicHeight(
                                      child: Row(
                                        children: [
                                          Container(
                                              width: vDividerSize,
                                              color: secColor),
                                          widthSpace10,
                                          Expanded(
                                            child: Text(articalData.title,
                                                style: blackSemiBold16),
                                          ),
                                        ],
                                      ),
                                    ),
                                    heightSpace5,
                                    Row(
                                      children: [
                                        MyCachedNetworkWidget(
                                          imageUrl: category.image,
                                          height: 2.15.h,
                                          width: 2.h,
                                        ),
                                        Padding(
                                          padding: const EdgeInsets.symmetric(
                                              horizontal: 5),
                                          child: Text(category.name,
                                              style: color94Medium14),
                                        ),
                                        Image.asset(clockIcon,
                                            height: IconSize.tiny),
                                        Padding(
                                          padding: const EdgeInsets.symmetric(
                                              horizontal: 5),
                                          child: Text(
                                              formatTimeAgo(
                                                  articalData.createdAt),
                                              style: color94Medium14),
                                        ),
                                        Image.asset(viewIcon,
                                            height: IconSize.tiny),
                                        Padding(
                                          padding: const EdgeInsets.symmetric(
                                              horizontal: 5),
                                          child: Text(
                                              '${articalData.viewCount} view',
                                              style: color94Medium14),
                                        ),
                                      ],
                                    ),
                                    heightSpace20,
                                    HtmlWidget(articalData.description),
                                    heightSpace20,
                                  ],
                                ),
                              ),
                              ..._relatedNews(articalP)
                            ],
                          )
                        ]))
                      ],
                    ));
              });
      },
    );
  }

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Log

══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during paint():
'package:flutter/src/material/flexible_space_bar.dart': Failed assertion: line 464 pos 12:
'needsCompositing': 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.yml

The relevant error-causing widget was:
  FlexibleSpaceBar
  FlexibleSpaceBar:file:///Users/ankitthummar/Desktop/fl_news_feed/lib/pages/home/artical_detail/image_artical.dart:62:42

When the exception was thrown, this was the stack:
#2      _RenderFlexibleSpaceHeaderOpacity.paint (package:flutter/src/material/flexible_space_bar.dart:464:12)
flexible_space_bar.dart:464
#3      RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:3155:7)
object.dart:3155
#4      PaintingContext.paintChild (package:flutter/src/rendering/object.dart:252:13)
object.dart:252
#5      RenderBoxContainerDefaultsMixin.defaultPaint (package:flutter/src/rendering/box.dart:2875:15)
box.dart:2875
#6      RenderStack.paintStack (package:flutter/src/rendering/stack.dart:639:5)
stack.dart:639
#7      PaintingContext.pushClipRect.<anonymous closure> (package:flutter/src/rendering/object.dart:535:83)
object.dart:535
#8      ClipContext._clipAndPaint (package:flutter/src/painting/clip.dart:25:12)
clip.dart:25
#9      ClipContext.clipRectAndPaint (package:flutter/src/painting/clip.dart:53:5)
clip.dart:53
#10     PaintingContext.pushClipRect (package:flutter/src/rendering/object.dart:535:7)
object.dart:535
#11     RenderStack.paint (package:flutter/src/rendering/stack.dart:645:38)
stack.dart:645
#12     RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:3155:7)
object.dart:3155
#13     PaintingContext.paintChild (package:flutter/src/rendering/object.dart:252:13)
object.dart:252
#14     RenderProxyBoxMixin.paint (package:flutter/src/rendering/proxy_box.dart:129:13)
proxy_box.dart:129
#15     PaintingContext.pushClipRect.<anonymous closure> (package:flutter/src/rendering/object.dart:535:83)
object.dart:535
#16     ClipContext._clipAndPaint (package:flutter/src/painting/clip.dart:25:12)
clip.dart:25
#17     ClipContext.clipRectAndPaint (package:flutter/src/painting/clip.dart:53:5)
clip.dart:53
#18     PaintingContext.pushClipRect (package:flutter/src/rendering/object.dart:535:7)
object.dart:535
#19     RenderClipRect.paint (package:flutter/src/rendering/proxy_box.dart:1530:25)
proxy_box.dart:1530
#20     RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:3155:7)
object.dart:3155
#21     PaintingContext.paintChild (package:flutter/src/rendering/object.dart:252:13)
object.dart:252
#22     _RenderLayoutBuilder.paint (package:flutter/src/widgets/layout_builder.dart:338:15)
layout_builder.dart:338
#23     RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:3155:7)
object.dart:3155
#24     PaintingContext.paintChild (package:flutter/src/rendering/object.dart:252:13)
object.dart:252
#25     RenderProxyBoxMixin.paint (package:flutter/src/rendering/proxy_box.dart:129:13)
proxy_box.dart:129
#26     RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:3155:7)
object.dart:3155
#27     PaintingContext.paintChild (package:flutter/src/rendering/object.dart:252:13)
object.dart:252
#28     RenderBoxContainerDefaultsMixin.defaultPaint (package:flutter/src/rendering/box.dart:2875:15)
box.dart:2875

Flutter Doctor output

flutter doctor -v


[✓] Flutter (Channel stable, 3.13.2, on macOS 13.5.1 22G90 darwin-arm64, locale
    en-IN)
    • Flutter version 3.13.2 on channel stable at /Users/ankitthummar/Flutter
      Install/Flutter 3.13.2/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ff5b5b5fa6 (5 weeks ago), 2023-08-24 08:12:28 -0500
    • Engine revision b20183e040
    • Dart version 3.1.0
    • DevTools version 2.25.0

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

[✓] Connected device (3 available)
    • iPhone 14 Pro Max (mobile) • 72B79D2F-D187-4C2F-B4B6-DB5E73BFA232 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
    • macOS (desktop)            • macos                                • darwin-arm64   • macOS 13.5.1 22G90 darwin-arm64
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 117.0.5938.92

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

• No issues found!
ankitthummar@192 ~ % 

Metadata

Metadata

Assignees

No one assigned

    Labels

    r: solvedIssue is closed as solved

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions