I am new to flutter development and trying to make a horizontal navigation bar that sticks to the top of the page when scrolling. I have worked out that I need to use a customScrollView with Slivers and have installed sliver_tools but I believe I have bitten off more than I can chew with my design.
My design consists of a medium sliver app bar displaying a few icons and a title. Then an image with the horizontal navigation positioned to the bottom of the image. (image can be seen below)
Any help with getting the navigation overlaying the bottom of the image and sticky would be amazing. P.S. Any help with moving the pink bar under the selected navigation page would also be amazing
This is my clostest attempt to getting this working but of course, I am no way near.
import 'package:find_your_event/models/festival.dart';
import 'package:flutter/material.dart';
import 'package:sliver_tools/sliver_tools.dart';
class FestivalInformation extends StatelessWidget {
const FestivalInformation({required this.festival, super.key});
final Festival festival;
@override
Widget build(BuildContext context) {
return CustomScrollView(
slivers: [
SliverAppBar.medium(
pinned: true,
title: Text(festival.name),
),
MultiSliver(
pushPinnedChildren: true,
children: [
SliverToBoxAdapter(
child: Stack(
children: [
Image(
image: NetworkImage(festival.bannerURL),
),
SliverPinnedHeader(key: ValueKey('header'), child: Text('About')),
],
),
),
SliverList(
delegate: SliverChildListDelegate(
[
Image(image: NetworkImage(festival.bannerURL)),
Container(
height: 900,
color: Colors.white,
)
],
),
),
],
),
],
);
}
}
You can simply use the
CustomSrollView
withSliverAppBar
with pinned property set to true and having a background image & a bottom child containingTabbar
widget which will stick to the top when scrolled. See this minimal example code on dartpad.