Skip to content

"fastLinearToSlowEaseIn" Curve in PageController Causes a Rendering Error in PageView on Android 11 emulator  #72278

@JMooreo

Description

@JMooreo

The following assertion was thrown during performLayout():

'package:flutter/src/rendering/sliver_fixed_extent_list.dart': Failed assertion: line 279 pos 12: 'firstIndex == 0 || childScrollOffset(firstChild!)! - scrollOffset <= precisionErrorTolerance': is not true.

Here is the full error message:

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=BUG.md

The relevant error-causing widget was
PageView
lib\screens\page_view_screen.dart:58
When the exception was thrown, this was the stack
#2      RenderSliverFixedExtentBoxAdaptor.performLayout
package:flutter/…/rendering/sliver_fixed_extent_list.dart:279
#3      RenderObject.layout
package:flutter/…/rendering/object.dart:1777
#4      RenderSliverEdgeInsetsPadding.performLayout
package:flutter/…/rendering/sliver_padding.dart:132
#5      _RenderSliverFractionalPadding.performLayout
package:flutter/…/widgets/sliver_fill.dart:170
#6      RenderObject.layout
package:flutter/…/rendering/object.dart:1777

The following RenderObject was being processed when the exception was fired: RenderSliverFillViewport#59dca relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-COMPOSITING-BITS-UPDATE
RenderObject: RenderSliverFillViewport#59dca relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-COMPOSITING-BITS-UPDATE
    needs compositing
    parentData: paintOffset=Offset(0.0, 0.0) (can use size)
    constraints: SliverConstraints(AxisDirection.right, GrowthDirection.forward, ScrollDirection.idle, scrollOffset: 785.5, remainingPaintExtent: 392.7, crossAxisExtent: 751.3, crossAxisDirection: AxisDirection.down, viewportMainAxisExtent: 392.7, remainingCacheExtent: 392.7, cacheOrigin: 0.0)
    geometry: SliverGeometry(scrollExtent: 1178.2, paintExtent: 392.7, maxPaintExtent: 1178.2, hasVisualOverflow: true, cacheExtent: 392.7)
        scrollExtent: 1178.2
        paintExtent: 392.7
        maxPaintExtent: 1178.2
        hasVisualOverflow: true
        cacheExtent: 392.7
    currently live children: 2 to 2
    child with index 2: RenderIndexedSemantics#e64a1
        needs compositing
        parentData: index=2; layoutOffset=785.5
        constraints: BoxConstraints(w=392.7, h=751.3)
        semantic boundary
        size: Size(392.7, 751.3)
        index: 2
        child: RenderRepaintBoundary#5303d
            needs compositing
            parentData: <none> (can use size)
            constraints: BoxConstraints(w=392.7, h=751.3)

Here is some relevant code that causes the issue:

import 'package:flutter/material.dart';

class PageViewScreen extends StatefulWidget {
  @override
  _PageViewScreenState createState() => _PageViewScreenState();
}

class _PageViewScreenState extends State<PageViewScreen> {
  final PageController _controller = PageController();
  final List<Widget> screens = [
    Screen1(),
    Screen2(),
    Screen3(),
  ];

  void nextPage() {
    _controller.nextPage(
      duration: const Duration(
        milliseconds: 200,
      ),
      curve: Curves.fastLinearToSlowEaseIn,
    );
  }

  void prevPage() {
    _controller.previousPage(
      duration: const Duration(
        milliseconds: 200,
      ),
      curve: Curves.fastLinearToSlowEaseIn,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: PageView.builder(
        physics: NeverScrollableScrollPhysics(),
        controller: _controller,
        itemCount: screens.length,
        itemBuilder: (ctx, index) => GestureDetector(
          onHorizontalDragEnd: (details) {
            if (details.primaryVelocity.isNegative) {
              nextPage();
            } else {
              prevPage();
            }
          },
          child: screens[index],
        ),
      ),
    );
  }
}

Emulator Details:

  • Name: Pixel 3a API 30
  • Resolution: 1080 x 2220: 440 dpi
  • Target: Android 11.0

An Alternative That Works Properly

  • Change Curves.fastLinearToSlowEaseIn to Curves.linearToEaseOut

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: animationAnimation APIsc: crashStack traces logged to the consolef: scrollingViewports, list views, slivers, etc.found in release: 1.22Found to occur in 1.22found in release: 1.24Found to occur in 1.24found in release: 1.25Found to occur in 1.25frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyr: duplicateIssue is closed as a duplicate of an existing issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions