Skip to content

Commit

Permalink
Merge pull request #2 from pedrolemoz/master
Browse files Browse the repository at this point in the history
Updated README and example with information about the controller
  • Loading branch information
edsonbonfim authored May 12, 2020
2 parents 73a24cb + ef8ad46 commit 16a095e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
21 changes: 16 additions & 5 deletions scroll_app_bar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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: ...,
),
);
Expand All @@ -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: ...,
),
),
Expand Down Expand Up @@ -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.
Expand All @@ -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.
BSD 3-Clause License. Please see [License File](./LICENSE) for more information.
6 changes: 3 additions & 3 deletions scroll_app_bar/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
),
Expand Down

0 comments on commit 16a095e

Please sign in to comment.