Commit 347bd25c authored by Adam Barth's avatar Adam Barth

Remove BuildContext argument to initState

This argument isn't needed anymore now that State has a getter for context.
parent 01f7c846
...@@ -54,8 +54,8 @@ class MineDiggerState extends State<MineDigger> { ...@@ -54,8 +54,8 @@ class MineDiggerState extends State<MineDigger> {
// |uiState| keeps track of the visible player progess. // |uiState| keeps track of the visible player progess.
List<List<CellState>> uiState; List<List<CellState>> uiState;
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
resetGame(); resetGame();
} }
......
...@@ -34,8 +34,8 @@ class StocksAppState extends State<StocksApp> { ...@@ -34,8 +34,8 @@ class StocksAppState extends State<StocksApp> {
final Map<String, Stock> _stocks = <String, Stock>{}; final Map<String, Stock> _stocks = <String, Stock>{};
final List<String> _symbols = <String>[]; final List<String> _symbols = <String>[];
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
new StockDataFetcher((StockData data) { new StockDataFetcher((StockData data) {
setState(() { setState(() {
data.appendTo(_stocks, _symbols); data.appendTo(_stocks, _symbols);
......
...@@ -65,8 +65,8 @@ class CardCollectionAppState extends State<CardCollectionApp> { ...@@ -65,8 +65,8 @@ class CardCollectionAppState extends State<CardCollectionApp> {
_initVariableSizedCardModels(); _initVariableSizedCardModels();
} }
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
_initCardModels(); _initCardModels();
} }
...@@ -264,7 +264,6 @@ class CardCollectionAppState extends State<CardCollectionApp> { ...@@ -264,7 +264,6 @@ class CardCollectionAppState extends State<CardCollectionApp> {
}) })
.toList(); .toList();
double offset;
for (int i = 0; i < cumulativeHeights.length; i++) { for (int i = 0; i < cumulativeHeights.length; i++) {
if (cumulativeHeights[i] >= scrollOffset) if (cumulativeHeights[i] >= scrollOffset)
return 12.0 + (margins + _cardModels[i].height) / 2.0 + ((i == 0) ? 0.0 : cumulativeHeights[i - 1]); return 12.0 + (margins + _cardModels[i].height) / 2.0 + ((i == 0) ? 0.0 : cumulativeHeights[i - 1]);
......
...@@ -12,8 +12,8 @@ class DatePickerDemo extends StatefulComponent { ...@@ -12,8 +12,8 @@ class DatePickerDemo extends StatefulComponent {
} }
class DatePickerDemoState extends State<DatePickerDemo> { class DatePickerDemoState extends State<DatePickerDemo> {
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
DateTime now = new DateTime.now(); DateTime now = new DateTime.now();
_dateTime = new DateTime(now.year, now.month, now.day); _dateTime = new DateTime(now.year, now.month, now.day);
} }
......
...@@ -21,8 +21,8 @@ class PageableListApp extends StatefulComponent { ...@@ -21,8 +21,8 @@ class PageableListApp extends StatefulComponent {
} }
class PageableListAppState extends State<PageableListApp> { class PageableListAppState extends State<PageableListApp> {
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
List<Size> cardSizes = [ List<Size> cardSizes = [
[100.0, 300.0], [300.0, 100.0], [200.0, 400.0], [400.0, 400.0], [300.0, 400.0] [100.0, 300.0], [300.0, 100.0], [200.0, 400.0], [400.0, 400.0], [300.0, 400.0]
] ]
......
...@@ -11,8 +11,8 @@ class ProgressIndicatorApp extends StatefulComponent { ...@@ -11,8 +11,8 @@ class ProgressIndicatorApp extends StatefulComponent {
} }
class ProgressIndicatorAppState extends State<ProgressIndicatorApp> { class ProgressIndicatorAppState extends State<ProgressIndicatorApp> {
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
valueAnimation = new ValueAnimation<double>() valueAnimation = new ValueAnimation<double>()
..duration = const Duration(milliseconds: 1500) ..duration = const Duration(milliseconds: 1500)
..variable = new AnimatedValue<double>( ..variable = new AnimatedValue<double>(
......
...@@ -11,8 +11,8 @@ class ScaleApp extends StatefulComponent { ...@@ -11,8 +11,8 @@ class ScaleApp extends StatefulComponent {
} }
class ScaleAppState extends State<ScaleApp> { class ScaleAppState extends State<ScaleApp> {
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
_offset = Offset.zero; _offset = Offset.zero;
_zoom = 1.0; _zoom = 1.0;
} }
......
...@@ -11,8 +11,8 @@ class StyledTextApp extends StatefulComponent { ...@@ -11,8 +11,8 @@ class StyledTextApp extends StatefulComponent {
} }
class StyledTextAppState extends State<StyledTextApp> { class StyledTextAppState extends State<StyledTextApp> {
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
toText = toStyledText; toText = toStyledText;
nameLines = dialogText nameLines = dialogText
.split('\n') .split('\n')
......
...@@ -13,8 +13,8 @@ abstract class AnimatedComponent extends StatefulComponent { ...@@ -13,8 +13,8 @@ abstract class AnimatedComponent extends StatefulComponent {
} }
abstract class AnimatedState<T extends AnimatedComponent> extends State<T> { abstract class AnimatedState<T extends AnimatedComponent> extends State<T> {
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
_performance = new AnimationPerformance(duration: config.duration); _performance = new AnimationPerformance(duration: config.duration);
performance.addStatusListener(_handleAnimationStatusChanged); performance.addStatusListener(_handleAnimationStatusChanged);
if (buildDependsOnPerformance) { if (buildDependsOnPerformance) {
......
...@@ -46,8 +46,8 @@ class AppState extends State<App> { ...@@ -46,8 +46,8 @@ class AppState extends State<App> {
GlobalObjectKey _navigator; GlobalObjectKey _navigator;
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
_navigator = new GlobalObjectKey(this); _navigator = new GlobalObjectKey(this);
WidgetFlutterBinding.instance.addEventListener(_backHandler); WidgetFlutterBinding.instance.addEventListener(_backHandler);
} }
......
...@@ -754,8 +754,8 @@ class ImageListener extends StatefulComponent { ...@@ -754,8 +754,8 @@ class ImageListener extends StatefulComponent {
} }
class ImageListenerState extends State<ImageListener> { class ImageListenerState extends State<ImageListener> {
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
config.image.addListener(_handleImageChanged); config.image.addListener(_handleImageChanged);
} }
......
...@@ -294,8 +294,8 @@ class MonthPicker extends ScrollableWidgetList { ...@@ -294,8 +294,8 @@ class MonthPicker extends ScrollableWidgetList {
} }
class MonthPickerState extends ScrollableWidgetListState<MonthPicker> { class MonthPickerState extends ScrollableWidgetListState<MonthPicker> {
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
_updateCurrentDate(); _updateCurrentDate();
} }
......
...@@ -48,8 +48,8 @@ class Dismissable extends StatefulComponent { ...@@ -48,8 +48,8 @@ class Dismissable extends StatefulComponent {
} }
class DismissableState extends State<Dismissable> { class DismissableState extends State<Dismissable> {
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
_fadePerformance = new AnimationPerformance(duration: _kCardDismissFadeout); _fadePerformance = new AnimationPerformance(duration: _kCardDismissFadeout);
_fadePerformance.addStatusListener((AnimationStatus status) { _fadePerformance.addStatusListener((AnimationStatus status) {
if (status == AnimationStatus.completed) if (status == AnimationStatus.completed)
......
...@@ -57,8 +57,8 @@ class Drawer extends StatefulComponent { ...@@ -57,8 +57,8 @@ class Drawer extends StatefulComponent {
} }
class DrawerState extends State<Drawer> { class DrawerState extends State<Drawer> {
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
_performance = new AnimationPerformance(duration: _kBaseSettleDuration); _performance = new AnimationPerformance(duration: _kBaseSettleDuration);
_performance.addStatusListener((AnimationStatus status) { _performance.addStatusListener((AnimationStatus status) {
if (status == AnimationStatus.dismissed) if (status == AnimationStatus.dismissed)
......
...@@ -152,8 +152,8 @@ class FocusState extends State<Focus> { ...@@ -152,8 +152,8 @@ class FocusState extends State<Focus> {
} }
} }
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
if (config.autofocus) if (config.autofocus)
FocusState._moveScopeTo(context, config); FocusState._moveScopeTo(context, config);
_updateWidgetRemovalListener(_focusedWidget); _updateWidgetRemovalListener(_focusedWidget);
......
...@@ -306,8 +306,8 @@ abstract class State<T extends StatefulComponent> { ...@@ -306,8 +306,8 @@ abstract class State<T extends StatefulComponent> {
/// object was inserted into the tree or on the widget configuration object. /// object was inserted into the tree or on the widget configuration object.
/// ///
/// If you override this, make sure your method starts with a call to /// If you override this, make sure your method starts with a call to
/// super.initState(context). /// super.initState().
void initState(BuildContext context) { void initState() {
assert(_debugLifecycleState == _StateLifecycle.created); assert(_debugLifecycleState == _StateLifecycle.created);
assert(() { _debugLifecycleState = _StateLifecycle.initialized; return true; }); assert(() { _debugLifecycleState = _StateLifecycle.initialized; return true; });
} }
...@@ -834,7 +834,7 @@ class StatefulComponentElement extends BuildableElement<StatefulComponent> { ...@@ -834,7 +834,7 @@ class StatefulComponentElement extends BuildableElement<StatefulComponent> {
assert(_state._debugLifecycleState == _StateLifecycle.created); assert(_state._debugLifecycleState == _StateLifecycle.created);
try { try {
_debugSetAllowIgnoredCallsToMarkNeedsBuild(true); _debugSetAllowIgnoredCallsToMarkNeedsBuild(true);
_state.initState(this); _state.initState();
} finally { } finally {
_debugSetAllowIgnoredCallsToMarkNeedsBuild(false); _debugSetAllowIgnoredCallsToMarkNeedsBuild(false);
} }
......
...@@ -55,8 +55,8 @@ class GestureDetector extends StatefulComponent { ...@@ -55,8 +55,8 @@ class GestureDetector extends StatefulComponent {
} }
class GestureDetectorState extends State<GestureDetector> { class GestureDetectorState extends State<GestureDetector> {
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
didUpdateConfig(null); didUpdateConfig(null);
} }
......
...@@ -50,8 +50,8 @@ class InputState extends ScrollableState<Input> { ...@@ -50,8 +50,8 @@ class InputState extends ScrollableState<Input> {
double _contentWidth = 0.0; double _contentWidth = 0.0;
double _containerWidth = 0.0; double _containerWidth = 0.0;
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
_value = config.initialValue; _value = config.initialValue;
_editableValue = new EditableString( _editableValue = new EditableString(
text: _value, text: _value,
......
...@@ -39,8 +39,8 @@ class NavigatorState extends State<Navigator> { ...@@ -39,8 +39,8 @@ class NavigatorState extends State<Navigator> {
Route get currentRoute => _history[_currentPosition]; Route get currentRoute => _history[_currentPosition];
bool get hasPreviousRoute => _history.length > 1; bool get hasPreviousRoute => _history.length > 1;
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
PageRoute route = new PageRoute(config.routes['/']); PageRoute route = new PageRoute(config.routes['/']);
assert(route != null); assert(route != null);
assert(!route.ephemeral); assert(!route.ephemeral);
......
...@@ -50,8 +50,8 @@ class PopupMenu extends StatefulComponent { ...@@ -50,8 +50,8 @@ class PopupMenu extends StatefulComponent {
} }
class PopupMenuState extends State<PopupMenu> { class PopupMenuState extends State<PopupMenu> {
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
config.performance.addListener(_performanceChanged); config.performance.addListener(_performanceChanged);
} }
......
...@@ -35,8 +35,8 @@ abstract class ProgressIndicator extends StatefulComponent { ...@@ -35,8 +35,8 @@ abstract class ProgressIndicator extends StatefulComponent {
} }
class ProgressIndicatorState extends State<ProgressIndicator> { class ProgressIndicatorState extends State<ProgressIndicator> {
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
_performance = new AnimationPerformance() _performance = new AnimationPerformance()
..duration = const Duration(milliseconds: 1500) ..duration = const Duration(milliseconds: 1500)
..variable = new AnimatedValue<double>(0.0, end: 1.0, curve: ease); ..variable = new AnimatedValue<double>(0.0, end: 1.0, curve: ease);
......
...@@ -47,8 +47,8 @@ abstract class Scrollable extends StatefulComponent { ...@@ -47,8 +47,8 @@ abstract class Scrollable extends StatefulComponent {
} }
abstract class ScrollableState<T extends Scrollable> extends State<T> { abstract class ScrollableState<T extends Scrollable> extends State<T> {
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
if (config.initialScrollOffset is double) if (config.initialScrollOffset is double)
_scrollOffset = config.initialScrollOffset; _scrollOffset = config.initialScrollOffset;
_toEndAnimation = new AnimatedSimulation(_setScrollOffset); _toEndAnimation = new AnimatedSimulation(_setScrollOffset);
...@@ -672,8 +672,8 @@ class ScrollableMixedWidgetList extends Scrollable { ...@@ -672,8 +672,8 @@ class ScrollableMixedWidgetList extends Scrollable {
} }
class ScrollableMixedWidgetListState extends ScrollableState<ScrollableMixedWidgetList> { class ScrollableMixedWidgetListState extends ScrollableState<ScrollableMixedWidgetList> {
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
scrollBehavior.updateExtents( scrollBehavior.updateExtents(
contentExtent: double.INFINITY contentExtent: double.INFINITY
); );
......
...@@ -401,8 +401,8 @@ class TabBar extends Scrollable { ...@@ -401,8 +401,8 @@ class TabBar extends Scrollable {
} }
class TabBarState extends ScrollableState<TabBar> { class TabBarState extends ScrollableState<TabBar> {
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
_indicatorAnimation = new ValueAnimation<Rect>() _indicatorAnimation = new ValueAnimation<Rect>()
..duration = _kTabBarScroll ..duration = _kTabBarScroll
..variable = new AnimatedRect(null, curve: ease); ..variable = new AnimatedRect(null, curve: ease);
......
...@@ -25,8 +25,8 @@ abstract class TransitionComponent extends StatefulComponent { ...@@ -25,8 +25,8 @@ abstract class TransitionComponent extends StatefulComponent {
} }
class TransitionState extends State<TransitionComponent> { class TransitionState extends State<TransitionComponent> {
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
config.performance.addListener(_performanceChanged); config.performance.addListener(_performanceChanged);
} }
......
...@@ -11,8 +11,8 @@ class ProbeWidget extends StatefulComponent { ...@@ -11,8 +11,8 @@ class ProbeWidget extends StatefulComponent {
class ProbeWidgetState extends State<ProbeWidget> { class ProbeWidgetState extends State<ProbeWidget> {
static int buildCount = 0; static int buildCount = 0;
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
setState(() {}); setState(() {});
} }
......
import 'package:quiver/testing/async.dart';
import 'package:sky/rendering.dart'; import 'package:sky/rendering.dart';
import 'package:sky/src/fn3.dart'; import 'package:sky/src/fn3.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
...@@ -8,10 +7,6 @@ import '../fn3/widget_tester.dart'; ...@@ -8,10 +7,6 @@ import '../fn3/widget_tester.dart';
const List<int> items = const <int>[0, 1, 2, 3, 4, 5]; const List<int> items = const <int>[0, 1, 2, 3, 4, 5];
List<int> tapped = <int>[]; List<int> tapped = <int>[];
Widget buildFrame() {
return ;
}
void main() { void main() {
double t = 0.0; double t = 0.0;
WidgetTester tester = new WidgetTester(); WidgetTester tester = new WidgetTester();
......
import 'package:quiver/testing/async.dart';
import 'package:sky/rendering.dart'; import 'package:sky/rendering.dart';
import 'package:sky/src/fn3.dart'; import 'package:sky/src/fn3.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
......
import 'package:quiver/testing/async.dart';
import 'package:sky/src/fn3.dart'; import 'package:sky/src/fn3.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
......
...@@ -20,8 +20,8 @@ class Changer extends StatefulComponent { ...@@ -20,8 +20,8 @@ class Changer extends StatefulComponent {
class ChangerState extends State<Changer> { class ChangerState extends State<Changer> {
bool _state = false; bool _state = false;
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
changer = this; changer = this;
} }
......
...@@ -11,8 +11,8 @@ class InnerComponent extends StatefulComponent { ...@@ -11,8 +11,8 @@ class InnerComponent extends StatefulComponent {
class InnerComponentState extends State<InnerComponent> { class InnerComponentState extends State<InnerComponent> {
bool _didInitState = false; bool _didInitState = false;
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
_didInitState = true; _didInitState = true;
} }
......
...@@ -18,8 +18,8 @@ class TestWidgetState extends State<TestWidget> { ...@@ -18,8 +18,8 @@ class TestWidgetState extends State<TestWidget> {
int syncedState; int syncedState;
int updates = 0; int updates = 0;
void initState(BuildContext context) { void initState() {
super.initState(context); super.initState();
persistentState = config.persistentState; persistentState = config.persistentState;
syncedState = config.syncedState; syncedState = config.syncedState;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment