-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Added seek forward and rewind buttons #717
base: master
Are you sure you want to change the base?
Conversation
@punit1111 Thank you for your PR. Please re-sync your changes with the latest changes in |
@diegotori re-sync done please review the PR Thank you |
@maherjaafar requested changes are done. please review the PR Thank you |
lib/src/hit_area_controls.dart
Outdated
SeekRewindButton _buildSeekRewindButton({bool isSeekForward = true}) { | ||
return SeekRewindButton( | ||
backgroundColor: backgroundColor, | ||
iconColor: iconColor, | ||
show: showSeekButton, | ||
onPressed: isSeekForward ? seekForward : seekRewind, | ||
onDoublePressed: isSeekForward ? seekForward : seekRewind, | ||
icon: isSeekForward ? Icons.fast_forward : Icons.fast_rewind, | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use methods to return widgets. Instead you can simply add SeekRewindButton
as part of your Row
children.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
earlier it was inside a Row children. it's extracted into method as changes requested #717 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maherjaafar just an FYI, according to this issue and the official documentation regarding this subject, large Widgets should be spun off into new ones instead of methods that return them.
That way, you'll be able to create them as const
s, thus increasing performance since they won't have to be re-built when build
is called again.
@punit1111 sorry for the extra work, but these widgets should ultimately be extracted as new StatelessWidget
s instead of being computed from a method.
Please let me know if this clears up things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diegotori SeekRewindButton
is already extracted as Stateless Widget lib/src/seek_rewind_button.dart
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@punit1111 that is true, but instead of creating it from _buildSeekRewindButton
, you should just replace those calls with the actual widget:
Change this:
_buildSeekRewindButton(isSeekForward: true),
to this:
SeekRewindButton(
backgroundColor: backgroundColor,
iconColor: iconColor,
show: showSeekButton,
onPressed: seekForward,
onDoublePressed: seekForward,
icon: Icons.fast_forward,
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do likewise for the other places where that method is being called from.
lib/src/seek_rewind_button.dart
Outdated
@@ -0,0 +1,61 @@ | |||
import 'package:flutter/material.dart'; | |||
|
|||
class SeekRewindButton extends StatefulWidget { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be renamed to SeekControlButton
, so that it better reflects its stated purpose.
That way, you can create buttons that just configure that widget for its specific purpose:
class SeekRewindButton extends StatefulWidget {
const SeekRewindButton({
super.key,
required this.backgroundColor,
this.iconColor,
required this.show,
this.onPressed,
this.onDoublePressed,
this.icon = const Icons.fast_rewind,
});
final Color backgroundColor;
final Color? iconColor;
final bool show;
final VoidCallback? onPressed;
final VoidCallback? onDoublePressed;
final IconData icon;
Widget build(BuildContext context) {
return SeekControlButton(
backgroundColor: backgroundColor,
iconColor: iconColor,
show: show,
icon: icon,
onPressed: onPressed,
onDoublePressed: onDoublePressed,
);
}
}
Do likewise for the fast-forward button: (i.e. SeekFastForwardButton
).
lib/src/seek_rewind_button.dart
Outdated
final bool show; | ||
final VoidCallback? onPressed; | ||
final VoidCallback? onDoublePressed; | ||
final IconData? icon; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If required
, make it non-nullable.
Hi @diegotori please review the Changes and let me know if anything needs to be fixed Thank you |
child: CenterPlayButton( | ||
backgroundColor: widget.backgroundColor, | ||
iconColor: widget.iconColor, | ||
isFinished: isFinished, | ||
isPlaying: controller.value.isPlaying, | ||
show: showPlayButton, | ||
onPressed: _playPause, | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cupertino controls already have the seek-forward and rewind buttons in the seek bar (i.e. the ones that rewind and fast-forward by 15 seconds).
As a result, this change should only apply to Material based widgets.
Do this for the other new widgets added in this PR, since they should only apply to Material.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@maherjaafar please give this PR one last look before I can finalize this change. Thanks. |
Hi, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
are there other controls? #715