diff --git a/scroll_app_bar/README.md b/scroll_app_bar/README.md index 7e4de68..cf76fd9 100644 --- a/scroll_app_bar/README.md +++ b/scroll_app_bar/README.md @@ -33,6 +33,10 @@ First, you need a `ScrollController` instance. final controller = ScrollController(); ``` +This controller is required in order to get the main functionality of this package. +You need to pass it on `ScrollAppBar`'s controller and inside your `ListView`, also in +controller property. Without this, you'll get an ordinary App Bar. + Now, you can use the `ScrollAppBar` widget in a `Scaffold` widget, and attach `ScrollController` instance in your scrollable main widget. > **_NOTE:_** Showing only essencial code. See [example](#example) section to a complete implementation. @@ -42,11 +46,11 @@ Now, you can use the `ScrollAppBar` widget in a `Scaffold` widget, and attach `S Widget build(BuildContext context) { Scaffold( appBar: ScrollAppBar( - controller: controller, + controller: controller, // Note the controller here title: Text("App Bar"), ), body: ListView.builder( - controller: controller, + controller: controller, // Controller is also here itemBuilder: ..., ), ); @@ -62,13 +66,13 @@ To enable the snap behavior, you need just wrap the main scrollable widget with Widget build(BuildContext context) { Scaffold( appBar: ScrollAppBar( - controller: controller, + controller: controller, // Note the controller here title: Text("App Bar"), ), body: Snap( controller: controller.appBar, child: ListView.builder( - controller: controller, + controller: controller, // Controller is also here itemBuilder: ..., ), ), @@ -109,6 +113,13 @@ controller.appBar.dispose(); Please see [CHANGELOG](./CHANGELOG.md) for more information on what has changed recently. +## Troubleshooting + +### My AppBar doesn't move like intended + +Have you assigned the `ScrollController` to the controller property of `ScrollAppBar` and inside +your `ListView`? This is required in order to get the main functionality. + ## Contributing Please send feature requests and bugs at the issue tracker. @@ -120,4 +131,4 @@ Please send feature requests and bugs at the issue tracker. ## License -BSD 3-Clause License. Please see [License File](./LICENSE) for more information. \ No newline at end of file +BSD 3-Clause License. Please see [License File](./LICENSE) for more information. diff --git a/scroll_app_bar/example/lib/main.dart b/scroll_app_bar/example/lib/main.dart index 97714ac..4aab557 100644 --- a/scroll_app_bar/example/lib/main.dart +++ b/scroll_app_bar/example/lib/main.dart @@ -6,20 +6,20 @@ import 'package:scroll_app_bar/scroll_app_bar.dart'; void main() => runApp(App()); class App extends StatelessWidget { - final controller = ScrollController(); + final controller = ScrollController(); // Controller is required @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: ScrollAppBar( - controller: controller, + controller: controller, // Note the controller here title: Text("App Bar"), ), body: Snap( controller: controller.appBar, child: ListView.builder( - controller: controller, + controller: controller, // Controller is also here itemBuilder: _listBuildItem, ), ),