stryder-dev / flutter_platform_widgets

Target the specific design of Material for Android and Cupertino for iOS widgets through a common set of Platform aware widgets
MIT License
1.59k stars 173 forks source link

Feature request: PlatformSliverAppBar (SliverAppBar / CupertinoSliverNavigationBar) #425

Open jhonatn opened 1 year ago

jhonatn commented 1 year ago

Is it possible for us to have a Platform widget for SliverAppBar (material) and CupertinoSliverNavigationBar?

JaidynBluesky commented 10 months ago

I had to make my own; this was taken from one of the examples in the repo though:

class LargeAppBarWrapper extends StatelessWidget {
  const LargeAppBarWrapper({
    super.key,
    required this.title,
    required this.children,
  });

  final String title;
  final List<Widget> children;

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    return PlatformScaffold(
      iosContentPadding: true,
      body: CustomScrollView(
        slivers: [
          PlatformWidget(
            material: (context, _) => SliverAppBar.medium(
              backgroundColor: theme.appBarTheme.backgroundColor,
              title: Text(
                title,
              ),
            ),
            cupertino: (context, _) => CupertinoSliverNavigationBar(
              largeTitle: Text(
                title,
              ),
            ),
          ),
          SliverSafeArea(
            top: false,
            sliver: SliverList(
              delegate: SliverChildListDelegate(children),
            ),
          ),
        ],
      ),
    );
  }
}