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

FlutterException: Null check operator used on a null value #58

Closed
LGang opened this issue Aug 10, 2022 · 6 comments · Fixed by #60
Closed

FlutterException: Null check operator used on a null value #58

LGang opened this issue Aug 10, 2022 · 6 comments · Fixed by #60

Comments

@LGang
Copy link

LGang commented Aug 10, 2022

Stack:

#0      RenderSliverStack.performLayout (package:sliver_tools/src/rendering/sliver_stack.dart:190)
#1      RenderObject.layout (package:flutter/src/rendering/object.dart:1915)
#2      RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:510)
#3      RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1580)
#4      RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1489)
#5      RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1757)
#6      PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:887)
#7      RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:504)
#8      WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:892)
#9      RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:370)
#10     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1146)
#11     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1083)
#12     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:997)
#13     _rootRun (dart:async/zone.dart:1426)
#14     _CustomZone.run (dart:async/zone.dart:1328)
#15     _CustomZone.runGuarded (dart:async/zone.dart:1236)
#16     _invoke (dart:ui/hooks.dart:151)
#17     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:308)
#18     _drawFrame (dart:ui/hooks.dart:115)
@Kavantix
Copy link
Owner

@LGang can you add some more information on what and when you run into this exception?

@LGang
Copy link
Author

LGang commented Aug 10, 2022

@LGang can you add some more information on what and when you run into this exception?

Online logs are reported up and cannot be reproduced

@LGang
Copy link
Author

LGang commented Aug 10, 2022

Partial code

LoadingMoreCustomScrollView(
                controller: controller.scrollController,
                physics: const ClampingScrollPhysics(),
                cacheExtent: 800,
                slivers: <Widget>[
                  SliverPersistentHeader(
                    delegate: PlaceholderPersistentHeaderDelegate(
                        child: _buildTabBar(0)),
                    floating: true,
                  ),
                  SliverPersistentHeader(
                    delegate: PersistentHeaderDelegate(
                      child: Obx(() => _buildOrderMenu(controller.orderMenus)),
                    ),
                    pinned: true,
                  ),
                  Obx(() => controller.categoryList.isNotEmpty
                      ? SliverToBoxAdapter(
                          child: _buildRecommendSubType(),
                        )
                      : const SliverToBoxAdapter()),
                  SliverStack(
                    children: [
                      SliverPositioned(
                        child: Container(
                          height: 192,
                          decoration: const BoxDecoration(
                            gradient: LinearGradient(
                              begin: Alignment.topCenter,
                              end: Alignment.bottomCenter,
                              colors: [
                                Colors.white,
                                Color(0xFFF7F8FA),
                              ],
                            ),
                          ),
                        ),
                        left: 0,
                        right: 0,
                        top: 0,
                        height: 192,
                      ),
                      Obx(
                        () => LoadingMoreSliverList<GoodsCardModel>(
                          SliverListConfig<GoodsCardModel>(
                            itemBuilder: (BuildContext context,
                                GoodsCardModel viewModel, int index) {
                              return _buildListitemView(viewModel, index);
                            },
                            sourceList: controller.repository,
                            padding: !controller.gridLayout.value
                                ? EdgeInsets.zero
                                : const EdgeInsets.only(
                                    left: 12, right: 12, top: 4),
                            extendedListDelegate: !controller.gridLayout.value
                                ? null
                                : const SliverWaterfallFlowDelegateWithMaxCrossAxisExtent(
                                    maxCrossAxisExtent: 300,
                                    crossAxisSpacing: 7,
                                    mainAxisSpacing: 7,
                                  ),
                          ),
                        ),
                      ),
                    ],
                  ),
                ],
              )

@Kavantix
Copy link
Owner

Which version of sliver_tools are you using?

@LGang
Copy link
Author

LGang commented Aug 11, 2022

Which version of sliver_tools are you using?

0.2.7

@Kavantix
Copy link
Owner

Kavantix commented Sep 4, 2022

@LGang I'v taken a look at what is crashing.
This error means that a sliver child of the SliverStack did not set its geometry after layout, that's not a good thing and not a fault of this package.

I'll add an assert for this case in an upcoming release though!

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

Successfully merging a pull request may close this issue.

2 participants