Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional scroll listener #31

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/src/lyrics_renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class LyricsRenderer extends StatefulWidget {
/// If not defined it will be the italic version of [textStyle]
final TextStyle? commentStyle;

/// Optional external scroll controller, otherwise will be created internally
final ScrollController? scrollController;

const LyricsRenderer(
{Key? key,
required this.lyrics,
Expand All @@ -70,7 +73,8 @@ class LyricsRenderer extends StatefulWidget {
this.scrollPhysics = const ClampingScrollPhysics(),
this.leadingWidget,
this.trailingWidget,
this.chordNotation = ChordNotation.american})
this.chordNotation = ChordNotation.american,
this.scrollController})
: super(key: key);

@override
Expand All @@ -97,7 +101,7 @@ class _LyricsRendererState extends State<LyricsRenderer> {
fontStyle: FontStyle.italic,
fontSize: widget.textStyle.fontSize! - 2,
);
_controller = ScrollController();
_controller = widget.scrollController ?? ScrollController();
WidgetsBinding.instance.addPostFrameCallback((_) {
// executes after build
_scrollToEnd();
Expand Down
Loading