Search packages, repositories and app categories

Package detailsv1.0.0

sliver_fab

A wrapper widget allowing to place a widget on the edge of FlexibleSpacebar

30-day downloads
1.2K
Likes
76
Pub points
40

Install package

flutter pub add sliver_fab

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The sliver_fab package provides a wrapper widget that enables placing a floating action button (FAB) or any other widget at the edge of a FlexibleSpaceBar in Flutter. It is designed to work seamlessly within a CustomScrollView, allowing precise positioning of UI elements relative to the scrollable content. This enhances the visual and interactive experience when using complex app bars with parallax effects. The package is lightweight and focused on solving a specific layout challenge in modern Flutter apps.

Use cases

  • Positioning FABs near the edge of a collapsible app bar
  • Creating visually cohesive scrollable interfaces
  • Enhancing user interaction with fixed-position widgets
  • Integrating widgets into FlexibleSpaceBar layouts
  • Designing responsive app bars with dynamic behavior

Key features

  • Precise edge placement of widgets
  • Compatibility with CustomScrollView
  • Support for FlexibleSpaceBar integration
  • Minimal performance overhead
  • Simple API for common use cases

Suitable for

  • Developers building material design apps with custom app bars
  • Teams implementing scroll-driven UIs with floating elements
  • Projects requiring elegant FAB positioning in scrollable views

Considerations

  • Limited to use within CustomScrollView contexts
  • Does not support non-edge placements
  • Requires understanding of sliver widgets and layout constraints
  • May need additional styling for complex animations

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

sliver_fab

A wrapper widget allowing to place a widget on the edge of FlexibleSpacebar.

gif

gif

Example usage

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new Builder(
        builder: (context) =>
        new SliverFab(
          floatingWidget: FloatingActionButton(
            onPressed: () =>
                Scaffold.of(context).showSnackBar(
                    SnackBar(content: Text("You clicked FAB!"))),
            child: Icon(Icons.add),
          ),
          floatingPosition: FloatingPosition(right: 16),
          expandedHeight: 256.0,
          slivers: <Widget>[
            new SliverAppBar(
              expandedHeight: 256.0,
              pinned: true,
              flexibleSpace: new FlexibleSpaceBar(
                title: new Text("SliverFab Example"),
                background: new Image.asset(
                  "img.jpg",
                  fit: BoxFit.cover,
                ),
              ),
            ),
            new SliverList(
              delegate: new SliverChildListDelegate(
                new List.generate(
                  30,
                      (int index) =>
                  new ListTile(title: new Text("Item $index")),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Installing

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  sliver_fab: "^1.0.0"

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

Alternatively, your editor might support packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:sliver_fab/sliver_fab.dart';

Contributing

This package was made mostly for use case I needed. If you fill it is missing any features or you have found a bug, pull requests are very welcome!

Categories

Source repository

Projects using this package