mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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:
parent
eb09095bd4
commit
ff1bbd35c5
@ -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;
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user