Flutter - showSlidingBottomSheet initial snap not occurring

Viewed 120

I'm working on a Flutter app where a user can tap a button and it will present a bottom sheet where they can drag & snap it to a couple of locations or drag it completely down to dismiss.

This sheet will have a custom header & footer and the body contents will vary. There may be an empty state or there'll be data they can scroll through.

I'm having issues getting this to always default to my initial snap. If I am in an empty state then my bottom sheet is smaller. I've also had it to where I can see my data & scroll through it but the sheet still didn't snap.

Right now I'm just trying to get the core of this working right. So right now my body is just an empty Container with some color.

All I see when I present this though is just the header & the footer.

I'm using sliding_sheet: ^0.5.2

Here's what I've tried:

Future showSheet(context) => showSlidingBottomSheet(
        context,
        useRootNavigator: true,
        builder: (context) => SlidingSheetDialog(
          duration: Duration(milliseconds: 200),
          avoidStatusBar: true,
          backdropColor: Colors.transparent,
          color: Colors.black,
          snapSpec: SnapSpec(
            initialSnap: 0.65,
            snappings: [0.65, 0.9],
          ),
          builder: buildChild,
          headerBuilder: _buildHeader,
          footerBuilder: _buildFooter,
        ),
      );

Widget buildChild(BuildContext context, SheetState state) {
    return Expanded(
      child: SingleChildScrollView(
        child: ConstrainedBox(
          constraints: BoxConstraints(),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              Container(
                color: Colors.blue,
              ),
            ],
          ),
        ),
      ),
    );
  }
0 Answers
Related