diff --git a/dev/manual_tests/drag_and_drop.dart b/dev/manual_tests/drag_and_drop.dart index 6a28a9dd39..496e5f4a8b 100644 --- a/dev/manual_tests/drag_and_drop.dart +++ b/dev/manual_tests/drag_and_drop.dart @@ -58,16 +58,16 @@ class DotState extends State { @override Widget build(BuildContext context) { return new GestureDetector( - onTap: config.tappable ? () { setState(() { taps += 1; }); } : null, + onTap: widget.tappable ? () { setState(() { taps += 1; }); } : null, child: new Container( - width: config.size, - height: config.size, + width: widget.size, + height: widget.size, decoration: new BoxDecoration( - backgroundColor: config.color, + backgroundColor: widget.color, border: new Border.all(width: taps.toDouble()), shape: BoxShape.circle ), - child: config.child + child: widget.child ) ); } diff --git a/dev/manual_tests/material_arc.dart b/dev/manual_tests/material_arc.dart index 7af7650074..9e815b5896 100644 --- a/dev/manual_tests/material_arc.dart +++ b/dev/manual_tests/material_arc.dart @@ -123,12 +123,12 @@ class _PointDemoState extends State<_PointDemo> { @override void initState() { super.initState(); - _animation = new CurvedAnimation(parent: config.controller, curve: Curves.fastOutSlowIn); + _animation = new CurvedAnimation(parent: widget.controller, curve: Curves.fastOutSlowIn); } @override void dispose() { - config.controller.value = 0.0; + widget.controller.value = 0.0; super.dispose(); } @@ -169,7 +169,7 @@ class _PointDemoState extends State<_PointDemo> { void _handleDragCancel() { _dragTarget = null; - config.controller.value = 0.0; + widget.controller.value = 0.0; } void _handleDragEnd(DragEndDetails details) { @@ -288,12 +288,12 @@ class _RectangleDemoState extends State<_RectangleDemo> { @override void initState() { super.initState(); - _animation = new CurvedAnimation(parent: config.controller, curve: Curves.fastOutSlowIn); + _animation = new CurvedAnimation(parent: widget.controller, curve: Curves.fastOutSlowIn); } @override void dispose() { - config.controller.value = 0.0; + widget.controller.value = 0.0; super.dispose(); } @@ -333,7 +333,7 @@ class _RectangleDemoState extends State<_RectangleDemo> { void _handleDragCancel() { _dragTarget = null; - config.controller.value = 0.0; + widget.controller.value = 0.0; } void _handleDragEnd(DragEndDetails details) { diff --git a/examples/flutter_gallery/lib/demo/material/buttons_demo.dart b/examples/flutter_gallery/lib/demo/material/buttons_demo.dart index c3aafd6d8f..be6c7bc5a1 100644 --- a/examples/flutter_gallery/lib/demo/material/buttons_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/buttons_demo.dart @@ -53,31 +53,31 @@ class _ButtonsDemoState extends State { new ComponentDemoTabData( tabName: 'RAISED', description: _raisedText, - widget: buildRaisedButton(), + demoWidget: buildRaisedButton(), exampleCodeTag: _raisedCode, ), new ComponentDemoTabData( tabName: 'FLAT', description: _flatText, - widget: buildFlatButton(), + demoWidget: buildFlatButton(), exampleCodeTag: _flatCode, ), new ComponentDemoTabData( tabName: 'DROPDOWN', description: _dropdownText, - widget: buildDropdownButton(), + demoWidget: buildDropdownButton(), exampleCodeTag: _dropdownCode, ), new ComponentDemoTabData( tabName: 'ICON', description: _iconText, - widget: buildIconButton(), + demoWidget: buildIconButton(), exampleCodeTag: _iconCode, ), new ComponentDemoTabData( tabName: 'ACTION', description: _actionText, - widget: buildActionButton(), + demoWidget: buildActionButton(), exampleCodeTag: _actionCode, ), ]; diff --git a/examples/flutter_gallery/lib/demo/material/chip_demo.dart b/examples/flutter_gallery/lib/demo/material/chip_demo.dart index 86be8a3449..0242ea557c 100644 --- a/examples/flutter_gallery/lib/demo/material/chip_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/chip_demo.dart @@ -42,10 +42,10 @@ class _ChipDemoState extends State { return new Scaffold( appBar: new AppBar(title: const Text('Chips')), body: new ListView( - children: chips.map((Widget widget) { + children: chips.map((Widget chip) { return new Container( height: 100.0, - child: new Center(child: widget) + child: new Center(child: chip) ); }).toList() ) diff --git a/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart b/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart index b139c5a6a0..6458b63c2c 100644 --- a/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart @@ -130,7 +130,7 @@ class _GridPhotoViewerState extends State with SingleTickerProv transform: new Matrix4.identity() ..translate(_offset.dx, _offset.dy) ..scale(_scale), - child: new Image.asset(config.photo.assetName, fit: BoxFit.cover), + child: new Image.asset(widget.photo.assetName, fit: BoxFit.cover), ), ), ); diff --git a/examples/flutter_gallery/lib/demo/material/selection_controls_demo.dart b/examples/flutter_gallery/lib/demo/material/selection_controls_demo.dart index dd3c79429f..009ef14f27 100644 --- a/examples/flutter_gallery/lib/demo/material/selection_controls_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/selection_controls_demo.dart @@ -39,19 +39,19 @@ class _SelectionControlsDemoState extends State { new ComponentDemoTabData( tabName: "CHECKBOX", description: _checkboxText, - widget: buildCheckbox(), + demoWidget: buildCheckbox(), exampleCodeTag: _checkboxCode ), new ComponentDemoTabData( tabName: "RADIO", description: _radioText, - widget: buildRadio(), + demoWidget: buildRadio(), exampleCodeTag: _radioCode ), new ComponentDemoTabData( tabName: "SWITCH", description: _switchText, - widget: buildSwitch(), + demoWidget: buildSwitch(), exampleCodeTag: _switchCode ) ]; diff --git a/examples/flutter_gallery/lib/demo/pesto_demo.dart b/examples/flutter_gallery/lib/demo/pesto_demo.dart index f6ce4db8cf..1ff9058399 100644 --- a/examples/flutter_gallery/lib/demo/pesto_demo.dart +++ b/examples/flutter_gallery/lib/demo/pesto_demo.dart @@ -147,13 +147,13 @@ class _RecipeGridPageState extends State { ), delegate: new SliverChildBuilderDelegate( (BuildContext context, int index) { - final Recipe recipe = config.recipes[index]; + final Recipe recipe = widget.recipes[index]; return new RecipeCard( recipe: recipe, onTap: () { showRecipePage(context, recipe); }, ); }, - childCount: config.recipes.length, + childCount: widget.recipes.length, ), ), ); @@ -209,7 +209,7 @@ class _PestoLogoState extends State { @override Widget build(BuildContext context) { return new Transform( - transform: new Matrix4.identity()..scale(config.height / kLogoHeight), + transform: new Matrix4.identity()..scale(widget.height / kLogoHeight), alignment: FractionalOffset.topCenter, child: new SizedBox( width: kLogoWidth, @@ -217,13 +217,13 @@ class _PestoLogoState extends State { overflow: Overflow.visible, children: [ new Positioned.fromRect( - rect: _imageRectTween.lerp(config.t), + rect: _imageRectTween.lerp(widget.t), child: new Image.asset(_kSmallLogoImage, fit: BoxFit.contain), ), new Positioned.fromRect( - rect: _textRectTween.lerp(config.t), + rect: _textRectTween.lerp(widget.t), child: new Opacity( - opacity: _textOpacity.transform(config.t), + opacity: _textOpacity.transform(widget.t), child: new Text('PESTO', style: titleStyle, textAlign: TextAlign.center), ), ), @@ -311,7 +311,7 @@ class _RecipePageState extends State { final double appBarHeight = _getAppBarHeight(context); final Size screenSize = MediaQuery.of(context).size; final bool fullWidth = (screenSize.width < _kRecipePageMaxWidth); - final bool isFavorite = _favoriteRecipes.contains(config.recipe); + final bool isFavorite = _favoriteRecipes.contains(widget.recipe); return new Scaffold( key: _scaffoldKey, body: new Stack( @@ -322,9 +322,9 @@ class _RecipePageState extends State { right: 0.0, height: appBarHeight + _kFabHalfSize, child: new Hero( - tag: config.recipe.imagePath, + tag: widget.recipe.imagePath, child: new Image.asset( - config.recipe.imagePath, + widget.recipe.imagePath, fit: fullWidth ? BoxFit.fitWidth : BoxFit.cover, ), ), @@ -363,7 +363,7 @@ class _RecipePageState extends State { new Container( padding: const EdgeInsets.only(top: _kFabHalfSize), width: fullWidth ? null : _kRecipePageMaxWidth, - child: new RecipeSheet(recipe: config.recipe), + child: new RecipeSheet(recipe: widget.recipe), ), new Positioned( right: 16.0, @@ -398,10 +398,10 @@ class _RecipePageState extends State { void _toggleFavorite() { setState(() { - if (_favoriteRecipes.contains(config.recipe)) - _favoriteRecipes.remove(config.recipe); + if (_favoriteRecipes.contains(widget.recipe)) + _favoriteRecipes.remove(widget.recipe); else - _favoriteRecipes.add(config.recipe); + _favoriteRecipes.add(widget.recipe); }); } } diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart index a53d702c5e..d57d8af382 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart @@ -236,7 +236,7 @@ class _OrderPageState extends State { @override void initState() { super.initState(); - scaffoldKey = new GlobalKey(debugLabel: 'Shrine Order ${config.order}'); + scaffoldKey = new GlobalKey(debugLabel: 'Shrine Order ${widget.order}'); } Order get currentOrder => ShrineOrderRoute.of(context).order; @@ -249,7 +249,7 @@ class _OrderPageState extends State { final Order newOrder = currentOrder.copyWith(quantity: quantity, inCart: inCart); if (currentOrder != newOrder) { setState(() { - config.shoppingCart[newOrder.product] = newOrder; + widget.shoppingCart[newOrder.product] = newOrder; currentOrder = newOrder; }); } @@ -263,8 +263,8 @@ class _OrderPageState extends State { Widget build(BuildContext context) { return new ShrinePage( scaffoldKey: scaffoldKey, - products: config.products, - shoppingCart: config.shoppingCart, + products: widget.products, + shoppingCart: widget.shoppingCart, floatingActionButton: new FloatingActionButton( onPressed: () { updateOrder(inCart: true); @@ -284,7 +284,7 @@ class _OrderPageState extends State { slivers: [ new SliverToBoxAdapter( child: new _Heading( - product: config.order.product, + product: widget.order.product, quantity: currentOrder.quantity, quantityChanged: (int value) { updateOrder(quantity: value); }, ), @@ -298,8 +298,8 @@ class _OrderPageState extends State { crossAxisSpacing: 8.0, ), delegate: new SliverChildListDelegate( - config.products - .where((Product product) => product != config.order.product) + widget.products + .where((Product product) => product != widget.order.product) .map((Product product) { return new Card( elevation: 1, diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart index 467bf1f08e..e1f877934c 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart @@ -53,7 +53,7 @@ class ShrinePageState extends State { void _showShoppingCart() { showModalBottomSheet(context: context, builder: (BuildContext context) { - if (config.shoppingCart.isEmpty) { + if (widget.shoppingCart.isEmpty) { return const Padding( padding: const EdgeInsets.all(24.0), child: const Text('The shopping cart is empty') @@ -61,7 +61,7 @@ class ShrinePageState extends State { } return new ListView( padding: kMaterialListPadding, - children: config.shoppingCart.values.map((Order order) { + children: widget.shoppingCart.values.map((Order order) { return new ListTile( title: new Text(order.product.name), leading: new Text('${order.quantity}'), @@ -73,23 +73,23 @@ class ShrinePageState extends State { } void _sortByPrice() { - config.products.sort((Product a, Product b) => a.price.compareTo(b.price)); + widget.products.sort((Product a, Product b) => a.price.compareTo(b.price)); } void _sortByProduct() { - config.products.sort((Product a, Product b) => a.name.compareTo(b.name)); + widget.products.sort((Product a, Product b) => a.name.compareTo(b.name)); } void _emptyCart() { - config.shoppingCart.clear(); - config.scaffoldKey.currentState.showSnackBar(new SnackBar(content: const Text('Shopping cart is empty'))); + widget.shoppingCart.clear(); + widget.scaffoldKey.currentState.showSnackBar(new SnackBar(content: const Text('Shopping cart is empty'))); } @override Widget build(BuildContext context) { final ShrineTheme theme = ShrineTheme.of(context); return new Scaffold( - key: config.scaffoldKey, + key: widget.scaffoldKey, appBar: new AppBar( elevation: _appBarElevation, backgroundColor: theme.appBarBackgroundColor, @@ -142,10 +142,10 @@ class ShrinePageState extends State { ) ] ), - floatingActionButton: config.floatingActionButton, + floatingActionButton: widget.floatingActionButton, body: new NotificationListener( onNotification: _handleScrollNotification, - child: config.body + child: widget.body ) ); } diff --git a/examples/flutter_gallery/lib/gallery/app.dart b/examples/flutter_gallery/lib/gallery/app.dart index d6353c9ca7..1985153009 100644 --- a/examples/flutter_gallery/lib/gallery/app.dart +++ b/examples/flutter_gallery/lib/gallery/app.dart @@ -84,13 +84,13 @@ class GalleryAppState extends State { }); }, showPerformanceOverlay: _showPerformanceOverlay, - onShowPerformanceOverlayChanged: config.enablePerformanceOverlay ? (bool value) { + onShowPerformanceOverlayChanged: widget.enablePerformanceOverlay ? (bool value) { setState(() { _showPerformanceOverlay = value; }); } : null, checkerboardRasterCacheImages: _checkerboardRasterCacheImages, - onCheckerboardRasterCacheImagesChanged: config.checkerboardRasterCacheImages ? (bool value) { + onCheckerboardRasterCacheImagesChanged: widget.checkerboardRasterCacheImages ? (bool value) { setState(() { _checkerboardRasterCacheImages = value; }); @@ -118,12 +118,12 @@ class GalleryAppState extends State { } }); }, - onSendFeedback: config.onSendFeedback, + onSendFeedback: widget.onSendFeedback, ); - if (config.updateUrlFetcher != null) { + if (widget.updateUrlFetcher != null) { home = new Updater( - updateUrlFetcher: config.updateUrlFetcher, + updateUrlFetcher: widget.updateUrlFetcher, child: home, ); } diff --git a/examples/flutter_gallery/lib/gallery/demo.dart b/examples/flutter_gallery/lib/gallery/demo.dart index 9099c14ce0..a7fab8b0bf 100644 --- a/examples/flutter_gallery/lib/gallery/demo.dart +++ b/examples/flutter_gallery/lib/gallery/demo.dart @@ -9,13 +9,13 @@ import 'syntax_highlighter.dart'; class ComponentDemoTabData { ComponentDemoTabData({ - this.widget, + this.demoWidget, this.exampleCodeTag, this.description, this.tabName }); - final Widget widget; + final Widget demoWidget; final String exampleCodeTag; final String description; final String tabName; @@ -85,7 +85,7 @@ class TabbedComponentDemoScaffold extends StatelessWidget { style: Theme.of(context).textTheme.subhead ) ), - new Expanded(child: demo.widget) + new Expanded(child: demo.demoWidget) ], ); }).toList(), @@ -110,7 +110,7 @@ class FullScreenCodeDialogState extends State { @override void didChangeDependencies() { - getExampleCode(config.exampleCodeTag, DefaultAssetBundle.of(context)).then((String code) { + getExampleCode(widget.exampleCodeTag, DefaultAssetBundle.of(context)).then((String code) { if (mounted) { setState(() { _exampleCode = code; diff --git a/examples/flutter_gallery/lib/gallery/drawer.dart b/examples/flutter_gallery/lib/gallery/drawer.dart index 0e2d138986..1070df9fd2 100644 --- a/examples/flutter_gallery/lib/gallery/drawer.dart +++ b/examples/flutter_gallery/lib/gallery/drawer.dart @@ -45,7 +45,7 @@ class _GalleryDrawerHeaderState extends State { : FlutterLogoStyle.markOnly, lightColor: _logoColor.shade400, darkColor: _logoColor.shade900, - textColor: config.light ? const Color(0xFF616161) : const Color(0xFF9E9E9E), + textColor: widget.light ? const Color(0xFF616161) : const Color(0xFF9E9E9E), ), duration: const Duration(milliseconds: 750), child: new GestureDetector( diff --git a/examples/flutter_gallery/lib/gallery/home.dart b/examples/flutter_gallery/lib/gallery/home.dart index adeace820c..6f28e3bf90 100644 --- a/examples/flutter_gallery/lib/gallery/home.dart +++ b/examples/flutter_gallery/lib/gallery/home.dart @@ -153,16 +153,16 @@ class GalleryHomeState extends State with SingleTickerProviderState Widget home = new Scaffold( key: _scaffoldKey, drawer: new GalleryDrawer( - useLightTheme: config.useLightTheme, - onThemeChanged: config.onThemeChanged, - timeDilation: config.timeDilation, - onTimeDilationChanged: config.onTimeDilationChanged, - showPerformanceOverlay: config.showPerformanceOverlay, - onShowPerformanceOverlayChanged: config.onShowPerformanceOverlayChanged, - checkerboardRasterCacheImages: config.checkerboardRasterCacheImages, - onCheckerboardRasterCacheImagesChanged: config.onCheckerboardRasterCacheImagesChanged, - onPlatformChanged: config.onPlatformChanged, - onSendFeedback: config.onSendFeedback, + useLightTheme: widget.useLightTheme, + onThemeChanged: widget.onThemeChanged, + timeDilation: widget.timeDilation, + onTimeDilationChanged: widget.onTimeDilationChanged, + showPerformanceOverlay: widget.showPerformanceOverlay, + onShowPerformanceOverlayChanged: widget.onShowPerformanceOverlayChanged, + checkerboardRasterCacheImages: widget.checkerboardRasterCacheImages, + onCheckerboardRasterCacheImagesChanged: widget.onCheckerboardRasterCacheImagesChanged, + onPlatformChanged: widget.onPlatformChanged, + onSendFeedback: widget.onSendFeedback, ), body: new CustomScrollView( slivers: [ diff --git a/examples/flutter_gallery/lib/gallery/updates.dart b/examples/flutter_gallery/lib/gallery/updates.dart index fcc110db53..157eab3483 100644 --- a/examples/flutter_gallery/lib/gallery/updates.dart +++ b/examples/flutter_gallery/lib/gallery/updates.dart @@ -38,7 +38,7 @@ class UpdaterState extends State { } _lastUpdateCheck = new DateTime.now(); - final String updateUrl = await config.updateUrlFetcher(); + final String updateUrl = await widget.updateUrlFetcher(); if (updateUrl != null) { final bool wantsUpdate = await showDialog(context: context, child: _buildDialog()); if (wantsUpdate != null && wantsUpdate) @@ -68,5 +68,5 @@ class UpdaterState extends State { } @override - Widget build(BuildContext context) => config.child; + Widget build(BuildContext context) => widget.child; } diff --git a/examples/stocks/lib/stock_home.dart b/examples/stocks/lib/stock_home.dart index 75a3a47c41..a8749d1e6f 100644 --- a/examples/stocks/lib/stock_home.dart +++ b/examples/stocks/lib/stock_home.dart @@ -87,8 +87,8 @@ class StockHomeState extends State { } void _handleStockModeChange(StockMode value) { - if (config.updater != null) - config.updater(config.configuration.copyWith(stockMode: value)); + if (widget.updater != null) + widget.updater(widget.configuration.copyWith(stockMode: value)); } void _handleStockMenu(BuildContext context, _StockMenuItem value) { @@ -148,7 +148,7 @@ class StockHomeState extends State { title: const Text('Optimistic'), trailing: new Radio( value: StockMode.optimistic, - groupValue: config.configuration.stockMode, + groupValue: widget.configuration.stockMode, onChanged: _handleStockModeChange, ), onTap: () { @@ -160,7 +160,7 @@ class StockHomeState extends State { title: const Text('Pessimistic'), trailing: new Radio( value: StockMode.pessimistic, - groupValue: config.configuration.stockMode, + groupValue: widget.configuration.stockMode, onChanged: _handleStockModeChange, ), onTap: () { @@ -234,7 +234,7 @@ class StockHomeState extends State { } Iterable _getStockList(Iterable symbols) { - return symbols.map((String symbol) => config.stocks[symbol]) + return symbols.map((String symbol) => widget.stocks[symbol]) .where((Stock stock) => stock != null); } @@ -330,7 +330,7 @@ class StockHomeState extends State { drawer: _buildDrawer(context), body: new TabBarView( children: [ - _buildStockTab(context, StockHomeTab.market, config.symbols), + _buildStockTab(context, StockHomeTab.market, widget.symbols), _buildStockTab(context, StockHomeTab.portfolio, portfolioSymbols), ], ), diff --git a/examples/stocks/lib/stock_settings.dart b/examples/stocks/lib/stock_settings.dart index 4865053ea5..33287318f5 100644 --- a/examples/stocks/lib/stock_settings.dart +++ b/examples/stocks/lib/stock_settings.dart @@ -19,48 +19,48 @@ class StockSettings extends StatefulWidget { class StockSettingsState extends State { void _handleOptimismChanged(bool value) { value ??= false; - sendUpdates(config.configuration.copyWith(stockMode: value ? StockMode.optimistic : StockMode.pessimistic)); + sendUpdates(widget.configuration.copyWith(stockMode: value ? StockMode.optimistic : StockMode.pessimistic)); } void _handleBackupChanged(bool value) { - sendUpdates(config.configuration.copyWith(backupMode: value ? BackupMode.enabled : BackupMode.disabled)); + sendUpdates(widget.configuration.copyWith(backupMode: value ? BackupMode.enabled : BackupMode.disabled)); } void _handleShowGridChanged(bool value) { - sendUpdates(config.configuration.copyWith(debugShowGrid: value)); + sendUpdates(widget.configuration.copyWith(debugShowGrid: value)); } void _handleShowSizesChanged(bool value) { - sendUpdates(config.configuration.copyWith(debugShowSizes: value)); + sendUpdates(widget.configuration.copyWith(debugShowSizes: value)); } void _handleShowBaselinesChanged(bool value) { - sendUpdates(config.configuration.copyWith(debugShowBaselines: value)); + sendUpdates(widget.configuration.copyWith(debugShowBaselines: value)); } void _handleShowLayersChanged(bool value) { - sendUpdates(config.configuration.copyWith(debugShowLayers: value)); + sendUpdates(widget.configuration.copyWith(debugShowLayers: value)); } void _handleShowPointersChanged(bool value) { - sendUpdates(config.configuration.copyWith(debugShowPointers: value)); + sendUpdates(widget.configuration.copyWith(debugShowPointers: value)); } void _handleShowRainbowChanged(bool value) { - sendUpdates(config.configuration.copyWith(debugShowRainbow: value)); + sendUpdates(widget.configuration.copyWith(debugShowRainbow: value)); } void _handleShowPerformanceOverlayChanged(bool value) { - sendUpdates(config.configuration.copyWith(showPerformanceOverlay: value)); + sendUpdates(widget.configuration.copyWith(showPerformanceOverlay: value)); } void _handleShowSemanticsDebuggerChanged(bool value) { - sendUpdates(config.configuration.copyWith(showSemanticsDebugger: value)); + sendUpdates(widget.configuration.copyWith(showSemanticsDebugger: value)); } void _confirmOptimismChange() { - switch (config.configuration.stockMode) { + switch (widget.configuration.stockMode) { case StockMode.optimistic: _handleOptimismChanged(false); break; @@ -91,8 +91,8 @@ class StockSettingsState extends State { } void sendUpdates(StockConfiguration value) { - if (config.updater != null) - config.updater(value); + if (widget.updater != null) + widget.updater(value); } Widget buildAppBar(BuildContext context) { @@ -108,34 +108,34 @@ class StockSettingsState extends State { title: const Text('Everything is awesome'), onTap: _confirmOptimismChange, trailing: new Checkbox( - value: config.configuration.stockMode == StockMode.optimistic, + value: widget.configuration.stockMode == StockMode.optimistic, onChanged: (bool value) => _confirmOptimismChange(), ), ), new ListTile( leading: const Icon(Icons.backup), title: const Text('Back up stock list to the cloud'), - onTap: () { _handleBackupChanged(!(config.configuration.backupMode == BackupMode.enabled)); }, + onTap: () { _handleBackupChanged(!(widget.configuration.backupMode == BackupMode.enabled)); }, trailing: new Switch( - value: config.configuration.backupMode == BackupMode.enabled, + value: widget.configuration.backupMode == BackupMode.enabled, onChanged: _handleBackupChanged, ), ), new ListTile( leading: const Icon(Icons.picture_in_picture), title: const Text('Show rendering performance overlay'), - onTap: () { _handleShowPerformanceOverlayChanged(!config.configuration.showPerformanceOverlay); }, + onTap: () { _handleShowPerformanceOverlayChanged(!widget.configuration.showPerformanceOverlay); }, trailing: new Switch( - value: config.configuration.showPerformanceOverlay, + value: widget.configuration.showPerformanceOverlay, onChanged: _handleShowPerformanceOverlayChanged, ), ), new ListTile( leading: const Icon(Icons.accessibility), title: const Text('Show semantics overlay'), - onTap: () { _handleShowSemanticsDebuggerChanged(!config.configuration.showSemanticsDebugger); }, + onTap: () { _handleShowSemanticsDebuggerChanged(!widget.configuration.showSemanticsDebugger); }, trailing: new Switch( - value: config.configuration.showSemanticsDebugger, + value: widget.configuration.showSemanticsDebugger, onChanged: _handleShowSemanticsDebuggerChanged, ), ), @@ -146,54 +146,54 @@ class StockSettingsState extends State { new ListTile( leading: const Icon(Icons.border_clear), title: const Text('Show material grid (for debugging)'), - onTap: () { _handleShowGridChanged(!config.configuration.debugShowGrid); }, + onTap: () { _handleShowGridChanged(!widget.configuration.debugShowGrid); }, trailing: new Switch( - value: config.configuration.debugShowGrid, + value: widget.configuration.debugShowGrid, onChanged: _handleShowGridChanged, ), ), new ListTile( leading: const Icon(Icons.border_all), title: const Text('Show construction lines (for debugging)'), - onTap: () { _handleShowSizesChanged(!config.configuration.debugShowSizes); }, + onTap: () { _handleShowSizesChanged(!widget.configuration.debugShowSizes); }, trailing: new Switch( - value: config.configuration.debugShowSizes, + value: widget.configuration.debugShowSizes, onChanged: _handleShowSizesChanged, ), ), new ListTile( leading: const Icon(Icons.format_color_text), title: const Text('Show baselines (for debugging)'), - onTap: () { _handleShowBaselinesChanged(!config.configuration.debugShowBaselines); }, + onTap: () { _handleShowBaselinesChanged(!widget.configuration.debugShowBaselines); }, trailing: new Switch( - value: config.configuration.debugShowBaselines, + value: widget.configuration.debugShowBaselines, onChanged: _handleShowBaselinesChanged, ), ), new ListTile( leading: const Icon(Icons.filter_none), title: const Text('Show layer boundaries (for debugging)'), - onTap: () { _handleShowLayersChanged(!config.configuration.debugShowLayers); }, + onTap: () { _handleShowLayersChanged(!widget.configuration.debugShowLayers); }, trailing: new Switch( - value: config.configuration.debugShowLayers, + value: widget.configuration.debugShowLayers, onChanged: _handleShowLayersChanged, ), ), new ListTile( leading: const Icon(Icons.mouse), title: const Text('Show pointer hit-testing (for debugging)'), - onTap: () { _handleShowPointersChanged(!config.configuration.debugShowPointers); }, + onTap: () { _handleShowPointersChanged(!widget.configuration.debugShowPointers); }, trailing: new Switch( - value: config.configuration.debugShowPointers, + value: widget.configuration.debugShowPointers, onChanged: _handleShowPointersChanged, ), ), new ListTile( leading: const Icon(Icons.gradient), title: const Text('Show repaint rainbow (for debugging)'), - onTap: () { _handleShowRainbowChanged(!config.configuration.debugShowRainbow); }, + onTap: () { _handleShowRainbowChanged(!widget.configuration.debugShowRainbow); }, trailing: new Switch( - value: config.configuration.debugShowRainbow, + value: widget.configuration.debugShowRainbow, onChanged: _handleShowRainbowChanged, ), ), diff --git a/packages/flutter/lib/src/cupertino/activity_indicator.dart b/packages/flutter/lib/src/cupertino/activity_indicator.dart index e5eb9c80a8..d4c1aafe14 100644 --- a/packages/flutter/lib/src/cupertino/activity_indicator.dart +++ b/packages/flutter/lib/src/cupertino/activity_indicator.dart @@ -43,14 +43,14 @@ class _CupertinoActivityIndicatorState extends State vsync: this, ); - if (config.animating) + if (widget.animating) _controller.repeat(); } @override - void didUpdateConfig(CupertinoActivityIndicator oldConfig) { - if (config.animating != oldConfig.animating) { - if (config.animating) + void didUpdateWidget(CupertinoActivityIndicator oldWidget) { + if (widget.animating != oldWidget.animating) { + if (widget.animating) _controller.repeat(); else _controller.stop(); diff --git a/packages/flutter/lib/src/cupertino/button.dart b/packages/flutter/lib/src/cupertino/button.dart index 2e10e0ed83..acc1cd001f 100644 --- a/packages/flutter/lib/src/cupertino/button.dart +++ b/packages/flutter/lib/src/cupertino/button.dart @@ -115,7 +115,7 @@ class _CupertinoButtonState extends State with SingleTickerProv void _setTween() { _opacityTween = new Tween( begin: 1.0, - end: config.pressedOpacity, + end: widget.pressedOpacity, ); } @@ -138,8 +138,8 @@ class _CupertinoButtonState extends State with SingleTickerProv } @override - void didUpdateConfig(CupertinoButton old) { - super.didUpdateConfig(old); + void didUpdateWidget(CupertinoButton old) { + super.didUpdateWidget(old); _setTween(); } @@ -157,19 +157,19 @@ class _CupertinoButtonState extends State with SingleTickerProv @override Widget build(BuildContext context) { - final bool enabled = config.enabled; - final Color backgroundColor = config.color; + final bool enabled = widget.enabled; + final Color backgroundColor = widget.color; return new Listener( onPointerDown: enabled ? _handleTapDown : null, onPointerUp: enabled ? _handleTapUp : null, onPointerCancel: enabled ? _handleTapCancel : null, child: new GestureDetector( - onTap: config.onPressed, + onTap: widget.onPressed, child: new ConstrainedBox( constraints: new BoxConstraints( - minWidth: config.minSize, - minHeight: config.minSize, + minWidth: widget.minSize, + minHeight: widget.minSize, ), child: new FadeTransition( opacity: _opacityTween.animate(new CurvedAnimation( @@ -184,8 +184,8 @@ class _CupertinoButtonState extends State with SingleTickerProv : backgroundColor, ), child: new Padding( - padding: config.padding != null - ? config.padding + padding: widget.padding != null + ? widget.padding : backgroundColor != null ? _kBackgroundButtonPadding : _kButtonPadding, @@ -198,7 +198,7 @@ class _CupertinoButtonState extends State with SingleTickerProv : enabled ? _kButtonTextStyle : _kDisabledButtonTextStyle, - child: config.child, + child: widget.child, ), ), ), diff --git a/packages/flutter/lib/src/cupertino/slider.dart b/packages/flutter/lib/src/cupertino/slider.dart index f72d6f3a0e..2e06b14c35 100644 --- a/packages/flutter/lib/src/cupertino/slider.dart +++ b/packages/flutter/lib/src/cupertino/slider.dart @@ -123,17 +123,17 @@ class CupertinoSlider extends StatefulWidget { class _CupertinoSliderState extends State with TickerProviderStateMixin { void _handleChanged(double value) { - assert(config.onChanged != null); - config.onChanged(value * (config.max - config.min) + config.min); + assert(widget.onChanged != null); + widget.onChanged(value * (widget.max - widget.min) + widget.min); } @override Widget build(BuildContext context) { return new _CupertinoSliderRenderObjectWidget( - value: (config.value - config.min) / (config.max - config.min), - divisions: config.divisions, - activeColor: config.activeColor, - onChanged: config.onChanged != null ? _handleChanged : null, + value: (widget.value - widget.min) / (widget.max - widget.min), + divisions: widget.divisions, + activeColor: widget.activeColor, + onChanged: widget.onChanged != null ? _handleChanged : null, vsync: this, ); } diff --git a/packages/flutter/lib/src/cupertino/switch.dart b/packages/flutter/lib/src/cupertino/switch.dart index b7d5a56958..ff3b40f87a 100644 --- a/packages/flutter/lib/src/cupertino/switch.dart +++ b/packages/flutter/lib/src/cupertino/switch.dart @@ -79,9 +79,9 @@ class _CupertinoSwitchState extends State with TickerProviderSt @override Widget build(BuildContext context) { return new _CupertinoSwitchRenderObjectWidget( - value: config.value, - activeColor: config.activeColor, - onChanged: config.onChanged, + value: widget.value, + activeColor: widget.activeColor, + onChanged: widget.onChanged, vsync: this, ); } diff --git a/packages/flutter/lib/src/material/about.dart b/packages/flutter/lib/src/material/about.dart index f8e5495024..760a8c7c4d 100644 --- a/packages/flutter/lib/src/material/about.dart +++ b/packages/flutter/lib/src/material/about.dart @@ -421,13 +421,13 @@ class _LicensePageState extends State { @override Widget build(BuildContext context) { - final String name = config.applicationName ?? _defaultApplicationName(context); - final String version = config.applicationVersion ?? _defaultApplicationVersion(context); + final String name = widget.applicationName ?? _defaultApplicationName(context); + final String version = widget.applicationVersion ?? _defaultApplicationVersion(context); final List contents = [ new Text(name, style: Theme.of(context).textTheme.headline, textAlign: TextAlign.center), new Text(version, style: Theme.of(context).textTheme.body1, textAlign: TextAlign.center), new Container(height: 18.0), - new Text(config.applicationLegalese ?? '', style: Theme.of(context).textTheme.caption, textAlign: TextAlign.center), + new Text(widget.applicationLegalese ?? '', style: Theme.of(context).textTheme.caption, textAlign: TextAlign.center), new Container(height: 18.0), new Text('Powered by Flutter', style: Theme.of(context).textTheme.body1, textAlign: TextAlign.center), new Container(height: 24.0), diff --git a/packages/flutter/lib/src/material/app.dart b/packages/flutter/lib/src/material/app.dart index ccddbe2319..83daa0c4f2 100644 --- a/packages/flutter/lib/src/material/app.dart +++ b/packages/flutter/lib/src/material/app.dart @@ -206,47 +206,47 @@ class _MaterialAppState extends State { } Route _onGenerateRoute(RouteSettings settings) { - WidgetBuilder builder = config.routes[settings.name]; - if (builder == null && config.home != null && settings.name == Navigator.defaultRouteName) - builder = (BuildContext context) => config.home; + WidgetBuilder builder = widget.routes[settings.name]; + if (builder == null && widget.home != null && settings.name == Navigator.defaultRouteName) + builder = (BuildContext context) => widget.home; if (builder != null) { return new MaterialPageRoute( builder: builder, settings: settings ); } - if (config.onGenerateRoute != null) - return config.onGenerateRoute(settings); + if (widget.onGenerateRoute != null) + return widget.onGenerateRoute(settings); return null; } @override Widget build(BuildContext context) { - final ThemeData theme = config.theme ?? new ThemeData.fallback(); + final ThemeData theme = widget.theme ?? new ThemeData.fallback(); Widget result = new AnimatedTheme( data: theme, isMaterialAppTheme: true, child: new WidgetsApp( key: new GlobalObjectKey(this), - title: config.title, + title: widget.title, textStyle: _errorTextStyle, // blue is the primary color of the default theme - color: config.color ?? theme?.primaryColor ?? Colors.blue, + color: widget.color ?? theme?.primaryColor ?? Colors.blue, navigatorObservers: - new List.from(config.navigatorObservers) + new List.from(widget.navigatorObservers) ..add(_heroController), - initialRoute: config.initialRoute, + initialRoute: widget.initialRoute, onGenerateRoute: _onGenerateRoute, - onLocaleChanged: config.onLocaleChanged, - showPerformanceOverlay: config.showPerformanceOverlay, - checkerboardRasterCacheImages: config.checkerboardRasterCacheImages, - showSemanticsDebugger: config.showSemanticsDebugger, - debugShowCheckedModeBanner: config.debugShowCheckedModeBanner + onLocaleChanged: widget.onLocaleChanged, + showPerformanceOverlay: widget.showPerformanceOverlay, + checkerboardRasterCacheImages: widget.checkerboardRasterCacheImages, + showSemanticsDebugger: widget.showSemanticsDebugger, + debugShowCheckedModeBanner: widget.debugShowCheckedModeBanner ) ); assert(() { - if (config.debugShowMaterialGrid) { + if (widget.debugShowMaterialGrid) { result = new GridPaper( color: const Color(0xE0F9BBE0), interval: 8.0, diff --git a/packages/flutter/lib/src/material/app_bar.dart b/packages/flutter/lib/src/material/app_bar.dart index 6e7278adb5..477b2f630d 100644 --- a/packages/flutter/lib/src/material/app_bar.dart +++ b/packages/flutter/lib/src/material/app_bar.dart @@ -353,17 +353,17 @@ class _AppBarState extends State { Widget build(BuildContext context) { final ThemeData themeData = Theme.of(context); - IconThemeData appBarIconTheme = config.iconTheme ?? themeData.primaryIconTheme; - TextStyle centerStyle = config.textTheme?.title ?? themeData.primaryTextTheme.title; - TextStyle sideStyle = config.textTheme?.body1 ?? themeData.primaryTextTheme.body1; + IconThemeData appBarIconTheme = widget.iconTheme ?? themeData.primaryIconTheme; + TextStyle centerStyle = widget.textTheme?.title ?? themeData.primaryTextTheme.title; + TextStyle sideStyle = widget.textTheme?.body1 ?? themeData.primaryTextTheme.body1; - final Brightness brightness = config.brightness ?? themeData.primaryColorBrightness; + final Brightness brightness = widget.brightness ?? themeData.primaryColorBrightness; SystemChrome.setSystemUIOverlayStyle(brightness == Brightness.dark ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark); - if (config.toolbarOpacity != 1.0) { - final double opacity = const Interval(0.25, 1.0, curve: Curves.fastOutSlowIn).transform(config.toolbarOpacity); + if (widget.toolbarOpacity != 1.0) { + final double opacity = const Interval(0.25, 1.0, curve: Curves.fastOutSlowIn).transform(widget.toolbarOpacity); if (centerStyle?.color != null) centerStyle = centerStyle.copyWith(color: centerStyle.color.withOpacity(opacity)); if (sideStyle?.color != null) @@ -374,7 +374,7 @@ class _AppBarState extends State { } final List toolbarChildren = []; - Widget leading = config.leading; + Widget leading = widget.leading; if (leading == null) { if (_hasDrawer) { leading = new IconButton( @@ -396,7 +396,7 @@ class _AppBarState extends State { ); } - if (config.title != null) { + if (widget.title != null) { toolbarChildren.add( new LayoutId( id: _ToolbarSlot.title, @@ -404,19 +404,19 @@ class _AppBarState extends State { style: centerStyle, softWrap: false, overflow: TextOverflow.ellipsis, - child: config.title, + child: widget.title, ), ), ); } - if (config.actions != null && config.actions.isNotEmpty) { + if (widget.actions != null && widget.actions.isNotEmpty) { toolbarChildren.add( new LayoutId( id: _ToolbarSlot.actions, child: new Row( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, - children: config.actions, + children: widget.actions, ), ), ); @@ -426,7 +426,7 @@ class _AppBarState extends State { padding: const EdgeInsets.only(right: 4.0), child: new CustomMultiChildLayout( delegate: new _ToolbarLayout( - centerTitle: config._getEffectiveCenterTitle(themeData), + centerTitle: widget._getEffectiveCenterTitle(themeData), ), children: toolbarChildren, ), @@ -448,7 +448,7 @@ class _AppBarState extends State { ), ); - if (config.bottom != null) { + if (widget.bottom != null) { appBar = new Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -458,34 +458,34 @@ class _AppBarState extends State { child: appBar, ), ), - config.bottomOpacity == 1.0 ? config.bottom : new Opacity( - opacity: const Interval(0.25, 1.0, curve: Curves.fastOutSlowIn).transform(config.bottomOpacity), - child: config.bottom, + widget.bottomOpacity == 1.0 ? widget.bottom : new Opacity( + opacity: const Interval(0.25, 1.0, curve: Curves.fastOutSlowIn).transform(widget.bottomOpacity), + child: widget.bottom, ), ], ); } // The padding applies to the toolbar and tabbar, not the flexible space. - if (config.primary) { + if (widget.primary) { appBar = new Padding( padding: new EdgeInsets.only(top: MediaQuery.of(context).padding.top), child: appBar, ); } - if (config.flexibleSpace != null) { + if (widget.flexibleSpace != null) { appBar = new Stack( children: [ - config.flexibleSpace, + widget.flexibleSpace, new Positioned(top: 0.0, left: 0.0, right: 0.0, child: appBar), ], ); } return new Material( - color: config.backgroundColor ?? themeData.primaryColor, - elevation: config.elevation, + color: widget.backgroundColor ?? themeData.primaryColor, + elevation: widget.elevation, child: new Align( alignment: FractionalOffset.topCenter, child: appBar, diff --git a/packages/flutter/lib/src/material/bottom_navigation_bar.dart b/packages/flutter/lib/src/material/bottom_navigation_bar.dart index 65b4449414..23e4cc8fd8 100644 --- a/packages/flutter/lib/src/material/bottom_navigation_bar.dart +++ b/packages/flutter/lib/src/material/bottom_navigation_bar.dart @@ -164,21 +164,21 @@ class _BottomNavigationBarState extends State with TickerPr @override void initState() { super.initState(); - _controllers = new List.generate(config.items.length, (int index) { + _controllers = new List.generate(widget.items.length, (int index) { return new AnimationController( duration: kThemeAnimationDuration, vsync: this, )..addListener(_rebuild); }); - _animations = new List.generate(config.items.length, (int index) { + _animations = new List.generate(widget.items.length, (int index) { return new CurvedAnimation( parent: _controllers[index], curve: Curves.fastOutSlowIn, reverseCurve: Curves.fastOutSlowIn.flipped ); }); - _controllers[config.currentIndex].value = 1.0; - _backgroundColor = config.items[config.currentIndex].backgroundColor; + _controllers[widget.currentIndex].value = 1.0; + _backgroundColor = widget.items[widget.currentIndex].backgroundColor; } @override @@ -198,12 +198,12 @@ class _BottomNavigationBarState extends State with TickerPr } double get _maxWidth { - assert(config.type != null); - switch (config.type) { + assert(widget.type != null); + switch (widget.type) { case BottomNavigationBarType.fixed: - return config.items.length * _kActiveMaxWidth; + return widget.items.length * _kActiveMaxWidth; case BottomNavigationBarType.shifting: - return _kActiveMaxWidth + (config.items.length - 1) * _kInactiveMaxWidth; + return _kActiveMaxWidth + (widget.items.length - 1) * _kInactiveMaxWidth; } return null; } @@ -257,7 +257,7 @@ class _BottomNavigationBarState extends State with TickerPr } FractionalOffset _circleOffset(int index) { - final double iconSize = config.iconSize; + final double iconSize = widget.iconSize; final Tween yOffsetTween = new Tween( begin: (18.0 + iconSize / 2.0) / kBottomNavigationBarHeight, // 18dp + icon center end: (6.0 + iconSize / 2.0) / kBottomNavigationBarHeight // 6dp + icon center @@ -270,12 +270,12 @@ class _BottomNavigationBarState extends State with TickerPr } void _pushCircle(int index) { - if (config.items[index].backgroundColor != null) + if (widget.items[index].backgroundColor != null) _circles.add( new _Circle( state: this, index: index, - color: config.items[index].backgroundColor, + color: widget.items[index].backgroundColor, vsync: this, )..controller.addStatusListener((AnimationStatus status) { if (status == AnimationStatus.completed) { @@ -290,37 +290,37 @@ class _BottomNavigationBarState extends State with TickerPr } @override - void didUpdateConfig(BottomNavigationBar oldConfig) { - if (config.currentIndex != oldConfig.currentIndex) { - if (config.type == BottomNavigationBarType.shifting) - _pushCircle(config.currentIndex); - _controllers[oldConfig.currentIndex].reverse(); - _controllers[config.currentIndex].forward(); + void didUpdateWidget(BottomNavigationBar oldWidget) { + if (widget.currentIndex != oldWidget.currentIndex) { + if (widget.type == BottomNavigationBarType.shifting) + _pushCircle(widget.currentIndex); + _controllers[oldWidget.currentIndex].reverse(); + _controllers[widget.currentIndex].forward(); } } @override Widget build(BuildContext context) { Widget bottomNavigation; - switch (config.type) { + switch (widget.type) { case BottomNavigationBarType.fixed: final List children = []; final ThemeData themeData = Theme.of(context); final TextTheme textTheme = themeData.textTheme; final ColorTween colorTween = new ColorTween( begin: textTheme.caption.color, - end: config.fixedColor ?? ( + end: widget.fixedColor ?? ( themeData.brightness == Brightness.light ? themeData.primaryColor : themeData.accentColor ) ); - for (int i = 0; i < config.items.length; i += 1) { + for (int i = 0; i < widget.items.length; i += 1) { children.add( new Expanded( child: new InkResponse( onTap: () { - if (config.onTap != null) - config.onTap(i); + if (widget.onTap != null) + widget.onTap(i); }, child: new Stack( alignment: FractionalOffset.center, @@ -337,9 +337,9 @@ class _BottomNavigationBarState extends State with TickerPr child: new IconTheme( data: new IconThemeData( color: colorTween.evaluate(_animations[i]), - size: config.iconSize, + size: widget.iconSize, ), - child: config.items[i].icon, + child: widget.items[i].icon, ), ), ), @@ -361,7 +361,7 @@ class _BottomNavigationBarState extends State with TickerPr ).evaluate(_animations[i]), )), alignment: FractionalOffset.bottomCenter, - child: config.items[i].title, + child: widget.items[i].title, ), ), ), @@ -381,7 +381,7 @@ class _BottomNavigationBarState extends State with TickerPr case BottomNavigationBarType.shifting: final List children = []; _computeWeight(); - for (int i = 0; i < config.items.length; i += 1) { + for (int i = 0; i < widget.items.length; i += 1) { children.add( new Expanded( // Since Flexible only supports integers, we're using large @@ -389,8 +389,8 @@ class _BottomNavigationBarState extends State with TickerPr flex: (_flex(_animations[i]) * 1000.0).round(), child: new InkResponse( onTap: () { - if (config.onTap != null) - config.onTap(i); + if (widget.onTap != null) + widget.onTap(i); }, child: new Stack( alignment: FractionalOffset.center, @@ -407,9 +407,9 @@ class _BottomNavigationBarState extends State with TickerPr child: new IconTheme( data: new IconThemeData( color: Colors.white, - size: config.iconSize, + size: widget.iconSize, ), - child: config.items[i].icon, + child: widget.items[i].icon, ), ), ), @@ -425,7 +425,7 @@ class _BottomNavigationBarState extends State with TickerPr fontSize: 14.0, color: Colors.white ), - child: config.items[i].title + child: widget.items[i].title ), ), ), @@ -450,7 +450,7 @@ class _BottomNavigationBarState extends State with TickerPr new Positioned.fill( child: new Material( // Casts shadow. elevation: 8, - color: config.type == BottomNavigationBarType.shifting ? _backgroundColor : null + color: widget.type == BottomNavigationBarType.shifting ? _backgroundColor : null ) ), new SizedBox( diff --git a/packages/flutter/lib/src/material/bottom_sheet.dart b/packages/flutter/lib/src/material/bottom_sheet.dart index 1c8ef863a1..0f8bfa6d38 100644 --- a/packages/flutter/lib/src/material/bottom_sheet.dart +++ b/packages/flutter/lib/src/material/bottom_sheet.dart @@ -98,12 +98,12 @@ class _BottomSheetState extends State { return renderBox.size.height; } - bool get _dismissUnderway => config.animationController.status == AnimationStatus.reverse; + bool get _dismissUnderway => widget.animationController.status == AnimationStatus.reverse; void _handleDragUpdate(DragUpdateDetails details) { if (_dismissUnderway) return; - config.animationController.value -= details.primaryDelta / (_childHeight ?? details.primaryDelta); + widget.animationController.value -= details.primaryDelta / (_childHeight ?? details.primaryDelta); } void _handleDragEnd(DragEndDetails details) { @@ -111,16 +111,16 @@ class _BottomSheetState extends State { return; if (details.velocity.pixelsPerSecond.dy > _kMinFlingVelocity) { final double flingVelocity = -details.velocity.pixelsPerSecond.dy / _childHeight; - if (config.animationController.value > 0.0) - config.animationController.fling(velocity: flingVelocity); + if (widget.animationController.value > 0.0) + widget.animationController.fling(velocity: flingVelocity); if (flingVelocity < 0.0) - config.onClosing(); - } else if (config.animationController.value < _kCloseProgressThreshold) { - if (config.animationController.value > 0.0) - config.animationController.fling(velocity: -1.0); - config.onClosing(); + widget.onClosing(); + } else if (widget.animationController.value < _kCloseProgressThreshold) { + if (widget.animationController.value > 0.0) + widget.animationController.fling(velocity: -1.0); + widget.onClosing(); } else { - config.animationController.forward(); + widget.animationController.forward(); } } @@ -131,7 +131,7 @@ class _BottomSheetState extends State { onVerticalDragEnd: _handleDragEnd, child: new Material( key: _childKey, - child: config.builder(context) + child: widget.builder(context) ) ); } @@ -185,15 +185,15 @@ class _ModalBottomSheetState extends State<_ModalBottomSheet> { return new GestureDetector( onTap: () => Navigator.pop(context), child: new AnimatedBuilder( - animation: config.route.animation, + animation: widget.route.animation, builder: (BuildContext context, Widget child) { return new ClipRect( child: new CustomSingleChildLayout( - delegate: new _ModalBottomSheetLayout(config.route.animation.value), + delegate: new _ModalBottomSheetLayout(widget.route.animation.value), child: new BottomSheet( - animationController: config.route._animationController, + animationController: widget.route._animationController, onClosing: () => Navigator.pop(context), - builder: config.route.builder + builder: widget.route.builder ) ) ); diff --git a/packages/flutter/lib/src/material/button.dart b/packages/flutter/lib/src/material/button.dart index 1bd69f8edc..182c2dfa7a 100644 --- a/packages/flutter/lib/src/material/button.dart +++ b/packages/flutter/lib/src/material/button.dart @@ -246,14 +246,14 @@ class _MaterialButtonState extends State { bool _highlight = false; Brightness get _colorBrightness { - return config.colorBrightness ?? Theme.of(context).brightness; + return widget.colorBrightness ?? Theme.of(context).brightness; } Color get _textColor { - if (config.textColor != null) - return config.textColor; - if (config.enabled) { - switch (config.textTheme ?? ButtonTheme.of(context).textTheme) { + if (widget.textColor != null) + return widget.textColor; + if (widget.enabled) { + switch (widget.textTheme ?? ButtonTheme.of(context).textTheme) { case ButtonTextTheme.accent: return Theme.of(context).accentColor; case ButtonTextTheme.normal: @@ -289,9 +289,9 @@ class _MaterialButtonState extends State { final Color textColor = _textColor; final TextStyle style = theme.textTheme.button.copyWith(color: textColor); final ButtonTheme buttonTheme = ButtonTheme.of(context); - final double height = config.height ?? buttonTheme.height; - final int elevation = (_highlight ? config.highlightElevation : config.elevation) ?? 0; - final bool hasColorOrElevation = (config.color != null || elevation > 0); + final double height = widget.height ?? buttonTheme.height; + final int elevation = (_highlight ? widget.highlightElevation : widget.elevation) ?? 0; + final bool hasColorOrElevation = (widget.color != null || elevation > 0); Widget contents = new IconTheme.merge( context: context, data: new IconThemeData( @@ -299,15 +299,15 @@ class _MaterialButtonState extends State { ), child: new InkWell( borderRadius: hasColorOrElevation ? null : kMaterialEdges[MaterialType.button], - highlightColor: config.highlightColor ?? theme.highlightColor, - splashColor: config.splashColor ?? theme.splashColor, - onTap: config.onPressed, + highlightColor: widget.highlightColor ?? theme.highlightColor, + splashColor: widget.splashColor ?? theme.splashColor, + onTap: widget.onPressed, onHighlightChanged: _handleHighlightChanged, child: new Container( - padding: config.padding ?? ButtonTheme.of(context).padding, + padding: widget.padding ?? ButtonTheme.of(context).padding, child: new Center( widthFactor: 1.0, - child: config.child + child: widget.child ) ) ) @@ -315,7 +315,7 @@ class _MaterialButtonState extends State { if (hasColorOrElevation) { contents = new Material( type: MaterialType.button, - color: config.color, + color: widget.color, elevation: elevation, textStyle: style, child: contents @@ -329,7 +329,7 @@ class _MaterialButtonState extends State { } return new ConstrainedBox( constraints: new BoxConstraints( - minWidth: config.minWidth ?? buttonTheme.minWidth, + minWidth: widget.minWidth ?? buttonTheme.minWidth, minHeight: height, maxHeight: height ), diff --git a/packages/flutter/lib/src/material/checkbox.dart b/packages/flutter/lib/src/material/checkbox.dart index 36fb01a281..cfd07260e6 100644 --- a/packages/flutter/lib/src/material/checkbox.dart +++ b/packages/flutter/lib/src/material/checkbox.dart @@ -93,10 +93,10 @@ class _CheckboxState extends State with TickerProviderStateMixin { assert(debugCheckHasMaterial(context)); final ThemeData themeData = Theme.of(context); return new _CheckboxRenderObjectWidget( - value: config.value, - activeColor: config.activeColor ?? themeData.accentColor, - inactiveColor: config.onChanged != null ? themeData.unselectedWidgetColor : themeData.disabledColor, - onChanged: config.onChanged, + value: widget.value, + activeColor: widget.activeColor ?? themeData.accentColor, + inactiveColor: widget.onChanged != null ? themeData.unselectedWidgetColor : themeData.disabledColor, + onChanged: widget.onChanged, vsync: this, ); } diff --git a/packages/flutter/lib/src/material/data_table.dart b/packages/flutter/lib/src/material/data_table.dart index 039597bade..4e11babe96 100644 --- a/packages/flutter/lib/src/material/data_table.dart +++ b/packages/flutter/lib/src/material/data_table.dart @@ -160,7 +160,7 @@ class DataCell { /// If the cell has no data, then a [Text] widget with placeholder /// text should be provided instead, and then the [placeholder] /// argument should be set to true. - const DataCell(this.widget, { + const DataCell(this.child, { this.placeholder: false, this.showEditIcon: false, this.onTap @@ -176,9 +176,9 @@ class DataCell { /// If the cell has no data, then a [Text] widget with placeholder /// text should be provided instead, and [placeholder] should be set /// to true. - final Widget widget; + final Widget child; - /// Whether the [widget] is actually a placeholder. + /// Whether the [child] is actually a placeholder. /// /// If this is true, the default text style for the cell is changed /// to be appropriate for placeholder text. @@ -571,7 +571,7 @@ class DataTable extends StatelessWidget { tableRows[rowIndex].children[displayColumnIndex] = _buildDataCell( context: context, padding: padding, - label: cell.widget, + label: cell.child, numeric: column.numeric, placeholder: cell.placeholder, showEditIcon: cell.showEditIcon, @@ -692,27 +692,27 @@ class _SortArrowState extends State<_SortArrow> with TickerProviderStateMixin { super.initState(); _opacityAnimation = new CurvedAnimation( parent: _opacityController = new AnimationController( - duration: config.duration, + duration: widget.duration, vsync: this, ), curve: Curves.fastOutSlowIn ) ..addListener(_rebuild); - _opacityController.value = config.visible ? 1.0 : 0.0; + _opacityController.value = widget.visible ? 1.0 : 0.0; _orientationAnimation = new Tween( begin: 0.0, end: math.PI ).animate(new CurvedAnimation( parent: _orientationController = new AnimationController( - duration: config.duration, + duration: widget.duration, vsync: this, ), curve: Curves.easeIn )) ..addListener(_rebuild) ..addStatusListener(_resetOrientationAnimation); - if (config.visible) - _orientationOffset = config.down ? 0.0 : math.PI; + if (widget.visible) + _orientationOffset = widget.down ? 0.0 : math.PI; } void _rebuild() { @@ -730,18 +730,18 @@ class _SortArrowState extends State<_SortArrow> with TickerProviderStateMixin { } @override - void didUpdateConfig(_SortArrow oldConfig) { - super.didUpdateConfig(oldConfig); + void didUpdateWidget(_SortArrow oldWidget) { + super.didUpdateWidget(oldWidget); bool skipArrow = false; - final bool newDown = config.down != null ? config.down : _down; - if (oldConfig.visible != config.visible) { - if (config.visible && (_opacityController.status == AnimationStatus.dismissed)) { + final bool newDown = widget.down != null ? widget.down : _down; + if (oldWidget.visible != widget.visible) { + if (widget.visible && (_opacityController.status == AnimationStatus.dismissed)) { _orientationController.stop(); _orientationController.value = 0.0; _orientationOffset = newDown ? 0.0 : math.PI; skipArrow = true; } - if (config.visible) { + if (widget.visible) { _opacityController.forward(); } else { _opacityController.reverse(); diff --git a/packages/flutter/lib/src/material/date_picker.dart b/packages/flutter/lib/src/material/date_picker.dart index 1d51fe39de..2d8762086d 100644 --- a/packages/flutter/lib/src/material/date_picker.dart +++ b/packages/flutter/lib/src/material/date_picker.dart @@ -365,17 +365,17 @@ class _MonthPickerState extends State { void initState() { super.initState(); // Initially display the pre-selected date. - _dayPickerController = new PageController(initialPage: _monthDelta(config.firstDate, config.selectedDate)); - _currentDisplayedMonthDate = new DateTime(config.selectedDate.year, config.selectedDate.month); + _dayPickerController = new PageController(initialPage: _monthDelta(widget.firstDate, widget.selectedDate)); + _currentDisplayedMonthDate = new DateTime(widget.selectedDate.year, widget.selectedDate.month); _updateCurrentDate(); } @override - void didUpdateConfig(MonthPicker oldConfig) { - if (config.selectedDate != oldConfig.selectedDate) { - _dayPickerController = new PageController(initialPage: _monthDelta(config.firstDate, config.selectedDate)); + void didUpdateWidget(MonthPicker oldWidget) { + if (widget.selectedDate != oldWidget.selectedDate) { + _dayPickerController = new PageController(initialPage: _monthDelta(widget.firstDate, widget.selectedDate)); _currentDisplayedMonthDate = - new DateTime(config.selectedDate.year, config.selectedDate.month); + new DateTime(widget.selectedDate.year, widget.selectedDate.month); } } @@ -407,16 +407,16 @@ class _MonthPickerState extends State { } Widget _buildItems(BuildContext context, int index) { - final DateTime month = _addMonthsToMonthDate(config.firstDate, index); + final DateTime month = _addMonthsToMonthDate(widget.firstDate, index); return new DayPicker( key: new ValueKey(month), - selectedDate: config.selectedDate, + selectedDate: widget.selectedDate, currentDate: _todayDate, - onChanged: config.onChanged, - firstDate: config.firstDate, - lastDate: config.lastDate, + onChanged: widget.onChanged, + firstDate: widget.firstDate, + lastDate: widget.lastDate, displayedMonth: month, - selectableDayPredicate: config.selectableDayPredicate, + selectableDayPredicate: widget.selectableDayPredicate, ); } @@ -433,18 +433,18 @@ class _MonthPickerState extends State { /// True if the earliest allowable month is displayed. bool get _isDisplayingFirstMonth { return !_currentDisplayedMonthDate.isAfter( - new DateTime(config.firstDate.year, config.firstDate.month)); + new DateTime(widget.firstDate.year, widget.firstDate.month)); } /// True if the latest allowable month is displayed. bool get _isDisplayingLastMonth { return !_currentDisplayedMonthDate.isBefore( - new DateTime(config.lastDate.year, config.lastDate.month)); + new DateTime(widget.lastDate.year, widget.lastDate.month)); } void _handleMonthPageChanged(int monthPage) { setState(() { - _currentDisplayedMonthDate = _addMonthsToMonthDate(config.firstDate, monthPage); + _currentDisplayedMonthDate = _addMonthsToMonthDate(widget.firstDate, monthPage); }); } @@ -456,10 +456,10 @@ class _MonthPickerState extends State { child: new Stack( children: [ new PageView.builder( - key: new ValueKey(config.selectedDate), + key: new ValueKey(widget.selectedDate), controller: _dayPickerController, scrollDirection: Axis.horizontal, - itemCount: _monthDelta(config.firstDate, config.lastDate) + 1, + itemCount: _monthDelta(widget.firstDate, widget.lastDate) + 1, itemBuilder: _buildItems, onPageChanged: _handleMonthPageChanged, ), @@ -552,15 +552,15 @@ class _YearPickerState extends State { final TextStyle style = themeData.textTheme.body1; return new ListView.builder( itemExtent: _itemExtent, - itemCount: config.lastDate.year - config.firstDate.year + 1, + itemCount: widget.lastDate.year - widget.firstDate.year + 1, itemBuilder: (BuildContext context, int index) { - final int year = config.firstDate.year + index; - final TextStyle itemStyle = year == config.selectedDate.year ? + final int year = widget.firstDate.year + index; + final TextStyle itemStyle = year == widget.selectedDate.year ? themeData.textTheme.headline.copyWith(color: themeData.accentColor) : style; return new InkWell( key: new ValueKey(year), onTap: () { - config.onChanged(new DateTime(year, config.selectedDate.month, config.selectedDate.day)); + widget.onChanged(new DateTime(year, widget.selectedDate.month, widget.selectedDate.day)); }, child: new Center( child: new Text(year.toString(), style: itemStyle), @@ -593,7 +593,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> { @override void initState() { super.initState(); - _selectedDate = config.initialDate; + _selectedDate = widget.initialDate; } DateTime _selectedDate; @@ -649,17 +649,17 @@ class _DatePickerDialogState extends State<_DatePickerDialog> { key: _pickerKey, selectedDate: _selectedDate, onChanged: _handleDayChanged, - firstDate: config.firstDate, - lastDate: config.lastDate, - selectableDayPredicate: config.selectableDayPredicate, + firstDate: widget.firstDate, + lastDate: widget.lastDate, + selectableDayPredicate: widget.selectableDayPredicate, ); case _DatePickerMode.year: return new YearPicker( key: _pickerKey, selectedDate: _selectedDate, onChanged: _handleYearChanged, - firstDate: config.firstDate, - lastDate: config.lastDate, + firstDate: widget.firstDate, + lastDate: widget.lastDate, ); } return null; diff --git a/packages/flutter/lib/src/material/drawer.dart b/packages/flutter/lib/src/material/drawer.dart index d112938a0d..a6f625b747 100644 --- a/packages/flutter/lib/src/material/drawer.dart +++ b/packages/flutter/lib/src/material/drawer.dart @@ -290,7 +290,7 @@ class DrawerControllerState extends State with SingleTickerPro child: new FocusScope( key: _drawerKey, node: _focusScopeNode, - child: config.child + child: widget.child ), ), ), diff --git a/packages/flutter/lib/src/material/dropdown.dart b/packages/flutter/lib/src/material/dropdown.dart index 8ba802323c..64d3a3a595 100644 --- a/packages/flutter/lib/src/material/dropdown.dart +++ b/packages/flutter/lib/src/material/dropdown.dart @@ -113,12 +113,12 @@ class _DropdownMenuState extends State<_DropdownMenu> { // the CurvedAnimation objects in build, we'd lose // CurvedAnimation._curveDirection. _fadeOpacity = new CurvedAnimation( - parent: config.route.animation, + parent: widget.route.animation, curve: const Interval(0.0, 0.25), reverseCurve: const Interval(0.75, 1.0), ); _resize = new CurvedAnimation( - parent: config.route.animation, + parent: widget.route.animation, curve: const Interval(0.25, 0.5), reverseCurve: const Threshold(0.0), ); @@ -134,7 +134,7 @@ class _DropdownMenuState extends State<_DropdownMenu> { // // When the menu is dismissed we just fade the entire thing out // in the first 0.25s. - final _DropdownRoute route = config.route; + final _DropdownRoute route = widget.route; final double unit = 0.5 / (route.items.length + 1.5); final List children = []; for (int itemIndex = 0; itemIndex < route.items.length; ++itemIndex) { @@ -177,7 +177,7 @@ class _DropdownMenuState extends State<_DropdownMenu> { behavior: const _DropdownScrollBehavior(), child: new Scrollbar( child: new ListView( - controller: config.route.scrollController, + controller: widget.route.scrollController, padding: kMaterialListPadding, itemExtent: _kMenuItemHeight, shrinkWrap: true, @@ -479,39 +479,39 @@ class _DropdownButtonState extends State> { } @override - void didUpdateConfig(DropdownButton oldConfig) { + void didUpdateWidget(DropdownButton oldWidget) { _updateSelectedIndex(); } void _updateSelectedIndex() { - assert(config.value == null || - config.items.where((DropdownMenuItem item) => item.value == config.value).length == 1); + assert(widget.value == null || + widget.items.where((DropdownMenuItem item) => item.value == widget.value).length == 1); _selectedIndex = null; - for (int itemIndex = 0; itemIndex < config.items.length; itemIndex++) { - if (config.items[itemIndex].value == config.value) { + for (int itemIndex = 0; itemIndex < widget.items.length; itemIndex++) { + if (widget.items[itemIndex].value == widget.value) { _selectedIndex = itemIndex; return; } } } - TextStyle get _textStyle => config.style ?? Theme.of(context).textTheme.subhead; + TextStyle get _textStyle => widget.style ?? Theme.of(context).textTheme.subhead; void _handleTap() { final RenderBox itemBox = context.findRenderObject(); final Rect itemRect = itemBox.localToGlobal(Point.origin) & itemBox.size; Navigator.push(context, new _DropdownRoute( - items: config.items, + items: widget.items, buttonRect: _kMenuHorizontalPadding.inflateRect(itemRect), selectedIndex: _selectedIndex ?? 0, - elevation: config.elevation, + elevation: widget.elevation, theme: Theme.of(context, shadowThemeOnly: true), style: _textStyle, )).then((_DropdownRouteResult newValue) { if (!mounted || newValue == null) return null; - if (config.onChanged != null) - config.onChanged(newValue.result); + if (widget.onChanged != null) + widget.onChanged(newValue.result); }); } @@ -520,7 +520,7 @@ class _DropdownButtonState extends State> { // Similarly, we don't reduce the height of the button so much that its icon // would be clipped. double get _denseButtonHeight { - return math.max(_textStyle.fontSize, math.max(config.iconSize, _kDenseButtonHeight)); + return math.max(_textStyle.fontSize, math.max(widget.iconSize, _kDenseButtonHeight)); } @override @@ -529,14 +529,14 @@ class _DropdownButtonState extends State> { // The width of the button and the menu are defined by the widest // item and the width of the hint. - final List items = new List.from(config.items); + final List items = new List.from(widget.items); int hintIndex; - if (config.hint != null) { + if (widget.hint != null) { hintIndex = items.length; items.add(new DefaultTextStyle( style: _textStyle.copyWith(color: Theme.of(context).hintColor), child: new IgnorePointer( - child: config.hint, + child: widget.hint, ), )); } @@ -544,7 +544,7 @@ class _DropdownButtonState extends State> { Widget result = new DefaultTextStyle( style: _textStyle, child: new SizedBox( - height: config.isDense ? _denseButtonHeight : null, + height: widget.isDense ? _denseButtonHeight : null, child: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.min, @@ -557,7 +557,7 @@ class _DropdownButtonState extends State> { children: items, ), new Icon(Icons.arrow_drop_down, - size: config.iconSize, + size: widget.iconSize, // These colors are not defined in the Material Design spec. color: Theme.of(context).brightness == Brightness.light ? Colors.grey.shade700 : Colors.white70 ), @@ -567,7 +567,7 @@ class _DropdownButtonState extends State> { ); if (!DropdownButtonHideUnderline.at(context)) { - final double bottom = config.isDense ? 0.0 : 8.0; + final double bottom = widget.isDense ? 0.0 : 8.0; result = new Stack( children: [ result, diff --git a/packages/flutter/lib/src/material/expand_icon.dart b/packages/flutter/lib/src/material/expand_icon.dart index 3bb261d2d8..0c4140ab96 100644 --- a/packages/flutter/lib/src/material/expand_icon.dart +++ b/packages/flutter/lib/src/material/expand_icon.dart @@ -83,9 +83,9 @@ class _ExpandIconState extends State with SingleTickerProviderStateM } @override - void didUpdateConfig(ExpandIcon oldConfig) { - if (config.isExpanded != oldConfig.isExpanded) { - if (config.isExpanded) { + void didUpdateWidget(ExpandIcon oldWidget) { + if (widget.isExpanded != oldWidget.isExpanded) { + if (widget.isExpanded) { _controller.forward(); } else { _controller.reverse(); @@ -94,17 +94,17 @@ class _ExpandIconState extends State with SingleTickerProviderStateM } void _handlePressed() { - if (config.onPressed != null) - config.onPressed(config.isExpanded); + if (widget.onPressed != null) + widget.onPressed(widget.isExpanded); } @override Widget build(BuildContext context) { assert(debugCheckHasMaterial(context)); return new IconButton( - padding: config.padding, + padding: widget.padding, color: Colors.black38, - onPressed: config.onPressed == null ? null : _handlePressed, + onPressed: widget.onPressed == null ? null : _handlePressed, icon: new RotationTransition( turns: _iconTurns, child: const Icon(Icons.expand_more) diff --git a/packages/flutter/lib/src/material/flexible_space_bar.dart b/packages/flutter/lib/src/material/flexible_space_bar.dart index 89366ecc3b..d30294e580 100644 --- a/packages/flutter/lib/src/material/flexible_space_bar.dart +++ b/packages/flutter/lib/src/material/flexible_space_bar.dart @@ -79,8 +79,8 @@ class FlexibleSpaceBar extends StatefulWidget { class _FlexibleSpaceBarState extends State { bool _getEffectiveCenterTitle(ThemeData theme) { - if (config.centerTitle != null) - return config.centerTitle; + if (widget.centerTitle != null) + return widget.centerTitle; assert(theme.platform != null); switch (theme.platform) { case TargetPlatform.android: @@ -106,7 +106,7 @@ class _FlexibleSpaceBarState extends State { final double t = (1.0 - (settings.currentExtent - settings.minExtent) / (deltaExtent)).clamp(0.0, 1.0); // background image - if (config.background != null) { + if (widget.background != null) { final double fadeStart = math.max(0.0, 1.0 - kToolbarHeight / deltaExtent); final double fadeEnd = 1.0; assert(fadeStart <= fadeEnd); @@ -120,13 +120,13 @@ class _FlexibleSpaceBarState extends State { height: settings.maxExtent, child: new Opacity( opacity: opacity, - child: config.background + child: widget.background ) )); } } - if (config.title != null) { + if (widget.title != null) { final ThemeData theme = Theme.of(context); final double opacity = settings.toolbarOpacity; if (opacity > 0.0) { @@ -149,7 +149,7 @@ class _FlexibleSpaceBarState extends State { transform: scaleTransform, child: new Align( alignment: titleAlignment, - child: new DefaultTextStyle(style: titleStyle, child: config.title) + child: new DefaultTextStyle(style: titleStyle, child: widget.title) ) ) )); diff --git a/packages/flutter/lib/src/material/floating_action_button.dart b/packages/flutter/lib/src/material/floating_action_button.dart index 653eb08e99..acaed34965 100644 --- a/packages/flutter/lib/src/material/floating_action_button.dart +++ b/packages/flutter/lib/src/material/floating_action_button.dart @@ -116,7 +116,7 @@ class _FloatingActionButtonState extends State { @override Widget build(BuildContext context) { Color iconColor = Colors.white; - Color materialColor = config.backgroundColor; + Color materialColor = widget.backgroundColor; if (materialColor == null) { final ThemeData themeData = Theme.of(context); materialColor = themeData.accentColor; @@ -127,28 +127,28 @@ class _FloatingActionButtonState extends State { child: new IconTheme.merge( context: context, data: new IconThemeData(color: iconColor), - child: config.child + child: widget.child ) ); - if (config.tooltip != null) { + if (widget.tooltip != null) { result = new Tooltip( - message: config.tooltip, + message: widget.tooltip, child: result ); } return new Hero( - tag: config.heroTag ?? _kDefaultHeroTag, + tag: widget.heroTag ?? _kDefaultHeroTag, child: new Material( color: materialColor, type: MaterialType.circle, - elevation: _highlight ? config.highlightElevation : config.elevation, + elevation: _highlight ? widget.highlightElevation : widget.elevation, child: new Container( - width: config.mini ? _kSizeMini : _kSize, - height: config.mini ? _kSizeMini : _kSize, + width: widget.mini ? _kSizeMini : _kSize, + height: widget.mini ? _kSizeMini : _kSize, child: new InkWell( - onTap: config.onPressed, + onTap: widget.onPressed, onHighlightChanged: _handleHighlightChanged, child: result ) diff --git a/packages/flutter/lib/src/material/ink_well.dart b/packages/flutter/lib/src/material/ink_well.dart index 841e4feaac..ffe186d2b9 100644 --- a/packages/flutter/lib/src/material/ink_well.dart +++ b/packages/flutter/lib/src/material/ink_well.dart @@ -130,10 +130,10 @@ class _InkResponseState extends State { _lastHighlight = new InkHighlight( controller: Material.of(context), referenceBox: referenceBox, - color: config.highlightColor ?? Theme.of(context).highlightColor, - shape: config.highlightShape, - borderRadius: config.borderRadius, - rectCallback: config.getRectCallback(referenceBox), + color: widget.highlightColor ?? Theme.of(context).highlightColor, + shape: widget.highlightShape, + borderRadius: widget.borderRadius, + rectCallback: widget.getRectCallback(referenceBox), onRemoved: () { assert(_lastHighlight != null); _lastHighlight = null; @@ -146,23 +146,23 @@ class _InkResponseState extends State { _lastHighlight.deactivate(); } assert(value == (_lastHighlight != null && _lastHighlight.active)); - if (config.onHighlightChanged != null) - config.onHighlightChanged(value); + if (widget.onHighlightChanged != null) + widget.onHighlightChanged(value); } void _handleTapDown(TapDownDetails details) { final RenderBox referenceBox = context.findRenderObject(); - final RectCallback rectCallback = config.getRectCallback(referenceBox); + final RectCallback rectCallback = widget.getRectCallback(referenceBox); InkSplash splash; splash = new InkSplash( controller: Material.of(context), referenceBox: referenceBox, position: referenceBox.globalToLocal(details.globalPosition), - color: config.splashColor ?? Theme.of(context).splashColor, - containedInkWell: config.containedInkWell, - rectCallback: config.containedInkWell ? rectCallback : null, - radius: config.radius, - borderRadius: config.borderRadius ?? BorderRadius.zero, + color: widget.splashColor ?? Theme.of(context).splashColor, + containedInkWell: widget.containedInkWell, + rectCallback: widget.containedInkWell ? rectCallback : null, + radius: widget.radius, + borderRadius: widget.borderRadius ?? BorderRadius.zero, onRemoved: () { if (_splashes != null) { assert(_splashes.contains(splash)); @@ -182,8 +182,8 @@ class _InkResponseState extends State { _currentSplash?.confirm(); _currentSplash = null; updateHighlight(false); - if (config.onTap != null) - config.onTap(); + if (widget.onTap != null) + widget.onTap(); } void _handleTapCancel() { @@ -195,15 +195,15 @@ class _InkResponseState extends State { void _handleDoubleTap() { _currentSplash?.confirm(); _currentSplash = null; - if (config.onDoubleTap != null) - config.onDoubleTap(); + if (widget.onDoubleTap != null) + widget.onDoubleTap(); } void _handleLongPress() { _currentSplash?.confirm(); _currentSplash = null; - if (config.onLongPress != null) - config.onLongPress(); + if (widget.onLongPress != null) + widget.onLongPress(); } @override @@ -223,19 +223,19 @@ class _InkResponseState extends State { @override Widget build(BuildContext context) { - assert(config.debugCheckContext(context)); + assert(widget.debugCheckContext(context)); final ThemeData themeData = Theme.of(context); - _lastHighlight?.color = config.highlightColor ?? themeData.highlightColor; - _currentSplash?.color = config.splashColor ?? themeData.splashColor; - final bool enabled = config.onTap != null || config.onDoubleTap != null || config.onLongPress != null; + _lastHighlight?.color = widget.highlightColor ?? themeData.highlightColor; + _currentSplash?.color = widget.splashColor ?? themeData.splashColor; + final bool enabled = widget.onTap != null || widget.onDoubleTap != null || widget.onLongPress != null; return new GestureDetector( onTapDown: enabled ? _handleTapDown : null, onTap: enabled ? _handleTap : null, onTapCancel: enabled ? _handleTapCancel : null, - onDoubleTap: config.onDoubleTap != null ? _handleDoubleTap : null, - onLongPress: config.onLongPress != null ? _handleLongPress : null, + onDoubleTap: widget.onDoubleTap != null ? _handleDoubleTap : null, + onLongPress: widget.onLongPress != null ? _handleLongPress : null, behavior: HitTestBehavior.opaque, - child: config.child + child: widget.child ); } diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index 1b543e71b3..ca12aa56e4 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -491,25 +491,25 @@ class _AnimatedLabelState extends AnimatedWidgetBaseState<_AnimatedLabel> { @override void forEachTween(TweenVisitor visitor) { - _style = visitor(_style, config.style, (dynamic value) => new TextStyleTween(begin: value)); + _style = visitor(_style, widget.style, (dynamic value) => new TextStyleTween(begin: value)); } @override Widget build(BuildContext context) { TextStyle style = _style.evaluate(animation); double scale = 1.0; - if (style.fontSize != config.style.fontSize) { + if (style.fontSize != widget.style.fontSize) { // While the fontSize is transitioning, use a scaled Transform as a // fraction of the original fontSize. That way we get a smooth scaling // effect with no snapping between discrete font sizes. - scale = style.fontSize / config.style.fontSize; - style = style.copyWith(fontSize: config.style.fontSize); + scale = style.fontSize / widget.style.fontSize; + style = style.copyWith(fontSize: widget.style.fontSize); } return new Transform( transform: new Matrix4.identity()..scale(scale), child: new Text( - config.text, + widget.text, style: style, ), ); diff --git a/packages/flutter/lib/src/material/material.dart b/packages/flutter/lib/src/material/material.dart index e8c09aa7cb..39e8b55ed6 100644 --- a/packages/flutter/lib/src/material/material.dart +++ b/packages/flutter/lib/src/material/material.dart @@ -199,9 +199,9 @@ class _MaterialState extends State with TickerProviderStateMixin { final GlobalKey _inkFeatureRenderer = new GlobalKey(debugLabel: 'ink renderer'); Color _getBackgroundColor(BuildContext context) { - if (config.color != null) - return config.color; - switch (config.type) { + if (widget.color != null) + return widget.color; + switch (widget.type) { case MaterialType.canvas: return Theme.of(context).canvasColor; case MaterialType.card: @@ -214,12 +214,12 @@ class _MaterialState extends State with TickerProviderStateMixin { @override Widget build(BuildContext context) { final Color backgroundColor = _getBackgroundColor(context); - assert(backgroundColor != null || config.type == MaterialType.transparency); - Widget contents = config.child; - final BorderRadius radius = config.borderRadius ?? kMaterialEdges[config.type]; + assert(backgroundColor != null || widget.type == MaterialType.transparency); + Widget contents = widget.child; + final BorderRadius radius = widget.borderRadius ?? kMaterialEdges[widget.type]; if (contents != null) { contents = new AnimatedDefaultTextStyle( - style: config.textStyle ?? Theme.of(context).textTheme.body1, + style: widget.textStyle ?? Theme.of(context).textTheme.body1, duration: kThemeChangeDuration, child: contents ); @@ -239,14 +239,14 @@ class _MaterialState extends State with TickerProviderStateMixin { ); if (Material.debugEnablePhysicalModel) { - if (config.type == MaterialType.circle) { + if (widget.type == MaterialType.circle) { contents = new PhysicalModel( shape: BoxShape.circle, - elevation: config.elevation, + elevation: widget.elevation, color: backgroundColor, child: contents, ); - } else if (config.type == MaterialType.transparency) { + } else if (widget.type == MaterialType.transparency) { if (radius == null) { contents = new ClipRect(child: contents); } else { @@ -259,15 +259,15 @@ class _MaterialState extends State with TickerProviderStateMixin { contents = new PhysicalModel( shape: BoxShape.rectangle, borderRadius: radius ?? BorderRadius.zero, - elevation: config.elevation, + elevation: widget.elevation, color: backgroundColor, child: contents, ); } } else { - if (config.type == MaterialType.circle) { + if (widget.type == MaterialType.circle) { contents = new ClipOval(child: contents); - } else if (kMaterialEdges[config.type] != null) { + } else if (kMaterialEdges[widget.type] != null) { contents = new ClipRRect( borderRadius: radius, child: contents @@ -275,21 +275,21 @@ class _MaterialState extends State with TickerProviderStateMixin { } } - if (config.type != MaterialType.transparency) { + if (widget.type != MaterialType.transparency) { contents = new AnimatedContainer( curve: Curves.fastOutSlowIn, duration: kThemeChangeDuration, decoration: new BoxDecoration( borderRadius: radius, - boxShadow: config.elevation == 0 || Material.debugEnablePhysicalModel ? - null : kElevationToShadow[config.elevation], - shape: config.type == MaterialType.circle ? BoxShape.circle : BoxShape.rectangle + boxShadow: widget.elevation == 0 || Material.debugEnablePhysicalModel ? + null : kElevationToShadow[widget.elevation], + shape: widget.type == MaterialType.circle ? BoxShape.circle : BoxShape.rectangle ), child: new Container( decoration: new BoxDecoration( borderRadius: radius, backgroundColor: backgroundColor, - shape: config.type == MaterialType.circle ? BoxShape.circle : BoxShape.rectangle + shape: widget.type == MaterialType.circle ? BoxShape.circle : BoxShape.rectangle ), child: contents ) diff --git a/packages/flutter/lib/src/material/mergeable_material.dart b/packages/flutter/lib/src/material/mergeable_material.dart index 026be0403a..7c6cea02b1 100644 --- a/packages/flutter/lib/src/material/mergeable_material.dart +++ b/packages/flutter/lib/src/material/mergeable_material.dart @@ -153,7 +153,7 @@ class _MergeableMaterialState extends State with TickerProvid @override void initState() { super.initState(); - _children = new List.from(config.children); + _children = new List.from(widget.children); for (int i = 0; i < _children.length; i += 1) { if (_children[i] is MaterialGap) { @@ -209,9 +209,9 @@ class _MergeableMaterialState extends State with TickerProvid } bool _debugHasConsecutiveGaps(List children) { - for (int i = 0; i < config.children.length - 1; i += 1) { - if (config.children[i] is MaterialGap && - config.children[i + 1] is MaterialGap) + for (int i = 0; i < widget.children.length - 1; i += 1) { + if (widget.children[i] is MaterialGap && + widget.children[i + 1] is MaterialGap) return true; } return false; @@ -270,19 +270,19 @@ class _MergeableMaterialState extends State with TickerProvid } @override - void didUpdateConfig(MergeableMaterial oldConfig) { - super.didUpdateConfig(oldConfig); + void didUpdateWidget(MergeableMaterial oldWidget) { + super.didUpdateWidget(oldWidget); - final Set oldKeys = oldConfig.children.map( + final Set oldKeys = oldWidget.children.map( (MergeableMaterialItem child) => child.key ).toSet(); - final Set newKeys = config.children.map( + final Set newKeys = widget.children.map( (MergeableMaterialItem child) => child.key ).toSet(); final Set newOnly = newKeys.difference(oldKeys); final Set oldOnly = oldKeys.difference(newKeys); - final List newChildren = config.children; + final List newChildren = widget.children; int i = 0; int j = 0; @@ -473,7 +473,7 @@ class _MergeableMaterialState extends State with TickerProvid ); } - if (config.mainAxis == Axis.vertical) { + if (widget.mainAxis == Axis.vertical) { return new BorderRadius.vertical( top: start ? cardRadius : startRadius, bottom: end ? cardRadius : endRadius @@ -523,7 +523,7 @@ class _MergeableMaterialState extends State with TickerProvid shape: BoxShape.rectangle ), child: new ListBody( - mainAxis: config.mainAxis, + mainAxis: widget.mainAxis, children: slices ) ) @@ -532,15 +532,15 @@ class _MergeableMaterialState extends State with TickerProvid widgets.add( new SizedBox( - width: config.mainAxis == Axis.horizontal ? _getGapSize(i) : null, - height: config.mainAxis == Axis.vertical ? _getGapSize(i) : null + width: widget.mainAxis == Axis.horizontal ? _getGapSize(i) : null, + height: widget.mainAxis == Axis.vertical ? _getGapSize(i) : null ) ); } else { final MaterialSlice slice = _children[i]; Widget child = slice.child; - if (config.hasDividers) { + if (widget.hasDividers) { final bool hasTopDivider = _willNeedDivider(i - 1); final bool hasBottomDivider = _willNeedDivider(i + 1); @@ -594,7 +594,7 @@ class _MergeableMaterialState extends State with TickerProvid shape: BoxShape.rectangle ), child: new ListBody( - mainAxis: config.mainAxis, + mainAxis: widget.mainAxis, children: slices ) ) @@ -603,8 +603,8 @@ class _MergeableMaterialState extends State with TickerProvid } return new _MergeableMaterialListBody( - mainAxis: config.mainAxis, - boxShadows: kElevationToShadow[config.elevation], + mainAxis: widget.mainAxis, + boxShadows: kElevationToShadow[widget.elevation], items: _children, children: widgets ); diff --git a/packages/flutter/lib/src/material/paginated_data_table.dart b/packages/flutter/lib/src/material/paginated_data_table.dart index f2d40c7eab..4d7205ff31 100644 --- a/packages/flutter/lib/src/material/paginated_data_table.dart +++ b/packages/flutter/lib/src/material/paginated_data_table.dart @@ -189,32 +189,32 @@ class PaginatedDataTableState extends State { @override void initState() { super.initState(); - _firstRowIndex = PageStorage.of(context)?.readState(context) ?? config.initialFirstRowIndex ?? 0; - config.source.addListener(_handleDataSourceChanged); + _firstRowIndex = PageStorage.of(context)?.readState(context) ?? widget.initialFirstRowIndex ?? 0; + widget.source.addListener(_handleDataSourceChanged); _handleDataSourceChanged(); } @override - void didUpdateConfig(PaginatedDataTable oldConfig) { - super.didUpdateConfig(oldConfig); - if (oldConfig.source != config.source) { - oldConfig.source.removeListener(_handleDataSourceChanged); - config.source.addListener(_handleDataSourceChanged); + void didUpdateWidget(PaginatedDataTable oldWidget) { + super.didUpdateWidget(oldWidget); + if (oldWidget.source != widget.source) { + oldWidget.source.removeListener(_handleDataSourceChanged); + widget.source.addListener(_handleDataSourceChanged); _handleDataSourceChanged(); } } @override void dispose() { - config.source.removeListener(_handleDataSourceChanged); + widget.source.removeListener(_handleDataSourceChanged); super.dispose(); } void _handleDataSourceChanged() { setState(() { - _rowCount = config.source.rowCount; - _rowCountApproximate = config.source.isRowCountApproximate; - _selectedRowCount = config.source.selectedRowCount; + _rowCount = widget.source.rowCount; + _rowCountApproximate = widget.source.isRowCountApproximate; + _selectedRowCount = widget.source.selectedRowCount; _rows.clear(); }); } @@ -223,24 +223,24 @@ class PaginatedDataTableState extends State { void pageTo(int rowIndex) { final int oldFirstRowIndex = _firstRowIndex; setState(() { - final int rowsPerPage = config.rowsPerPage; + final int rowsPerPage = widget.rowsPerPage; _firstRowIndex = (rowIndex ~/ rowsPerPage) * rowsPerPage; }); - if ((config.onPageChanged != null) && + if ((widget.onPageChanged != null) && (oldFirstRowIndex != _firstRowIndex)) - config.onPageChanged(_firstRowIndex); + widget.onPageChanged(_firstRowIndex); } DataRow _getBlankRowFor(int index) { return new DataRow.byIndex( index: index, - cells: config.columns.map((DataColumn column) => DataCell.empty).toList() + cells: widget.columns.map((DataColumn column) => DataCell.empty).toList() ); } DataRow _getProgressIndicatorRowFor(int index) { bool haveProgressIndicator = false; - final List cells = config.columns.map((DataColumn column) { + final List cells = widget.columns.map((DataColumn column) { if (!column.numeric) { haveProgressIndicator = true; return new DataCell(new CircularProgressIndicator()); @@ -264,7 +264,7 @@ class PaginatedDataTableState extends State { for (int index = firstRowIndex; index < nextPageFirstRowIndex; index += 1) { DataRow row; if (index < _rowCount || _rowCountApproximate) { - row = _rows.putIfAbsent(index, () => config.source.getRow(index)); + row = _rows.putIfAbsent(index, () => widget.source.getRow(index)); if (row == null && !haveProgressIndicator) { row ??= _getProgressIndicatorRowFor(index); haveProgressIndicator = true; @@ -286,8 +286,8 @@ class PaginatedDataTableState extends State { final List headerWidgets = []; double leftPadding = 24.0; if (_selectedRowCount == 0) { - headerWidgets.add(new Expanded(child: config.header)); - if (config.header is ButtonBar) { + headerWidgets.add(new Expanded(child: widget.header)); + if (widget.header is ButtonBar) { // We adjust the padding when a button bar is present, because the // ButtonBar introduces 2 pixels of outside padding, plus 2 pixels // around each button on each side, and the button itself will have 8 @@ -302,13 +302,13 @@ class PaginatedDataTableState extends State { } else { headerWidgets.add(new Expanded(child: new Text('$_selectedRowCount items selected'))); } - if (config.actions != null) { + if (widget.actions != null) { headerWidgets.addAll( - config.actions.map((Widget widget) { + widget.actions.map((Widget action) { return new Padding( // 8.0 is the default padding of an icon button padding: const EdgeInsets.only(left: 24.0 - 8.0 * 2.0), - child: widget + child: action, ); }).toList() ); @@ -317,8 +317,8 @@ class PaginatedDataTableState extends State { // FOOTER final TextStyle footerTextStyle = themeData.textTheme.caption; final List footerWidgets = []; - if (config.onRowsPerPageChanged != null) { - final List availableRowsPerPage = config.availableRowsPerPage + if (widget.onRowsPerPageChanged != null) { + final List availableRowsPerPage = widget.availableRowsPerPage .where((int value) => value <= _rowCount) .map>((int value) { return new DropdownMenuItem( @@ -332,8 +332,8 @@ class PaginatedDataTableState extends State { new DropdownButtonHideUnderline( child: new DropdownButton( items: availableRowsPerPage, - value: config.rowsPerPage, - onChanged: config.onRowsPerPageChanged, + value: widget.rowsPerPage, + onChanged: widget.onRowsPerPageChanged, style: footerTextStyle, iconSize: 24.0 ) @@ -343,7 +343,7 @@ class PaginatedDataTableState extends State { footerWidgets.addAll([ new Container(width: 32.0), new Text( - '${_firstRowIndex + 1}\u2013${_firstRowIndex + config.rowsPerPage} ${ _rowCountApproximate ? "of about" : "of" } $_rowCount' + '${_firstRowIndex + 1}\u2013${_firstRowIndex + widget.rowsPerPage} ${ _rowCountApproximate ? "of about" : "of" } $_rowCount' ), new Container(width: 32.0), new IconButton( @@ -351,7 +351,7 @@ class PaginatedDataTableState extends State { padding: EdgeInsets.zero, tooltip: 'Previous page', onPressed: _firstRowIndex <= 0 ? null : () { - pageTo(math.max(_firstRowIndex - config.rowsPerPage, 0)); + pageTo(math.max(_firstRowIndex - widget.rowsPerPage, 0)); } ), new Container(width: 24.0), @@ -359,8 +359,8 @@ class PaginatedDataTableState extends State { icon: const Icon(Icons.chevron_right), padding: EdgeInsets.zero, tooltip: 'Next page', - onPressed: (!_rowCountApproximate && (_firstRowIndex + config.rowsPerPage >= _rowCount)) ? null : () { - pageTo(_firstRowIndex + config.rowsPerPage); + onPressed: (!_rowCountApproximate && (_firstRowIndex + widget.rowsPerPage >= _rowCount)) ? null : () { + pageTo(_firstRowIndex + widget.rowsPerPage); } ), new Container(width: 14.0), @@ -404,11 +404,11 @@ class PaginatedDataTableState extends State { scrollDirection: Axis.horizontal, child: new DataTable( key: _tableKey, - columns: config.columns, - sortColumnIndex: config.sortColumnIndex, - sortAscending: config.sortAscending, - onSelectAll: config.onSelectAll, - rows: _getRows(_firstRowIndex, config.rowsPerPage) + columns: widget.columns, + sortColumnIndex: widget.sortColumnIndex, + sortAscending: widget.sortAscending, + onSelectAll: widget.onSelectAll, + rows: _getRows(_firstRowIndex, widget.rowsPerPage) ) ), new DefaultTextStyle( diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart index 251bb027fe..97f49eb93a 100644 --- a/packages/flutter/lib/src/material/popup_menu.dart +++ b/packages/flutter/lib/src/material/popup_menu.dart @@ -90,7 +90,7 @@ class PopupMenuDivider extends PopupMenuEntry { class _PopupMenuDividerState extends State { @override - Widget build(BuildContext context) => new Divider(height: config.height); + Widget build(BuildContext context) => new Divider(height: widget.height); } /// An item in a material design popup menu. @@ -136,29 +136,29 @@ class PopupMenuItem extends PopupMenuEntry { class _PopupMenuItemState> extends State { // Override this to put something else in the menu entry. - Widget buildChild() => config.child; + Widget buildChild() => widget.child; void onTap() { - Navigator.pop(context, config.value); + Navigator.pop(context, widget.value); } @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); TextStyle style = theme.textTheme.subhead; - if (!config.enabled) + if (!widget.enabled) style = style.copyWith(color: theme.disabledColor); Widget item = new AnimatedDefaultTextStyle( style: style, duration: kThemeChangeDuration, child: new Baseline( - baseline: config.height - _kBaselineOffsetFromBottom, + baseline: widget.height - _kBaselineOffsetFromBottom, baselineType: TextBaseline.alphabetic, child: buildChild() ) ); - if (!config.enabled) { + if (!widget.enabled) { final bool isDark = theme.brightness == Brightness.dark; item = new IconTheme.merge( context: context, @@ -168,10 +168,10 @@ class _PopupMenuItemState> extends State { } return new InkWell( - onTap: config.enabled ? onTap : null, + onTap: widget.enabled ? onTap : null, child: new MergeSemantics( child: new Container( - height: config.height, + height: widget.height, padding: const EdgeInsets.symmetric(horizontal: _kMenuHorizontalPadding), child: item ) @@ -225,14 +225,14 @@ class _CheckedPopupMenuItemState extends _PopupMenuItemState setState(() { /* animation changed */ })); } @override void onTap() { // This fades the checkmark in or out when tapped. - if (config.checked) + if (widget.checked) _controller.reverse(); else _controller.forward(); @@ -242,12 +242,12 @@ class _CheckedPopupMenuItemState extends _PopupMenuItemState extends State> { final Point topLeft = renderBox.localToGlobal(Point.origin); showMenu( context: context, - elevation: config.elevation, - items: config.itemBuilder(context), - initialValue: config.initialValue, + elevation: widget.elevation, + items: widget.itemBuilder(context), + initialValue: widget.initialValue, position: new RelativeRect.fromLTRB( - topLeft.x, topLeft.y + (config.initialValue != null ? renderBox.size.height / 2.0 : 0.0), + topLeft.x, topLeft.y + (widget.initialValue != null ? renderBox.size.height / 2.0 : 0.0), 0.0, 0.0 ) ) .then((T newValue) { if (!mounted || newValue == null) return null; - if (config.onSelected != null) - config.onSelected(newValue); + if (widget.onSelected != null) + widget.onSelected(newValue); }); } @override Widget build(BuildContext context) { - if (config.child == null) { + if (widget.child == null) { return new IconButton( icon: const Icon(Icons.more_vert), - padding: config.padding, - tooltip: config.tooltip, + padding: widget.padding, + tooltip: widget.tooltip, onPressed: showButtonMenu, ); } return new InkWell( onTap: showButtonMenu, - child: config.child, + child: widget.child, ); } } diff --git a/packages/flutter/lib/src/material/progress_indicator.dart b/packages/flutter/lib/src/material/progress_indicator.dart index 22b2daa7a2..455e235633 100644 --- a/packages/flutter/lib/src/material/progress_indicator.dart +++ b/packages/flutter/lib/src/material/progress_indicator.dart @@ -174,10 +174,10 @@ class _LinearProgressIndicatorState extends State with ), child: new CustomPaint( painter: new _LinearProgressIndicatorPainter( - backgroundColor: config._getBackgroundColor(context), - valueColor: config._getValueColor(context), - value: config.value, // may be null - animationValue: animationValue // ignored if config.value is not null + backgroundColor: widget._getBackgroundColor(context), + valueColor: widget._getValueColor(context), + value: widget.value, // may be null + animationValue: animationValue // ignored if widget.value is not null ) ) ); @@ -185,7 +185,7 @@ class _LinearProgressIndicatorState extends State with @override Widget build(BuildContext context) { - if (config.value != null) + if (widget.value != null) return _buildIndicator(context, _animation.value); return new AnimatedBuilder( @@ -332,9 +332,9 @@ class _CircularProgressIndicatorState extends State w ), child: new CustomPaint( painter: new _CircularProgressIndicatorPainter( - valueColor: config._getValueColor(context), - value: config.value, // may be null - headValue: headValue, // remaining arguments are ignored if config.value is not null + valueColor: widget._getValueColor(context), + value: widget.value, // may be null + headValue: headValue, // remaining arguments are ignored if widget.value is not null tailValue: tailValue, stepValue: stepValue, rotationValue: rotationValue, @@ -361,7 +361,7 @@ class _CircularProgressIndicatorState extends State w @override Widget build(BuildContext context) { - if (config.value != null) + if (widget.value != null) return _buildIndicator(context, 0.0, 0.0, 0, 0.0); return _buildAnimation(); } @@ -463,8 +463,8 @@ class _RefreshProgressIndicatorState extends _CircularProgressIndicatorState { // starting from wherever we left it. @override Widget build(BuildContext context) { - if (config.value != null) - _controller.value = config.value / 10.0; + if (widget.value != null) + _controller.value = widget.value / 10.0; else _controller.forward(); return _buildAnimation(); @@ -472,20 +472,20 @@ class _RefreshProgressIndicatorState extends _CircularProgressIndicatorState { @override Widget _buildIndicator(BuildContext context, double headValue, double tailValue, int stepValue, double rotationValue) { - final double arrowheadScale = config.value == null ? 0.0 : (config.value * 2.0).clamp(0.0, 1.0); + final double arrowheadScale = widget.value == null ? 0.0 : (widget.value * 2.0).clamp(0.0, 1.0); return new Container( width: _kIndicatorSize, height: _kIndicatorSize, margin: const EdgeInsets.all(4.0), // acommodate the shadow child: new Material( type: MaterialType.circle, - color: config.backgroundColor ?? Theme.of(context).canvasColor, + color: widget.backgroundColor ?? Theme.of(context).canvasColor, elevation: 2, child: new Padding( padding: const EdgeInsets.all(12.0), child: new CustomPaint( painter: new _RefreshProgressIndicatorPainter( - valueColor: config._getValueColor(context), + valueColor: widget._getValueColor(context), value: null, // Draw the indeterminate progress indicator. headValue: headValue, tailValue: tailValue, diff --git a/packages/flutter/lib/src/material/radio.dart b/packages/flutter/lib/src/material/radio.dart index ca24454026..7cf8bb2ec7 100644 --- a/packages/flutter/lib/src/material/radio.dart +++ b/packages/flutter/lib/src/material/radio.dart @@ -98,7 +98,7 @@ class Radio extends StatefulWidget { } class _RadioState extends State> with TickerProviderStateMixin { - bool get _enabled => config.onChanged != null; + bool get _enabled => widget.onChanged != null; Color _getInactiveColor(ThemeData themeData) { return _enabled ? themeData.unselectedWidgetColor : themeData.disabledColor; @@ -106,7 +106,7 @@ class _RadioState extends State> with TickerProviderStateMixin { void _handleChanged(bool selected) { if (selected) - config.onChanged(config.value); + widget.onChanged(widget.value); } @override @@ -114,10 +114,10 @@ class _RadioState extends State> with TickerProviderStateMixin { assert(debugCheckHasMaterial(context)); final ThemeData themeData = Theme.of(context); return new Semantics( - checked: config.value == config.groupValue, + checked: widget.value == widget.groupValue, child: new _RadioRenderObjectWidget( - selected: config.value == config.groupValue, - activeColor: config.activeColor ?? themeData.accentColor, + selected: widget.value == widget.groupValue, + activeColor: widget.activeColor ?? themeData.accentColor, inactiveColor: _getInactiveColor(themeData), onChanged: _enabled ? _handleChanged : null, vsync: this, diff --git a/packages/flutter/lib/src/material/refresh_indicator.dart b/packages/flutter/lib/src/material/refresh_indicator.dart index e778ac028b..e6a453f166 100644 --- a/packages/flutter/lib/src/material/refresh_indicator.dart +++ b/packages/flutter/lib/src/material/refresh_indicator.dart @@ -158,8 +158,8 @@ class RefreshIndicatorState extends State with TickerProviderS void didChangeDependencies() { final ThemeData theme = Theme.of(context); _valueColor = new ColorTween( - begin: (config.color ?? theme.accentColor).withOpacity(0.0), - end: (config.color ?? theme.accentColor).withOpacity(1.0) + begin: (widget.color ?? theme.accentColor).withOpacity(0.0), + end: (widget.color ?? theme.accentColor).withOpacity(1.0) ).animate(new CurvedAnimation( parent: _positionController, curve: const Interval(0.0, 1.0 / _kDragSizeFactorLimit) @@ -311,13 +311,13 @@ class RefreshIndicatorState extends State with TickerProviderS .animateTo(1.0 / _kDragSizeFactorLimit, duration: _kIndicatorSnapDuration) .whenComplete(() { if (mounted && _mode == _RefreshIndicatorMode.snap) { - assert(config.onRefresh != null); + assert(widget.onRefresh != null); setState(() { // Show the indeterminate progress indicator. _mode = _RefreshIndicatorMode.refresh; }); - config.onRefresh().whenComplete(() { + widget.onRefresh().whenComplete(() { if (mounted && _mode == _RefreshIndicatorMode.refresh) { completer.complete(); _dismiss(_RefreshIndicatorMode.done); @@ -362,7 +362,7 @@ class RefreshIndicatorState extends State with TickerProviderS onNotification: _handleScrollNotification, child: new NotificationListener( onNotification: _handleGlowNotification, - child: config.child, + child: widget.child, ), ); if (_mode == null) { @@ -389,8 +389,8 @@ class RefreshIndicatorState extends State with TickerProviderS sizeFactor: _positionFactor, // this is what brings it down child: new Container( padding: _isIndicatorAtTop - ? new EdgeInsets.only(top: config.displacement) - : new EdgeInsets.only(bottom: config.displacement), + ? new EdgeInsets.only(top: widget.displacement) + : new EdgeInsets.only(bottom: widget.displacement), alignment: _isIndicatorAtTop ? FractionalOffset.topCenter : FractionalOffset.bottomCenter, @@ -402,7 +402,7 @@ class RefreshIndicatorState extends State with TickerProviderS return new RefreshProgressIndicator( value: showIndeterminateIndicator ? null : _value.value, valueColor: _valueColor, - backgroundColor: config.backgroundColor, + backgroundColor: widget.backgroundColor, ); }, ), diff --git a/packages/flutter/lib/src/material/scaffold.dart b/packages/flutter/lib/src/material/scaffold.dart index b9706869f0..86b91251e3 100644 --- a/packages/flutter/lib/src/material/scaffold.dart +++ b/packages/flutter/lib/src/material/scaffold.dart @@ -183,7 +183,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr // If we start out with a child, have the child appear fully visible instead // of animating in. - if (config.child != null) + if (widget.child != null) _currentController.value = 1.0; } @@ -195,24 +195,24 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr } @override - void didUpdateConfig(_FloatingActionButtonTransition oldConfig) { - final bool oldChildIsNull = oldConfig.child == null; - final bool newChildIsNull = config.child == null; - if (oldChildIsNull == newChildIsNull && oldConfig.child?.key == config.child?.key) + void didUpdateWidget(_FloatingActionButtonTransition oldWidget) { + final bool oldChildIsNull = oldWidget.child == null; + final bool newChildIsNull = widget.child == null; + if (oldChildIsNull == newChildIsNull && oldWidget.child?.key == widget.child?.key) return; if (_previousController.status == AnimationStatus.dismissed) { final double currentValue = _currentController.value; - if (currentValue == 0.0 || oldConfig.child == null) { + if (currentValue == 0.0 || oldWidget.child == null) { // The current child hasn't started its entrance animation yet. We can // just skip directly to the new child's entrance. _previousChild = null; - if (config.child != null) + if (widget.child != null) _currentController.forward(); } else { // Otherwise, we need to copy the state from the current controller to // the previous controller and run an exit animation for the previous // widget before running the entrance animation for the new child. - _previousChild = oldConfig.child; + _previousChild = oldWidget.child; _previousController ..value = currentValue ..reverse(); @@ -225,7 +225,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr setState(() { if (status == AnimationStatus.dismissed) { assert(_currentController.status == AnimationStatus.dismissed); - if (config.child != null) + if (widget.child != null) _currentController.forward(); } }); @@ -245,7 +245,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr scale: _currentAnimation, child: new RotationTransition( turns: _kFloatingActionButtonTurnTween.animate(_currentAnimation), - child: config.child, + child: widget.child, ) )); } @@ -492,7 +492,7 @@ class ScaffoldState extends State with TickerProviderStateMixin { final GlobalKey _drawerKey = new GlobalKey(); /// Whether this scaffold has a non-null [Scaffold.drawer]. - bool get hasDrawer => config.drawer != null; + bool get hasDrawer => widget.drawer != null; /// Opens the [Drawer] (if any). /// @@ -759,7 +759,7 @@ class ScaffoldState extends State with TickerProviderStateMixin { Widget build(BuildContext context) { EdgeInsets padding = MediaQuery.of(context).padding; final ThemeData themeData = Theme.of(context); - if (!config.resizeToAvoidBottomPadding) + if (!widget.resizeToAvoidBottomPadding) padding = new EdgeInsets.fromLTRB(padding.left, padding.top, padding.right, 0.0); if (_snackBars.isNotEmpty) { @@ -779,14 +779,14 @@ class ScaffoldState extends State with TickerProviderStateMixin { final List children = []; - _addIfNonNull(children, config.body, _ScaffoldSlot.body); + _addIfNonNull(children, widget.body, _ScaffoldSlot.body); - if (config.appBar != null) { - assert(config.appBar.primary || padding.top == 0.0, 'A non-primary AppBar was passed to a Scaffold but the MediaQuery in scope has top padding.'); - final double topPadding = config.appBar.primary ? padding.top : 0.0; - Widget appBar = config.appBar; - final double extent = config.appBar.minExtent + topPadding; - if (config.appBar.flexibleSpace != null) { + if (widget.appBar != null) { + assert(widget.appBar.primary || padding.top == 0.0, 'A non-primary AppBar was passed to a Scaffold but the MediaQuery in scope has top padding.'); + final double topPadding = widget.appBar.primary ? padding.top : 0.0; + Widget appBar = widget.appBar; + final double extent = widget.appBar.minExtent + topPadding; + if (widget.appBar.flexibleSpace != null) { appBar = FlexibleSpaceBar.createSettings( currentExtent: extent, child: appBar, @@ -805,7 +805,7 @@ class ScaffoldState extends State with TickerProviderStateMixin { if (_snackBars.isNotEmpty) _addIfNonNull(children, _snackBars.first._widget, _ScaffoldSlot.snackBar); - if (config.persistentFooterButtons != null) { + if (widget.persistentFooterButtons != null) { children.add(new LayoutId( id: _ScaffoldSlot.persistentFooter, child: new Container( @@ -818,17 +818,17 @@ class ScaffoldState extends State with TickerProviderStateMixin { ), child: new ButtonTheme.bar( child: new ButtonBar( - children: config.persistentFooterButtons + children: widget.persistentFooterButtons ), ), ), )); } - if (config.bottomNavigationBar != null) { + if (widget.bottomNavigationBar != null) { children.add(new LayoutId( id: _ScaffoldSlot.bottomNavigationBar, - child: config.bottomNavigationBar, + child: widget.bottomNavigationBar, )); } @@ -848,7 +848,7 @@ class ScaffoldState extends State with TickerProviderStateMixin { children.add(new LayoutId( id: _ScaffoldSlot.floatingActionButton, child: new _FloatingActionButtonTransition( - child: config.floatingActionButton, + child: widget.floatingActionButton, ) )); @@ -862,13 +862,13 @@ class ScaffoldState extends State with TickerProviderStateMixin { )); } - if (config.drawer != null) { + if (widget.drawer != null) { assert(hasDrawer); children.add(new LayoutId( id: _ScaffoldSlot.drawer, child: new DrawerController( key: _drawerKey, - child: config.drawer, + child: widget.drawer, ) )); } else if (_shouldHandleBackGesture()) { @@ -897,7 +897,7 @@ class ScaffoldState extends State with TickerProviderStateMixin { child: new PrimaryScrollController( controller: _primaryScrollController, child: new Material( - color: config.backgroundColor ?? themeData.scaffoldBackgroundColor, + color: widget.backgroundColor ?? themeData.scaffoldBackgroundColor, child: new CustomMultiChildLayout( children: children, delegate: new _ScaffoldLayout( @@ -955,48 +955,48 @@ class _PersistentBottomSheetState extends State<_PersistentBottomSheet> { @override void initState() { super.initState(); - assert(config.animationController.status == AnimationStatus.forward); - config.animationController.addStatusListener(_handleStatusChange); + assert(widget.animationController.status == AnimationStatus.forward); + widget.animationController.addStatusListener(_handleStatusChange); } @override - void didUpdateConfig(_PersistentBottomSheet oldConfig) { - super.didUpdateConfig(oldConfig); - assert(config.animationController == oldConfig.animationController); + void didUpdateWidget(_PersistentBottomSheet oldWidget) { + super.didUpdateWidget(oldWidget); + assert(widget.animationController == oldWidget.animationController); } @override void dispose() { - config.animationController.stop(); + widget.animationController.stop(); super.dispose(); } void close() { - config.animationController.reverse(); + widget.animationController.reverse(); } void _handleStatusChange(AnimationStatus status) { - if (status == AnimationStatus.dismissed && config.onDismissed != null) - config.onDismissed(); + if (status == AnimationStatus.dismissed && widget.onDismissed != null) + widget.onDismissed(); } @override Widget build(BuildContext context) { return new AnimatedBuilder( - animation: config.animationController, + animation: widget.animationController, builder: (BuildContext context, Widget child) { return new Align( alignment: FractionalOffset.topLeft, - heightFactor: config.animationController.value, + heightFactor: widget.animationController.value, child: child ); }, child: new Semantics( container: true, child: new BottomSheet( - animationController: config.animationController, - onClosing: config.onClosing, - builder: config.builder + animationController: widget.animationController, + onClosing: widget.onClosing, + builder: widget.builder ) ) ); diff --git a/packages/flutter/lib/src/material/scrollbar.dart b/packages/flutter/lib/src/material/scrollbar.dart index d9985ecc1f..a014268a0e 100644 --- a/packages/flutter/lib/src/material/scrollbar.dart +++ b/packages/flutter/lib/src/material/scrollbar.dart @@ -75,7 +75,7 @@ class _ScrollbarState extends State with TickerProviderStateMixin { child: new CustomPaint( foregroundPainter: new _ScrollbarPainter(_controller), child: new RepaintBoundary( - child: config.child, + child: widget.child, ), ), ), diff --git a/packages/flutter/lib/src/material/slider.dart b/packages/flutter/lib/src/material/slider.dart index 9395520acf..161125e946 100644 --- a/packages/flutter/lib/src/material/slider.dart +++ b/packages/flutter/lib/src/material/slider.dart @@ -155,8 +155,8 @@ class Slider extends StatefulWidget { class _SliderState extends State with TickerProviderStateMixin { void _handleChanged(double value) { - assert(config.onChanged != null); - config.onChanged(value * (config.max - config.min) + config.min); + assert(widget.onChanged != null); + widget.onChanged(value * (widget.max - widget.min) + widget.min); } @override @@ -164,13 +164,13 @@ class _SliderState extends State with TickerProviderStateMixin { assert(debugCheckHasMaterial(context)); final ThemeData theme = Theme.of(context); return new _SliderRenderObjectWidget( - value: (config.value - config.min) / (config.max - config.min), - divisions: config.divisions, - label: config.label, - activeColor: config.activeColor ?? theme.accentColor, - thumbOpenAtMin: config.thumbOpenAtMin, + value: (widget.value - widget.min) / (widget.max - widget.min), + divisions: widget.divisions, + label: widget.label, + activeColor: widget.activeColor ?? theme.accentColor, + thumbOpenAtMin: widget.thumbOpenAtMin, textTheme: theme.accentTextTheme, - onChanged: config.onChanged != null ? _handleChanged : null, + onChanged: widget.onChanged != null ? _handleChanged : null, vsync: this, ); } diff --git a/packages/flutter/lib/src/material/snack_bar.dart b/packages/flutter/lib/src/material/snack_bar.dart index 73509379a3..bdf4836154 100644 --- a/packages/flutter/lib/src/material/snack_bar.dart +++ b/packages/flutter/lib/src/material/snack_bar.dart @@ -110,7 +110,7 @@ class _SnackBarActionState extends State { setState(() { _haveTriggeredAction = true; }); - config.onPressed(); + widget.onPressed(); Scaffold.of(context).hideCurrentSnackBar(reason: SnackBarClosedReason.action); } @@ -118,7 +118,7 @@ class _SnackBarActionState extends State { Widget build(BuildContext context) { return new FlatButton( onPressed: _haveTriggeredAction ? null : _handlePressed, - child: new Text(config.label) + child: new Text(widget.label) ); } } diff --git a/packages/flutter/lib/src/material/stepper.dart b/packages/flutter/lib/src/material/stepper.dart index 48add10658..0073b2de4e 100644 --- a/packages/flutter/lib/src/material/stepper.dart +++ b/packages/flutter/lib/src/material/stepper.dart @@ -184,21 +184,21 @@ class _StepperState extends State with TickerProviderStateMixin { void initState() { super.initState(); _keys = new List.generate( - config.steps.length, + widget.steps.length, (int i) => new GlobalKey(), ); - for (int i = 0; i < config.steps.length; i += 1) - _oldStates[i] = config.steps[i].state; + for (int i = 0; i < widget.steps.length; i += 1) + _oldStates[i] = widget.steps[i].state; } @override - void didUpdateConfig(Stepper oldConfig) { - super.didUpdateConfig(oldConfig); - assert(config.steps.length == oldConfig.steps.length); + void didUpdateWidget(Stepper oldWidget) { + super.didUpdateWidget(oldWidget); + assert(widget.steps.length == oldWidget.steps.length); - for (int i = 0; i < oldConfig.steps.length; i += 1) - _oldStates[i] = oldConfig.steps[i].state; + for (int i = 0; i < oldWidget.steps.length; i += 1) + _oldStates[i] = oldWidget.steps[i].state; } bool _isFirst(int index) { @@ -206,11 +206,11 @@ class _StepperState extends State with TickerProviderStateMixin { } bool _isLast(int index) { - return config.steps.length - 1 == index; + return widget.steps.length - 1 == index; } bool _isCurrent(int index) { - return config.currentStep == index; + return widget.currentStep == index; } bool _isDark() { @@ -228,8 +228,8 @@ class _StepperState extends State with TickerProviderStateMixin { } Widget _buildCircleChild(int index, bool oldState) { - final StepState state = oldState ? _oldStates[index] : config.steps[index].state; - final bool isDarkActive = _isDark() && config.steps[index].isActive; + final StepState state = oldState ? _oldStates[index] : widget.steps[index].state; + final bool isDarkActive = _isDark() && widget.steps[index].isActive; assert(state != null); switch (state) { case StepState.indexed: @@ -257,9 +257,9 @@ class _StepperState extends State with TickerProviderStateMixin { Color _circleColor(int index) { final ThemeData themeData = Theme.of(context); if (!_isDark()) { - return config.steps[index].isActive ? themeData.primaryColor : Colors.black38; + return widget.steps[index].isActive ? themeData.primaryColor : Colors.black38; } else { - return config.steps[index].isActive ? themeData.accentColor : themeData.backgroundColor; + return widget.steps[index].isActive ? themeData.accentColor : themeData.backgroundColor; } } @@ -276,7 +276,7 @@ class _StepperState extends State with TickerProviderStateMixin { shape: BoxShape.circle, ), child: new Center( - child: _buildCircleChild(index, oldState && config.steps[index].state == StepState.error), + child: _buildCircleChild(index, oldState && widget.steps[index].state == StepState.error), ), ), ); @@ -297,7 +297,7 @@ class _StepperState extends State with TickerProviderStateMixin { ), child: new Align( alignment: const FractionalOffset(0.5, 0.9), // 0.9 looks better than the geometrical 0.66. - child: _buildCircleChild(index, oldState && config.steps[index].state != StepState.error), + child: _buildCircleChild(index, oldState && widget.steps[index].state != StepState.error), ), ), ), @@ -306,18 +306,18 @@ class _StepperState extends State with TickerProviderStateMixin { } Widget _buildIcon(int index) { - if (config.steps[index].state != _oldStates[index]) { + if (widget.steps[index].state != _oldStates[index]) { return new AnimatedCrossFade( firstChild: _buildCircle(index, true), secondChild: _buildTriangle(index, true), firstCurve: const Interval(0.0, 0.6, curve: Curves.fastOutSlowIn), secondCurve: const Interval(0.4, 1.0, curve: Curves.fastOutSlowIn), sizeCurve: Curves.fastOutSlowIn, - crossFadeState: config.steps[index].state == StepState.error ? CrossFadeState.showSecond : CrossFadeState.showFirst, + crossFadeState: widget.steps[index].state == StepState.error ? CrossFadeState.showSecond : CrossFadeState.showFirst, duration: kThemeAnimationDuration, ); } else { - if (config.steps[index].state != StepState.error) + if (widget.steps[index].state != StepState.error) return _buildCircle(index, false); else return _buildTriangle(index, false); @@ -347,7 +347,7 @@ class _StepperState extends State with TickerProviderStateMixin { child: new Row( children: [ new FlatButton( - onPressed: config.onStepContinue, + onPressed: widget.onStepContinue, color: _isDark() ? themeData.backgroundColor : themeData.primaryColor, textColor: Colors.white, textTheme: ButtonTextTheme.normal, @@ -356,7 +356,7 @@ class _StepperState extends State with TickerProviderStateMixin { new Container( margin: const EdgeInsets.only(left: 8.0), child: new FlatButton( - onPressed: config.onStepCancel, + onPressed: widget.onStepCancel, textColor: cancelColor, textTheme: ButtonTextTheme.normal, child: const Text('CANCEL'), @@ -372,8 +372,8 @@ class _StepperState extends State with TickerProviderStateMixin { final ThemeData themeData = Theme.of(context); final TextTheme textTheme = themeData.textTheme; - assert(config.steps[index].state != null); - switch (config.steps[index].state) { + assert(widget.steps[index].state != null); + switch (widget.steps[index].state) { case StepState.indexed: case StepState.editing: case StepState.complete: @@ -394,8 +394,8 @@ class _StepperState extends State with TickerProviderStateMixin { final ThemeData themeData = Theme.of(context); final TextTheme textTheme = themeData.textTheme; - assert(config.steps[index].state != null); - switch (config.steps[index].state) { + assert(widget.steps[index].state != null); + switch (widget.steps[index].state) { case StepState.indexed: case StepState.editing: case StepState.complete: @@ -418,11 +418,11 @@ class _StepperState extends State with TickerProviderStateMixin { style: _titleStyle(index), duration: kThemeAnimationDuration, curve: Curves.fastOutSlowIn, - child: config.steps[index].title, + child: widget.steps[index].title, ), ]; - if (config.steps[index].subtitle != null) + if (widget.steps[index].subtitle != null) children.add( new Container( margin: const EdgeInsets.only(top: 2.0), @@ -430,7 +430,7 @@ class _StepperState extends State with TickerProviderStateMixin { style: _subtitleStyle(index), duration: kThemeAnimationDuration, curve: Curves.fastOutSlowIn, - child: config.steps[index].subtitle, + child: widget.steps[index].subtitle, ), ), ); @@ -498,7 +498,7 @@ class _StepperState extends State with TickerProviderStateMixin { ), child: new Column( children: [ - config.steps[index].content, + widget.steps[index].content, _buildVerticalControls(), ], ), @@ -516,13 +516,13 @@ class _StepperState extends State with TickerProviderStateMixin { Widget _buildVertical() { final List children = []; - for (int i = 0; i < config.steps.length; i += 1) { + for (int i = 0; i < widget.steps.length; i += 1) { children.add( new Column( key: _keys[i], children: [ new InkWell( - onTap: config.steps[i].state != StepState.disabled ? () { + onTap: widget.steps[i].state != StepState.disabled ? () { // In the vertical case we need to scroll to the newly tapped // step. Scrollable.ensureVisible( @@ -531,8 +531,8 @@ class _StepperState extends State with TickerProviderStateMixin { duration: kThemeAnimationDuration, ); - if (config.onStepTapped != null) - config.onStepTapped(i); + if (widget.onStepTapped != null) + widget.onStepTapped(i); } : null, child: _buildVerticalHeader(i) ), @@ -551,12 +551,12 @@ class _StepperState extends State with TickerProviderStateMixin { Widget _buildHorizontal() { final List children = []; - for (int i = 0; i < config.steps.length; i += 1) { + for (int i = 0; i < widget.steps.length; i += 1) { children.add( new InkResponse( - onTap: config.steps[i].state != StepState.disabled ? () { - if (config.onStepTapped != null) - config.onStepTapped(i); + onTap: widget.steps[i].state != StepState.disabled ? () { + if (widget.onStepTapped != null) + widget.onStepTapped(i); } : null, child: new Row( children: [ @@ -609,7 +609,7 @@ class _StepperState extends State with TickerProviderStateMixin { curve: Curves.fastOutSlowIn, duration: kThemeAnimationDuration, vsync: this, - child: config.steps[config.currentStep].content, + child: widget.steps[widget.currentStep].content, ), _buildVerticalControls(), ], @@ -631,8 +631,8 @@ class _StepperState extends State with TickerProviderStateMixin { ); return true; }); - assert(config.type != null); - switch (config.type) { + assert(widget.type != null); + switch (widget.type) { case StepperType.vertical: return _buildVertical(); case StepperType.horizontal: diff --git a/packages/flutter/lib/src/material/switch.dart b/packages/flutter/lib/src/material/switch.dart index 7595b6622a..0a80643cf3 100644 --- a/packages/flutter/lib/src/material/switch.dart +++ b/packages/flutter/lib/src/material/switch.dart @@ -108,12 +108,12 @@ class _SwitchState extends State with TickerProviderStateMixin { final ThemeData themeData = Theme.of(context); final bool isDark = themeData.brightness == Brightness.dark; - final Color activeThumbColor = config.activeColor ?? themeData.accentColor; + final Color activeThumbColor = widget.activeColor ?? themeData.accentColor; final Color activeTrackColor = activeThumbColor.withAlpha(0x80); Color inactiveThumbColor; Color inactiveTrackColor; - if (config.onChanged != null) { + if (widget.onChanged != null) { inactiveThumbColor = isDark ? Colors.grey.shade400 : Colors.grey.shade50; inactiveTrackColor = isDark ? Colors.white30 : Colors.black26; } else { @@ -122,15 +122,15 @@ class _SwitchState extends State with TickerProviderStateMixin { } return new _SwitchRenderObjectWidget( - value: config.value, + value: widget.value, activeColor: activeThumbColor, inactiveColor: inactiveThumbColor, - activeThumbImage: config.activeThumbImage, - inactiveThumbImage: config.inactiveThumbImage, + activeThumbImage: widget.activeThumbImage, + inactiveThumbImage: widget.inactiveThumbImage, activeTrackColor: activeTrackColor, inactiveTrackColor: inactiveTrackColor, configuration: createLocalImageConfiguration(context), - onChanged: config.onChanged, + onChanged: widget.onChanged, vsync: this, ); } diff --git a/packages/flutter/lib/src/material/tab_controller.dart b/packages/flutter/lib/src/material/tab_controller.dart index 039950d2ed..39685f078f 100644 --- a/packages/flutter/lib/src/material/tab_controller.dart +++ b/packages/flutter/lib/src/material/tab_controller.dart @@ -265,8 +265,8 @@ class _DefaultTabControllerState extends State with Single super.initState(); _controller = new TabController( vsync: this, - length: config.length, - initialIndex: config.initialIndex, + length: widget.length, + initialIndex: widget.initialIndex, ); } @@ -281,7 +281,7 @@ class _DefaultTabControllerState extends State with Single return new _TabControllerScope( controller: _controller, enabled: TickerMode.of(context), - child: config.child, + child: widget.child, ); } } diff --git a/packages/flutter/lib/src/material/tabs.dart b/packages/flutter/lib/src/material/tabs.dart index 79318323a7..9b0a07e673 100644 --- a/packages/flutter/lib/src/material/tabs.dart +++ b/packages/flutter/lib/src/material/tabs.dart @@ -423,9 +423,9 @@ class TabBar extends StatefulWidget implements AppBarBottomWidget { @override double get bottomHeight { - for (Widget widget in tabs) { - if (widget is Tab) { - final Tab tab = widget; + for (Widget item in tabs) { + if (item is Tab) { + final Tab tab = item; if (tab.text != null && tab.icon != null) return _kTextAndIconTabHeight + _kTabIndicatorHeight; } @@ -445,14 +445,14 @@ class _TabBarState extends State { int _currentIndex; void _updateTabController() { - final TabController newController = config.controller ?? DefaultTabController.of(context); + final TabController newController = widget.controller ?? DefaultTabController.of(context); assert(() { if (newController == null) { throw new FlutterError( - 'No TabController for ${config.runtimeType}.\n' - 'When creating a ${config.runtimeType}, you must either provide an explicit ' + 'No TabController for ${widget.runtimeType}.\n' + 'When creating a ${widget.runtimeType}, you must either provide an explicit ' 'TabController using the "controller" property, or you must ensure that there ' - 'is a DefaultTabController above the ${config.runtimeType}.\n' + 'is a DefaultTabController above the ${widget.runtimeType}.\n' 'In this case, there was neither an explicit controller nor a default controller.' ); } @@ -482,9 +482,9 @@ class _TabBarState extends State { } @override - void didUpdateConfig(TabBar oldConfig) { - super.didUpdateConfig(oldConfig); - if (config.controller != oldConfig.controller) + void didUpdateWidget(TabBar oldWidget) { + super.didUpdateWidget(oldWidget); + if (widget.controller != oldWidget.controller) _updateTabController(); } @@ -541,7 +541,7 @@ class _TabBarState extends State { void _handleTabControllerAnimationTick() { assert(mounted); - if (!_controller.indexIsChanging && config.isScrollable) { + if (!_controller.indexIsChanging && widget.isScrollable) { // Sync the TabBar's scroll position with the TabBarView's PageView. _currentIndex = _controller.index; _scrollToControllerValue(); @@ -560,7 +560,7 @@ class _TabBarState extends State { } void _handleTap(int index) { - assert(index >= 0 && index < config.tabs.length); + assert(index >= 0 && index < widget.tabs.length); _controller.animateTo(index); } @@ -568,23 +568,23 @@ class _TabBarState extends State { return new _TabStyle( animation: animation, selected: selected, - labelColor: config.labelColor, - unselectedLabelColor: config.unselectedLabelColor, - labelStyle: config.labelStyle, - unselectedLabelStyle: config.unselectedLabelStyle, + labelColor: widget.labelColor, + unselectedLabelColor: widget.unselectedLabelColor, + labelStyle: widget.labelStyle, + unselectedLabelStyle: widget.unselectedLabelStyle, child: child, ); } @override Widget build(BuildContext context) { - final List wrappedTabs = new List.from(config.tabs, growable: false); + final List wrappedTabs = new List.from(widget.tabs, growable: false); // If the controller was provided by DefaultTabController and we're part // of a Hero (typically the AppBar), then we will not be able to find the // controller during a Hero transition. See https://github.com/flutter/flutter/issues/213. if (_controller != null) { - _indicatorPainter.color = config.indicatorColor ?? Theme.of(context).indicatorColor; + _indicatorPainter.color = widget.indicatorColor ?? Theme.of(context).indicatorColor; if (_indicatorPainter.color == Material.of(context).color) { // ThemeData tries to avoid this by having indicatorColor avoid being the // primaryColor. However, it's possible that the tab bar is on a @@ -598,7 +598,7 @@ class _TabBarState extends State { if (_controller.index != _currentIndex) { _currentIndex = _controller.index; - if (config.isScrollable) + if (widget.isScrollable) _scrollToCurrentIndex(); } @@ -620,7 +620,7 @@ class _TabBarState extends State { final Animation leftAnimation = new _DragAnimation(_controller, tabIndex); wrappedTabs[tabIndex] = _buildStyledTab(wrappedTabs[tabIndex], true, leftAnimation); } - if (_currentIndex < config.tabs.length - 1) { + if (_currentIndex < widget.tabs.length - 1) { final int tabIndex = _currentIndex + 1; final Animation rightAnimation = new _DragAnimation(_controller, tabIndex); wrappedTabs[tabIndex] = _buildStyledTab(wrappedTabs[tabIndex], true, rightAnimation); @@ -631,12 +631,12 @@ class _TabBarState extends State { // Add the tap handler to each tab. If the tab bar is scrollable // then give all of the tabs equal flexibility so that their widths // reflect the intrinsic width of their labels. - for (int index = 0; index < config.tabs.length; index++) { + for (int index = 0; index < widget.tabs.length; index++) { wrappedTabs[index] = new InkWell( onTap: () { _handleTap(index); }, child: wrappedTabs[index], ); - if (!config.isScrollable) + if (!widget.isScrollable) wrappedTabs[index] = new Expanded(child: wrappedTabs[index]); } @@ -647,10 +647,10 @@ class _TabBarState extends State { child: new _TabStyle( animation: kAlwaysDismissedAnimation, selected: false, - labelColor: config.labelColor, - unselectedLabelColor: config.unselectedLabelColor, - labelStyle: config.labelStyle, - unselectedLabelStyle: config.unselectedLabelStyle, + labelColor: widget.labelColor, + unselectedLabelColor: widget.unselectedLabelColor, + labelStyle: widget.labelStyle, + unselectedLabelStyle: widget.unselectedLabelStyle, child: new _TabLabelBar( onPerformLayout: _saveTabOffsets, children: wrappedTabs, @@ -659,7 +659,7 @@ class _TabBarState extends State { ), ); - if (config.isScrollable) { + if (widget.isScrollable) { tabBar = new SingleChildScrollView( scrollDirection: Axis.horizontal, controller: _scrollController, @@ -711,14 +711,14 @@ class _TabBarViewState extends State { int _warpUnderwayCount = 0; void _updateTabController() { - final TabController newController = config.controller ?? DefaultTabController.of(context); + final TabController newController = widget.controller ?? DefaultTabController.of(context); assert(() { if (newController == null) { throw new FlutterError( - 'No TabController for ${config.runtimeType}.\n' - 'When creating a ${config.runtimeType}, you must either provide an explicit ' + 'No TabController for ${widget.runtimeType}.\n' + 'When creating a ${widget.runtimeType}, you must either provide an explicit ' 'TabController using the "controller" property, or you must ensure that there ' - 'is a DefaultTabController above the ${config.runtimeType}.\n' + 'is a DefaultTabController above the ${widget.runtimeType}.\n' 'In this case, there was neither an explicit controller nor a default controller.' ); } @@ -737,7 +737,7 @@ class _TabBarViewState extends State { @override void initState() { super.initState(); - _children = config.children; + _children = widget.children; } @override @@ -749,12 +749,12 @@ class _TabBarViewState extends State { } @override - void didUpdateConfig(TabBarView oldConfig) { - super.didUpdateConfig(oldConfig); - if (config.controller != oldConfig.controller) + void didUpdateWidget(TabBarView oldWidget) { + super.didUpdateWidget(oldWidget); + if (widget.controller != oldWidget.controller) _updateTabController(); - if (config.children != oldConfig.children && _warpUnderwayCount == 0) - _children = config.children; + if (widget.children != oldWidget.children && _warpUnderwayCount == 0) + _children = widget.children; } @override @@ -790,7 +790,7 @@ class _TabBarViewState extends State { int initialPage; setState(() { _warpUnderwayCount += 1; - _children = new List.from(config.children, growable: false); + _children = new List.from(widget.children, growable: false); if (_currentIndex > previousIndex) { _children[_currentIndex - 1] = _children[previousIndex]; initialPage = _currentIndex - 1; @@ -808,7 +808,7 @@ class _TabBarViewState extends State { setState(() { _warpUnderwayCount -= 1; - _children = config.children; + _children = widget.children; }); } diff --git a/packages/flutter/lib/src/material/text_field.dart b/packages/flutter/lib/src/material/text_field.dart index e9367eae92..a42966e2c0 100644 --- a/packages/flutter/lib/src/material/text_field.dart +++ b/packages/flutter/lib/src/material/text_field.dart @@ -169,23 +169,23 @@ class _TextFieldState extends State { final GlobalKey _editableTextKey = new GlobalKey(); TextEditingController _controller; - TextEditingController get _effectiveController => config.controller ?? _controller; + TextEditingController get _effectiveController => widget.controller ?? _controller; FocusNode _focusNode; - FocusNode get _effectiveFocusNode => config.focusNode ?? (_focusNode ??= new FocusNode()); + FocusNode get _effectiveFocusNode => widget.focusNode ?? (_focusNode ??= new FocusNode()); @override void initState() { super.initState(); - if (config.controller == null) + if (widget.controller == null) _controller = new TextEditingController(); } @override - void didUpdateConfig(TextField oldConfig) { - if (config.controller == null && oldConfig.controller != null) - _controller == new TextEditingController.fromValue(oldConfig.controller.value); - else if (config.controller != null && oldConfig.controller == null) + void didUpdateWidget(TextField oldWidget) { + if (widget.controller == null && oldWidget.controller != null) + _controller == new TextEditingController.fromValue(oldWidget.controller.value); + else if (widget.controller != null && oldWidget.controller == null) _controller = null; } @@ -202,7 +202,7 @@ class _TextFieldState extends State { @override Widget build(BuildContext context) { final ThemeData themeData = Theme.of(context); - final TextStyle style = config.style ?? themeData.textTheme.subhead; + final TextStyle style = widget.style ?? themeData.textTheme.subhead; final TextEditingController controller = _effectiveController; final FocusNode focusNode = _effectiveFocusNode; @@ -211,28 +211,28 @@ class _TextFieldState extends State { key: _editableTextKey, controller: controller, focusNode: focusNode, - keyboardType: config.keyboardType, + keyboardType: widget.keyboardType, style: style, - textAlign: config.textAlign, - autofocus: config.autofocus, - obscureText: config.obscureText, - maxLines: config.maxLines, + textAlign: widget.textAlign, + autofocus: widget.autofocus, + obscureText: widget.obscureText, + maxLines: widget.maxLines, cursorColor: themeData.textSelectionColor, selectionColor: themeData.textSelectionColor, selectionControls: materialTextSelectionControls, - onChanged: config.onChanged, - onSubmitted: config.onSubmitted, + onChanged: widget.onChanged, + onSubmitted: widget.onSubmitted, ), ); - if (config.decoration != null) { + if (widget.decoration != null) { child = new AnimatedBuilder( animation: new Listenable.merge([ focusNode, controller ]), builder: (BuildContext context, Widget child) { return new InputDecorator( - decoration: config.decoration, - baseStyle: config.style, - textAlign: config.textAlign, + decoration: widget.decoration, + baseStyle: widget.style, + textAlign: widget.textAlign, isFocused: focusNode.hasFocus, isEmpty: controller.value.text.isEmpty, child: child, diff --git a/packages/flutter/lib/src/material/theme.dart b/packages/flutter/lib/src/material/theme.dart index fc6a578add..edf56cde71 100644 --- a/packages/flutter/lib/src/material/theme.dart +++ b/packages/flutter/lib/src/material/theme.dart @@ -185,15 +185,15 @@ class _AnimatedThemeState extends AnimatedWidgetBaseState { @override void forEachTween(TweenVisitor visitor) { // TODO(ianh): Use constructor tear-offs when it becomes possible - _data = visitor(_data, config.data, (dynamic value) => new ThemeDataTween(begin: value)); + _data = visitor(_data, widget.data, (dynamic value) => new ThemeDataTween(begin: value)); assert(_data != null); } @override Widget build(BuildContext context) { return new Theme( - isMaterialAppTheme: config.isMaterialAppTheme, - child: config.child, + isMaterialAppTheme: widget.isMaterialAppTheme, + child: widget.child, data: _data.evaluate(animation) ); } diff --git a/packages/flutter/lib/src/material/time_picker.dart b/packages/flutter/lib/src/material/time_picker.dart index 57d65e48e8..4edeb6b481 100644 --- a/packages/flutter/lib/src/material/time_picker.dart +++ b/packages/flutter/lib/src/material/time_picker.dart @@ -470,7 +470,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin { duration: _kDialAnimateDuration, vsync: this, ); - _thetaTween = new Tween(begin: _getThetaForTime(config.selectedTime)); + _thetaTween = new Tween(begin: _getThetaForTime(widget.selectedTime)); _theta = _thetaTween.animate(new CurvedAnimation( parent: _thetaController, curve: Curves.fastOutSlowIn @@ -478,9 +478,9 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin { } @override - void didUpdateConfig(_Dial oldConfig) { - if (config.mode != oldConfig.mode && !_dragging) - _animateTo(_getThetaForTime(config.selectedTime)); + void didUpdateWidget(_Dial oldWidget) { + if (widget.mode != oldWidget.mode && !_dragging) + _animateTo(_getThetaForTime(widget.selectedTime)); } @override @@ -511,7 +511,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin { } double _getThetaForTime(TimeOfDay time) { - final double fraction = (config.mode == _TimePickerMode.hour) ? + final double fraction = (widget.mode == _TimePickerMode.hour) ? (time.hour / _kHoursPerPeriod) % _kHoursPerPeriod : (time.minute / _kMinutesPerHour) % _kMinutesPerHour; return (math.PI / 2.0 - fraction * _kTwoPi) % _kTwoPi; @@ -519,24 +519,24 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin { TimeOfDay _getTimeForTheta(double theta) { final double fraction = (0.25 - (theta % _kTwoPi) / _kTwoPi) % 1.0; - if (config.mode == _TimePickerMode.hour) { + if (widget.mode == _TimePickerMode.hour) { final int hourOfPeriod = (fraction * _kHoursPerPeriod).round() % _kHoursPerPeriod; - return config.selectedTime.replacing( - hour: hourOfPeriod + config.selectedTime.periodOffset + return widget.selectedTime.replacing( + hour: hourOfPeriod + widget.selectedTime.periodOffset ); } else { - return config.selectedTime.replacing( + return widget.selectedTime.replacing( minute: (fraction * _kMinutesPerHour).round() % _kMinutesPerHour ); } } void _notifyOnChangedIfNeeded() { - if (config.onChanged == null) + if (widget.onChanged == null) return; final TimeOfDay current = _getTimeForTheta(_theta.value); - if (current != config.selectedTime) - config.onChanged(current); + if (current != widget.selectedTime) + widget.onChanged(current); } void _updateThetaForPan() { @@ -573,7 +573,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin { _dragging = false; _position = null; _center = null; - _animateTo(_getThetaForTime(config.selectedTime)); + _animateTo(_getThetaForTime(widget.selectedTime)); } @override @@ -593,7 +593,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin { final ThemeData theme = Theme.of(context); List primaryLabels; List secondaryLabels; - switch (config.mode) { + switch (widget.mode) { case _TimePickerMode.hour: primaryLabels = _initHours(theme.textTheme); secondaryLabels = _initHours(theme.accentTextTheme); @@ -640,7 +640,7 @@ class _TimePickerDialogState extends State<_TimePickerDialog> { @override void initState() { super.initState(); - _selectedTime = config.initialTime; + _selectedTime = widget.initialTime; } _TimePickerMode _mode = _TimePickerMode.hour; diff --git a/packages/flutter/lib/src/material/tooltip.dart b/packages/flutter/lib/src/material/tooltip.dart index de8242a283..f3a4fcbc64 100644 --- a/packages/flutter/lib/src/material/tooltip.dart +++ b/packages/flutter/lib/src/material/tooltip.dart @@ -124,19 +124,19 @@ class _TooltipState extends State with SingleTickerProviderStateMixin { // updated values from happening to leak into the overlay when the overlay // rebuilds. final Widget overlay = new _TooltipOverlay( - message: config.message, - height: config.height, - padding: config.padding, + message: widget.message, + height: widget.height, + padding: widget.padding, animation: new CurvedAnimation( parent: _controller, curve: Curves.fastOutSlowIn ), target: target, - verticalOffset: config.verticalOffset, - preferBelow: config.preferBelow + verticalOffset: widget.verticalOffset, + preferBelow: widget.preferBelow ); _entry = new OverlayEntry(builder: (BuildContext context) => overlay); - Overlay.of(context, debugRequiredFor: config).insert(_entry); + Overlay.of(context, debugRequiredFor: widget).insert(_entry); GestureBinding.instance.pointerRouter.addGlobalRoute(_handlePointerEvent); _controller.forward(); } @@ -175,14 +175,14 @@ class _TooltipState extends State with SingleTickerProviderStateMixin { @override Widget build(BuildContext context) { - assert(Overlay.of(context, debugRequiredFor: config) != null); + assert(Overlay.of(context, debugRequiredFor: widget) != null); return new GestureDetector( behavior: HitTestBehavior.opaque, onLongPress: ensureTooltipVisible, excludeFromSemantics: true, child: new Semantics( - label: config.message, - child: config.child, + label: widget.message, + child: widget.child, ) ); } diff --git a/packages/flutter/lib/src/material/two_level_list.dart b/packages/flutter/lib/src/material/two_level_list.dart index 4203e30eca..9c4f319497 100644 --- a/packages/flutter/lib/src/material/two_level_list.dart +++ b/packages/flutter/lib/src/material/two_level_list.dart @@ -186,8 +186,8 @@ class _TwoLevelSublistState extends State with SingleTickerProv _controller.reverse(); PageStorage.of(context)?.writeState(context, _isExpanded); }); - if (config.onOpenChanged != null) - config.onOpenChanged(_isExpanded); + if (widget.onOpenChanged != null) + widget.onOpenChanged(_isExpanded); } Widget buildList(BuildContext context, Widget child) { @@ -206,10 +206,10 @@ class _TwoLevelSublistState extends State with SingleTickerProv data: new IconThemeData(color: _iconColor.evaluate(_easeInAnimation)), child: new TwoLevelListItem( onTap: _handleOnTap, - leading: config.leading, + leading: widget.leading, title: new DefaultTextStyle( style: Theme.of(context).textTheme.subhead.copyWith(color: _headerColor.evaluate(_easeInAnimation)), - child: config.title + child: widget.title ), trailing: new RotationTransition( turns: _iconTurns, @@ -220,7 +220,7 @@ class _TwoLevelSublistState extends State with SingleTickerProv new ClipRect( child: new Align( heightFactor: _easeInAnimation.value, - child: new Column(children: config.children) + child: new Column(children: widget.children) ) ) ] @@ -240,7 +240,7 @@ class _TwoLevelSublistState extends State with SingleTickerProv ..end = theme.accentColor; _backgroundColor ..begin = Colors.transparent - ..end = config.backgroundColor ?? Colors.transparent; + ..end = widget.backgroundColor ?? Colors.transparent; return new AnimatedBuilder( animation: _controller.view, diff --git a/packages/flutter/lib/src/material/user_accounts_drawer_header.dart b/packages/flutter/lib/src/material/user_accounts_drawer_header.dart index 77c5f718fe..9b54b018c7 100644 --- a/packages/flutter/lib/src/material/user_accounts_drawer_header.dart +++ b/packages/flutter/lib/src/material/user_accounts_drawer_header.dart @@ -182,28 +182,28 @@ class _UserAccountsDrawerHeaderState extends State { Widget build(BuildContext context) { assert(debugCheckHasMaterial(context)); return new DrawerHeader( - decoration: config.decoration ?? new BoxDecoration( + decoration: widget.decoration ?? new BoxDecoration( backgroundColor: Theme.of(context).primaryColor, ), - margin: config.margin, + margin: widget.margin, child: new Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ new Expanded( child: new _AccountPictures( - currentAccountPicture: config.currentAccountPicture, - otherAccountsPictures: config.otherAccountsPictures, + currentAccountPicture: widget.currentAccountPicture, + otherAccountsPictures: widget.otherAccountsPictures, ) ), new _AccountDetails( - accountName: config.accountName, - accountEmail: config.accountEmail, + accountName: widget.accountName, + accountEmail: widget.accountEmail, isOpen: _isOpen, - onTap: config.onDetailsPressed == null ? null : () { + onTap: widget.onDetailsPressed == null ? null : () { setState(() { _isOpen = !_isOpen; }); - config.onDetailsPressed(); + widget.onDetailsPressed(); }, ), ], diff --git a/packages/flutter/lib/src/widgets/animated_cross_fade.dart b/packages/flutter/lib/src/widgets/animated_cross_fade.dart index 07d01e886a..2867c3aed6 100644 --- a/packages/flutter/lib/src/widgets/animated_cross_fade.dart +++ b/packages/flutter/lib/src/widgets/animated_cross_fade.dart @@ -93,11 +93,11 @@ class _AnimatedCrossFadeState extends State with TickerProvid @override void initState() { super.initState(); - _controller = new AnimationController(duration: config.duration, vsync: this); - if (config.crossFadeState == CrossFadeState.showSecond) + _controller = new AnimationController(duration: widget.duration, vsync: this); + if (widget.crossFadeState == CrossFadeState.showSecond) _controller.value = 1.0; - _firstAnimation = _initAnimation(config.firstCurve, true); - _secondAnimation = _initAnimation(config.secondCurve, false); + _firstAnimation = _initAnimation(widget.firstCurve, true); + _secondAnimation = _initAnimation(widget.secondCurve, false); } Animation _initAnimation(Curve curve, bool inverted) { @@ -119,16 +119,16 @@ class _AnimatedCrossFadeState extends State with TickerProvid } @override - void didUpdateConfig(AnimatedCrossFade oldConfig) { - super.didUpdateConfig(oldConfig); - if (config.duration != oldConfig.duration) - _controller.duration = config.duration; - if (config.firstCurve != oldConfig.firstCurve) - _firstAnimation = _initAnimation(config.firstCurve, true); - if (config.secondCurve != oldConfig.secondCurve) - _secondAnimation = _initAnimation(config.secondCurve, false); - if (config.crossFadeState != oldConfig.crossFadeState) { - switch (config.crossFadeState) { + void didUpdateWidget(AnimatedCrossFade oldWidget) { + super.didUpdateWidget(oldWidget); + if (widget.duration != oldWidget.duration) + _controller.duration = widget.duration; + if (widget.firstCurve != oldWidget.firstCurve) + _firstAnimation = _initAnimation(widget.firstCurve, true); + if (widget.secondCurve != oldWidget.secondCurve) + _secondAnimation = _initAnimation(widget.secondCurve, false); + if (widget.crossFadeState != oldWidget.crossFadeState) { + switch (widget.crossFadeState) { case CrossFadeState.showFirst: _controller.reverse(); break; @@ -148,7 +148,7 @@ class _AnimatedCrossFadeState extends State with TickerProvid children = [ new FadeTransition( opacity: _secondAnimation, - child: config.secondChild + child: widget.secondChild ), new Positioned( // TODO(dragostis): Add a way to crop from top right for @@ -158,7 +158,7 @@ class _AnimatedCrossFadeState extends State with TickerProvid right: 0.0, child: new FadeTransition( opacity: _firstAnimation, - child: config.firstChild + child: widget.firstChild ) ) ]; @@ -166,7 +166,7 @@ class _AnimatedCrossFadeState extends State with TickerProvid children = [ new FadeTransition( opacity: _firstAnimation, - child: config.firstChild + child: widget.firstChild ), new Positioned( // TODO(dragostis): Add a way to crop from top right for @@ -176,7 +176,7 @@ class _AnimatedCrossFadeState extends State with TickerProvid right: 0.0, child: new FadeTransition( opacity: _secondAnimation, - child: config.secondChild + child: widget.secondChild ) ) ]; @@ -184,10 +184,10 @@ class _AnimatedCrossFadeState extends State with TickerProvid return new ClipRect( child: new AnimatedSize( - key: new ValueKey(config.key), + key: new ValueKey(widget.key), alignment: FractionalOffset.topCenter, - duration: config.duration, - curve: config.sizeCurve, + duration: widget.duration, + curve: widget.sizeCurve, vsync: this, child: new Stack( overflow: Overflow.visible, diff --git a/packages/flutter/lib/src/widgets/app.dart b/packages/flutter/lib/src/widgets/app.dart index a505c5344f..6bf4178f6e 100644 --- a/packages/flutter/lib/src/widgets/app.dart +++ b/packages/flutter/lib/src/widgets/app.dart @@ -168,8 +168,8 @@ class _WidgetsAppState extends State implements WidgetsBindingObserv @override void didChangeLocale(Locale locale) { - if (config.onLocaleChanged != null) { - config.onLocaleChanged(locale).then((LocaleQueryData data) { + if (widget.onLocaleChanged != null) { + widget.onLocaleChanged(locale).then((LocaleQueryData data) { if (mounted) setState(() { _localeData = data; }); }); @@ -184,7 +184,7 @@ class _WidgetsAppState extends State implements WidgetsBindingObserv @override Widget build(BuildContext context) { - if (config.onLocaleChanged != null && _localeData == null) { + if (widget.onLocaleChanged != null && _localeData == null) { // If the app expects a locale but we don't yet know the locale, then // don't build the widgets now. // TODO(ianh): Make this unnecessary. See https://github.com/flutter/flutter/issues/1865 @@ -198,20 +198,20 @@ class _WidgetsAppState extends State implements WidgetsBindingObserv child: new LocaleQuery( data: _localeData, child: new Title( - title: config.title, - color: config.color, + title: widget.title, + color: widget.color, child: new Navigator( key: _navigator, - initialRoute: config.initialRoute ?? ui.window.defaultRouteName, - onGenerateRoute: config.onGenerateRoute, - observers: config.navigatorObservers + initialRoute: widget.initialRoute ?? ui.window.defaultRouteName, + onGenerateRoute: widget.onGenerateRoute, + observers: widget.navigatorObservers ) ) ) ); - if (config.textStyle != null) { + if (widget.textStyle != null) { result = new DefaultTextStyle( - style: config.textStyle, + style: widget.textStyle, child: result ); } @@ -219,10 +219,10 @@ class _WidgetsAppState extends State implements WidgetsBindingObserv PerformanceOverlay performanceOverlay; // We need to push a performance overlay if any of the display or checkerboarding // options are set. - if (config.showPerformanceOverlay || WidgetsApp.showPerformanceOverlayOverride) { + if (widget.showPerformanceOverlay || WidgetsApp.showPerformanceOverlayOverride) { performanceOverlay = new PerformanceOverlay.allEnabled( - checkerboardRasterCacheImages: config.checkerboardRasterCacheImages); - } else if (config.checkerboardRasterCacheImages) { + checkerboardRasterCacheImages: widget.checkerboardRasterCacheImages); + } else if (widget.checkerboardRasterCacheImages) { performanceOverlay = new PerformanceOverlay(checkerboardRasterCacheImages: true); } @@ -234,13 +234,13 @@ class _WidgetsAppState extends State implements WidgetsBindingObserv ] ); } - if (config.showSemanticsDebugger) { + if (widget.showSemanticsDebugger) { result = new SemanticsDebugger( child: result ); } assert(() { - if (config.debugShowCheckedModeBanner && WidgetsApp.debugAllowBannerOverride) { + if (widget.debugShowCheckedModeBanner && WidgetsApp.debugAllowBannerOverride) { result = new CheckedModeBanner( child: result ); diff --git a/packages/flutter/lib/src/widgets/async.dart b/packages/flutter/lib/src/widgets/async.dart index 88b01ddac7..9119fd2055 100644 --- a/packages/flutter/lib/src/widgets/async.dart +++ b/packages/flutter/lib/src/widgets/async.dart @@ -101,23 +101,23 @@ class _StreamBuilderBaseState extends State> { @override void initState() { super.initState(); - _summary = config.initial(); + _summary = widget.initial(); _subscribe(); } @override - void didUpdateConfig(StreamBuilderBase oldConfig) { - if (oldConfig.stream != config.stream) { + void didUpdateWidget(StreamBuilderBase oldWidget) { + if (oldWidget.stream != widget.stream) { if (_subscription != null) { _unsubscribe(); - _summary = config.afterDisconnected(_summary); + _summary = widget.afterDisconnected(_summary); } _subscribe(); } } @override - Widget build(BuildContext context) => config.build(context, _summary); + Widget build(BuildContext context) => widget.build(context, _summary); @override void dispose() { @@ -126,21 +126,21 @@ class _StreamBuilderBaseState extends State> { } void _subscribe() { - if (config.stream != null) { - _subscription = config.stream.listen((T data) { + if (widget.stream != null) { + _subscription = widget.stream.listen((T data) { setState(() { - _summary = config.afterData(_summary, data); + _summary = widget.afterData(_summary, data); }); }, onError: (Object error) { setState(() { - _summary = config.afterError(_summary, error); + _summary = widget.afterError(_summary, error); }); }, onDone: () { setState(() { - _summary = config.afterDone(_summary); + _summary = widget.afterDone(_summary); }); }); - _summary = config.afterConnected(_summary); + _summary = widget.afterConnected(_summary); } } @@ -418,8 +418,8 @@ class _FutureBuilderState extends State> { } @override - void didUpdateConfig(FutureBuilder oldConfig) { - if (oldConfig.future != config.future) { + void didUpdateWidget(FutureBuilder oldWidget) { + if (oldWidget.future != widget.future) { if (_activeCallbackIdentity != null) { _unsubscribe(); _snapshot = _snapshot.inState(ConnectionState.none); @@ -429,7 +429,7 @@ class _FutureBuilderState extends State> { } @override - Widget build(BuildContext context) => config.builder(context, _snapshot); + Widget build(BuildContext context) => widget.builder(context, _snapshot); @override void dispose() { @@ -438,10 +438,10 @@ class _FutureBuilderState extends State> { } void _subscribe() { - if (config.future != null) { + if (widget.future != null) { final Object callbackIdentity = new Object(); _activeCallbackIdentity = callbackIdentity; - config.future.then((T data) { + widget.future.then((T data) { if (_activeCallbackIdentity == callbackIdentity) { setState(() { _snapshot = new AsyncSnapshot.withData(ConnectionState.done, data); diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index a6f8dfa7ac..e9054e0df1 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -3241,5 +3241,5 @@ class StatefulBuilder extends StatefulWidget { class _StatefulBuilderState extends State { @override - Widget build(BuildContext context) => config.builder(context, setState); + Widget build(BuildContext context) => widget.builder(context, setState); } diff --git a/packages/flutter/lib/src/widgets/dismissible.dart b/packages/flutter/lib/src/widgets/dismissible.dart index 7ddc73aeed..09fd6be9bc 100644 --- a/packages/flutter/lib/src/widgets/dismissible.dart +++ b/packages/flutter/lib/src/widgets/dismissible.dart @@ -193,9 +193,9 @@ class _DismissibleState extends State with TickerProviderStateMixin } bool get _directionIsXAxis { - return config.direction == DismissDirection.horizontal - || config.direction == DismissDirection.endToStart - || config.direction == DismissDirection.startToEnd; + return widget.direction == DismissDirection.horizontal + || widget.direction == DismissDirection.endToStart + || widget.direction == DismissDirection.startToEnd; } DismissDirection get _dismissDirection { @@ -205,7 +205,7 @@ class _DismissibleState extends State with TickerProviderStateMixin } double get _dismissThreshold { - return config.dismissThresholds[_dismissDirection] ?? _kDismissThreshold; + return widget.dismissThresholds[_dismissDirection] ?? _kDismissThreshold; } bool get _isActive { @@ -237,7 +237,7 @@ class _DismissibleState extends State with TickerProviderStateMixin final double delta = details.primaryDelta; final double oldDragExtent = _dragExtent; - switch (config.direction) { + switch (widget.direction) { case DismissDirection.horizontal: case DismissDirection.vertical: _dragExtent += delta; @@ -283,7 +283,7 @@ class _DismissibleState extends State with TickerProviderStateMixin if (_directionIsXAxis) { if (vx.abs() - vy.abs() < _kMinFlingVelocityDelta) return false; - switch(config.direction) { + switch(widget.direction) { case DismissDirection.horizontal: return vx.abs() > _kMinFlingVelocity; case DismissDirection.endToStart: @@ -294,7 +294,7 @@ class _DismissibleState extends State with TickerProviderStateMixin } else { if (vy.abs() - vx.abs() < _kMinFlingVelocityDelta) return false; - switch(config.direction) { + switch(widget.direction) { case DismissDirection.vertical: return vy.abs() > _kMinFlingVelocity; case DismissDirection.up: @@ -332,11 +332,11 @@ class _DismissibleState extends State with TickerProviderStateMixin assert(_moveController.isCompleted); assert(_resizeController == null); assert(_sizePriorToCollapse == null); - if (config.resizeDuration == null) { - if (config.onDismissed != null) - config.onDismissed(_dismissDirection); + if (widget.resizeDuration == null) { + if (widget.onDismissed != null) + widget.onDismissed(_dismissDirection); } else { - _resizeController = new AnimationController(duration: config.resizeDuration, vsync: this) + _resizeController = new AnimationController(duration: widget.resizeDuration, vsync: this) ..addListener(_handleResizeProgressChanged); _resizeController.forward(); setState(() { @@ -354,21 +354,21 @@ class _DismissibleState extends State with TickerProviderStateMixin void _handleResizeProgressChanged() { if (_resizeController.isCompleted) { - if (config.onDismissed != null) - config.onDismissed(_dismissDirection); + if (widget.onDismissed != null) + widget.onDismissed(_dismissDirection); } else { - if (config.onResize != null) - config.onResize(); + if (widget.onResize != null) + widget.onResize(); } } @override Widget build(BuildContext context) { - Widget background = config.background; - if (config.secondaryBackground != null) { + Widget background = widget.background; + if (widget.secondaryBackground != null) { final DismissDirection direction = _dismissDirection; if (direction == DismissDirection.endToStart || direction == DismissDirection.up) - background = config.secondaryBackground; + background = widget.secondaryBackground; } if (_resizeAnimation != null) { @@ -398,7 +398,7 @@ class _DismissibleState extends State with TickerProviderStateMixin Widget content = new SlideTransition( position: _moveAnimation, - child: config.child + child: widget.child ); if (background != null) { @@ -420,7 +420,7 @@ class _DismissibleState extends State with TickerProviderStateMixin content = new Stack(children: children); } - // We are not resizing but we may be being dragging in config.direction. + // We are not resizing but we may be being dragging in widget.direction. return new GestureDetector( onHorizontalDragStart: _directionIsXAxis ? _handleDragStart : null, onHorizontalDragUpdate: _directionIsXAxis ? _handleDragUpdate : null, diff --git a/packages/flutter/lib/src/widgets/drag_target.dart b/packages/flutter/lib/src/widgets/drag_target.dart index befd1eff7b..75aba72a94 100644 --- a/packages/flutter/lib/src/widgets/drag_target.dart +++ b/packages/flutter/lib/src/widgets/drag_target.dart @@ -247,7 +247,7 @@ class _DraggableState extends State> { @override void initState() { super.initState(); - _recognizer = config.createRecognizer(_startDrag); + _recognizer = widget.createRecognizer(_startDrag); } @override @@ -276,16 +276,16 @@ class _DraggableState extends State> { } void _routePointer(PointerEvent event) { - if (config.maxSimultaneousDrags != null && _activeCount >= config.maxSimultaneousDrags) + if (widget.maxSimultaneousDrags != null && _activeCount >= widget.maxSimultaneousDrags) return; _recognizer.addPointer(event); } _DragAvatar _startDrag(Point position) { - if (config.maxSimultaneousDrags != null && _activeCount >= config.maxSimultaneousDrags) + if (widget.maxSimultaneousDrags != null && _activeCount >= widget.maxSimultaneousDrags) return null; Point dragStartPoint; - switch (config.dragAnchor) { + switch (widget.dragAnchor) { case DragAnchor.child: final RenderBox renderObject = context.findRenderObject(); dragStartPoint = renderObject.globalToLocal(position); @@ -298,12 +298,12 @@ class _DraggableState extends State> { _activeCount += 1; }); final _DragAvatar avatar = new _DragAvatar( - overlayState: Overlay.of(context, debugRequiredFor: config), - data: config.data, + overlayState: Overlay.of(context, debugRequiredFor: widget), + data: widget.data, initialPosition: position, dragStartPoint: dragStartPoint, - feedback: config.feedback, - feedbackOffset: config.feedbackOffset, + feedback: widget.feedback, + feedbackOffset: widget.feedbackOffset, onDragEnd: (Velocity velocity, Offset offset, bool wasAccepted) { if (mounted) { setState(() { @@ -313,24 +313,24 @@ class _DraggableState extends State> { _activeCount -= 1; _disposeRecognizerIfInactive(); } - if (!wasAccepted && config.onDraggableCanceled != null) - config.onDraggableCanceled(velocity, offset); + if (!wasAccepted && widget.onDraggableCanceled != null) + widget.onDraggableCanceled(velocity, offset); } ); - if (config.onDragStarted != null) - config.onDragStarted(); + if (widget.onDragStarted != null) + widget.onDragStarted(); return avatar; } @override Widget build(BuildContext context) { - assert(Overlay.of(context, debugRequiredFor: config) != null); - final bool canDrag = config.maxSimultaneousDrags == null || - _activeCount < config.maxSimultaneousDrags; - final bool showChild = _activeCount == 0 || config.childWhenDragging == null; + assert(Overlay.of(context, debugRequiredFor: widget) != null); + final bool canDrag = widget.maxSimultaneousDrags == null || + _activeCount < widget.maxSimultaneousDrags; + final bool showChild = _activeCount == 0 || widget.childWhenDragging == null; return new Listener( onPointerDown: canDrag ? _routePointer : null, - child: showChild ? config.child : config.childWhenDragging + child: showChild ? widget.child : widget.childWhenDragging ); } } @@ -386,7 +386,7 @@ class _DragTargetState extends State> { bool didEnter(_DragAvatar avatar) { assert(!_candidateAvatars.contains(avatar)); assert(!_rejectedAvatars.contains(avatar)); - if (avatar.data is T && (config.onWillAccept == null || config.onWillAccept(avatar.data))) { + if (avatar.data is T && (widget.onWillAccept == null || widget.onWillAccept(avatar.data))) { setState(() { _candidateAvatars.add(avatar); }); @@ -413,17 +413,17 @@ class _DragTargetState extends State> { setState(() { _candidateAvatars.remove(avatar); }); - if (config.onAccept != null) - config.onAccept(avatar.data); + if (widget.onAccept != null) + widget.onAccept(avatar.data); } @override Widget build(BuildContext context) { - assert(config.builder != null); + assert(widget.builder != null); return new MetaData( metaData: this, behavior: HitTestBehavior.translucent, - child: config.builder(context, _mapAvatarsToData(_candidateAvatars), _mapAvatarsToData(_rejectedAvatars)) + child: widget.builder(context, _mapAvatarsToData(_candidateAvatars), _mapAvatarsToData(_rejectedAvatars)) ); } } diff --git a/packages/flutter/lib/src/widgets/editable_text.dart b/packages/flutter/lib/src/widgets/editable_text.dart index c1fcecb97f..34b998e425 100644 --- a/packages/flutter/lib/src/widgets/editable_text.dart +++ b/packages/flutter/lib/src/widgets/editable_text.dart @@ -220,43 +220,43 @@ class EditableTextState extends State implements TextInputClient { @override void initState() { super.initState(); - config.controller.addListener(_didChangeTextEditingValue); - config.focusNode.addListener(_handleFocusChanged); + widget.controller.addListener(_didChangeTextEditingValue); + widget.focusNode.addListener(_handleFocusChanged); } @override void didChangeDependencies() { super.didChangeDependencies(); - if (!_didAutoFocus && config.autofocus) { + if (!_didAutoFocus && widget.autofocus) { _didRequestKeyboard = true; - FocusScope.of(context).autofocus(config.focusNode); + FocusScope.of(context).autofocus(widget.focusNode); _didAutoFocus = true; } } @override - void didUpdateConfig(EditableText oldConfig) { - if (config.controller != oldConfig.controller) { - oldConfig.controller.removeListener(_didChangeTextEditingValue); - config.controller.addListener(_didChangeTextEditingValue); + void didUpdateWidget(EditableText oldWidget) { + if (widget.controller != oldWidget.controller) { + oldWidget.controller.removeListener(_didChangeTextEditingValue); + widget.controller.addListener(_didChangeTextEditingValue); _updateRemoteEditingValueIfNeeded(); } - if (config.focusNode != oldConfig.focusNode) { - oldConfig.focusNode.removeListener(_handleFocusChanged); - config.focusNode.addListener(_handleFocusChanged); + if (widget.focusNode != oldWidget.focusNode) { + oldWidget.focusNode.removeListener(_handleFocusChanged); + widget.focusNode.addListener(_handleFocusChanged); } } @override void dispose() { - config.controller.removeListener(_didChangeTextEditingValue); + widget.controller.removeListener(_didChangeTextEditingValue); _closeInputConnectionIfNeeded(); assert(!_hasInputConnection); _stopCursorTimer(); assert(_cursorTimer == null); _selectionOverlay?.dispose(); _selectionOverlay = null; - config.focusNode.removeListener(_handleFocusChanged); + widget.focusNode.removeListener(_handleFocusChanged); super.dispose(); } @@ -270,16 +270,16 @@ class EditableTextState extends State implements TextInputClient { _hideSelectionOverlayIfNeeded(); _lastKnownRemoteTextEditingValue = value; _value = value; - if (config.onChanged != null) - config.onChanged(value.text); + if (widget.onChanged != null) + widget.onChanged(value.text); } @override void performAction(TextInputAction action) { - config.controller.clearComposing(); - config.focusNode.unfocus(); - if (config.onSubmitted != null) - config.onSubmitted(_value.text); + widget.controller.clearComposing(); + widget.focusNode.unfocus(); + if (widget.onSubmitted != null) + widget.onSubmitted(_value.text); } void _updateRemoteEditingValueIfNeeded() { @@ -292,13 +292,13 @@ class EditableTextState extends State implements TextInputClient { _textInputConnection.setEditingState(localValue); } - TextEditingValue get _value => config.controller.value; + TextEditingValue get _value => widget.controller.value; set _value(TextEditingValue value) { - config.controller.value = value; + widget.controller.value = value; } - bool get _hasFocus => config.focusNode.hasFocus; - bool get _isMultiline => config.maxLines > 1; + bool get _hasFocus => widget.focusNode.hasFocus; + bool get _isMultiline => widget.maxLines > 1; // Calculate the new scroll offset so the cursor remains visible. double _getScrollOffsetForCaret(Rect caretRect) { @@ -320,7 +320,7 @@ class EditableTextState extends State implements TextInputClient { if (!_hasInputConnection) { final TextEditingValue localValue = _value; _lastKnownRemoteTextEditingValue = localValue; - _textInputConnection = TextInput.attach(this, new TextInputConfiguration(inputType: config.keyboardType)) + _textInputConnection = TextInput.attach(this, new TextInputConfiguration(inputType: widget.keyboardType)) ..setEditingState(localValue) ..show(); } @@ -339,7 +339,7 @@ class EditableTextState extends State implements TextInputClient { _openInputConnectionIfNeeded(); } else if (!_hasFocus) { _closeInputConnectionIfNeeded(); - config.controller.clearComposing(); + widget.controller.clearComposing(); } _didRequestKeyboard = false; } @@ -359,7 +359,7 @@ class EditableTextState extends State implements TextInputClient { _openInputConnectionIfNeeded(); } else { _didRequestKeyboard = true; - FocusScope.of(context).requestFocus(config.focusNode); + FocusScope.of(context).requestFocus(widget.focusNode); } } } @@ -381,7 +381,7 @@ class EditableTextState extends State implements TextInputClient { } void _handleSelectionChanged(TextSelection selection, RenderEditable renderObject, bool longPress) { - config.controller.selection = selection; + widget.controller.selection = selection; // Note that this will show the keyboard for all selection changes on the // EditableWidget, not just changes triggered by user gestures. @@ -389,14 +389,14 @@ class EditableTextState extends State implements TextInputClient { _hideSelectionOverlayIfNeeded(); - if (config.selectionControls != null) { + if (widget.selectionControls != null) { _selectionOverlay = new TextSelectionOverlay( context: context, value: _value, - debugRequiredFor: config, + debugRequiredFor: widget, renderObject: renderObject, onSelectionOverlayChanged: _handleSelectionOverlayChanged, - selectionControls: config.selectionControls, + selectionControls: widget.selectionControls, ); if (_value.text.isNotEmpty || longPress) _selectionOverlay.showHandles(); @@ -450,7 +450,7 @@ class EditableTextState extends State implements TextInputClient { _updateOrDisposeSelectionOverlayIfNeeded(); // TODO(abarth): Teach RenderEditable about ValueNotifier // to avoid this setState(). - setState(() { /* We use config.controller.value in build(). */ }); + setState(() { /* We use widget.controller.value in build(). */ }); } void _handleFocusChanged() { @@ -461,7 +461,7 @@ class EditableTextState extends State implements TextInputClient { @override Widget build(BuildContext context) { - FocusScope.of(context).reparentIfNeeded(config.focusNode); + FocusScope.of(context).reparentIfNeeded(widget.focusNode); return new Scrollable( axisDirection: _isMultiline ? AxisDirection.down : AxisDirection.right, controller: _scrollController, @@ -469,14 +469,14 @@ class EditableTextState extends State implements TextInputClient { viewportBuilder: (BuildContext context, ViewportOffset offset) { return new _Editable( value: _value, - style: config.style, - cursorColor: config.cursorColor, + style: widget.style, + cursorColor: widget.cursorColor, showCursor: _showCursor, - maxLines: config.maxLines, - selectionColor: config.selectionColor, - textScaleFactor: config.textScaleFactor ?? MediaQuery.of(context).textScaleFactor, - textAlign: config.textAlign, - obscureText: config.obscureText, + maxLines: widget.maxLines, + selectionColor: widget.selectionColor, + textScaleFactor: widget.textScaleFactor ?? MediaQuery.of(context).textScaleFactor, + textAlign: widget.textAlign, + obscureText: widget.obscureText, offset: offset, onSelectionChanged: _handleSelectionChanged, ); diff --git a/packages/flutter/lib/src/widgets/focus_scope.dart b/packages/flutter/lib/src/widgets/focus_scope.dart index ffeb933c8c..f5c9bbb6b8 100644 --- a/packages/flutter/lib/src/widgets/focus_scope.dart +++ b/packages/flutter/lib/src/widgets/focus_scope.dart @@ -90,26 +90,26 @@ class _FocusScopeState extends State { @override void didChangeDependencies() { super.didChangeDependencies(); - if (!_didAutofocus && config.autofocus) { - FocusScope.of(context).setFirstFocus(config.node); + if (!_didAutofocus && widget.autofocus) { + FocusScope.of(context).setFirstFocus(widget.node); _didAutofocus = true; } } @override void dispose() { - config.node.detach(); + widget.node.detach(); super.dispose(); } @override Widget build(BuildContext context) { - FocusScope.of(context).reparentScopeIfNeeded(config.node); + FocusScope.of(context).reparentScopeIfNeeded(widget.node); return new Semantics( container: true, child: new _FocusScopeMarker( - node: config.node, - child: config.child, + node: widget.node, + child: widget.child, ), ); } diff --git a/packages/flutter/lib/src/widgets/form.dart b/packages/flutter/lib/src/widgets/form.dart index 0bb1b8158a..6df0a30825 100644 --- a/packages/flutter/lib/src/widgets/form.dart +++ b/packages/flutter/lib/src/widgets/form.dart @@ -90,14 +90,14 @@ class FormState extends State
{ @override Widget build(BuildContext context) { - if (config.autovalidate) + if (widget.autovalidate) _validate(); return new WillPopScope( - onWillPop: config.onWillPop, + onWillPop: widget.onWillPop, child: new _FormScope( formState: this, generation: _generation, - child: config.child, + child: widget.child, ), ); } @@ -148,7 +148,7 @@ class _FormScope extends InheritedWidget { final int _generation; /// The [Form] associated with this widget. - Form get form => _formState.config; + Form get form => _formState.widget; @override bool updateShouldNotify(_FormScope old) => _generation != old._generation; @@ -250,14 +250,14 @@ class FormFieldState extends State> { /// Calls the [FormField]'s onSaved method with the current value. void save() { - if (config.onSaved != null) - config.onSaved(value); + if (widget.onSaved != null) + widget.onSaved(value); } /// Resets the field to its initial value. void reset() { setState(() { - _value = config.initialValue; + _value = widget.initialValue; _errorText = null; }); } @@ -272,8 +272,8 @@ class FormFieldState extends State> { } bool _validate() { - if (config.validator != null) - _errorText = config.validator(_value); + if (widget.validator != null) + _errorText = widget.validator(_value); return !hasError; } @@ -289,7 +289,7 @@ class FormFieldState extends State> { @override void initState() { super.initState(); - _value = config.initialValue; + _value = widget.initialValue; } @override @@ -300,9 +300,9 @@ class FormFieldState extends State> { @override Widget build(BuildContext context) { - if (config.autovalidate) + if (widget.autovalidate) _validate(); Form.of(context)?._register(this); - return config.builder(this); + return widget.builder(this); } } diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index 54405cc5f4..3502c8dfbe 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -670,7 +670,7 @@ typedef void StateSetter(VoidCallback fn); /// * The framework calls [initState]. Subclasses of [State] should override /// [initState] to perform one-time initialization that depends on the /// [BuildContext] or the widget, which are available as the [context] and -/// [config] properties, respectively, when the [initState] method is +/// [widget] properties, respectively, when the [initState] method is /// called. /// * The framework calls [didChangeDependencies]. Subclasses of [State] should /// override [didChangeDependencies] to perform initialization involving @@ -687,12 +687,12 @@ typedef void StateSetter(VoidCallback fn); /// * During this time, a parent widget might rebuild and request that this /// location in the tree update to display a new widget with the same /// [runtimeType] and [key]. When this happens, the framework will update the -/// [config] property to refer to the new widget and then call the -/// [didUpdateConfig] method with the previous widget as an argument. -/// [State] objects should override [didUpdateConfig] to respond to changes +/// [widget] property to refer to the new widget and then call the +/// [didUpdateWidget] method with the previous widget as an argument. +/// [State] objects should override [didUpdateWidget] to respond to changes /// in their associated wiget (e.g., to start implicit animations). -/// The framework always calls [build] after calling [didUpdateConfig], which -/// means any calls to [setState] in [didUpdateConfig] are redundant. +/// The framework always calls [build] after calling [didUpdateWidget], which +/// means any calls to [setState] in [didUpdateWidget] are redundant. /// * If the subtree containing the [State] object is removed from the tree /// (e.g., because the parent built a widget with a different [runtimeType] /// or [key]), the framework calls the [deactivate] method. Subclasses @@ -720,7 +720,7 @@ typedef void StateSetter(VoidCallback fn); /// See also: /// /// * [StatefulWidget], where the current configuration of a [State] is hosted -/// (see [config]). +/// (see [Widget]). /// * [StatelessWidget], for widgets that always build the same way given a /// particular configuration and ambient state. /// * [InheritedWidget], for widgets that introduce ambient state that can @@ -734,9 +734,15 @@ abstract class State { /// [initState]. If the parent updates this location in the tree to a new /// widget with the same [runtimeType] and [key] as the current configuration, /// the framework will update this property to refer to the new widget and - /// then call [didUpdateConfig], passing the old configuration as an argument. - T get config => _config; - T _config; + /// then call [didUpdateWidget], passing the old configuration as an argument. + T get widget => _widget; + T _widget; + + /// Deprecated getter for [widget]. Use the [widget] getter instead. This + /// getter will be removed on 2017/04/20. + @Deprecated('The "config" property is now called "widget". Please migrate ' + 'now, as we will remove this feature soon.') + T get config => _widget; /// The current stage in the lifecycle for this state object. /// @@ -779,14 +785,14 @@ abstract class State { /// /// Override this method to perform initialization that depends on the /// location at which this object was inserted into the tree (i.e., [context]) - /// or on the widget used to configure this object (i.e., [config]). + /// or on the widget used to configure this object (i.e., [widget]). /// /// If a [State]'s [build] method depends on an object that can itself change /// state, for example a [ChangeNotifier] or [Stream], or some other object to /// which one can subscribe to receive notifications, then the [State] should /// subscribe to that object during [initState], unsubscribe from the old /// object and subscribe to the new object when it changes in - /// [didUpdateConfig], and then unsubscribe from the object in [dispose]. + /// [didUpdateWidget], and then unsubscribe from the object in [dispose]. /// /// You cannot use [BuildContext.inheritFromWidgetOfExactType] from this /// method. However, [didChangeDependencies] will be called immediately @@ -801,31 +807,38 @@ abstract class State { assert(_debugLifecycleState == _StateLifecycle.created); } - /// Called whenever the configuration changes. + /// Called whenever the widget configuration changes. /// /// If the parent widget rebuilds and request that this location in the tree /// update to display a new widget with the same [runtimeType] and [key], the - /// framework will update the [config] property of this [State] object to + /// framework will update the [widget] property of this [State] object to /// refer to the new widget and then call the this method with the previous /// widget as an argument. /// - /// Override this method to respond to changes in the [config] widget (e.g., + /// Override this method to respond to changes in the [widget] widget (e.g., /// to start implicit animations). /// - /// The framework always calls [build] after calling [didUpdateConfig], which - /// means any calls to [setState] in [didUpdateConfig] are redundant. + /// The framework always calls [build] after calling [didUpdateWidget], which + /// means any calls to [setState] in [didUpdateWidget] are redundant. /// /// If a [State]'s [build] method depends on an object that can itself change /// state, for example a [ChangeNotifier] or [Stream], or some other object to /// which one can subscribe to receive notifications, then the [State] should /// subscribe to that object during [initState], unsubscribe from the old /// object and subscribe to the new object when it changes in - /// [didUpdateConfig], and then unsubscribe from the object in [dispose]. + /// [didUpdateWidget], and then unsubscribe from the object in [dispose]. /// /// If you override this, make sure your method starts with a call to - /// super.didUpdateConfig(oldConfig). + /// super.didUpdateWidget(oldWidget). // TODO(abarth): Add @mustCallSuper. @protected + void didUpdateWidget(covariant T oldWidget) { } + + /// Deprecated callback when the widget configuration changes. + /// + /// Use [didUpdateWidget] instead. This method will be removed on 2017/04/20. + @Deprecated('The "didUpdateConfig" method is now called "didUpdateWidget". ' + 'Please migrate now, as we will remove this feature soon.') void didUpdateConfig(covariant T oldConfig) { } /// Called whenever the application is reassembled during debugging. @@ -976,7 +989,7 @@ abstract class State { /// which one can subscribe to receive notifications, then the [State] should /// subscribe to that object during [initState], unsubscribe from the old /// object and subscribe to the new object when it changes in - /// [didUpdateConfig], and then unsubscribe from the object in [dispose]. + /// [didUpdateWidget], and then unsubscribe from the object in [dispose]. /// /// If you override this, make sure to end your method with a call to /// super.dispose(). @@ -994,7 +1007,7 @@ abstract class State { /// The framework calls this method in a number of different situations: /// /// * After calling [initState]. - /// * After calling [didUpdateConfig]. + /// * After calling [didUpdateWidget]. /// * After receiving a call to [setState]. /// * After a dependency of this [State] object changes (e.g., an /// [InheritedWidget] referenced by the previous [build] changes). @@ -1074,15 +1087,15 @@ abstract class State { /// ... /// @override /// Widget build(BuildContext context) { - /// ... () { print("color: ${config.color}"); } ... + /// ... () { print("color: ${widget.color}"); } ... /// } /// } /// ``` /// /// Now when the parent rebuilds `MyButton` with green, the closure created by /// the first build still refers to [State] object, which is preserved across - /// rebuilds, but the framework has updated that [State] object's [config] - /// property to refer to the new `MyButton` instance and `${config.color}` + /// rebuilds, but the framework has updated that [State] object's [widget] + /// property to refer to the new `MyButton` instance and `${widget.color}` /// prints green, as expected. @protected Widget build(BuildContext context); @@ -1129,8 +1142,8 @@ abstract class State { description.add('$_debugLifecycleState'); return true; }); - if (_config == null) - description.add('no config'); + if (_widget == null) + description.add('no widget'); if (_element == null) description.add('not mounted'); } @@ -2898,10 +2911,10 @@ abstract class Element implements BuildContext { // Whether we've already built or not. Set in [rebuild]. bool _debugBuiltOnce = false; - // We let widget authors call setState from initState, didUpdateConfig, and + // We let widget authors call setState from initState, didUpdateWidget, and // build even when state is locked because its convenient and a no-op anyway. // This flag ensures that this convenience is only allowed on the element - // currently undergoing initState, didUpdateConfig, or build. + // currently undergoing initState, didUpdateWidget, or build. bool _debugAllowIgnoredCallsToMarkNeedsBuild = false; bool _debugSetAllowIgnoredCallsToMarkNeedsBuild(bool value) { assert(_debugAllowIgnoredCallsToMarkNeedsBuild == !value); @@ -3171,8 +3184,8 @@ class StatefulElement extends ComponentElement { }); assert(_state._element == null); _state._element = this; - assert(_state._config == null); - _state._config = widget; + assert(_state._widget == null); + _state._widget = widget; assert(_state._debugLifecycleState == _StateLifecycle.created); } @@ -3212,15 +3225,17 @@ class StatefulElement extends ComponentElement { void update(StatefulWidget newWidget) { super.update(newWidget); assert(widget == newWidget); - final StatefulWidget oldConfig = _state._config; - // Notice that we mark ourselves as dirty before calling didUpdateConfig to - // let authors call setState from within didUpdateConfig without triggering + final StatefulWidget oldWidget = _state._widget; + // Notice that we mark ourselves as dirty before calling didUpdateWidget to + // let authors call setState from within didUpdateWidget without triggering // asserts. _dirty = true; - _state._config = widget; + _state._widget = widget; try { _debugSetAllowIgnoredCallsToMarkNeedsBuild(true); - _state.didUpdateConfig(oldConfig); + _state.didUpdateWidget(oldWidget); + // ignore: deprecated_member_use + _state.didUpdateConfig(oldWidget); } finally { _debugSetAllowIgnoredCallsToMarkNeedsBuild(false); } diff --git a/packages/flutter/lib/src/widgets/gesture_detector.dart b/packages/flutter/lib/src/widgets/gesture_detector.dart index 1a22d5603f..5c2b5353fc 100644 --- a/packages/flutter/lib/src/widgets/gesture_detector.dart +++ b/packages/flutter/lib/src/widgets/gesture_detector.dart @@ -363,12 +363,12 @@ class RawGestureDetectorState extends State { @override void initState() { super.initState(); - _syncAll(config.gestures); + _syncAll(widget.gestures); } @override - void didUpdateConfig(RawGestureDetector oldConfig) { - _syncAll(config.gestures); + void didUpdateWidget(RawGestureDetector oldWidget) { + _syncAll(widget.gestures); } /// This method can be called after the build phase, during the @@ -394,7 +394,7 @@ class RawGestureDetectorState extends State { return true; }); _syncAll(gestures); - if (!config.excludeFromSemantics) { + if (!widget.excludeFromSemantics) { final RenderSemanticsGestureHandler semanticsGestureHandler = context.findRenderObject(); context.visitChildElements((Element element) { final _GestureSemantics widget = element.widget; @@ -433,17 +433,17 @@ class RawGestureDetectorState extends State { } HitTestBehavior get _defaultBehavior { - return config.child == null ? HitTestBehavior.translucent : HitTestBehavior.deferToChild; + return widget.child == null ? HitTestBehavior.translucent : HitTestBehavior.deferToChild; } @override Widget build(BuildContext context) { Widget result = new Listener( onPointerDown: _handlePointerDown, - behavior: config.behavior ?? _defaultBehavior, - child: config.child + behavior: widget.behavior ?? _defaultBehavior, + child: widget.child ); - if (!config.excludeFromSemantics) + if (!widget.excludeFromSemantics) result = new _GestureSemantics(owner: this, child: result); return result; } @@ -459,7 +459,7 @@ class RawGestureDetectorState extends State { gestures.add(''); description.add('gestures: ${gestures.join(", ")}'); } - switch (config.behavior) { + switch (widget.behavior) { case HitTestBehavior.translucent: description.add('behavior: translucent'); break; diff --git a/packages/flutter/lib/src/widgets/heroes.dart b/packages/flutter/lib/src/widgets/heroes.dart index 625b027e4d..ce5081b709 100644 --- a/packages/flutter/lib/src/widgets/heroes.dart +++ b/packages/flutter/lib/src/widgets/heroes.dart @@ -165,7 +165,7 @@ class _HeroState extends State { } return new KeyedSubtree( key: _key, - child: config.child, + child: widget.child, ); } } @@ -182,7 +182,7 @@ class _HeroFlightManifest { @required this.toHero, @required this.createRectTween, }) { - assert(fromHero.config.tag == toHero.config.tag); + assert(fromHero.widget.tag == toHero.widget.tag); } final _HeroFlightType type; @@ -194,7 +194,7 @@ class _HeroFlightManifest { final _HeroState toHero; final CreateRectTween createRectTween; - Object get tag => fromHero.config.tag; + Object get tag => fromHero.widget.tag; Animation get animation { return new CurvedAnimation( @@ -235,7 +235,7 @@ class _HeroFlight { assert(manifest != null); return new AnimatedBuilder( animation: _proxyAnimation, - child: manifest.toHero.config, + child: manifest.toHero.widget, builder: (BuildContext context, Widget child) { final RenderBox toHeroBox = manifest.toHero.context?.findRenderObject(); if (_aborted || toHeroBox == null || !toHeroBox.attached) { diff --git a/packages/flutter/lib/src/widgets/image.dart b/packages/flutter/lib/src/widgets/image.dart index 322ba71cc5..9ab5a49ea1 100644 --- a/packages/flutter/lib/src/widgets/image.dart +++ b/packages/flutter/lib/src/widgets/image.dart @@ -243,8 +243,8 @@ class _ImageState extends State { } @override - void didUpdateConfig(Image oldConfig) { - if (config.image != oldConfig.image) + void didUpdateWidget(Image oldWidget) { + if (widget.image != oldWidget.image) _resolveImage(); } @@ -256,14 +256,14 @@ class _ImageState extends State { void _resolveImage() { final ImageStream oldImageStream = _imageStream; - _imageStream = config.image.resolve(createLocalImageConfiguration( + _imageStream = widget.image.resolve(createLocalImageConfiguration( context, - size: config.width != null && config.height != null ? new Size(config.width, config.height) : null + size: widget.width != null && widget.height != null ? new Size(widget.width, widget.height) : null )); assert(_imageStream != null); if (_imageStream.key != oldImageStream?.key) { oldImageStream?.removeListener(_handleImageChanged); - if (!config.gaplessPlayback) + if (!widget.gaplessPlayback) setState(() { _imageInfo = null; }); _imageStream.addListener(_handleImageChanged); } @@ -286,14 +286,14 @@ class _ImageState extends State { Widget build(BuildContext context) { return new RawImage( image: _imageInfo?.image, - width: config.width, - height: config.height, + width: widget.width, + height: widget.height, scale: _imageInfo?.scale ?? 1.0, - color: config.color, - fit: config.fit, - alignment: config.alignment, - repeat: config.repeat, - centerSlice: config.centerSlice + color: widget.color, + fit: widget.fit, + alignment: widget.alignment, + repeat: widget.repeat, + centerSlice: widget.centerSlice ); } diff --git a/packages/flutter/lib/src/widgets/implicit_animations.dart b/packages/flutter/lib/src/widgets/implicit_animations.dart index 8264788650..7bfc8e0b50 100644 --- a/packages/flutter/lib/src/widgets/implicit_animations.dart +++ b/packages/flutter/lib/src/widgets/implicit_animations.dart @@ -138,8 +138,8 @@ abstract class AnimatedWidgetBaseState exten void initState() { super.initState(); _controller = new AnimationController( - duration: config.duration, - debugLabel: '${config.toStringShort()}', + duration: widget.duration, + debugLabel: '${widget.toStringShort()}', vsync: this, )..addListener(_handleAnimationChanged); _updateCurve(); @@ -147,10 +147,10 @@ abstract class AnimatedWidgetBaseState exten } @override - void didUpdateConfig(T oldConfig) { - if (config.curve != oldConfig.curve) + void didUpdateWidget(T oldWidget) { + if (widget.curve != oldWidget.curve) _updateCurve(); - _controller.duration = config.duration; + _controller.duration = widget.duration; if (_constructTweens()) { forEachTween((Tween tween, dynamic targetValue, TweenConstructor constructor) { _updateTween(tween, targetValue); @@ -163,8 +163,8 @@ abstract class AnimatedWidgetBaseState exten } void _updateCurve() { - if (config.curve != null) - _animation = new CurvedAnimation(parent: _controller, curve: config.curve); + if (widget.curve != null) + _animation = new CurvedAnimation(parent: _controller, curve: widget.curve); else _animation = _controller; } @@ -212,7 +212,7 @@ abstract class AnimatedWidgetBaseState exten /// 1. Call the visitor callback with three arguments, the first argument /// being the current value of the Tween object that represents the /// tween (initially null), the second argument, of type T, being the value - /// on the Widget (config) that represents the current target value of the + /// on the Widget that represents the current target value of the /// tween, and the third being a callback that takes a value T (which will /// be the second argument to the visitor callback), and that returns an /// Tween object for the tween, configured with the given value @@ -324,20 +324,20 @@ class _AnimatedContainerState extends AnimatedWidgetBaseState @override void forEachTween(TweenVisitor visitor) { // TODO(ianh): Use constructor tear-offs when it becomes possible - _constraints = visitor(_constraints, config.constraints, (dynamic value) => new BoxConstraintsTween(begin: value)); - _decoration = visitor(_decoration, config.decoration, (dynamic value) => new DecorationTween(begin: value)); - _foregroundDecoration = visitor(_foregroundDecoration, config.foregroundDecoration, (dynamic value) => new DecorationTween(begin: value)); - _margin = visitor(_margin, config.margin, (dynamic value) => new EdgeInsetsTween(begin: value)); - _padding = visitor(_padding, config.padding, (dynamic value) => new EdgeInsetsTween(begin: value)); - _transform = visitor(_transform, config.transform, (dynamic value) => new Matrix4Tween(begin: value)); - _width = visitor(_width, config.width, (dynamic value) => new Tween(begin: value)); - _height = visitor(_height, config.height, (dynamic value) => new Tween(begin: value)); + _constraints = visitor(_constraints, widget.constraints, (dynamic value) => new BoxConstraintsTween(begin: value)); + _decoration = visitor(_decoration, widget.decoration, (dynamic value) => new DecorationTween(begin: value)); + _foregroundDecoration = visitor(_foregroundDecoration, widget.foregroundDecoration, (dynamic value) => new DecorationTween(begin: value)); + _margin = visitor(_margin, widget.margin, (dynamic value) => new EdgeInsetsTween(begin: value)); + _padding = visitor(_padding, widget.padding, (dynamic value) => new EdgeInsetsTween(begin: value)); + _transform = visitor(_transform, widget.transform, (dynamic value) => new Matrix4Tween(begin: value)); + _width = visitor(_width, widget.width, (dynamic value) => new Tween(begin: value)); + _height = visitor(_height, widget.height, (dynamic value) => new Tween(begin: value)); } @override Widget build(BuildContext context) { return new Container( - child: config.child, + child: widget.child, constraints: _constraints?.evaluate(animation), decoration: _decoration?.evaluate(animation), foregroundDecoration: _foregroundDecoration?.evaluate(animation), @@ -476,18 +476,18 @@ class _AnimatedPositionedState extends AnimatedWidgetBaseState visitor) { // TODO(ianh): Use constructor tear-offs when it becomes possible - _left = visitor(_left, config.left, (dynamic value) => new Tween(begin: value)); - _top = visitor(_top, config.top, (dynamic value) => new Tween(begin: value)); - _right = visitor(_right, config.right, (dynamic value) => new Tween(begin: value)); - _bottom = visitor(_bottom, config.bottom, (dynamic value) => new Tween(begin: value)); - _width = visitor(_width, config.width, (dynamic value) => new Tween(begin: value)); - _height = visitor(_height, config.height, (dynamic value) => new Tween(begin: value)); + _left = visitor(_left, widget.left, (dynamic value) => new Tween(begin: value)); + _top = visitor(_top, widget.top, (dynamic value) => new Tween(begin: value)); + _right = visitor(_right, widget.right, (dynamic value) => new Tween(begin: value)); + _bottom = visitor(_bottom, widget.bottom, (dynamic value) => new Tween(begin: value)); + _width = visitor(_width, widget.width, (dynamic value) => new Tween(begin: value)); + _height = visitor(_height, widget.height, (dynamic value) => new Tween(begin: value)); } @override Widget build(BuildContext context) { return new Positioned( - child: config.child, + child: widget.child, left: _left?.evaluate(animation), top: _top?.evaluate(animation), right: _right?.evaluate(animation), @@ -561,14 +561,14 @@ class _AnimatedOpacityState extends AnimatedWidgetBaseState { @override void forEachTween(TweenVisitor visitor) { // TODO(ianh): Use constructor tear-offs when it becomes possible - _opacity = visitor(_opacity, config.opacity, (dynamic value) => new Tween(begin: value)); + _opacity = visitor(_opacity, widget.opacity, (dynamic value) => new Tween(begin: value)); } @override Widget build(BuildContext context) { return new Opacity( opacity: _opacity.evaluate(animation), - child: config.child + child: widget.child ); } } @@ -616,14 +616,14 @@ class _AnimatedDefaultTextStyleState extends AnimatedWidgetBaseState visitor) { // TODO(ianh): Use constructor tear-offs when it becomes possible - _style = visitor(_style, config.style, (dynamic value) => new TextStyleTween(begin: value)); + _style = visitor(_style, widget.style, (dynamic value) => new TextStyleTween(begin: value)); } @override Widget build(BuildContext context) { return new DefaultTextStyle( style: _style.evaluate(animation), - child: config.child + child: widget.child ); } } diff --git a/packages/flutter/lib/src/widgets/navigator.dart b/packages/flutter/lib/src/widgets/navigator.dart index a8f897d2cc..0e4615d4a4 100644 --- a/packages/flutter/lib/src/widgets/navigator.dart +++ b/packages/flutter/lib/src/widgets/navigator.dart @@ -704,22 +704,22 @@ class NavigatorState extends State with TickerProviderStateMixin { @override void initState() { super.initState(); - for (NavigatorObserver observer in config.observers) { + for (NavigatorObserver observer in widget.observers) { assert(observer.navigator == null); observer._navigator = this; } - push(config.onGenerateRoute(new RouteSettings( - name: config.initialRoute ?? Navigator.defaultRouteName, + push(widget.onGenerateRoute(new RouteSettings( + name: widget.initialRoute ?? Navigator.defaultRouteName, isInitialRoute: true ))); } @override - void didUpdateConfig(Navigator oldConfig) { - if (oldConfig.observers != config.observers) { - for (NavigatorObserver observer in oldConfig.observers) + void didUpdateWidget(Navigator oldWidget) { + if (oldWidget.observers != widget.observers) { + for (NavigatorObserver observer in oldWidget.observers) observer._navigator = null; - for (NavigatorObserver observer in config.observers) { + for (NavigatorObserver observer in widget.observers) { assert(observer.navigator == null); observer._navigator = this; } @@ -730,7 +730,7 @@ class NavigatorState extends State with TickerProviderStateMixin { void dispose() { assert(!_debugLocked); assert(() { _debugLocked = true; return true; }); - for (NavigatorObserver observer in config.observers) + for (NavigatorObserver observer in widget.observers) observer._navigator = null; final List> doomed = _poppedRoutes.toList()..addAll(_history); for (Route route in doomed) @@ -759,10 +759,10 @@ class NavigatorState extends State with TickerProviderStateMixin { assert(!_debugLocked); assert(name != null); final RouteSettings settings = new RouteSettings(name: name); - Route route = config.onGenerateRoute(settings); + Route route = widget.onGenerateRoute(settings); if (route == null) { - assert(config.onUnknownRoute != null); - route = config.onUnknownRoute(settings); + assert(widget.onUnknownRoute != null); + route = widget.onUnknownRoute(settings); assert(route != null); } return route; @@ -811,7 +811,7 @@ class NavigatorState extends State with TickerProviderStateMixin { route.didChangeNext(null); if (oldRoute != null) oldRoute.didChangeNext(route); - for (NavigatorObserver observer in config.observers) + for (NavigatorObserver observer in widget.observers) observer.didPush(route, oldRoute); }); assert(() { _debugLocked = false; return true; }); @@ -896,7 +896,7 @@ class NavigatorState extends State with TickerProviderStateMixin { newRoute.didChangeNext(null); if (index > 0) _history[index - 1].didChangeNext(newRoute); - for (NavigatorObserver observer in config.observers) + for (NavigatorObserver observer in widget.observers) observer.didPush(newRoute, oldRoute); }); assert(() { _debugLocked = false; return true; }); @@ -1015,7 +1015,7 @@ class NavigatorState extends State with TickerProviderStateMixin { if (route._navigator != null) _poppedRoutes.add(route); _history.last.didPopNext(route); - for (NavigatorObserver observer in config.observers) + for (NavigatorObserver observer in widget.observers) observer.didPop(route, _history.last); }); } else { @@ -1085,14 +1085,14 @@ class NavigatorState extends State with TickerProviderStateMixin { /// Used for the iOS back gesture. void didStartUserGesture() { _userGestureInProgress = true; - for (NavigatorObserver observer in config.observers) + for (NavigatorObserver observer in widget.observers) observer.didStartUserGesture(); } /// A user gesture is no longer controlling the navigator. void didStopUserGesture() { _userGestureInProgress = false; - for (NavigatorObserver observer in config.observers) + for (NavigatorObserver observer in widget.observers) observer.didStopUserGesture(); } diff --git a/packages/flutter/lib/src/widgets/overlay.dart b/packages/flutter/lib/src/widgets/overlay.dart index 63a3acd8e2..9d26c8313b 100644 --- a/packages/flutter/lib/src/widgets/overlay.dart +++ b/packages/flutter/lib/src/widgets/overlay.dart @@ -167,7 +167,7 @@ class _OverlayEntry extends StatefulWidget { class _OverlayEntryState extends State<_OverlayEntry> { @override Widget build(BuildContext context) { - return config.entry.builder(context); + return widget.entry.builder(context); } void _markNeedsBuild() { @@ -271,7 +271,7 @@ class OverlayState extends State with TickerProviderStateMixin { @override void initState() { super.initState(); - insertAll(config.initialEntries); + insertAll(widget.initialEntries); } /// Insert the given entry into the overlay. diff --git a/packages/flutter/lib/src/widgets/overscroll_indicator.dart b/packages/flutter/lib/src/widgets/overscroll_indicator.dart index d1eff68f83..b84bff6042 100644 --- a/packages/flutter/lib/src/widgets/overscroll_indicator.dart +++ b/packages/flutter/lib/src/widgets/overscroll_indicator.dart @@ -116,17 +116,17 @@ class _GlowingOverscrollIndicatorState extends State @override void initState() { super.initState(); - _leadingController = new _GlowController(vsync: this, color: config.color, axis: config.axis); - _trailingController = new _GlowController(vsync: this, color: config.color, axis: config.axis); + _leadingController = new _GlowController(vsync: this, color: widget.color, axis: widget.axis); + _trailingController = new _GlowController(vsync: this, color: widget.color, axis: widget.axis); } @override - void didUpdateConfig(GlowingOverscrollIndicator oldConfig) { - if (oldConfig.color != config.color || oldConfig.axis != config.axis) { - _leadingController.color = config.color; - _leadingController.axis = config.axis; - _trailingController.color = config.color; - _trailingController.axis = config.axis; + void didUpdateWidget(GlowingOverscrollIndicator oldWidget) { + if (oldWidget.color != widget.color || oldWidget.axis != widget.axis) { + _leadingController.color = widget.color; + _leadingController.axis = widget.axis; + _trailingController.color = widget.color; + _trailingController.axis = widget.axis; } } @@ -152,7 +152,7 @@ class _GlowingOverscrollIndicatorState extends State _accepted[isLeading] = confirmationNotification._accepted; } assert(controller != null); - assert(notification.axis == config.axis); + assert(notification.axis == widget.axis); if (_accepted[isLeading]) { if (notification.velocity != 0.0) { assert(notification.dragDetails == null); @@ -201,12 +201,12 @@ class _GlowingOverscrollIndicatorState extends State child: new RepaintBoundary( child: new CustomPaint( foregroundPainter: new _GlowingOverscrollIndicatorPainter( - leadingController: config.showLeading ? _leadingController : null, - trailingController: config.showTrailing ? _trailingController : null, - axisDirection: config.axisDirection, + leadingController: widget.showLeading ? _leadingController : null, + trailingController: widget.showTrailing ? _trailingController : null, + axisDirection: widget.axisDirection, ), child: new RepaintBoundary( - child: config.child, + child: widget.child, ), ), ), diff --git a/packages/flutter/lib/src/widgets/page_view.dart b/packages/flutter/lib/src/widgets/page_view.dart index 18f886190b..ec6328a664 100644 --- a/packages/flutter/lib/src/widgets/page_view.dart +++ b/packages/flutter/lib/src/widgets/page_view.dart @@ -388,16 +388,16 @@ class _PageViewState extends State { @override void initState() { super.initState(); - _lastReportedPage = config.controller.initialPage; + _lastReportedPage = widget.controller.initialPage; } AxisDirection _getDirection(BuildContext context) { // TODO(abarth): Consider reading direction. - switch (config.scrollDirection) { + switch (widget.scrollDirection) { case Axis.horizontal: - return config.reverse ? AxisDirection.left : AxisDirection.right; + return widget.reverse ? AxisDirection.left : AxisDirection.right; case Axis.vertical: - return config.reverse ? AxisDirection.up : AxisDirection.down; + return widget.reverse ? AxisDirection.up : AxisDirection.down; } return null; } @@ -407,28 +407,28 @@ class _PageViewState extends State { final AxisDirection axisDirection = _getDirection(context); return new NotificationListener( onNotification: (ScrollNotification notification) { - if (notification.depth == 0 && config.onPageChanged != null && notification is ScrollUpdateNotification) { + if (notification.depth == 0 && widget.onPageChanged != null && notification is ScrollUpdateNotification) { final PageMetrics metrics = notification.metrics; final int currentPage = metrics.page.round(); if (currentPage != _lastReportedPage) { _lastReportedPage = currentPage; - config.onPageChanged(currentPage); + widget.onPageChanged(currentPage); } } return false; }, child: new Scrollable( axisDirection: axisDirection, - controller: config.controller, - physics: config.physics == null ? _kPagePhysics : _kPagePhysics.applyTo(config.physics), + controller: widget.controller, + physics: widget.physics == null ? _kPagePhysics : _kPagePhysics.applyTo(widget.physics), viewportBuilder: (BuildContext context, ViewportOffset offset) { return new Viewport( axisDirection: axisDirection, offset: offset, slivers: [ new SliverFillViewport( - viewportFraction: config.controller.viewportFraction, - delegate: config.childrenDelegate + viewportFraction: widget.controller.viewportFraction, + delegate: widget.childrenDelegate ), ], ); @@ -440,10 +440,10 @@ class _PageViewState extends State { @override void debugFillDescription(List description) { super.debugFillDescription(description); - description.add('${config.scrollDirection}'); - if (config.reverse) + description.add('${widget.scrollDirection}'); + if (widget.reverse) description.add('reversed'); - description.add('${config.controller}'); - description.add('${config.physics}'); + description.add('${widget.controller}'); + description.add('${widget.physics}'); } } diff --git a/packages/flutter/lib/src/widgets/raw_keyboard_listener.dart b/packages/flutter/lib/src/widgets/raw_keyboard_listener.dart index abc5491397..b4f54d6627 100644 --- a/packages/flutter/lib/src/widgets/raw_keyboard_listener.dart +++ b/packages/flutter/lib/src/widgets/raw_keyboard_listener.dart @@ -55,26 +55,26 @@ class _RawKeyboardListenerState extends State { @override void initState() { super.initState(); - config.focusNode.addListener(_handleFocusChanged); + widget.focusNode.addListener(_handleFocusChanged); } @override - void didUpdateConfig(RawKeyboardListener oldConfig) { - if (config.focusNode != oldConfig.focusNode) { - oldConfig.focusNode.removeListener(_handleFocusChanged); - config.focusNode.addListener(_handleFocusChanged); + void didUpdateWidget(RawKeyboardListener oldWidget) { + if (widget.focusNode != oldWidget.focusNode) { + oldWidget.focusNode.removeListener(_handleFocusChanged); + widget.focusNode.addListener(_handleFocusChanged); } } @override void dispose() { - config.focusNode.removeListener(_handleFocusChanged); + widget.focusNode.removeListener(_handleFocusChanged); _detachKeyboardIfAttached(); super.dispose(); } void _handleFocusChanged() { - if (config.focusNode.hasFocus) + if (widget.focusNode.hasFocus) _attachKeyboardIfDetached(); else _detachKeyboardIfAttached(); @@ -97,10 +97,10 @@ class _RawKeyboardListenerState extends State { } void _handleRawKeyEvent(RawKeyEvent event) { - if (config.onKey != null) - config.onKey(event); + if (widget.onKey != null) + widget.onKey(event); } @override - Widget build(BuildContext context) => config.child; + Widget build(BuildContext context) => widget.child; } diff --git a/packages/flutter/lib/src/widgets/routes.dart b/packages/flutter/lib/src/widgets/routes.dart index 0165235af5..01542991cd 100644 --- a/packages/flutter/lib/src/widgets/routes.dart +++ b/packages/flutter/lib/src/widgets/routes.dart @@ -436,19 +436,19 @@ class _ModalScopeState extends State<_ModalScope> { @override void initState() { super.initState(); - config.route.animation?.addStatusListener(_animationStatusChanged); - config.route.secondaryAnimation?.addStatusListener(_animationStatusChanged); + widget.route.animation?.addStatusListener(_animationStatusChanged); + widget.route.secondaryAnimation?.addStatusListener(_animationStatusChanged); } @override - void didUpdateConfig(_ModalScope oldConfig) { - assert(config.route == oldConfig.route); + void didUpdateWidget(_ModalScope oldWidget) { + assert(widget.route == oldWidget.route); } @override void dispose() { - config.route.animation?.removeStatusListener(_animationStatusChanged); - config.route.secondaryAnimation?.removeStatusListener(_animationStatusChanged); + widget.route.animation?.removeStatusListener(_animationStatusChanged); + widget.route.secondaryAnimation?.removeStatusListener(_animationStatusChanged); super.dispose(); } @@ -475,24 +475,24 @@ class _ModalScopeState extends State<_ModalScope> { @override Widget build(BuildContext context) { return new FocusScope( - node: config.route.focusScopeNode, + node: widget.route.focusScopeNode, child: new Offstage( - offstage: config.route.offstage, + offstage: widget.route.offstage, child: new IgnorePointer( - ignoring: config.route.animation?.status == AnimationStatus.reverse, - child: config.route.buildTransitions( + ignoring: widget.route.animation?.status == AnimationStatus.reverse, + child: widget.route.buildTransitions( context, - config.route.animation, - config.route.secondaryAnimation, + widget.route.animation, + widget.route.secondaryAnimation, new RepaintBoundary( child: new PageStorage( - key: config.route._subtreeKey, - bucket: config.route._storageBucket, + key: widget.route._subtreeKey, + bucket: widget.route._storageBucket, child: new _ModalScopeStatus( - route: config.route, - isCurrent: config.route.isCurrent, - canPop: config.route.canPop, - child: config.page, + route: widget.route, + isCurrent: widget.route.isCurrent, + canPop: widget.route.canPop, + child: widget.page, ), ), ), diff --git a/packages/flutter/lib/src/widgets/scroll_notification.dart b/packages/flutter/lib/src/widgets/scroll_notification.dart index 7b1718d604..3280694130 100644 --- a/packages/flutter/lib/src/widgets/scroll_notification.dart +++ b/packages/flutter/lib/src/widgets/scroll_notification.dart @@ -95,7 +95,7 @@ abstract class ScrollNotification extends LayoutChangedNotification with Viewpor /// Creates a notification about scrolling. ScrollNotification({ @required ScrollableState scrollable, - }) : axisDirection = scrollable.config.axisDirection, + }) : axisDirection = scrollable.widget.axisDirection, metrics = scrollable.position.getMetrics(), context = scrollable.context; diff --git a/packages/flutter/lib/src/widgets/scrollable.dart b/packages/flutter/lib/src/widgets/scrollable.dart index bb9768f2ce..aa18f0b7ef 100644 --- a/packages/flutter/lib/src/widgets/scrollable.dart +++ b/packages/flutter/lib/src/widgets/scrollable.dart @@ -124,9 +124,9 @@ class ScrollableState extends State with TickerProviderStateMixin void _updatePosition() { _configuration = ScrollConfiguration.of(context); _physics = _configuration.getScrollPhysics(context); - if (config.physics != null) - _physics = config.physics.applyTo(_physics); - final ScrollController controller = config.controller; + if (widget.physics != null) + _physics = widget.physics.applyTo(_physics); + final ScrollController controller = widget.controller; final ScrollPosition oldPosition = position; if (oldPosition != null) { controller?.detach(oldPosition); @@ -148,27 +148,27 @@ class ScrollableState extends State with TickerProviderStateMixin _updatePosition(); } - bool _shouldUpdatePosition(Scrollable oldConfig) { - return config.physics?.runtimeType != oldConfig.physics?.runtimeType - || config.controller?.runtimeType != oldConfig.controller?.runtimeType; + bool _shouldUpdatePosition(Scrollable oldWidget) { + return widget.physics?.runtimeType != oldWidget.physics?.runtimeType + || widget.controller?.runtimeType != oldWidget.controller?.runtimeType; } @override - void didUpdateConfig(Scrollable oldConfig) { - super.didUpdateConfig(oldConfig); + void didUpdateWidget(Scrollable oldWidget) { + super.didUpdateWidget(oldWidget); - if (config.controller != oldConfig.controller) { - oldConfig.controller?.detach(position); - config.controller?.attach(position); + if (widget.controller != oldWidget.controller) { + oldWidget.controller?.detach(position); + widget.controller?.attach(position); } - if (_shouldUpdatePosition(oldConfig)) + if (_shouldUpdatePosition(oldWidget)) _updatePosition(); } @override void dispose() { - config.controller?.detach(position); + widget.controller?.detach(position); position.dispose(); super.dispose(); } @@ -189,12 +189,12 @@ class ScrollableState extends State with TickerProviderStateMixin @override @protected void setCanDrag(bool canDrag) { - if (canDrag == _lastCanDrag && (!canDrag || config.axis == _lastAxisDirection)) + if (canDrag == _lastCanDrag && (!canDrag || widget.axis == _lastAxisDirection)) return; if (!canDrag) { _gestureRecognizers = const {}; } else { - switch (config.axis) { + switch (widget.axis) { case Axis.vertical: _gestureRecognizers = { VerticalDragGestureRecognizer: (VerticalDragGestureRecognizer recognizer) { // ignore: map_value_type_not_assignable, https://github.com/flutter/flutter/issues/7173 @@ -226,7 +226,7 @@ class ScrollableState extends State with TickerProviderStateMixin } } _lastCanDrag = canDrag; - _lastAxisDirection = config.axis; + _lastAxisDirection = widget.axis; if (_gestureDetectorKey.currentState != null) _gestureDetectorKey.currentState.replaceGestureRecognizers(_gestureRecognizers); } @@ -258,8 +258,8 @@ class ScrollableState extends State with TickerProviderStateMixin DragScrollActivity _drag; bool get _reverseDirection { - assert(config.axisDirection != null); - switch (config.axisDirection) { + assert(widget.axisDirection != null); + switch (widget.axisDirection) { case AxisDirection.up: case AxisDirection.left: return true; @@ -312,10 +312,10 @@ class ScrollableState extends State with TickerProviderStateMixin child: new IgnorePointer( key: _ignorePointerKey, ignoring: _shouldIgnorePointer, - child: config.viewportBuilder(context, position), + child: widget.viewportBuilder(context, position), ), ); - return _configuration.buildViewportChrome(context, result, config.axisDirection); + return _configuration.buildViewportChrome(context, result, widget.axisDirection); } @override diff --git a/packages/flutter/lib/src/widgets/semantics_debugger.dart b/packages/flutter/lib/src/widgets/semantics_debugger.dart index d51dd75405..9af7c604c7 100644 --- a/packages/flutter/lib/src/widgets/semantics_debugger.dart +++ b/packages/flutter/lib/src/widgets/semantics_debugger.dart @@ -142,7 +142,7 @@ class _SemanticsDebuggerState extends State { behavior: HitTestBehavior.opaque, child: new IgnorePointer( ignoringSemantics: false, - child: config.child + child: widget.child ) ) ) diff --git a/packages/flutter/lib/src/widgets/status_transitions.dart b/packages/flutter/lib/src/widgets/status_transitions.dart index 2239f2c5a7..1909d26437 100644 --- a/packages/flutter/lib/src/widgets/status_transitions.dart +++ b/packages/flutter/lib/src/widgets/status_transitions.dart @@ -34,20 +34,20 @@ class _StatusTransitionState extends State { @override void initState() { super.initState(); - config.animation.addStatusListener(_animationStatusChanged); + widget.animation.addStatusListener(_animationStatusChanged); } @override - void didUpdateConfig(StatusTransitionWidget oldConfig) { - if (config.animation != oldConfig.animation) { - oldConfig.animation.removeStatusListener(_animationStatusChanged); - config.animation.addStatusListener(_animationStatusChanged); + void didUpdateWidget(StatusTransitionWidget oldWidget) { + if (widget.animation != oldWidget.animation) { + oldWidget.animation.removeStatusListener(_animationStatusChanged); + widget.animation.addStatusListener(_animationStatusChanged); } } @override void dispose() { - config.animation.removeStatusListener(_animationStatusChanged); + widget.animation.removeStatusListener(_animationStatusChanged); super.dispose(); } @@ -59,6 +59,6 @@ class _StatusTransitionState extends State { @override Widget build(BuildContext context) { - return config.build(context); + return widget.build(context); } } diff --git a/packages/flutter/lib/src/widgets/text_selection.dart b/packages/flutter/lib/src/widgets/text_selection.dart index 80f75778d1..64fbaf8276 100644 --- a/packages/flutter/lib/src/widgets/text_selection.dart +++ b/packages/flutter/lib/src/widgets/text_selection.dart @@ -321,29 +321,29 @@ class _TextSelectionHandleOverlayState extends State<_TextSelectionHandleOverlay Point _dragPosition; void _handleDragStart(DragStartDetails details) { - _dragPosition = details.globalPosition + new Offset(0.0, -config.selectionControls.handleSize.height); + _dragPosition = details.globalPosition + new Offset(0.0, -widget.selectionControls.handleSize.height); } void _handleDragUpdate(DragUpdateDetails details) { _dragPosition += details.delta; - final TextPosition position = config.renderObject.getPositionForPoint(_dragPosition); + final TextPosition position = widget.renderObject.getPositionForPoint(_dragPosition); - if (config.selection.isCollapsed) { - config.onSelectionHandleChanged(new TextSelection.fromPosition(position)); + if (widget.selection.isCollapsed) { + widget.onSelectionHandleChanged(new TextSelection.fromPosition(position)); return; } TextSelection newSelection; - switch (config.position) { + switch (widget.position) { case _TextSelectionHandlePosition.start: newSelection = new TextSelection( baseOffset: position.offset, - extentOffset: config.selection.extentOffset + extentOffset: widget.selection.extentOffset ); break; case _TextSelectionHandlePosition.end: newSelection = new TextSelection( - baseOffset: config.selection.baseOffset, + baseOffset: widget.selection.baseOffset, extentOffset: position.offset ); break; @@ -352,20 +352,20 @@ class _TextSelectionHandleOverlayState extends State<_TextSelectionHandleOverlay if (newSelection.baseOffset >= newSelection.extentOffset) return; // don't allow order swapping. - config.onSelectionHandleChanged(newSelection); + widget.onSelectionHandleChanged(newSelection); } void _handleTap() { - config.onSelectionHandleTapped(); + widget.onSelectionHandleTapped(); } @override Widget build(BuildContext context) { - final List endpoints = config.renderObject.getEndpointsForSelection(config.selection); + final List endpoints = widget.renderObject.getEndpointsForSelection(widget.selection); Point point; TextSelectionHandleType type; - switch (config.position) { + switch (widget.position) { case _TextSelectionHandlePosition.start: point = endpoints[0].point; type = _chooseType(endpoints[0], TextSelectionHandleType.left, TextSelectionHandleType.right); @@ -388,7 +388,7 @@ class _TextSelectionHandleOverlayState extends State<_TextSelectionHandleOverlay new Positioned( left: point.x, top: point.y, - child: config.selectionControls.buildHandle(context, type) + child: widget.selectionControls.buildHandle(context, type) ) ] ) @@ -400,7 +400,7 @@ class _TextSelectionHandleOverlayState extends State<_TextSelectionHandleOverlay TextSelectionHandleType ltrType, TextSelectionHandleType rtlType ) { - if (config.selection.isCollapsed) + if (widget.selection.isCollapsed) return TextSelectionHandleType.collapsed; assert(endpoint.direction != null); diff --git a/packages/flutter/lib/src/widgets/transitions.dart b/packages/flutter/lib/src/widgets/transitions.dart index 5083e4c316..81546264dc 100644 --- a/packages/flutter/lib/src/widgets/transitions.dart +++ b/packages/flutter/lib/src/widgets/transitions.dart @@ -68,20 +68,20 @@ class _AnimatedState extends State { @override void initState() { super.initState(); - config.listenable.addListener(_handleChange); + widget.listenable.addListener(_handleChange); } @override - void didUpdateConfig(AnimatedWidget oldConfig) { - if (config.listenable != oldConfig.listenable) { - oldConfig.listenable.removeListener(_handleChange); - config.listenable.addListener(_handleChange); + void didUpdateWidget(AnimatedWidget oldWidget) { + if (widget.listenable != oldWidget.listenable) { + oldWidget.listenable.removeListener(_handleChange); + widget.listenable.addListener(_handleChange); } } @override void dispose() { - config.listenable.removeListener(_handleChange); + widget.listenable.removeListener(_handleChange); super.dispose(); } @@ -92,7 +92,7 @@ class _AnimatedState extends State { } @override - Widget build(BuildContext context) => config.build(context); + Widget build(BuildContext context) => widget.build(context); } /// Animates the position of a widget relative to its normal position. diff --git a/packages/flutter/lib/src/widgets/will_pop_scope.dart b/packages/flutter/lib/src/widgets/will_pop_scope.dart index adf4b84cda..62ebb2ba6b 100644 --- a/packages/flutter/lib/src/widgets/will_pop_scope.dart +++ b/packages/flutter/lib/src/widgets/will_pop_scope.dart @@ -46,31 +46,31 @@ class _WillPopScopeState extends State { @override void didChangeDependencies() { super.didChangeDependencies(); - if (config.onWillPop != null) - _route?.removeScopedWillPopCallback(config.onWillPop); + if (widget.onWillPop != null) + _route?.removeScopedWillPopCallback(widget.onWillPop); _route = ModalRoute.of(context); - if (config.onWillPop != null) - _route?.addScopedWillPopCallback(config.onWillPop); + if (widget.onWillPop != null) + _route?.addScopedWillPopCallback(widget.onWillPop); } @override - void didUpdateConfig(WillPopScope oldConfig) { + void didUpdateWidget(WillPopScope oldWidget) { assert(_route == ModalRoute.of(context)); - if (config.onWillPop != oldConfig.onWillPop && _route != null) { - if (oldConfig.onWillPop != null) - _route.removeScopedWillPopCallback(oldConfig.onWillPop); - if (config.onWillPop != null) - _route.addScopedWillPopCallback(config.onWillPop); + if (widget.onWillPop != oldWidget.onWillPop && _route != null) { + if (oldWidget.onWillPop != null) + _route.removeScopedWillPopCallback(oldWidget.onWillPop); + if (widget.onWillPop != null) + _route.addScopedWillPopCallback(widget.onWillPop); } } @override void dispose() { - if (config.onWillPop != null) - _route?.removeScopedWillPopCallback(config.onWillPop); + if (widget.onWillPop != null) + _route?.removeScopedWillPopCallback(widget.onWillPop); super.dispose(); } @override - Widget build(BuildContext context) => config.child; + Widget build(BuildContext context) => widget.child; } diff --git a/packages/flutter/test/material/app_test.dart b/packages/flutter/test/material/app_test.dart index f9a7a8aa2a..ebd9875517 100644 --- a/packages/flutter/test/material/app_test.dart +++ b/packages/flutter/test/material/app_test.dart @@ -19,8 +19,8 @@ class StateMarkerState extends State { @override Widget build(BuildContext context) { - if (config.child != null) - return config.child; + if (widget.child != null) + return widget.child; return new Container(); } } diff --git a/packages/flutter/test/material/dialog_test.dart b/packages/flutter/test/material/dialog_test.dart index f947cea2d6..ae97b63134 100644 --- a/packages/flutter/test/material/dialog_test.dart +++ b/packages/flutter/test/material/dialog_test.dart @@ -90,11 +90,11 @@ void main() { await tester.pump(const Duration(seconds: 1)); final StatefulElement widget = tester.element(find.byType(Material).last); - final Material materialconfig = widget.state.config; + final Material materialWidget = widget.state.widget; //first and second expect check that the material is the dialog's one - expect(materialconfig.type, MaterialType.card); - expect(materialconfig.elevation, 24); - expect(materialconfig.color, Colors.grey[800]); + expect(materialWidget.type, MaterialType.card); + expect(materialWidget.elevation, 24); + expect(materialWidget.color, Colors.grey[800]); }); testWidgets('Simple dialog control test', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/dropdown_test.dart b/packages/flutter/test/material/dropdown_test.dart index cb0417bb57..971ab8a98d 100644 --- a/packages/flutter/test/material/dropdown_test.dart +++ b/packages/flutter/test/material/dropdown_test.dart @@ -191,7 +191,7 @@ void main() { expect(tester.elementList(find.text('19')), hasLength(1)); expect(value, 4); - await tester.tap(find.byConfig(button)); + await tester.tap(find.byWidget(button)); expect(value, 4); // this waits for the route's completer to complete, which calls handleChanged await tester.idle(); diff --git a/packages/flutter/test/material/list_tile_test.dart b/packages/flutter/test/material/list_tile_test.dart index 068f6a0065..5bebac339a 100644 --- a/packages/flutter/test/material/list_tile_test.dart +++ b/packages/flutter/test/material/list_tile_test.dart @@ -37,7 +37,7 @@ class TestTextState extends State { @override Widget build(BuildContext context) { textStyle = DefaultTextStyle.of(context).style; - return new Text(config.text); + return new Text(widget.text); } } diff --git a/packages/flutter/test/material/tabs_test.dart b/packages/flutter/test/material/tabs_test.dart index 932373ffb8..ea27c9ae3f 100644 --- a/packages/flutter/test/material/tabs_test.dart +++ b/packages/flutter/test/material/tabs_test.dart @@ -22,8 +22,8 @@ class StateMarkerState extends State { @override Widget build(BuildContext context) { - if (config.child != null) - return config.child; + if (widget.child != null) + return widget.child; return new Container(); } } @@ -70,8 +70,8 @@ class TabControllerFrameState extends State with SingleTicke super.initState(); _controller = new TabController( vsync: this, - length: config.length, - initialIndex: config.initialIndex, + length: widget.length, + initialIndex: widget.initialIndex, ); } @@ -83,7 +83,7 @@ class TabControllerFrameState extends State with SingleTicke @override Widget build(BuildContext context) { - return config.builder(context, _controller); + return widget.builder(context, _controller); } } diff --git a/packages/flutter/test/widgets/build_scope_test.dart b/packages/flutter/test/widgets/build_scope_test.dart index c6613245ce..00f66d3788 100644 --- a/packages/flutter/test/widgets/build_scope_test.dart +++ b/packages/flutter/test/widgets/build_scope_test.dart @@ -22,7 +22,7 @@ class ProbeWidgetState extends State { } @override - void didUpdateConfig(ProbeWidget oldConfig) { + void didUpdateWidget(ProbeWidget oldWidget) { setState(() {}); } @@ -110,7 +110,7 @@ class StatefulWrapperState extends State { Widget build(BuildContext context) { buildId += 1; built = buildId; - return config.child; + return widget.child; } } diff --git a/packages/flutter/test/widgets/focus_test.dart b/packages/flutter/test/widgets/focus_test.dart index e1e4a59891..272a126bb2 100644 --- a/packages/flutter/test/widgets/focus_test.dart +++ b/packages/flutter/test/widgets/focus_test.dart @@ -28,7 +28,7 @@ class TestFocusableState extends State { @override void didChangeDependencies() { super.didChangeDependencies(); - if (!_didAutofocus && config.autofocus) { + if (!_didAutofocus && widget.autofocus) { _didAutofocus = true; FocusScope.of(context).autofocus(focusNode); } @@ -47,8 +47,7 @@ class TestFocusableState extends State { child: new AnimatedBuilder( animation: focusNode, builder: (BuildContext context, Widget child) { - // print('focusNode.hasFocus = ${focusNode.hasFocus} ${focusNode.hashCode} ${focusNode.hasFocus ? config.yes : config.no}'); - return new Text(focusNode.hasFocus ? config.yes : config.no); + return new Text(focusNode.hasFocus ? widget.yes : widget.no); }, ), ); diff --git a/packages/flutter/test/widgets/form_test.dart b/packages/flutter/test/widgets/form_test.dart index 37f421ec1e..09aebc5f34 100644 --- a/packages/flutter/test/widgets/form_test.dart +++ b/packages/flutter/test/widgets/form_test.dart @@ -180,14 +180,14 @@ void main() { // initial value should also be visible in the raw input line final EditableTextState editableText = tester.state(find.byType(EditableText)); - expect(editableText.config.controller.text, equals(initialValue)); + expect(editableText.widget.controller.text, equals(initialValue)); // sanity check, make sure we can still edit the text and everything updates expect(inputKey.currentState.value, equals(initialValue)); await tester.enterText(find.byType(EditableText), 'world'); await tester.pump(); expect(inputKey.currentState.value, equals('world')); - expect(editableText.config.controller.text, equals('world')); + expect(editableText.widget.controller.text, equals('world')); }); testWidgets('No crash when a TextFormField is removed from the tree', (WidgetTester tester) async { diff --git a/packages/flutter/test/widgets/framework_test.dart b/packages/flutter/test/widgets/framework_test.dart index c16ec5b1ce..a1028c6093 100644 --- a/packages/flutter/test/widgets/framework_test.dart +++ b/packages/flutter/test/widgets/framework_test.dart @@ -423,7 +423,7 @@ void main() { testWidgets('State toString', (WidgetTester tester) async { final TestState state = new TestState(); - expect(state.toString(), contains('no config')); + expect(state.toString(), contains('no widget')); }); testWidgets('debugPrintGlobalKeyedWidgetLifecycle control test', (WidgetTester tester) async { diff --git a/packages/flutter/test/widgets/heroes_test.dart b/packages/flutter/test/widgets/heroes_test.dart index c6312513e4..7a0643dc92 100644 --- a/packages/flutter/test/widgets/heroes_test.dart +++ b/packages/flutter/test/widgets/heroes_test.dart @@ -85,7 +85,7 @@ class MyStatefulWidget extends StatefulWidget { class MyStatefulWidgetState extends State { @override - Widget build(BuildContext context) => new Text(config.value); + Widget build(BuildContext context) => new Text(widget.value); } void main() { diff --git a/packages/flutter/test/widgets/independent_widget_layout_test.dart b/packages/flutter/test/widgets/independent_widget_layout_test.dart index 7d8ac6edaf..1e1b64c46b 100644 --- a/packages/flutter/test/widgets/independent_widget_layout_test.dart +++ b/packages/flutter/test/widgets/independent_widget_layout_test.dart @@ -73,12 +73,12 @@ class TriggerableState extends State { @override void initState() { super.initState(); - config.trigger.callback = fire; + widget.trigger.callback = fire; } @override - void didUpdateConfig(TriggerableWidget oldConfig) { - config.trigger.callback = fire; + void didUpdateWidget(TriggerableWidget oldWidget) { + widget.trigger.callback = fire; } int _count = 0; @@ -90,7 +90,7 @@ class TriggerableState extends State { @override Widget build(BuildContext context) { - config.counter.count++; + widget.counter.count++; return new Text("Bang $_count!"); } } diff --git a/packages/flutter/test/widgets/inherited_test.dart b/packages/flutter/test/widgets/inherited_test.dart index 813bde213e..97b4968b7c 100644 --- a/packages/flutter/test/widgets/inherited_test.dart +++ b/packages/flutter/test/widgets/inherited_test.dart @@ -44,7 +44,7 @@ class ExpectFailState extends State { try { context.inheritFromWidgetOfExactType(TestInherited); // should fail } catch (e) { - config.onError(); + widget.onError(); } } diff --git a/packages/flutter/test/widgets/layout_builder_and_global_keys_test.dart b/packages/flutter/test/widgets/layout_builder_and_global_keys_test.dart index 77505712a3..07e6248ddc 100644 --- a/packages/flutter/test/widgets/layout_builder_and_global_keys_test.dart +++ b/packages/flutter/test/widgets/layout_builder_and_global_keys_test.dart @@ -36,7 +36,7 @@ class StatefulWrapperState extends State { } @override - Widget build(BuildContext context) => config.child; + Widget build(BuildContext context) => widget.child; } void main() { diff --git a/packages/flutter/test/widgets/layout_builder_and_parent_data_test.dart b/packages/flutter/test/widgets/layout_builder_and_parent_data_test.dart index 2fb57980be..d8ddf410c2 100644 --- a/packages/flutter/test/widgets/layout_builder_and_parent_data_test.dart +++ b/packages/flutter/test/widgets/layout_builder_and_parent_data_test.dart @@ -33,7 +33,7 @@ class SizeChangerState extends State { new SizedBox( height: _flag ? 50.0 : 100.0, width: 100.0, - child: config.child + child: widget.child ) ], ); diff --git a/packages/flutter/test/widgets/layout_builder_and_state_test.dart b/packages/flutter/test/widgets/layout_builder_and_state_test.dart index c1ad973bc1..5a5ba4150c 100644 --- a/packages/flutter/test/widgets/layout_builder_and_state_test.dart +++ b/packages/flutter/test/widgets/layout_builder_and_state_test.dart @@ -29,7 +29,7 @@ class StatefulWrapperState extends State { @override Widget build(BuildContext context) { built = true; - return config.child; + return widget.child; } } diff --git a/packages/flutter/test/widgets/reparent_state_harder_test.dart b/packages/flutter/test/widgets/reparent_state_harder_test.dart index d52f1bf292..e7f3aff4bf 100644 --- a/packages/flutter/test/widgets/reparent_state_harder_test.dart +++ b/packages/flutter/test/widgets/reparent_state_harder_test.dart @@ -31,11 +31,11 @@ class OrderSwitcherState extends State { Widget build(BuildContext context) { final List children = []; if (_aFirst) { - children.add(new KeyedSubtree(child: config.a)); - children.add(config.b); + children.add(new KeyedSubtree(child: widget.a)); + children.add(widget.b); } else { - children.add(new KeyedSubtree(child: config.b)); - children.add(config.a); + children.add(new KeyedSubtree(child: widget.b)); + children.add(widget.a); } return new Stack( children: children @@ -69,7 +69,7 @@ class RekeyableDummyStatefulWidgetWrapperState extends State { @override Widget build(BuildContext context) { - if (config.child != null) - return config.child; + if (widget.child != null) + return widget.child; return new Container(); } } @@ -37,13 +37,13 @@ class DeactivateLogger extends StatefulWidget { class DeactivateLoggerState extends State { @override void deactivate() { - config.log.add('deactivate'); + widget.log.add('deactivate'); super.deactivate(); } @override Widget build(BuildContext context) { - config.log.add('build'); + widget.log.add('build'); return new Container(); } } @@ -75,7 +75,7 @@ void main() { final StateMarkerState rightState = right.currentState; rightState.marker = "right"; - final StateMarkerState grandchildState = tester.state(find.byConfig(grandchild)); + final StateMarkerState grandchildState = tester.state(find.byWidget(grandchild)); expect(grandchildState, isNotNull); grandchildState.marker = "grandchild"; @@ -101,7 +101,7 @@ void main() { expect(right.currentState, equals(rightState)); expect(rightState.marker, equals("right")); - final StateMarkerState newGrandchildState = tester.state(find.byConfig(newGrandchild)); + final StateMarkerState newGrandchildState = tester.state(find.byWidget(newGrandchild)); expect(newGrandchildState, isNotNull); expect(newGrandchildState, equals(grandchildState)); expect(newGrandchildState.marker, equals("grandchild")); @@ -144,7 +144,7 @@ void main() { final StateMarkerState rightState = right.currentState; rightState.marker = "right"; - final StateMarkerState grandchildState = tester.state(find.byConfig(grandchild)); + final StateMarkerState grandchildState = tester.state(find.byWidget(grandchild)); expect(grandchildState, isNotNull); grandchildState.marker = "grandchild"; @@ -166,7 +166,7 @@ void main() { expect(right.currentState, equals(rightState)); expect(rightState.marker, equals("right")); - final StateMarkerState newGrandchildState = tester.state(find.byConfig(newGrandchild)); + final StateMarkerState newGrandchildState = tester.state(find.byWidget(newGrandchild)); expect(newGrandchildState, isNotNull); expect(newGrandchildState, equals(grandchildState)); expect(newGrandchildState.marker, equals("grandchild")); diff --git a/packages/flutter/test/widgets/set_state_1_test.dart b/packages/flutter/test/widgets/set_state_1_test.dart index 2ce0f1f51e..3f5f643963 100644 --- a/packages/flutter/test/widgets/set_state_1_test.dart +++ b/packages/flutter/test/widgets/set_state_1_test.dart @@ -38,7 +38,7 @@ class MiddleState extends State { Widget build(BuildContext context) { return new Listener( onPointerDown: _handlePointerDown, - child: config.child + child: widget.child ); } diff --git a/packages/flutter/test/widgets/set_state_3_test.dart b/packages/flutter/test/widgets/set_state_3_test.dart index 0db63bd925..db234ae4ff 100644 --- a/packages/flutter/test/widgets/set_state_3_test.dart +++ b/packages/flutter/test/widgets/set_state_3_test.dart @@ -28,7 +28,7 @@ class ChangerState extends State { void test() { setState(() { _state = true; }); } @override - Widget build(BuildContext context) => _state ? new Wrapper(config.child) : config.child; + Widget build(BuildContext context) => _state ? new Wrapper(widget.child) : widget.child; } class Wrapper extends StatelessWidget { diff --git a/packages/flutter/test/widgets/slivers_block_global_key_test.dart b/packages/flutter/test/widgets/slivers_block_global_key_test.dart index 7d7f65f6eb..04d5a59263 100644 --- a/packages/flutter/test/widgets/slivers_block_global_key_test.dart +++ b/packages/flutter/test/widgets/slivers_block_global_key_test.dart @@ -19,7 +19,7 @@ class _GenerationTextState extends State { _GenerationTextState() : generation = globalGeneration; final int generation; @override - Widget build(BuildContext context) => new Text('${config.value}:$generation '); + Widget build(BuildContext context) => new Text('${widget.value}:$generation '); } Future test(WidgetTester tester, double offset, List keys) { diff --git a/packages/flutter/test/widgets/stateful_components_test.dart b/packages/flutter/test/widgets/stateful_components_test.dart index f6df5e4121..b8f0a2f9cd 100644 --- a/packages/flutter/test/widgets/stateful_components_test.dart +++ b/packages/flutter/test/widgets/stateful_components_test.dart @@ -39,7 +39,7 @@ class OuterContainer extends StatefulWidget { class OuterContainerState extends State { @override Widget build(BuildContext context) { - return config.child; + return widget.child; } } @@ -57,7 +57,7 @@ void main() { final StatefulElement innerElement = tester.element(find.byKey(innerKey)); final InnerWidgetState innerElementState = innerElement.state; - expect(innerElementState.config, equals(inner1)); + expect(innerElementState.widget, equals(inner1)); expect(innerElementState._didInitState, isTrue); expect(innerElement.renderObject.attached, isTrue); @@ -69,18 +69,18 @@ void main() { expect(tester.element(find.byKey(innerKey)), equals(innerElement)); expect(innerElement.state, equals(innerElementState)); - expect(innerElementState.config, equals(inner2)); + expect(innerElementState.widget, equals(inner2)); expect(innerElementState._didInitState, isTrue); expect(innerElement.renderObject.attached, isTrue); final StatefulElement outerElement = tester.element(find.byKey(outerKey)); - expect(outerElement.state.config, equals(outer2)); + expect(outerElement.state.widget, equals(outer2)); outerElement.markNeedsBuild(); await tester.pump(); expect(tester.element(find.byKey(innerKey)), equals(innerElement)); expect(innerElement.state, equals(innerElementState)); - expect(innerElementState.config, equals(inner2)); + expect(innerElementState.widget, equals(inner2)); expect(innerElement.renderObject.attached, isTrue); }); } diff --git a/packages/flutter/test/widgets/syncing_test.dart b/packages/flutter/test/widgets/syncing_test.dart index b5cc9ff2c3..dffc47b390 100644 --- a/packages/flutter/test/widgets/syncing_test.dart +++ b/packages/flutter/test/widgets/syncing_test.dart @@ -24,20 +24,20 @@ class TestWidgetState extends State { @override void initState() { super.initState(); - persistentState = config.persistentState; - syncedState = config.syncedState; + persistentState = widget.persistentState; + syncedState = widget.syncedState; } @override - void didUpdateConfig(TestWidget oldConfig) { - syncedState = config.syncedState; + void didUpdateWidget(TestWidget oldWidget) { + syncedState = widget.syncedState; // we explicitly do NOT sync the persistentState from the new instance // because we're using that to track whether we got recreated updates += 1; } @override - Widget build(BuildContext context) => config.child; + Widget build(BuildContext context) => widget.child; } void main() { @@ -135,13 +135,13 @@ void main() { TestWidgetState first, second; - first = tester.state(find.byConfig(a)); - second = tester.state(find.byConfig(b)); + first = tester.state(find.byWidget(a)); + second = tester.state(find.byWidget(b)); - expect(first.config, equals(a)); + expect(first.widget, equals(a)); expect(first.persistentState, equals(0x61)); expect(first.syncedState, equals(0x41)); - expect(second.config, equals(b)); + expect(second.widget, equals(b)); expect(second.persistentState, equals(0x62)); expect(second.syncedState, equals(0x42)); @@ -160,14 +160,14 @@ void main() { ) ); - first = tester.state(find.byConfig(a)); - second = tester.state(find.byConfig(b)); + first = tester.state(find.byWidget(a)); + second = tester.state(find.byWidget(b)); // same as before - expect(first.config, equals(a)); + expect(first.widget, equals(a)); expect(first.persistentState, equals(0x61)); expect(first.syncedState, equals(0x41)); - expect(second.config, equals(b)); + expect(second.widget, equals(b)); expect(second.persistentState, equals(0x62)); expect(second.syncedState, equals(0x42)); @@ -189,13 +189,13 @@ void main() { ) ); - first = tester.state(find.byConfig(b)); - second = tester.state(find.byConfig(a)); + first = tester.state(find.byWidget(b)); + second = tester.state(find.byWidget(a)); - expect(first.config, equals(b)); + expect(first.widget, equals(b)); expect(first.persistentState, equals(0x61)); expect(first.syncedState, equals(0x42)); - expect(second.config, equals(a)); + expect(second.widget, equals(a)); expect(second.persistentState, equals(0x62)); expect(second.syncedState, equals(0x41)); }); diff --git a/packages/flutter/test/widgets/test_widgets.dart b/packages/flutter/test/widgets/test_widgets.dart index d8314c90af..739044348c 100644 --- a/packages/flutter/test/widgets/test_widgets.dart +++ b/packages/flutter/test/widgets/test_widgets.dart @@ -50,7 +50,7 @@ class FlipWidgetState extends State { @override Widget build(BuildContext context) { - return _showLeft ? config.left : config.right; + return _showLeft ? widget.left : widget.right; } } diff --git a/packages/flutter_driver/lib/src/extension.dart b/packages/flutter_driver/lib/src/extension.dart index 366daede88..a3ef896453 100644 --- a/packages/flutter_driver/lib/src/extension.dart +++ b/packages/flutter_driver/lib/src/extension.dart @@ -285,7 +285,7 @@ class FlutterDriverExtension { final Finder target = await _waitForElement(_findEditableText(submitInputTextCommand.finder)); final EditableTextState editable = _getEditableTextState(target); editable.performAction(TextInputAction.done); - return new SubmitInputTextResult(editable.config.controller.value.text); + return new SubmitInputTextResult(editable.widget.controller.value.text); } Future _getText(Command command) async { diff --git a/packages/flutter_markdown/lib/src/widget.dart b/packages/flutter_markdown/lib/src/widget.dart index 72931d0a59..52f9cac855 100644 --- a/packages/flutter_markdown/lib/src/widget.dart +++ b/packages/flutter_markdown/lib/src/widget.dart @@ -83,10 +83,10 @@ class _MarkdownWidgetState extends State implements MarkdownBuil } @override - void didUpdateConfig(MarkdownWidget oldConfig) { - super.didUpdateConfig(oldConfig); - if (config.data != oldConfig.data - || config.styleSheet != oldConfig.styleSheet) + void didUpdateWidget(MarkdownWidget oldWidget) { + super.didUpdateWidget(oldWidget); + if (widget.data != oldWidget.data + || widget.styleSheet != oldWidget.styleSheet) _parseMarkdown(); } @@ -97,12 +97,12 @@ class _MarkdownWidgetState extends State implements MarkdownBuil } void _parseMarkdown() { - final MarkdownStyleSheet styleSheet = config.styleSheet ?? new MarkdownStyleSheet.fromTheme(Theme.of(context)); + final MarkdownStyleSheet styleSheet = widget.styleSheet ?? new MarkdownStyleSheet.fromTheme(Theme.of(context)); _disposeRecognizers(); // TODO: This can be optimized by doing the split and removing \r at the same time - final List lines = config.data.replaceAll('\r\n', '\n').split('\n'); + final List lines = widget.data.replaceAll('\r\n', '\n').split('\n'); final md.Document document = new md.Document(); final MarkdownBuilder builder = new MarkdownBuilder(delegate: this, styleSheet: styleSheet); _children = builder.build(document.parseLines(lines)); @@ -121,8 +121,8 @@ class _MarkdownWidgetState extends State implements MarkdownBuil GestureRecognizer createLink(String href) { final TapGestureRecognizer recognizer = new TapGestureRecognizer() ..onTap = () { - if (config.onTapLink != null) - config.onTapLink(href); + if (widget.onTapLink != null) + widget.onTapLink(href); }; _recognizers.add(recognizer); return recognizer; @@ -130,13 +130,13 @@ class _MarkdownWidgetState extends State implements MarkdownBuil @override TextSpan formatText(MarkdownStyleSheet styleSheet, String code) { - if (config.syntaxHighlighter != null) - return config.syntaxHighlighter.format(code); + if (widget.syntaxHighlighter != null) + return widget.syntaxHighlighter.format(code); return new TextSpan(style: styleSheet.code, text: code); } @override - Widget build(BuildContext context) => config.build(context, _children); + Widget build(BuildContext context) => widget.build(context, _children); } /// A non-scrolling widget that parses and displays Markdown. diff --git a/packages/flutter_test/lib/src/finders.dart b/packages/flutter_test/lib/src/finders.dart index 7cd74f8fb7..af8b7cb462 100644 --- a/packages/flutter_test/lib/src/finders.dart +++ b/packages/flutter_test/lib/src/finders.dart @@ -116,11 +116,11 @@ class CommonFinders { /// ); /// /// // You can find and tap on it like this: - /// tester.tap(find.byConfig(myButton)); + /// tester.tap(find.byWidget(myButton)); /// /// If the `skipOffstage` argument is true (the default), then this skips /// nodes that are [Offstage] or that are from inactive [Route]s. - Finder byConfig(Widget config, { bool skipOffstage: true }) => new _ConfigFinder(config, skipOffstage: skipOffstage); + Finder byWidget(Widget widget, { bool skipOffstage: true }) => new _WidgetFinder(widget, skipOffstage: skipOffstage); /// Finds widgets using a widget [predicate]. /// @@ -439,17 +439,17 @@ class _ElementTypeFinder extends MatchFinder { } } -class _ConfigFinder extends MatchFinder { - _ConfigFinder(this.config, { bool skipOffstage: true }) : super(skipOffstage: skipOffstage); +class _WidgetFinder extends MatchFinder { + _WidgetFinder(this.widget, { bool skipOffstage: true }) : super(skipOffstage: skipOffstage); - final Widget config; + final Widget widget; @override - String get description => 'the given configuration ($config)'; + String get description => 'the given widget ($widget)'; @override bool matches(Element candidate) { - return candidate.widget == config; + return candidate.widget == widget; } } diff --git a/packages/flutter_tools/templates/create/lib/main.dart.tmpl b/packages/flutter_tools/templates/create/lib/main.dart.tmpl index ff923fcc65..e81b55b538 100644 --- a/packages/flutter_tools/templates/create/lib/main.dart.tmpl +++ b/packages/flutter_tools/templates/create/lib/main.dart.tmpl @@ -97,7 +97,7 @@ class _MyHomePageState extends State { // Here we take the value from the MyHomePage object that // was created by the App.build method, and use it to set // our appbar title. - title: new Text(config.title), + title: new Text(widget.title), ), body: new Center( {{#withPluginHook}}