Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
yusukeinouehatchout committed Dec 29, 2020
2 parents 4dffb71 + 3459ec9 commit 266df8f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 1.3.1
- Cannot use the same id

# 1.3.0
- Get id by scroll position
- To set ScrollController
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ You should add the following to your `pubspec.yaml` file:

```yaml
dependencies:
scroll_to_id: ^1.3.0
scroll_to_id: ^1.3.1
```
## Getting Started
Expand All @@ -22,9 +22,14 @@ To start, import the dependency in your code:
import 'package:scroll_to_id/scroll_to_id.dart';
```

Next, to create instance:
Next, to define ScrollController:
```dart
final ScrollToId scrollToId = ScrollToId();
final scrollController = ScrollController();
```

Next, to create instance with ScrollController:
```dart
ScrollToId scrollToId = ScrollToId(scrollController: scrollController);
```

Next, to set InteractiveScrollViewer and ScrollContent:
Expand Down Expand Up @@ -54,6 +59,7 @@ InteractiveScrollViewer(
```

id property is destination of scroll.
Do not use the same id.

Next, to scroll to id:

Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.2.1"
version: "1.3.0"
sky_engine:
dependency: transitive
description: flutter
Expand Down
7 changes: 7 additions & 0 deletions lib/src/interactive_scroll_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class InteractiveScrollViewer extends StatefulWidget {
}

class _InteractiveScrollViewerState extends State<InteractiveScrollViewer> {
List<String> _idList = [];

@override
void initState() {
super.initState();
Expand All @@ -33,6 +35,11 @@ class _InteractiveScrollViewerState extends State<InteractiveScrollViewer> {

/// Convert ScrollContent to ScrollContentWithKey
for (ScrollContent scrollContents in widget.children) {
if (_idList.contains(scrollContents.id)) {
throw Exception('Do not use the same id');
} else {
_idList.add(scrollContents.id);
}
widget.scrollToId.scrollContentsList
.add(ScrollContentWithKey.fromWithout(scrollContents));
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: scroll_to_id
description: scroll_to_id is a Flutter library that enables screen to auto-scroll by selecting id defined for each widget in scrollview.
version: 1.3.0
version: 1.3.1
homepage: https://github.com/yusukeinouehatchout/scroll_to_id

environment:
Expand Down

0 comments on commit 266df8f

Please sign in to comment.