Commit 89a7fdfc authored by xster's avatar xster Committed by GitHub

Rename State.config to widget everywhere (#9273)

Rename State.config to State.widget
Rename State.didUpdateConfig to State.didUpdateWidget
Renamed all State subclasses' local variables named config to something else
parent a5593b16
......@@ -58,16 +58,16 @@ class DotState extends State<Dot> {
@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
)
);
}
......
......@@ -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) {
......
......@@ -53,31 +53,31 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
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,
),
];
......
......@@ -42,10 +42,10 @@ class _ChipDemoState extends State<ChipDemo> {
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()
)
......
......@@ -130,7 +130,7 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> 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),
),
),
);
......
......@@ -39,19 +39,19 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
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
)
];
......
......@@ -147,13 +147,13 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
),
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<PestoLogo> {
@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<PestoLogo> {
overflow: Overflow.visible,
children: <Widget>[
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<RecipePage> {
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<RecipePage> {
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<RecipePage> {
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<RecipePage> {
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);
});
}
}
......
......@@ -236,7 +236,7 @@ class _OrderPageState extends State<OrderPage> {
@override
void initState() {
super.initState();
scaffoldKey = new GlobalKey<ScaffoldState>(debugLabel: 'Shrine Order ${config.order}');
scaffoldKey = new GlobalKey<ScaffoldState>(debugLabel: 'Shrine Order ${widget.order}');
}
Order get currentOrder => ShrineOrderRoute.of(context).order;
......@@ -249,7 +249,7 @@ class _OrderPageState extends State<OrderPage> {
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<OrderPage> {
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<OrderPage> {
slivers: <Widget>[
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<OrderPage> {
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,
......
......@@ -53,7 +53,7 @@ class ShrinePageState extends State<ShrinePage> {
void _showShoppingCart() {
showModalBottomSheet<Null>(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<ShrinePage> {
}
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<ShrinePage> {
}
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<ShrinePage> {
)
]
),
floatingActionButton: config.floatingActionButton,
floatingActionButton: widget.floatingActionButton,
body: new NotificationListener<ScrollNotification>(
onNotification: _handleScrollNotification,
child: config.body
child: widget.body
)
);
}
......
......@@ -84,13 +84,13 @@ class GalleryAppState extends State<GalleryApp> {
});
},
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<GalleryApp> {
}
});
},
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,
);
}
......
......@@ -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<FullScreenCodeDialog> {
@override
void didChangeDependencies() {
getExampleCode(config.exampleCodeTag, DefaultAssetBundle.of(context)).then<Null>((String code) {
getExampleCode(widget.exampleCodeTag, DefaultAssetBundle.of(context)).then<Null>((String code) {
if (mounted) {
setState(() {
_exampleCode = code;
......
......@@ -45,7 +45,7 @@ class _GalleryDrawerHeaderState extends State<GalleryDrawerHeader> {
: 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(
......
......@@ -153,16 +153,16 @@ class GalleryHomeState extends State<GalleryHome> 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: <Widget>[
......
......@@ -38,7 +38,7 @@ class UpdaterState extends State<Updater> {
}
_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<Updater> {
}
@override
Widget build(BuildContext context) => config.child;
Widget build(BuildContext context) => widget.child;
}
......@@ -87,8 +87,8 @@ class StockHomeState extends State<StockHome> {
}
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<StockHome> {
title: const Text('Optimistic'),
trailing: new Radio<StockMode>(
value: StockMode.optimistic,
groupValue: config.configuration.stockMode,
groupValue: widget.configuration.stockMode,
onChanged: _handleStockModeChange,
),
onTap: () {
......@@ -160,7 +160,7 @@ class StockHomeState extends State<StockHome> {
title: const Text('Pessimistic'),
trailing: new Radio<StockMode>(
value: StockMode.pessimistic,
groupValue: config.configuration.stockMode,
groupValue: widget.configuration.stockMode,
onChanged: _handleStockModeChange,
),
onTap: () {
......@@ -234,7 +234,7 @@ class StockHomeState extends State<StockHome> {
}
Iterable<Stock> _getStockList(Iterable<String> 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<StockHome> {
drawer: _buildDrawer(context),
body: new TabBarView(
children: <Widget>[
_buildStockTab(context, StockHomeTab.market, config.symbols),
_buildStockTab(context, StockHomeTab.market, widget.symbols),
_buildStockTab(context, StockHomeTab.portfolio, portfolioSymbols),
],
),
......
......@@ -19,48 +19,48 @@ class StockSettings extends StatefulWidget {
class StockSettingsState extends State<StockSettings> {
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<StockSettings> {
}
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<StockSettings> {
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<StockSettings> {
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,
),
),
......
......@@ -43,14 +43,14 @@ class _CupertinoActivityIndicatorState extends State<CupertinoActivityIndicator>
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();
......
......@@ -115,7 +115,7 @@ class _CupertinoButtonState extends State<CupertinoButton> with SingleTickerProv
void _setTween() {
_opacityTween = new Tween<double>(
begin: 1.0,
end: config.pressedOpacity,
end: widget.pressedOpacity,
);
}
......@@ -138,8 +138,8 @@ class _CupertinoButtonState extends State<CupertinoButton> 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<CupertinoButton> 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<CupertinoButton> 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<CupertinoButton> with SingleTickerProv
: enabled
? _kButtonTextStyle
: _kDisabledButtonTextStyle,
child: config.child,
child: widget.child,
),
),
),
......
......@@ -123,17 +123,17 @@ class CupertinoSlider extends StatefulWidget {
class _CupertinoSliderState extends State<CupertinoSlider> 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,
);
}
......
......@@ -79,9 +79,9 @@ class _CupertinoSwitchState extends State<CupertinoSwitch> 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,
);
}
......
......@@ -421,13 +421,13 @@ class _LicensePageState extends State<LicensePage> {
@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<Widget> contents = <Widget>[
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),
......
......@@ -206,47 +206,47 @@ class _MaterialAppState extends State<MaterialApp> {
}
Route<dynamic> _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<Null>(
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<NavigatorObserver>.from(config.navigatorObservers)
new List<NavigatorObserver>.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,
......
......@@ -353,17 +353,17 @@ class _AppBarState extends State<AppBar> {
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<AppBar> {
}
final List<Widget> toolbarChildren = <Widget>[];
Widget leading = config.leading;
Widget leading = widget.leading;
if (leading == null) {
if (_hasDrawer) {
leading = new IconButton(
......@@ -396,7 +396,7 @@ class _AppBarState extends State<AppBar> {
);
}
if (config.title != null) {
if (widget.title != null) {
toolbarChildren.add(
new LayoutId(
id: _ToolbarSlot.title,
......@@ -404,19 +404,19 @@ class _AppBarState extends State<AppBar> {
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<AppBar> {
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<AppBar> {
),
);
if (config.bottom != null) {
if (widget.bottom != null) {
appBar = new Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
......@@ -458,34 +458,34 @@ class _AppBarState extends State<AppBar> {
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: <Widget>[
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,
......
......@@ -164,21 +164,21 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
@override
void initState() {
super.initState();
_controllers = new List<AnimationController>.generate(config.items.length, (int index) {
_controllers = new List<AnimationController>.generate(widget.items.length, (int index) {
return new AnimationController(
duration: kThemeAnimationDuration,
vsync: this,
)..addListener(_rebuild);
});
_animations = new List<CurvedAnimation>.generate(config.items.length, (int index) {
_animations = new List<CurvedAnimation>.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<BottomNavigationBar> 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<BottomNavigationBar> with TickerPr
}
FractionalOffset _circleOffset(int index) {
final double iconSize = config.iconSize;
final double iconSize = widget.iconSize;
final Tween<double> yOffsetTween = new Tween<double>(
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<BottomNavigationBar> 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<BottomNavigationBar> 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<Widget> children = <Widget>[];
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<BottomNavigationBar> 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<BottomNavigationBar> 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<BottomNavigationBar> with TickerPr
case BottomNavigationBarType.shifting:
final List<Widget> children = <Widget>[];
_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<BottomNavigationBar> 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<BottomNavigationBar> 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<BottomNavigationBar> 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<BottomNavigationBar> 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(
......
......@@ -98,12 +98,12 @@ class _BottomSheetState extends State<BottomSheet> {
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<BottomSheet> {
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<BottomSheet> {
onVerticalDragEnd: _handleDragEnd,
child: new Material(
key: _childKey,
child: config.builder(context)
child: widget.builder(context)
)
);
}
......@@ -185,15 +185,15 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
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
)
)
);
......
......@@ -246,14 +246,14 @@ class _MaterialButtonState extends State<MaterialButton> {
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<MaterialButton> {
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<MaterialButton> {
),
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<MaterialButton> {
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<MaterialButton> {
}
return new ConstrainedBox(
constraints: new BoxConstraints(
minWidth: config.minWidth ?? buttonTheme.minWidth,
minWidth: widget.minWidth ?? buttonTheme.minWidth,
minHeight: height,
maxHeight: height
),
......
......@@ -93,10 +93,10 @@ class _CheckboxState extends State<Checkbox> 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,
);
}
......
......@@ -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<double>(
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();
......
......@@ -365,17 +365,17 @@ class _MonthPickerState extends State<MonthPicker> {
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<MonthPicker> {
}
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<DateTime>(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<MonthPicker> {
/// 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<MonthPicker> {
child: new Stack(
children: <Widget>[
new PageView.builder(
key: new ValueKey<DateTime>(config.selectedDate),
key: new ValueKey<DateTime>(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<YearPicker> {
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<int>(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;
......
......@@ -290,7 +290,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
child: new FocusScope(
key: _drawerKey,
node: _focusScopeNode,
child: config.child
child: widget.child
),
),
),
......
......@@ -113,12 +113,12 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
// 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<T> extends State<_DropdownMenu<T>> {
//
// When the menu is dismissed we just fade the entire thing out
// in the first 0.25s.
final _DropdownRoute<T> route = config.route;
final _DropdownRoute<T> route = widget.route;
final double unit = 0.5 / (route.items.length + 1.5);
final List<Widget> children = <Widget>[];
for (int itemIndex = 0; itemIndex < route.items.length; ++itemIndex) {
......@@ -177,7 +177,7 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
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<T> extends State<DropdownButton<T>> {
}
@override
void didUpdateConfig(DropdownButton<T> oldConfig) {
void didUpdateWidget(DropdownButton<T> oldWidget) {
_updateSelectedIndex();
}
void _updateSelectedIndex() {
assert(config.value == null ||
config.items.where((DropdownMenuItem<T> item) => item.value == config.value).length == 1);
assert(widget.value == null ||
widget.items.where((DropdownMenuItem<T> 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<T>(
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<Null>((_DropdownRouteResult<T> 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<T> extends State<DropdownButton<T>> {
// 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<T> extends State<DropdownButton<T>> {
// The width of the button and the menu are defined by the widest
// item and the width of the hint.
final List<Widget> items = new List<Widget>.from(config.items);
final List<Widget> items = new List<Widget>.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<T> extends State<DropdownButton<T>> {
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<T> extends State<DropdownButton<T>> {
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<T> extends State<DropdownButton<T>> {
);
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: <Widget>[
result,
......
......@@ -83,9 +83,9 @@ class _ExpandIconState extends State<ExpandIcon> 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<ExpandIcon> 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)
......
......@@ -79,8 +79,8 @@ class FlexibleSpaceBar extends StatefulWidget {
class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> {
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<FlexibleSpaceBar> {
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<FlexibleSpaceBar> {
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<FlexibleSpaceBar> {
transform: scaleTransform,
child: new Align(
alignment: titleAlignment,
child: new DefaultTextStyle(style: titleStyle, child: config.title)
child: new DefaultTextStyle(style: titleStyle, child: widget.title)
)
)
));
......
......@@ -116,7 +116,7 @@ class _FloatingActionButtonState extends State<FloatingActionButton> {
@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<FloatingActionButton> {
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
)
......
......@@ -130,10 +130,10 @@ class _InkResponseState<T extends InkResponse> extends State<T> {
_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<T extends InkResponse> extends State<T> {
_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<T extends InkResponse> extends State<T> {
_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<T extends InkResponse> extends State<T> {
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<T extends InkResponse> extends State<T> {
@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
);
}
......
......@@ -491,25 +491,25 @@ class _AnimatedLabelState extends AnimatedWidgetBaseState<_AnimatedLabel> {
@override
void forEachTween(TweenVisitor<dynamic> 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,
),
);
......
......@@ -199,9 +199,9 @@ class _MaterialState extends State<Material> 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<Material> 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<Material> 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<Material> 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<Material> 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
)
......
......@@ -153,7 +153,7 @@ class _MergeableMaterialState extends State<MergeableMaterial> with TickerProvid
@override
void initState() {
super.initState();
_children = new List<MergeableMaterialItem>.from(config.children);
_children = new List<MergeableMaterialItem>.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<MergeableMaterial> with TickerProvid
}
bool _debugHasConsecutiveGaps(List<MergeableMaterialItem> 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<MergeableMaterial> with TickerProvid
}
@override
void didUpdateConfig(MergeableMaterial oldConfig) {
super.didUpdateConfig(oldConfig);
void didUpdateWidget(MergeableMaterial oldWidget) {
super.didUpdateWidget(oldWidget);
final Set<LocalKey> oldKeys = oldConfig.children.map(
final Set<LocalKey> oldKeys = oldWidget.children.map(
(MergeableMaterialItem child) => child.key
).toSet();
final Set<LocalKey> newKeys = config.children.map(
final Set<LocalKey> newKeys = widget.children.map(
(MergeableMaterialItem child) => child.key
).toSet();
final Set<LocalKey> newOnly = newKeys.difference(oldKeys);
final Set<LocalKey> oldOnly = oldKeys.difference(newKeys);
final List<MergeableMaterialItem> newChildren = config.children;
final List<MergeableMaterialItem> newChildren = widget.children;
int i = 0;
int j = 0;
......@@ -473,7 +473,7 @@ class _MergeableMaterialState extends State<MergeableMaterial> 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<MergeableMaterial> with TickerProvid
shape: BoxShape.rectangle
),
child: new ListBody(
mainAxis: config.mainAxis,
mainAxis: widget.mainAxis,
children: slices
)
)
......@@ -532,15 +532,15 @@ class _MergeableMaterialState extends State<MergeableMaterial> 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<MergeableMaterial> with TickerProvid
shape: BoxShape.rectangle
),
child: new ListBody(
mainAxis: config.mainAxis,
mainAxis: widget.mainAxis,
children: slices
)
)
......@@ -603,8 +603,8 @@ class _MergeableMaterialState extends State<MergeableMaterial> with TickerProvid
}
return new _MergeableMaterialListBody(
mainAxis: config.mainAxis,
boxShadows: kElevationToShadow[config.elevation],
mainAxis: widget.mainAxis,
boxShadows: kElevationToShadow[widget.elevation],
items: _children,
children: widgets
);
......
......@@ -189,32 +189,32 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
@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<PaginatedDataTable> {
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<DataCell>((DataColumn column) => DataCell.empty).toList()
cells: widget.columns.map<DataCell>((DataColumn column) => DataCell.empty).toList()
);
}
DataRow _getProgressIndicatorRowFor(int index) {
bool haveProgressIndicator = false;
final List<DataCell> cells = config.columns.map<DataCell>((DataColumn column) {
final List<DataCell> cells = widget.columns.map<DataCell>((DataColumn column) {
if (!column.numeric) {
haveProgressIndicator = true;
return new DataCell(new CircularProgressIndicator());
......@@ -264,7 +264,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
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<PaginatedDataTable> {
final List<Widget> headerWidgets = <Widget>[];
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<PaginatedDataTable> {
} 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) {
widget.actions.map<Widget>((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<PaginatedDataTable> {
// FOOTER
final TextStyle footerTextStyle = themeData.textTheme.caption;
final List<Widget> footerWidgets = <Widget>[];
if (config.onRowsPerPageChanged != null) {
final List<Widget> availableRowsPerPage = config.availableRowsPerPage
if (widget.onRowsPerPageChanged != null) {
final List<Widget> availableRowsPerPage = widget.availableRowsPerPage
.where((int value) => value <= _rowCount)
.map<DropdownMenuItem<int>>((int value) {
return new DropdownMenuItem<int>(
......@@ -332,8 +332,8 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
new DropdownButtonHideUnderline(
child: new DropdownButton<int>(
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<PaginatedDataTable> {
footerWidgets.addAll(<Widget>[
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<PaginatedDataTable> {
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<PaginatedDataTable> {
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<PaginatedDataTable> {
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(
......
......@@ -90,7 +90,7 @@ class PopupMenuDivider extends PopupMenuEntry<dynamic> {
class _PopupMenuDividerState extends State<PopupMenuDivider> {
@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<T> extends PopupMenuEntry<T> {
class _PopupMenuItemState<T extends PopupMenuItem<dynamic>> extends State<T> {
// 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<T extends PopupMenuItem<dynamic>> extends State<T> {
}
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<T> extends _PopupMenuItemState<CheckedPopupMenu
void initState() {
super.initState();
_controller = new AnimationController(duration: _kFadeDuration, vsync: this)
..value = config.checked ? 1.0 : 0.0
..value = widget.checked ? 1.0 : 0.0
..addListener(() => 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<T> extends _PopupMenuItemState<CheckedPopupMenu
@override
Widget buildChild() {
return new ListTile(
enabled: config.enabled,
enabled: widget.enabled,
leading: new FadeTransition(
opacity: _opacity,
child: new Icon(_controller.isDismissed ? null : Icons.done)
),
title: config.child
title: widget.child
);
}
}
......@@ -527,35 +527,35 @@ class _PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
final Point topLeft = renderBox.localToGlobal(Point.origin);
showMenu<T>(
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<Null>((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,
);
}
}
......@@ -174,10 +174,10 @@ class _LinearProgressIndicatorState extends State<LinearProgressIndicator> 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<LinearProgressIndicator> 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<CircularProgressIndicator> 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<CircularProgressIndicator> 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,
......
......@@ -98,7 +98,7 @@ class Radio<T> extends StatefulWidget {
}
class _RadioState<T> extends State<Radio<T>> 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<T> extends State<Radio<T>> with TickerProviderStateMixin {
void _handleChanged(bool selected) {
if (selected)
config.onChanged(config.value);
widget.onChanged(widget.value);
}
@override
......@@ -114,10 +114,10 @@ class _RadioState<T> extends State<Radio<T>> 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,
......
......@@ -158,8 +158,8 @@ class RefreshIndicatorState extends State<RefreshIndicator> 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<RefreshIndicator> 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<RefreshIndicator> with TickerProviderS
onNotification: _handleScrollNotification,
child: new NotificationListener<OverscrollIndicatorNotification>(
onNotification: _handleGlowNotification,
child: config.child,
child: widget.child,
),
);
if (_mode == null) {
......@@ -389,8 +389,8 @@ class RefreshIndicatorState extends State<RefreshIndicator> 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<RefreshIndicator> with TickerProviderS
return new RefreshProgressIndicator(
value: showIndeterminateIndicator ? null : _value.value,
valueColor: _valueColor,
backgroundColor: config.backgroundColor,
backgroundColor: widget.backgroundColor,
);
},
),
......
......@@ -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<Scaffold> with TickerProviderStateMixin {
final GlobalKey<DrawerControllerState> _drawerKey = new GlobalKey<DrawerControllerState>();
/// 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<Scaffold> 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<Scaffold> with TickerProviderStateMixin {
final List<LayoutId> children = <LayoutId>[];
_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<Scaffold> 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<Scaffold> 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<Scaffold> 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<Scaffold> 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<Scaffold> 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
)
)
);
......
......@@ -75,7 +75,7 @@ class _ScrollbarState extends State<Scrollbar> with TickerProviderStateMixin {
child: new CustomPaint(
foregroundPainter: new _ScrollbarPainter(_controller),
child: new RepaintBoundary(
child: config.child,
child: widget.child,
),
),
),
......
......@@ -155,8 +155,8 @@ class Slider extends StatefulWidget {
class _SliderState extends State<Slider> 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<Slider> 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,
);
}
......
......@@ -110,7 +110,7 @@ class _SnackBarActionState extends State<SnackBarAction> {
setState(() {
_haveTriggeredAction = true;
});
config.onPressed();
widget.onPressed();
Scaffold.of(context).hideCurrentSnackBar(reason: SnackBarClosedReason.action);
}
......@@ -118,7 +118,7 @@ class _SnackBarActionState extends State<SnackBarAction> {
Widget build(BuildContext context) {
return new FlatButton(
onPressed: _haveTriggeredAction ? null : _handlePressed,
child: new Text(config.label)
child: new Text(widget.label)
);
}
}
......
......@@ -108,12 +108,12 @@ class _SwitchState extends State<Switch> 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<Switch> 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,
);
}
......
......@@ -265,8 +265,8 @@ class _DefaultTabControllerState extends State<DefaultTabController> 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<DefaultTabController> with Single
return new _TabControllerScope(
controller: _controller,
enabled: TickerMode.of(context),
child: config.child,
child: widget.child,
);
}
}
......@@ -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<TabBar> {
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<TabBar> {
}
@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<TabBar> {
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<TabBar> {
}
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<TabBar> {
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<Widget> wrappedTabs = new List<Widget>.from(config.tabs, growable: false);
final List<Widget> wrappedTabs = new List<Widget>.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<TabBar> {
if (_controller.index != _currentIndex) {
_currentIndex = _controller.index;
if (config.isScrollable)
if (widget.isScrollable)
_scrollToCurrentIndex();
}
......@@ -620,7 +620,7 @@ class _TabBarState extends State<TabBar> {
final Animation<double> 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<double> rightAnimation = new _DragAnimation(_controller, tabIndex);
wrappedTabs[tabIndex] = _buildStyledTab(wrappedTabs[tabIndex], true, rightAnimation);
......@@ -631,12 +631,12 @@ class _TabBarState extends State<TabBar> {
// 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<TabBar> {
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<TabBar> {
),
);
if (config.isScrollable) {
if (widget.isScrollable) {
tabBar = new SingleChildScrollView(
scrollDirection: Axis.horizontal,
controller: _scrollController,
......@@ -711,14 +711,14 @@ class _TabBarViewState extends State<TabBarView> {
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<TabBarView> {
@override
void initState() {
super.initState();
_children = config.children;
_children = widget.children;
}
@override
......@@ -749,12 +749,12 @@ class _TabBarViewState extends State<TabBarView> {
}
@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<TabBarView> {
int initialPage;
setState(() {
_warpUnderwayCount += 1;
_children = new List<Widget>.from(config.children, growable: false);
_children = new List<Widget>.from(widget.children, growable: false);
if (_currentIndex > previousIndex) {
_children[_currentIndex - 1] = _children[previousIndex];
initialPage = _currentIndex - 1;
......@@ -808,7 +808,7 @@ class _TabBarViewState extends State<TabBarView> {
setState(() {
_warpUnderwayCount -= 1;
_children = config.children;
_children = widget.children;
});
}
......
......@@ -169,23 +169,23 @@ class _TextFieldState extends State<TextField> {
final GlobalKey<EditableTextState> _editableTextKey = new GlobalKey<EditableTextState>();
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<TextField> {
@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<TextField> {
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(<Listenable>[ 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,
......
......@@ -185,15 +185,15 @@ class _AnimatedThemeState extends AnimatedWidgetBaseState<AnimatedTheme> {
@override
void forEachTween(TweenVisitor<dynamic> 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)
);
}
......
......@@ -470,7 +470,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin {
duration: _kDialAnimateDuration,
vsync: this,
);
_thetaTween = new Tween<double>(begin: _getThetaForTime(config.selectedTime));
_thetaTween = new Tween<double>(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<TextPainter> primaryLabels;
List<TextPainter> 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;
......
......@@ -124,19 +124,19 @@ class _TooltipState extends State<Tooltip> 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<Tooltip> 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,
)
);
}
......
......@@ -186,8 +186,8 @@ class _TwoLevelSublistState extends State<TwoLevelSublist> 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<TwoLevelSublist> 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<TwoLevelSublist> 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<TwoLevelSublist> 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,
......
......@@ -182,28 +182,28 @@ class _UserAccountsDrawerHeaderState extends State<UserAccountsDrawerHeader> {
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: <Widget>[
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();
},
),
],
......
......@@ -93,11 +93,11 @@ class _AnimatedCrossFadeState extends State<AnimatedCrossFade> 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<double> _initAnimation(Curve curve, bool inverted) {
......@@ -119,16 +119,16 @@ class _AnimatedCrossFadeState extends State<AnimatedCrossFade> 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<AnimatedCrossFade> with TickerProvid
children = <Widget>[
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<AnimatedCrossFade> with TickerProvid
right: 0.0,
child: new FadeTransition(
opacity: _firstAnimation,
child: config.firstChild
child: widget.firstChild
)
)
];
......@@ -166,7 +166,7 @@ class _AnimatedCrossFadeState extends State<AnimatedCrossFade> with TickerProvid
children = <Widget>[
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<AnimatedCrossFade> with TickerProvid
right: 0.0,
child: new FadeTransition(
opacity: _secondAnimation,
child: config.secondChild
child: widget.secondChild
)
)
];
......@@ -184,10 +184,10 @@ class _AnimatedCrossFadeState extends State<AnimatedCrossFade> with TickerProvid
return new ClipRect(
child: new AnimatedSize(
key: new ValueKey<Key>(config.key),
key: new ValueKey<Key>(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,
......
......@@ -168,8 +168,8 @@ class _WidgetsAppState extends State<WidgetsApp> implements WidgetsBindingObserv
@override
void didChangeLocale(Locale locale) {
if (config.onLocaleChanged != null) {
config.onLocaleChanged(locale).then<Null>((LocaleQueryData data) {
if (widget.onLocaleChanged != null) {
widget.onLocaleChanged(locale).then<Null>((LocaleQueryData data) {
if (mounted)
setState(() { _localeData = data; });
});
......@@ -184,7 +184,7 @@ class _WidgetsAppState extends State<WidgetsApp> 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<WidgetsApp> 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<WidgetsApp> 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<WidgetsApp> 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
);
......
......@@ -101,23 +101,23 @@ class _StreamBuilderBaseState<T, S> extends State<StreamBuilderBase<T, S>> {
@override
void initState() {
super.initState();
_summary = config.initial();
_summary = widget.initial();
_subscribe();
}
@override
void didUpdateConfig(StreamBuilderBase<T, S> oldConfig) {
if (oldConfig.stream != config.stream) {
void didUpdateWidget(StreamBuilderBase<T, S> 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<T, S> extends State<StreamBuilderBase<T, S>> {
}
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<T> extends State<FutureBuilder<T>> {
}
@override
void didUpdateConfig(FutureBuilder<T> oldConfig) {
if (oldConfig.future != config.future) {
void didUpdateWidget(FutureBuilder<T> oldWidget) {
if (oldWidget.future != widget.future) {
if (_activeCallbackIdentity != null) {
_unsubscribe();
_snapshot = _snapshot.inState(ConnectionState.none);
......@@ -429,7 +429,7 @@ class _FutureBuilderState<T> extends State<FutureBuilder<T>> {
}
@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<T> extends State<FutureBuilder<T>> {
}
void _subscribe() {
if (config.future != null) {
if (widget.future != null) {
final Object callbackIdentity = new Object();
_activeCallbackIdentity = callbackIdentity;
config.future.then<Null>((T data) {
widget.future.then<Null>((T data) {
if (_activeCallbackIdentity == callbackIdentity) {
setState(() {
_snapshot = new AsyncSnapshot<T>.withData(ConnectionState.done, data);
......
......@@ -3241,5 +3241,5 @@ class StatefulBuilder extends StatefulWidget {
class _StatefulBuilderState extends State<StatefulBuilder> {
@override
Widget build(BuildContext context) => config.builder(context, setState);
Widget build(BuildContext context) => widget.builder(context, setState);
}
......@@ -193,9 +193,9 @@ class _DismissibleState extends State<Dismissible> 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<Dismissible> 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<Dismissible> 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<Dismissible> 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<Dismissible> 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<Dismissible> 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<Dismissible> 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<Dismissible> 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<Dismissible> 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,
......
......@@ -247,7 +247,7 @@ class _DraggableState<T> extends State<Draggable<T>> {
@override
void initState() {
super.initState();
_recognizer = config.createRecognizer(_startDrag);
_recognizer = widget.createRecognizer(_startDrag);
}
@override
......@@ -276,16 +276,16 @@ class _DraggableState<T> extends State<Draggable<T>> {
}
void _routePointer(PointerEvent event) {
if (config.maxSimultaneousDrags != null && _activeCount >= config.maxSimultaneousDrags)
if (widget.maxSimultaneousDrags != null && _activeCount >= widget.maxSimultaneousDrags)
return;
_recognizer.addPointer(event);
}
_DragAvatar<T> _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<T> extends State<Draggable<T>> {
_activeCount += 1;
});
final _DragAvatar<T> avatar = new _DragAvatar<T>(
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<T> extends State<Draggable<T>> {
_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<T> extends State<DragTarget<T>> {
bool didEnter(_DragAvatar<dynamic> 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<T> extends State<DragTarget<T>> {
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<T>(_candidateAvatars), _mapAvatarsToData<dynamic>(_rejectedAvatars))
child: widget.builder(context, _mapAvatarsToData<T>(_candidateAvatars), _mapAvatarsToData<dynamic>(_rejectedAvatars))
);
}
}
......
......@@ -220,43 +220,43 @@ class EditableTextState extends State<EditableText> 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<EditableText> 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<EditableText> 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<EditableText> 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<EditableText> implements TextInputClient {
_openInputConnectionIfNeeded();
} else if (!_hasFocus) {
_closeInputConnectionIfNeeded();
config.controller.clearComposing();
widget.controller.clearComposing();
}
_didRequestKeyboard = false;
}
......@@ -359,7 +359,7 @@ class EditableTextState extends State<EditableText> 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<EditableText> 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<EditableText> 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<EditableText> implements TextInputClient {
_updateOrDisposeSelectionOverlayIfNeeded();
// TODO(abarth): Teach RenderEditable about ValueNotifier<TextEditingValue>
// 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<EditableText> 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<EditableText> 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,
);
......
......@@ -90,26 +90,26 @@ class _FocusScopeState extends State<FocusScope> {
@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,
),
);
}
......
......@@ -90,14 +90,14 @@ class FormState extends State<Form> {
@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<T> extends State<FormField<T>> {
/// 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<T> extends State<FormField<T>> {
}
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<T> extends State<FormField<T>> {
@override
void initState() {
super.initState();
_value = config.initialValue;
_value = widget.initialValue;
}
@override
......@@ -300,9 +300,9 @@ class FormFieldState<T> extends State<FormField<T>> {
@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);
}
}
......@@ -363,12 +363,12 @@ class RawGestureDetectorState extends State<RawGestureDetector> {
@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<RawGestureDetector> {
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<RawGestureDetector> {
}
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<RawGestureDetector> {
gestures.add('<none>');
description.add('gestures: ${gestures.join(", ")}');
}
switch (config.behavior) {
switch (widget.behavior) {
case HitTestBehavior.translucent:
description.add('behavior: translucent');
break;
......
......@@ -165,7 +165,7 @@ class _HeroState extends State<Hero> {
}
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<double> 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) {
......
......@@ -243,8 +243,8 @@ class _ImageState extends State<Image> {
}
@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<Image> {
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<Image> {
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
);
}
......
......@@ -138,8 +138,8 @@ abstract class AnimatedWidgetBaseState<T extends ImplicitlyAnimatedWidget> 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<T extends ImplicitlyAnimatedWidget> 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<dynamic> tween, dynamic targetValue, TweenConstructor<dynamic> constructor) {
_updateTween(tween, targetValue);
......@@ -163,8 +163,8 @@ abstract class AnimatedWidgetBaseState<T extends ImplicitlyAnimatedWidget> 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<T extends ImplicitlyAnimatedWidget> exten
/// 1. Call the visitor callback with three arguments, the first argument
/// being the current value of the Tween<T> 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<T> object for the tween, configured with the given value
......@@ -324,20 +324,20 @@ class _AnimatedContainerState extends AnimatedWidgetBaseState<AnimatedContainer>
@override
void forEachTween(TweenVisitor<dynamic> 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<double>(begin: value));
_height = visitor(_height, config.height, (dynamic value) => new Tween<double>(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<double>(begin: value));
_height = visitor(_height, widget.height, (dynamic value) => new Tween<double>(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<AnimatedPositione
@override
void forEachTween(TweenVisitor<dynamic> visitor) {
// TODO(ianh): Use constructor tear-offs when it becomes possible
_left = visitor(_left, config.left, (dynamic value) => new Tween<double>(begin: value));
_top = visitor(_top, config.top, (dynamic value) => new Tween<double>(begin: value));
_right = visitor(_right, config.right, (dynamic value) => new Tween<double>(begin: value));
_bottom = visitor(_bottom, config.bottom, (dynamic value) => new Tween<double>(begin: value));
_width = visitor(_width, config.width, (dynamic value) => new Tween<double>(begin: value));
_height = visitor(_height, config.height, (dynamic value) => new Tween<double>(begin: value));
_left = visitor(_left, widget.left, (dynamic value) => new Tween<double>(begin: value));
_top = visitor(_top, widget.top, (dynamic value) => new Tween<double>(begin: value));
_right = visitor(_right, widget.right, (dynamic value) => new Tween<double>(begin: value));
_bottom = visitor(_bottom, widget.bottom, (dynamic value) => new Tween<double>(begin: value));
_width = visitor(_width, widget.width, (dynamic value) => new Tween<double>(begin: value));
_height = visitor(_height, widget.height, (dynamic value) => new Tween<double>(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<AnimatedOpacity> {
@override
void forEachTween(TweenVisitor<dynamic> visitor) {
// TODO(ianh): Use constructor tear-offs when it becomes possible
_opacity = visitor(_opacity, config.opacity, (dynamic value) => new Tween<double>(begin: value));
_opacity = visitor(_opacity, widget.opacity, (dynamic value) => new Tween<double>(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<AnimatedDef
@override
void forEachTween(TweenVisitor<dynamic> 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
);
}
}
......@@ -704,22 +704,22 @@ class NavigatorState extends State<Navigator> 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<Navigator> 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<Route<dynamic>> doomed = _poppedRoutes.toList()..addAll(_history);
for (Route<dynamic> route in doomed)
......@@ -759,10 +759,10 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
assert(!_debugLocked);
assert(name != null);
final RouteSettings settings = new RouteSettings(name: name);
Route<dynamic> route = config.onGenerateRoute(settings);
Route<dynamic> 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<Navigator> 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<Navigator> 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<Navigator> 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<Navigator> 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();
}
......
......@@ -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<Overlay> with TickerProviderStateMixin {
@override
void initState() {
super.initState();
insertAll(config.initialEntries);
insertAll(widget.initialEntries);
}
/// Insert the given entry into the overlay.
......
......@@ -116,17 +116,17 @@ class _GlowingOverscrollIndicatorState extends State<GlowingOverscrollIndicator>
@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<GlowingOverscrollIndicator>
_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<GlowingOverscrollIndicator>
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,
),
),
),
......
......@@ -388,16 +388,16 @@ class _PageViewState extends State<PageView> {
@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<PageView> {
final AxisDirection axisDirection = _getDirection(context);
return new NotificationListener<ScrollNotification>(
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: <Widget>[
new SliverFillViewport(
viewportFraction: config.controller.viewportFraction,
delegate: config.childrenDelegate
viewportFraction: widget.controller.viewportFraction,
delegate: widget.childrenDelegate
),
],
);
......@@ -440,10 +440,10 @@ class _PageViewState extends State<PageView> {
@override
void debugFillDescription(List<String> 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}');
}
}
......@@ -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;
......
......@@ -142,7 +142,7 @@ class _SemanticsDebuggerState extends State<SemanticsDebugger> {
behavior: HitTestBehavior.opaque,
child: new IgnorePointer(
ignoringSemantics: false,
child: config.child
child: widget.child
)
)
)
......
......@@ -19,8 +19,8 @@ class StateMarkerState extends State<StateMarker> {
@override
Widget build(BuildContext context) {
if (config.child != null)
return config.child;
if (widget.child != null)
return widget.child;
return new Container();
}
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment