TabBarView快速切换导致页面崩溃白屏

Flutter最新修复了这个bug 

https://github.com/flutter/flutter/issues/57662#event-3479331509


https://github.com/flutter/flutter/commit/62378a3755e0cd7cbc20f2c33a068cec51d92dd1

sliver_multi_box_adaptor.dart这个文件里面applyPaintTransform这个方法改为 

@override

void applyPaintTransform(RenderBox child, Matrix4 transform) {

if (_keepAliveBucket.containsKey(indexOf(child))) {

// It is possible that widgets under kept alive children want to paint

// themselves. For example, the Material widget tries to paint all

// InkFeatures under its subtree as long as they are not disposed. In

// such case, we give it a zero transform to prevent them from painting.

    transform.setZero();

  }else {

applyPaintTransformForBoxChild(child, transform);

  }

}

-------------------------------------------

将flutter中TabBar和TabBarView保持状态

https://www.jianshu.com/p/9944bdd17fc9

发现问题任然存在,把TabBarView改为PageView问题解决了



报错如下:

════════ Exception caught by rendering library ═════════════════════════════════════════════════════

The following NoSuchMethodError was thrown during paint():

The method '-' was called on null.

Receiver: null

Tried calling: -(0.0)

The relevant error-causing widget was:

  Scaffold file:///Users/xxxx_page.dart:268:12

When the exception was thrown, this was the stack:

#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)

#1      RenderSliverMultiBoxAdaptor.childMainAxisPosition (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:573:37)

#2      RenderSliverHelpers.applyPaintTransformForBoxChild (package:flutter/src/rendering/sliver.dart:1695:20)

#3      RenderSliverMultiBoxAdaptor.applyPaintTransform (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:586:5)

#4      InkFeature._paint (package:flutter/src/material/material.dart:623:26)

...

The following RenderObject was being processed when the exception was fired: _RenderInkFeatures#723fa relayoutBoundary=up7

...  needs compositing

...  parentData: (can use size)

...  constraints: BoxConstraints(0.0<=w<=360.0, 0.0<=h<=592.0)

...  size: Size(360.0, 592.0)

RenderObject: _RenderInkFeatures#723fa relayoutBoundary=up7

  needs compositing

  parentData: (can use size)

  constraints: BoxConstraints(0.0<=w<=360.0, 0.0<=h<=592.0)

  size: Size(360.0, 592.0)

...  child: RenderCustomMultiChildLayoutBox#44d85 relayoutBoundary=up8 NEEDS-PAINT

...    needs compositing

...    parentData: (can use size)

...    constraints: BoxConstraints(0.0<=w<=360.0, 0.0<=h<=592.0)

...    size: Size(360.0, 592.0)

...    child 1: RenderPadding#11aad relayoutBoundary=up9

...      needs compositing

...      parentData: offset=Offset(0.0, 106.0); id=_ScaffoldSlot.body (can use size)

...      constraints: BoxConstraints(0.0<=w<=360.0, 0.0<=h<=486.0)

...      size: Size(360.0, 486.0)

...      padding: EdgeInsets.zero

...      textDirection: ltr

...      child: RenderRepaintBoundary#7b6b8 relayoutBoundary=up10

...        needs compositing

...        parentData: offset=Offset(0.0, 0.0) (can use size)

...        constraints: BoxConstraints(0.0<=w<=360.0, 0.0<=h<=486.0)

...        layer: OffsetLayer#f7326 DETACHED

...          engine layer: OffsetEngineLayer#c5afe

...          offset: Offset(0.0, 106.0)

...        size: Size(360.0, 486.0)

...        metrics: 98.7% useful (2 bad vs 147 good)

...        diagnosis: this is an outstandingly useful repaint boundary and should definitely be kept

...        child: RenderCustomPaint#8cad4 relayoutBoundary=up11

...          needs compositing

...          parentData: (can use size)

...          constraints: BoxConstraints(0.0<=w<=360.0, 0.0<=h<=486.0)

...          size: Size(360.0, 486.0)

...    child 2: RenderConstrainedBox#a0be4 relayoutBoundary=up9 NEEDS-PAINT

...      needs compositing

...      parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.appBar (can use size)

...      constraints: BoxConstraints(w=360.0, 0.0<=h<=592.0)

...      size: Size(360.0, 106.0)

...      additionalConstraints: BoxConstraints(0.0<=w<=Infinity, 0.0<=h<=106.0)

...      child: RenderSemanticsAnnotations#ef5cc relayoutBoundary=up10 NEEDS-PAINT

...        needs compositing

...        parentData: (can use size)

...        constraints: BoxConstraints(w=360.0, 0.0<=h<=106.0)

...        semantic boundary

...        size: Size(360.0, 106.0)

...        child: RenderAnnotatedRegion#0ca85 relayoutBoundary=up11 NEEDS-PAINT

...          needs compositing

...          parentData: (can use size)

...          constraints: BoxConstraints(w=360.0, 0.0<=h<=106.0)

...          size: Size(360.0, 106.0)

...    child 3: RenderStack#77a60 relayoutBoundary=up9

...      parentData: offset=Offset(344.0, 576.0); id=_ScaffoldSlot.floatingActionButton (can use size)

...      constraints: BoxConstraints(0.0<=w<=360.0, 0.0<=h<=592.0)

...      size: Size(0.0, 0.0)

...      alignment: centerRight

...      textDirection: ltr

...      fit: loose

...      overflow: clip

...      child 1: RenderTransform#fff78 relayoutBoundary=up10

...        parentData: not positioned; offset=Offset(0.0, 0.0) (can use size)

...        constraints: BoxConstraints(0.0<=w<=360.0, 0.0<=h<=592.0)

...        size: Size(0.0, 0.0)

...        transform matrix: [0] 0.0,0.0,0.0,0.0

[1] 0.0,0.0,0.0,0.0

[2] 0.0,0.0,1.0,0.0

[3] 0.0,0.0,0.0,1.0

...        origin: null

...        alignment: center

...        textDirection: ltr

...        transformHitTests: true

...        child: RenderTransform#bc381 relayoutBoundary=up11

...          parentData: (can use size)

...          constraints: BoxConstraints(0.0<=w<=360.0, 0.0<=h<=592.0)

...          size: Size(0.0, 0.0)

...          transform matrix: [0] 0.7,0.7,0.0,0.0

[1] -0.7,0.7,0.0,0.0

[2] 0.0,0.0,1.0,0.0

[3] 0.0,0.0,0.0,1.0

...          origin: null

...          alignment: center

...          textDirection: ltr

...          transformHitTests: true

═════════════════════════════════════════════════════

你可能感兴趣的:(TabBarView快速切换导致页面崩溃白屏)