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

[BUG] showFlexibleBottomSheet How to add header #96

Closed
zhaoxiuyu opened this issue Feb 27, 2024 · 1 comment
Closed

[BUG] showFlexibleBottomSheet How to add header #96

zhaoxiuyu opened this issue Feb 27, 2024 · 1 comment
Labels
bug Something isn't working new issues

Comments

@zhaoxiuyu
Copy link

showFlexibleBottomSheet How to add header

@zhaoxiuyu zhaoxiuyu added the bug Something isn't working label Feb 27, 2024
@internetova
Copy link
Collaborator

@zhaoxiuyu
Hi! show Flexible Bottom Sheet does not have a separate header creation. If you need a header, make it yourself when creating the bottom sheet content. For example, you can use Scaffold and App Bar.

class _BottomSheet extends StatelessWidget {
  final ScrollController scrollController;
  final double bottomSheetOffset;

  const _BottomSheet({
    required this.scrollController,
    required this.bottomSheetOffset,
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Header'),
        automaticallyImplyLeading: false,
      ),
      body: ListView(
        padding: const EdgeInsets.all(16),
        controller: scrollController,
        children: [
          Text(
            'position $bottomSheetOffset',
            style: Theme.of(context).textTheme.titleLarge,
          ),
          Column(
            children: _children,
          ),
        ],
      ),
    );
  }
}
2024-03-25.13.33.50.mov

You can create a separate header from the showStickyFlexibleBottomSheet:

void _showWithHeader() {
    showStickyFlexibleBottomSheet<void>(
      minHeight: 0,
      initHeight: 0.5,
      maxHeight: 0.8,
      headerHeight: 100,
      context: context,
      bottomSheetColor: Colors.teal,
      bottomSheetBorderRadius: const BorderRadius.only(
        topLeft: Radius.circular(40),
        topRight: Radius.circular(40),
      ),
      headerBuilder: (context, offset) {
        return DecoratedBox(
          decoration: const BoxDecoration(color: Colors.yellow),
          child: Center(
            child: Text(
              'Header',
              style: Theme.of(context).textTheme.headlineMedium,
            ),
          ),
        );
      },
      bodyBuilder: (context, offset) {
        return SliverChildListDelegate(List.generate(
          40,
          (index) => Text('Item $index'),
        ));
      },
    );
  }
2024-03-25.13.27.48.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working new issues
Projects
None yet
Development

No branches or pull requests

3 participants