flutter_stopper 1.0.2 copy "flutter_stopper: ^1.0.2" to clipboard
flutter_stopper: ^1.0.2 copied to clipboard

A bottom sheet that can be expanded to one of the pre-defined stop heights by dragging.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_stopper/stopper.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("Hello")),
      body: Builder(
        builder: (context) {
          final h = MediaQuery.of(context).size.height;
          return Center(
              child: MaterialButton(
            color: Colors.green,
            child: const Text("Show Stopper"),
            onPressed: () {
              showStopper(
                context: context,
                stops: [0.4 * h, h],
                builder: (context, scrollController, scrollPhysics, stop) {
                  return ClipRRect(
                    borderRadius: stop == 0
                        ? const BorderRadius.only(
                            topLeft: Radius.circular(10),
                            topRight: Radius.circular(10),
                          )
                        : const BorderRadius.only(),
                    clipBehavior: Clip.antiAlias,
                    child: Container(
                      color: Colors.orange,
                      child: CustomScrollView(
                        slivers: <Widget>[
                          const SliverAppBar(
                            title: Text("What's Up?"),
                            backgroundColor: Colors.orange,
                            automaticallyImplyLeading: false,
                            primary: false,
                            floating: true,
                            pinned: true,
                          ),
                          SliverList(
                            delegate: SliverChildBuilderDelegate(
                              (context, idx) => ListTile(
                                title: const Text("Nothing much"),
                                subtitle: Text("$idx"),
                              ),
                              childCount: 100,
                            ),
                          )
                        ],
                        controller: scrollController,
                        physics: scrollPhysics,
                      ),
                    ),
                  );
                },
              );
            },
          ));
        },
      ),
    );
  }
}
1
likes
90
points
52
downloads

Publisher

unverified uploader

Weekly Downloads

A bottom sheet that can be expanded to one of the pre-defined stop heights by dragging.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_stopper