Widgets should be stateful in order to call setState

R=abarth@chromium.org, abarth

Review URL: https://codereview.chromium.org/1183143012.
This commit is contained in:
Collin Jackson 2015-06-18 16:36:08 -07:00
parent eb09095bd4
commit ff1bbd35c5
2 changed files with 6 additions and 2 deletions

View File

@ -6,7 +6,7 @@ import 'basic.dart';
abstract class ButtonBase extends Component {
ButtonBase({ String key, this.highlight: false }) : super(key: key);
ButtonBase({ String key, this.highlight: false }) : super(key: key, stateful: true);
bool highlight;

View File

@ -416,7 +416,7 @@ abstract class Component extends Widget {
void setState(Function fn()) {
assert(!_disqualifiedFromEverAppearingAgain);
_stateful = true;
assert(_stateful);
fn();
if (_isBuilding || _dirty || !_mounted)
return;
@ -813,6 +813,10 @@ class WidgetSkyBinding extends SkyBinding {
}
abstract class App extends Component {
// Apps are assumed to be stateful
App({ String key }) : super(key: key, stateful: true);
void _handleEvent(sky.Event event) {
if (event.type == 'back')
onBack();