Skip to content

Commit 62035af

Browse files
committed
Merge commit '68064248428713d75125cd758701eaa34b660766' into custom-lg
* commit '68064248428713d75125cd758701eaa34b660766': chewie, version 1.10.0. Addresses Issue fluttercommunity#618. refactor: fixed formatting and made onTap not null refactor: removed unused parameter refactor: refactored fix: added _buildOptions fix: fixed closing when options are opened
2 parents 4c49feb + 6806424 commit 62035af

File tree

8 files changed

+25
-14
lines changed

8 files changed

+25
-14
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [1.10.0]
2+
* [#871](https://github.com/fluttercommunity/chewie/pull/871): Fixed pop the wrong page when changing the speed. Thanks [akmalova](https://github.com/akmalova).
3+
* **BREAKING CHANGES**:
4+
* `OptionItem.onTap` now takes in a `BuildContext`.
5+
* `OptionItem`'s properties are now marked as `final`. Use `copyWith` to mutate its properties into
6+
a new instance.
7+
18
## [1.9.2]
29
* Fixed broken Table of Contents links in `README.md`, take two.
310

example/lib/app/app.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class _ChewieDemoState extends State<ChewieDemo> {
127127
additionalOptions: (context) {
128128
return <OptionItem>[
129129
OptionItem(
130-
onTap: toggleVideo,
130+
onTap: (context) => toggleVideo(),
131131
iconData: Icons.live_tv_sharp,
132132
title: 'Toggle Video Src',
133133
),

lib/src/cupertino/widgets/cupertino_options_dialog.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class _CupertinoOptionsDialogState extends State<CupertinoOptionsDialog> {
2424
actions: widget.options
2525
.map(
2626
(option) => CupertinoActionSheetAction(
27-
onPressed: () => option.onTap!(),
27+
onPressed: () => option.onTap(context),
2828
child: Text(option.title),
2929
),
3030
)

lib/src/material/material_controls.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ class _MaterialControlsState extends State<MaterialControls>
162162
);
163163
}
164164

165-
Widget _buildOptionsButton() {
165+
List<OptionItem> _buildOptions(BuildContext context) {
166166
final options = <OptionItem>[
167167
OptionItem(
168-
onTap: () async {
168+
onTap: (context) async {
169169
Navigator.pop(context);
170170
_onSpeedButtonTap();
171171
},
@@ -179,7 +179,10 @@ class _MaterialControlsState extends State<MaterialControls>
179179
chewieController.additionalOptions!(context).isNotEmpty) {
180180
options.addAll(chewieController.additionalOptions!(context));
181181
}
182+
return options;
183+
}
182184

185+
Widget _buildOptionsButton() {
183186
return AnimatedOpacity(
184187
opacity: notifier.hideStuff ? 0.0 : 1.0,
185188
duration: const Duration(milliseconds: 250),
@@ -188,14 +191,15 @@ class _MaterialControlsState extends State<MaterialControls>
188191
_hideTimer?.cancel();
189192

190193
if (chewieController.optionsBuilder != null) {
191-
await chewieController.optionsBuilder!(context, options);
194+
await chewieController.optionsBuilder!(
195+
context, _buildOptions(context));
192196
} else {
193197
await showModalBottomSheet<OptionItem>(
194198
context: context,
195199
isScrollControlled: true,
196200
useRootNavigator: chewieController.useRootNavigator,
197201
builder: (context) => OptionsDialog(
198-
options: options,
202+
options: _buildOptions(context),
199203
cancelButtonText:
200204
chewieController.optionsTranslation?.cancelButtonText,
201205
),

lib/src/material/material_desktop_controls.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
183183
}) {
184184
final options = <OptionItem>[
185185
OptionItem(
186-
onTap: () async {
186+
onTap: (context) async {
187187
Navigator.pop(context);
188188
_onSpeedButtonTap();
189189
},

lib/src/material/widgets/options_dialog.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class _OptionsDialogState extends State<OptionsDialog> {
2828
itemCount: widget.options.length,
2929
itemBuilder: (context, i) {
3030
return ListTile(
31-
onTap: widget.options[i].onTap,
31+
onTap: () => widget.options[i].onTap(context),
3232
leading: Icon(widget.options[i].iconData),
3333
title: Text(widget.options[i].title),
3434
subtitle: widget.options[i].subtitle != null

lib/src/models/option_item.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ class OptionItem {
88
this.subtitle,
99
});
1010

11-
Function()? onTap;
12-
IconData iconData;
13-
String title;
14-
String? subtitle;
11+
final void Function(BuildContext context) onTap;
12+
final IconData iconData;
13+
final String title;
14+
final String? subtitle;
1515

1616
OptionItem copyWith({
17-
Function()? onTap,
17+
Function(BuildContext context)? onTap,
1818
IconData? iconData,
1919
String? title,
2020
String? subtitle,

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: chewie
22
description: A video player for Flutter with Cupertino and Material play controls
3-
version: 1.9.2
3+
version: 1.10.0
44
homepage: https://github.com/fluttercommunity/chewie
55

66
environment:

0 commit comments

Comments
 (0)