scroll_app_bar_fork_height 1.0.4 copy "scroll_app_bar_fork_height: ^1.0.4" to clipboard
scroll_app_bar_fork_height: ^1.0.4 copied to clipboard

Hide or show app bar while scrolling. This package works without custom scroll view and slivers.

example/lib/main.dart

import 'dart:math';

import 'package:flutter/material.dart';
import 'package:scroll_app_bar_fork_height/scroll_app_bar_fork_height.dart';

void main() => runApp(App());

class App extends StatefulWidget {
  @override
  _AppState createState() => _AppState();
}

class _AppState extends State<App> {
  final controller = ScrollController();

  bool notification;

  @override
  void initState() {
    super.initState();
    notification = false;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: ScrollAppBar(
          height: 200,
          controller: controller, // Note the controller here
          title: Text("App Bar"),
          backgroundColor: Colors.red, // Will make background transparent
          materialType: MaterialType
              .transparency, // Needed if you want a transparent background
          actions: [
            IconButton(
              icon: Icon(
                notification ? Icons.notifications : Icons.notifications_off,
              ),
              onPressed: () {
                setState(() => notification = !notification);
              },
            ),
          ],
          flexibleSpace: Align(
            alignment: Alignment.bottomLeft,
            child: Text("This is Sub App Bar"),
          ),
        ),
        body: Snap(
          controller: controller.appBar,
          child: ListView.builder(
            controller: controller, // Controller is also here
            itemBuilder: _listBuildItem,
          ),
        ),
      ),
      debugShowCheckedModeBanner: false,
    );
  }

  Widget _listBuildItem(BuildContext context, int index) {
    return Container(
      padding: const EdgeInsets.symmetric(vertical: 50),
      color: Color(Random().nextInt(0xffffffff)),
      child: Center(child: Text("$index")),
    );
  }
}
2
likes
40
pub points
0%
popularity

Publisher

unverified uploader

Hide or show app bar while scrolling. This package works without custom scroll view and slivers.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, scroll_bars_common

More

Packages that depend on scroll_app_bar_fork_height