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

Null check operator used on a null value #10

Open
YAPEIZG opened this issue Jan 28, 2021 · 2 comments
Open

Null check operator used on a null value #10

YAPEIZG opened this issue Jan 28, 2021 · 2 comments

Comments

@YAPEIZG
Copy link

YAPEIZG commented Jan 28, 2021

I am getting this Error:

The following _CastError was thrown during performLayout():
Null check operator used on a null value

The relevant error-causing widget was
Parallax
When the exception was thrown, this was the stack
#0      RenderSliverMultiBoxAdaptor.childMainAxisPosition
#1      RenderSliverHelpers.applyPaintTransformForBoxChild
#2      RenderSliverMultiBoxAdaptor.applyPaintTransform
#3      RenderObject.getTransformTo
#4      RenderBox.localToGlobal
...
The following RenderObject was being processed when the exception was fired: RenderParallaxSingleChildLayoutBox#a29ec NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
RenderObject: RenderParallaxSingleChildLayoutBox#a29ec NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
    parentData: <none> (can use size)
    constraints: BoxConstraints(w=428.0, h=130.0)
    size: Size(428.0, 130.0)
    child: RenderSemanticsAnnotations#bb227 relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
        parentData: offset=Offset(0.0, 0.0) (can use size)
        constraints: BoxConstraints(w=428.0, 0.0<=h<=Infinity)
        size: Size(428.0, 149.5)
        child: RenderImage#ae8ff relayoutBoundary=up2 NEEDS-PAINT
            parentData: <none> (can use size)
            constraints: BoxConstraints(w=428.0, 0.0<=h<=Infinity)
            size: Size(428.0, 149.5)
            image: [750×262]
            alignment: center
            invertColors: false
            filterQuality: low
@elmobark
Copy link

@letsar @YAPEIZG i think this project is dead the creator is not answering , so the best thing to do is to fork the project and fix the problem b your self :(

@Gastrolize
Copy link

Gastrolize commented Jul 20, 2021

change in file rendering/parallax.dart the method getChildScrollRatio into:

 @override
  double getChildScrollRatio(
      Offset offsetUnit, double childExtent, RenderBox renderBox) {
    final RenderAbstractViewport viewport =
        RenderAbstractViewport.of(renderBox);
    assert(viewport != null);


    assert(renderBox != null);
    final ScrollPosition position = controller.position;
    assert(position != null);
    final bool isHorizontalAxis = (position.axis == Axis.horizontal);


    final Offset localPositionOffset = isHorizontalAxis
        ? new Offset(mainAxisExtent, 0.0)
        : new Offset(0.0, mainAxisExtent);//offsetUnit * mainAxisExtent;

    assert(localPositionOffset != null);
    Offset positionInViewport;
    try{
      positionInViewport = renderBox.localToGlobal(localPositionOffset, ancestor: viewport);
    } catch(e,s){

    }
    if(positionInViewport == null){
      return 0;
    }

    // One dimension should be 0.0, so this should be ok.
    final double distanceFromLeading =
        math.max(positionInViewport.dx, positionInViewport.dy);
    assert(distanceFromLeading != null);
    double scrollRatio = distanceFromLeading /
        (controller.position.viewportDimension + mainAxisExtent);
    return scrollRatio;
  }

This Error appears when the Widget is building and the method trys to access the viewport.
This should fix and return 0 while building the widget.

geoextra added a commit to geoextra/flutter_parallax that referenced this issue Jun 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants