Skip to content

No error message when SliverOverlapAbsorber is omitted  #128074

@Piinks

Description

@Piinks

The SliverOverlapAbsorber and SliverOverlapInjector are meant to be used together in the NestedScrollView. If a developer inserts a SliverOverlapInjector into the body of a NestedScrollView and does not make use of a SliverOverlapAbsorber, then the app crashes without a helpful error message:

Null check operator used on a null value

image

This is very hard to understand why and how to fix. 🙃

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: NestedScrollView(
          headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
            return <Widget>[
              const SliverAppBar(),
            ];
          },
          body: Builder(builder: (BuildContext context) {
            return CustomScrollView(
              slivers: <Widget>[
                SliverOverlapInjector(
                  handle:
                      NestedScrollView.sliverOverlapAbsorberHandleFor(context),
                ),
              ],
            );
          }),
        ),
      ),
    );
  }
}

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: error messageError messages from the Flutter frameworka: qualityA truly polished experiencef: scrollingViewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.waiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions