Skip to content

Commit

Permalink
Use VoidCallback for onPressed and friends
Browse files Browse the repository at this point in the history
Previous these callbacks were leaking the implementation detail that they were
triggered by taps. In a later patch, we're going to add a parameter to
GestureTapCallback that these callbacks won't have.

Related to #1807
  • Loading branch information
abarth committed Oct 27, 2015
1 parent 5f2c17b commit e448acb
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion examples/game/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class TextureButton extends StatefulComponent {
this.height: 128.0
}) : super(key: key);

final GestureTapCallback onPressed;
final VoidCallback onPressed;
final Texture texture;
final Texture textureDown;
final double width;
Expand Down
2 changes: 1 addition & 1 deletion sky/packages/sky/lib/src/material/dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Dialog extends StatelessComponent {
final List<Widget> actions;

/// An (optional) callback that is called when the dialog is dismissed.
final GestureTapCallback onDismiss;
final VoidCallback onDismiss;

Color _getColor(BuildContext context) {
switch (Theme.of(context).brightness) {
Expand Down
2 changes: 1 addition & 1 deletion sky/packages/sky/lib/src/material/drawer_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DrawerItem extends StatelessComponent {

final String icon;
final Widget child;
final GestureTapCallback onPressed;
final VoidCallback onPressed;
final bool selected;

TextStyle _getTextStyle(ThemeData themeData) {
Expand Down
2 changes: 1 addition & 1 deletion sky/packages/sky/lib/src/material/flat_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class FlatButton extends MaterialButton {
FlatButton({
Key key,
Widget child,
GestureTapCallback onPressed
VoidCallback onPressed
}) : super(key: key,
child: child,
onPressed: onPressed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FloatingActionButton extends StatefulComponent {

final Widget child;
final Color backgroundColor;
final GestureTapCallback onPressed;
final VoidCallback onPressed;

_FloatingActionButtonState createState() => new _FloatingActionButtonState();
}
Expand Down
2 changes: 1 addition & 1 deletion sky/packages/sky/lib/src/material/icon_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class IconButton extends StatelessComponent {
final String icon;
final IconThemeColor color;
final ColorFilter colorFilter;
final GestureTapCallback onPressed;
final VoidCallback onPressed;

Widget build(BuildContext context) {
return new GestureDetector(
Expand Down
2 changes: 1 addition & 1 deletion sky/packages/sky/lib/src/material/material_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract class MaterialButton extends StatefulComponent {

final Widget child;
final ButtonColor textColor;
final GestureTapCallback onPressed;
final VoidCallback onPressed;

bool get enabled => onPressed != null;

Expand Down
2 changes: 1 addition & 1 deletion sky/packages/sky/lib/src/material/snack_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SnackBarAction extends StatelessComponent {
}

final String label;
final GestureTapCallback onPressed;
final VoidCallback onPressed;

Widget build(BuildContext context) {
return new GestureDetector(
Expand Down
2 changes: 1 addition & 1 deletion sky/packages/sky/lib/src/material/tabs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class Tab extends StatelessComponent {
assert(label.text != null || label.icon != null);
}

final GestureTapCallback onSelected;
final VoidCallback onSelected;
final TabLabel label;
final Color color;
final bool selected;
Expand Down
3 changes: 2 additions & 1 deletion sky/packages/sky/lib/src/rendering/basic_types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export 'dart:ui' show
Point,
Rect,
Size,
TransferMode;
TransferMode,
VoidCallback;
3 changes: 2 additions & 1 deletion sky/packages/sky/lib/src/widgets/basic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ export 'package:flutter/rendering.dart' show
TextStyle,
TransferMode,
ValueChanged,
normal,
VoidCallback,
bold,
normal,
underline,
overline,
lineThrough;
Expand Down

0 comments on commit e448acb

Please sign in to comment.