Use @required for onPressed and onChanged (#4534)

We now use the `@required` annotation to encourage developers to
explicitly set onPressed and onChanged callbacks to null when that would
disable the widget.

Fixes #287
This commit is contained in:
Adam Barth
2016-06-12 13:25:06 -07:00
committed by GitHub
parent cc44696754
commit 1a3adae101
23 changed files with 133 additions and 101 deletions

View File

@@ -26,7 +26,8 @@ new RaisedButton(
// Buttons are disabled when onPressed isn't
// specified or is null.
new RaisedButton(
child: new Text('BUTTON TITLE')
child: new Text('BUTTON TITLE'),
onPressed: null
);
// END
@@ -44,7 +45,8 @@ new FlatButton(
// Buttons are disabled when onPressed isn't
// specified or is null.
new FlatButton(
child: new Text('BUTTON TITLE')
child: new Text('BUTTON TITLE'),
onPressed: null
);
// END
@@ -97,7 +99,8 @@ new Scaffold(
title: new Text('Demo')
),
floatingActionButton: new FloatingActionButton(
child: new Icon(icon: Icons.add)
child: new Icon(icon: Icons.add),
onPressed: null
)
);
// END
@@ -127,7 +130,7 @@ new Checkbox(
// Create a disabled checkbox.
// Checkboxes are disabled when onChanged isn't
// specified or null.
new Checkbox(value: false);
new Checkbox(value: false, onChanged: null);
// END
@@ -166,7 +169,8 @@ new Row(
// Creates a disabled radio button.
new Radio<int>(
value: 0,
groupValue: 0
groupValue: 0,
onChanged: null
);
// END
@@ -188,7 +192,7 @@ new Switch(
// Create a disabled switch.
// Switches are disabled when onChanged isn't
// specified or null.
new Switch(value: false);
new Switch(value: false, onChanged: null);
// END
}
}