diff --git a/packages/flutter/lib/src/widgets/animated_container.dart b/packages/flutter/lib/src/widgets/animated_container.dart index e9c56a115a..12f65ad1ea 100644 --- a/packages/flutter/lib/src/widgets/animated_container.dart +++ b/packages/flutter/lib/src/widgets/animated_container.dart @@ -77,10 +77,10 @@ class AnimatedContainer extends StatefulComponent { final Curve curve; final Duration duration; - AnimatedContainerState createState() => new AnimatedContainerState(); + _AnimatedContainerState createState() => new _AnimatedContainerState(); } -class AnimatedContainerState extends State { +class _AnimatedContainerState extends State { AnimatedBoxConstraintsValue _constraints; AnimatedBoxDecorationValue _decoration; AnimatedBoxDecorationValue _foregroundDecoration; diff --git a/packages/flutter/lib/src/widgets/app.dart b/packages/flutter/lib/src/widgets/app.dart index ea317a4f0b..c38da71607 100644 --- a/packages/flutter/lib/src/widgets/app.dart +++ b/packages/flutter/lib/src/widgets/app.dart @@ -38,7 +38,7 @@ class App extends StatefulComponent { 'This might be a sign that you have not upgraded to our new Widgets framework.'; 'For more details see: https://groups.google.com/forum/#!topic/flutter-dev/hcX3OvLws9c'; '...or look at our examples: https://github.com/flutter/engine/tree/master/examples'; - return routes != null; + return routes != null; }); } @@ -47,10 +47,10 @@ class App extends StatefulComponent { final Map routes; final RouteGenerator onGenerateRoute; - AppState createState() => new AppState(); + _AppState createState() => new _AppState(); } -class AppState extends State { +class _AppState extends State { GlobalObjectKey _navigator; diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 22f7d3e6a0..7b17690178 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -808,10 +808,10 @@ class ImageListener extends StatefulComponent { final ImageFit fit; final ImageRepeat repeat; - ImageListenerState createState() => new ImageListenerState(); + _ImageListenerState createState() => new _ImageListenerState(); } -class ImageListenerState extends State { +class _ImageListenerState extends State { void initState() { super.initState(); config.image.addListener(_handleImageChanged); diff --git a/packages/flutter/lib/src/widgets/date_picker.dart b/packages/flutter/lib/src/widgets/date_picker.dart index 5773c0a264..56f4ed7fb3 100644 --- a/packages/flutter/lib/src/widgets/date_picker.dart +++ b/packages/flutter/lib/src/widgets/date_picker.dart @@ -39,10 +39,10 @@ class DatePicker extends StatefulComponent { final DateTime firstDate; final DateTime lastDate; - DatePickerState createState() => new DatePickerState(); + _DatePickerState createState() => new _DatePickerState(); } -class DatePickerState extends State { +class _DatePickerState extends State { DatePickerMode _mode = DatePickerMode.day; void _handleModeChanged(DatePickerMode mode) { @@ -70,7 +70,7 @@ class DatePickerState extends State { static const double _calendarHeight = 210.0; Widget build(BuildContext context) { - Widget header = new DatePickerHeader( + Widget header = new _DatePickerHeader( selectedDate: config.selectedDate, mode: _mode, onModeChanged: _handleModeChanged @@ -107,8 +107,8 @@ class DatePickerState extends State { } // Shows the selected date in large font and toggles between year and day mode -class DatePickerHeader extends StatelessComponent { - DatePickerHeader({ this.selectedDate, this.mode, this.onModeChanged }) { +class _DatePickerHeader extends StatelessComponent { + _DatePickerHeader({ this.selectedDate, this.mode, this.onModeChanged }) { assert(selectedDate != null); assert(mode != null); } @@ -290,10 +290,10 @@ class MonthPicker extends ScrollableWidgetList { final DateTime firstDate; final DateTime lastDate; - MonthPickerState createState() => new MonthPickerState(); + _MonthPickerState createState() => new _MonthPickerState(); } -class MonthPickerState extends ScrollableWidgetListState { +class _MonthPickerState extends ScrollableWidgetListState { void initState() { super.initState(); _updateCurrentDate(); @@ -363,10 +363,10 @@ class YearPicker extends ScrollableWidgetList { final DateTime firstDate; final DateTime lastDate; - YearPickerState createState() => new YearPickerState(); + _YearPickerState createState() => new _YearPickerState(); } -class YearPickerState extends ScrollableWidgetListState { +class _YearPickerState extends ScrollableWidgetListState { int get itemCount => config.lastDate.year - config.firstDate.year + 1; List buildItems(BuildContext context, int start, int count) { diff --git a/packages/flutter/lib/src/widgets/dialog.dart b/packages/flutter/lib/src/widgets/dialog.dart index 4efe02b5a9..688f0f9174 100644 --- a/packages/flutter/lib/src/widgets/dialog.dart +++ b/packages/flutter/lib/src/widgets/dialog.dart @@ -131,16 +131,15 @@ class Dialog extends StatelessComponent { } } -const Duration _kTransitionDuration = const Duration(milliseconds: 150); - -class DialogRoute extends Route { - DialogRoute({ this.completer, this.builder }); +class _DialogRoute extends Route { + _DialogRoute({ this.completer, this.builder }); final Completer completer; final RouteBuilder builder; - Duration get transitionDuration => _kTransitionDuration; bool get opaque => false; + Duration get transitionDuration => const Duration(milliseconds: 150); + Widget build(NavigatorState navigator, PerformanceView nextRoutePerformance) { return new FadeTransition( performance: performance, @@ -157,7 +156,7 @@ class DialogRoute extends Route { Future showDialog(NavigatorState navigator, DialogBuilder builder) { Completer completer = new Completer(); - navigator.push(new DialogRoute( + navigator.push(new _DialogRoute( completer: completer, builder: (RouteArguments args) { return new Focus( diff --git a/packages/flutter/lib/src/widgets/dismissable.dart b/packages/flutter/lib/src/widgets/dismissable.dart index b9c11e2ecf..b47729bdd0 100644 --- a/packages/flutter/lib/src/widgets/dismissable.dart +++ b/packages/flutter/lib/src/widgets/dismissable.dart @@ -39,15 +39,15 @@ class Dismissable extends StatefulComponent { this.direction: DismissDirection.horizontal }) : super(key: key); - Widget child; - ResizedCallback onResized; - DismissedCallback onDismissed; - DismissDirection direction; + final Widget child; + final ResizedCallback onResized; + final DismissedCallback onDismissed; + final DismissDirection direction; - DismissableState createState() => new DismissableState(); + _DismissableState createState() => new _DismissableState(); } -class DismissableState extends State { +class _DismissableState extends State { void initState() { super.initState(); _fadePerformance = new Performance(duration: _kCardDismissFadeout); diff --git a/packages/flutter/lib/src/widgets/drag_target.dart b/packages/flutter/lib/src/widgets/drag_target.dart index 51800d7891..5d1533c270 100644 --- a/packages/flutter/lib/src/widgets/drag_target.dart +++ b/packages/flutter/lib/src/widgets/drag_target.dart @@ -62,10 +62,10 @@ class Draggable extends StatefulComponent { final Offset feedbackOffset; final DragAnchor dragAnchor; - DraggableState createState() => new DraggableState(); + _DraggableState createState() => new _DraggableState(); } -class DraggableState extends State { +class _DraggableState extends State { DragRoute _route; void _startDrag(sky.PointerEvent event) { diff --git a/packages/flutter/lib/src/widgets/drawer_item.dart b/packages/flutter/lib/src/widgets/drawer_item.dart index 2850d9418d..c41ac4a321 100644 --- a/packages/flutter/lib/src/widgets/drawer_item.dart +++ b/packages/flutter/lib/src/widgets/drawer_item.dart @@ -23,10 +23,10 @@ class DrawerItem extends StatefulComponent { final GestureTapCallback onPressed; final bool selected; - DrawerItemState createState() => new DrawerItemState(); + _DrawerItemState createState() => new _DrawerItemState(); } -class DrawerItemState extends ButtonState { +class _DrawerItemState extends ButtonState { TextStyle _getTextStyle(ThemeData themeData) { TextStyle result = themeData.text.body2; if (config.selected) diff --git a/packages/flutter/lib/src/widgets/flat_button.dart b/packages/flutter/lib/src/widgets/flat_button.dart index 02beead355..164b087f59 100644 --- a/packages/flutter/lib/src/widgets/flat_button.dart +++ b/packages/flutter/lib/src/widgets/flat_button.dart @@ -20,10 +20,10 @@ class FlatButton extends MaterialButton { enabled: enabled, onPressed: onPressed); - FlatButtonState createState() => new FlatButtonState(); + _FlatButtonState createState() => new _FlatButtonState(); } -class FlatButtonState extends MaterialButtonState { +class _FlatButtonState extends MaterialButtonState { Color getColor(BuildContext context) { if (!config.enabled || !highlight) return null; diff --git a/packages/flutter/lib/src/widgets/floating_action_button.dart b/packages/flutter/lib/src/widgets/floating_action_button.dart index 6b7d4b66c3..d2fb663cab 100644 --- a/packages/flutter/lib/src/widgets/floating_action_button.dart +++ b/packages/flutter/lib/src/widgets/floating_action_button.dart @@ -27,10 +27,10 @@ class FloatingActionButton extends StatefulComponent { final Color backgroundColor; final GestureTapCallback onPressed; - FloatingActionButtonState createState() => new FloatingActionButtonState(); + _FloatingActionButtonState createState() => new _FloatingActionButtonState(); } -class FloatingActionButtonState extends ButtonState { +class _FloatingActionButtonState extends ButtonState { Widget buildContent(BuildContext context) { IconThemeColor iconThemeColor = IconThemeColor.white; Color materialColor = config.backgroundColor; diff --git a/packages/flutter/lib/src/widgets/gesture_detector.dart b/packages/flutter/lib/src/widgets/gesture_detector.dart index fb3407908b..c2d1454c13 100644 --- a/packages/flutter/lib/src/widgets/gesture_detector.dart +++ b/packages/flutter/lib/src/widgets/gesture_detector.dart @@ -57,10 +57,10 @@ class GestureDetector extends StatefulComponent { final GestureScaleUpdateCallback onScaleUpdate; final GestureScaleEndCallback onScaleEnd; - GestureDetectorState createState() => new GestureDetectorState(); + _GestureDetectorState createState() => new _GestureDetectorState(); } -class GestureDetectorState extends State { +class _GestureDetectorState extends State { final PointerRouter _router = FlutterBinding.instance.pointerRouter; TapGestureRecognizer _tap; diff --git a/packages/flutter/lib/src/widgets/homogeneous_viewport.dart b/packages/flutter/lib/src/widgets/homogeneous_viewport.dart index 19dade6689..85f8009bc4 100644 --- a/packages/flutter/lib/src/widgets/homogeneous_viewport.dart +++ b/packages/flutter/lib/src/widgets/homogeneous_viewport.dart @@ -30,7 +30,7 @@ class HomogeneousViewport extends RenderObjectWidget { final ScrollDirection direction; final double startOffset; - HomogeneousViewportElement createElement() => new HomogeneousViewportElement(this); + _HomogeneousViewportElement createElement() => new _HomogeneousViewportElement(this); // we don't pass constructor arguments to the RenderBlockViewport() because until // we know our children, the constructor arguments we could give have no effect @@ -48,8 +48,8 @@ class HomogeneousViewport extends RenderObjectWidget { // all the actual work is done in the element } -class HomogeneousViewportElement extends RenderObjectElement { - HomogeneousViewportElement(HomogeneousViewport widget) : super(widget); +class _HomogeneousViewportElement extends RenderObjectElement { + _HomogeneousViewportElement(HomogeneousViewport widget) : super(widget); List _children = const []; int _layoutFirstIndex; diff --git a/packages/flutter/lib/src/widgets/icon.dart b/packages/flutter/lib/src/widgets/icon.dart index dc95312ba3..5dcee05232 100644 --- a/packages/flutter/lib/src/widgets/icon.dart +++ b/packages/flutter/lib/src/widgets/icon.dart @@ -61,7 +61,7 @@ class Icon extends StatelessComponent { final IconThemeColor color; final sky.ColorFilter colorFilter; - String getColorSuffix(BuildContext context) { + String _getColorSuffix(BuildContext context) { IconThemeColor iconThemeColor = color; if (iconThemeColor == null) { IconThemeData iconThemeData = IconTheme.of(context); @@ -90,7 +90,7 @@ class Icon extends StatelessComponent { // TODO(eseidel): This clearly isn't correct. Not sure what would be. // Should we use the ios images on ios? String density = 'drawable-xxhdpi'; - String colorSuffix = getColorSuffix(context); + String colorSuffix = _getColorSuffix(context); return new AssetImage( bundle: _iconBundle, name: '${category}/${density}/ic_${subtype}_${colorSuffix}_${size}dp.png', diff --git a/packages/flutter/lib/src/widgets/ink_well.dart b/packages/flutter/lib/src/widgets/ink_well.dart index 9abe7745da..df493434bd 100644 --- a/packages/flutter/lib/src/widgets/ink_well.dart +++ b/packages/flutter/lib/src/widgets/ink_well.dart @@ -26,8 +26,8 @@ double _getSplashTargetSize(Size bounds, Point position) { return math.max(math.max(d1, d2), math.max(d3, d4)).ceil().toDouble(); } -class InkSplash { - InkSplash(this.position, this.well) { +class _InkSplash { + _InkSplash(this.position, this.well) { _targetRadius = _getSplashTargetSize(well.size, position); _radius = new AnimatedValue( _kSplashInitialSize, end: _targetRadius, curve: easeOut); @@ -42,7 +42,7 @@ class InkSplash { } final Point position; - final RenderInkWell well; + final _RenderInkWell well; double _targetRadius; double _pinnedRadius; @@ -98,8 +98,8 @@ class InkSplash { } } -class RenderInkWell extends RenderProxyBox { - RenderInkWell({ +class _RenderInkWell extends RenderProxyBox { + _RenderInkWell({ RenderBox child, GestureTapCallback onTap, GestureLongPressCallback onLongPress @@ -122,7 +122,7 @@ class RenderInkWell extends RenderProxyBox { _syncLongPressRecognizer(); } - final List _splashes = new List(); + final List<_InkSplash> _splashes = new List<_InkSplash>(); TapGestureRecognizer _tap; LongPressGestureRecognizer _longPress; @@ -131,7 +131,7 @@ class RenderInkWell extends RenderProxyBox { if (event.type == 'pointerdown' && (_tap != null || _longPress != null)) { _tap?.addPointer(event); _longPress?.addPointer(event); - _splashes.add(new InkSplash(entry.localPosition, this)); + _splashes.add(new _InkSplash(entry.localPosition, this)); } } @@ -196,7 +196,7 @@ class RenderInkWell extends RenderProxyBox { canvas.save(); canvas.translate(offset.dx, offset.dy); canvas.clipRect(Point.origin & size); - for (InkSplash splash in _splashes) + for (_InkSplash splash in _splashes) splash.paint(canvas); canvas.restore(); } @@ -215,9 +215,9 @@ class InkWell extends OneChildRenderObjectWidget { final GestureTapCallback onTap; final GestureLongPressCallback onLongPress; - RenderInkWell createRenderObject() => new RenderInkWell(onTap: onTap, onLongPress: onLongPress); + _RenderInkWell createRenderObject() => new _RenderInkWell(onTap: onTap, onLongPress: onLongPress); - void updateRenderObject(RenderInkWell renderObject, InkWell oldWidget) { + void updateRenderObject(_RenderInkWell renderObject, InkWell oldWidget) { renderObject.onTap = onTap; renderObject.onLongPress = onLongPress; } diff --git a/packages/flutter/lib/src/widgets/input.dart b/packages/flutter/lib/src/widgets/input.dart index 5ec60a81e1..d3a1373073 100644 --- a/packages/flutter/lib/src/widgets/input.dart +++ b/packages/flutter/lib/src/widgets/input.dart @@ -39,10 +39,10 @@ class Input extends Scrollable { final String placeholder; final StringValueChanged onChanged; - InputState createState() => new InputState(); + _InputState createState() => new _InputState(); } -class InputState extends ScrollableState { +class _InputState extends ScrollableState { String _value; EditableString _editableValue; KeyboardHandle _keyboardHandle = KeyboardHandle.unattached; diff --git a/packages/flutter/lib/src/widgets/material.dart b/packages/flutter/lib/src/widgets/material.dart index eb79290ec9..c14b29fa6f 100644 --- a/packages/flutter/lib/src/widgets/material.dart +++ b/packages/flutter/lib/src/widgets/material.dart @@ -12,7 +12,7 @@ import 'package:sky/src/widgets/theme.dart'; enum MaterialType { canvas, card, circle, button } -const Map edges = const { +const Map _kEdges = const { MaterialType.canvas: null, MaterialType.card: 2.0, MaterialType.circle: null, @@ -35,7 +35,7 @@ class Material extends StatelessComponent { final int level; final Color color; - Color getBackgroundColor(BuildContext context) { + Color _getBackgroundColor(BuildContext context) { if (color != null) return color; switch (type) { @@ -55,10 +55,10 @@ class Material extends StatelessComponent { style: Theme.of(context).text.body1, child: contents ); - if (edges[type] != null) { + if (_kEdges[type] != null) { contents = new ClipRRect( - xRadius: edges[type], - yRadius: edges[type], + xRadius: _kEdges[type], + yRadius: _kEdges[type], child: contents ); } @@ -69,8 +69,8 @@ class Material extends StatelessComponent { curve: ease, duration: const Duration(milliseconds: 200), decoration: new BoxDecoration( - backgroundColor: getBackgroundColor(context), - borderRadius: edges[type], + backgroundColor: _getBackgroundColor(context), + borderRadius: _kEdges[type], boxShadow: level == 0 ? null : shadows[level], shape: type == MaterialType.circle ? Shape.circle : Shape.rectangle ), diff --git a/packages/flutter/lib/src/widgets/material_button.dart b/packages/flutter/lib/src/widgets/material_button.dart index b18cc313c1..70161208c5 100644 --- a/packages/flutter/lib/src/widgets/material_button.dart +++ b/packages/flutter/lib/src/widgets/material_button.dart @@ -9,7 +9,7 @@ import 'package:sky/src/widgets/framework.dart'; import 'package:sky/src/widgets/ink_well.dart'; import 'package:sky/src/widgets/material.dart'; -// Rather than using this class directly, please use FlatButton or RaisedButton. +/// Rather than using this class directly, please use FlatButton or RaisedButton. abstract class MaterialButton extends StatefulComponent { MaterialButton({ Key key, diff --git a/packages/flutter/lib/src/widgets/mimic.dart b/packages/flutter/lib/src/widgets/mimic.dart index 961db37986..45bb12f782 100644 --- a/packages/flutter/lib/src/widgets/mimic.dart +++ b/packages/flutter/lib/src/widgets/mimic.dart @@ -9,7 +9,7 @@ import 'package:sky/src/widgets/framework.dart'; class MimicableKey { MimicableKey._(this._state); - final MimicableState _state; + final _MimicableState _state; Rect get globalBounds => _state._globalBounds; @@ -35,10 +35,10 @@ class Mimicable extends StatefulComponent { final Widget child; - MimicableState createState() => new MimicableState(); + _MimicableState createState() => new _MimicableState(); } -class MimicableState extends State { +class _MimicableState extends State { Size _size; bool _beingMimicked = false; diff --git a/packages/flutter/lib/src/widgets/mixed_viewport.dart b/packages/flutter/lib/src/widgets/mixed_viewport.dart index 5336e80c71..120fd3457f 100644 --- a/packages/flutter/lib/src/widgets/mixed_viewport.dart +++ b/packages/flutter/lib/src/widgets/mixed_viewport.dart @@ -31,7 +31,7 @@ class MixedViewport extends RenderObjectWidget { final ExtentsUpdateCallback onExtentsUpdate; final InvalidatorAvailableCallback onInvalidatorAvailable; - MixedViewportElement createElement() => new MixedViewportElement(this); + _MixedViewportElement createElement() => new _MixedViewportElement(this); // we don't pass constructor arguments to the RenderBlockViewport() because until // we know our children, the constructor arguments we could give have no effect @@ -60,8 +60,8 @@ class _ChildKey { String toString() => "_ChildKey(type: $type, key: $key)"; } -class MixedViewportElement extends RenderObjectElement { - MixedViewportElement(MixedViewport widget) : super(widget) { +class _MixedViewportElement extends RenderObjectElement { + _MixedViewportElement(MixedViewport widget) : super(widget) { if (widget.onInvalidatorAvailable != null) widget.onInvalidatorAvailable(invalidate); } diff --git a/packages/flutter/lib/src/widgets/popup_menu.dart b/packages/flutter/lib/src/widgets/popup_menu.dart index 85295fd7c4..930b2513c9 100644 --- a/packages/flutter/lib/src/widgets/popup_menu.dart +++ b/packages/flutter/lib/src/widgets/popup_menu.dart @@ -121,8 +121,8 @@ class MenuPosition { final double left; } -class MenuRoute extends Route { - MenuRoute({ this.completer, this.position, this.builder, this.level }); +class _MenuRoute extends Route { + _MenuRoute({ this.completer, this.position, this.builder, this.level }); final Completer completer; final MenuPosition position; @@ -169,7 +169,7 @@ class MenuRoute extends Route { Future showMenu({ NavigatorState navigator, MenuPosition position, PopupMenuItemsBuilder builder, int level: 4 }) { Completer completer = new Completer(); - navigator.push(new MenuRoute( + navigator.push(new _MenuRoute( completer: completer, position: position, builder: builder, diff --git a/packages/flutter/lib/src/widgets/progress_indicator.dart b/packages/flutter/lib/src/widgets/progress_indicator.dart index c661fced9e..92cdeda620 100644 --- a/packages/flutter/lib/src/widgets/progress_indicator.dart +++ b/packages/flutter/lib/src/widgets/progress_indicator.dart @@ -31,10 +31,10 @@ abstract class ProgressIndicator extends StatefulComponent { Widget _buildIndicator(BuildContext context, double performanceValue); - ProgressIndicatorState createState() => new ProgressIndicatorState(); + _ProgressIndicatorState createState() => new _ProgressIndicatorState(); } -class ProgressIndicatorState extends State { +class _ProgressIndicatorState extends State { ValuePerformance _performance; diff --git a/packages/flutter/lib/src/widgets/radio.dart b/packages/flutter/lib/src/widgets/radio.dart index ab51bea716..53f487d08b 100644 --- a/packages/flutter/lib/src/widgets/radio.dart +++ b/packages/flutter/lib/src/widgets/radio.dart @@ -14,7 +14,7 @@ const sky.Color _kDarkOffColor = const sky.Color(0xB2FFFFFF); typedef RadioValueChanged(Object value); -class Radio extends StatefulComponent { +class Radio extends StatelessComponent { Radio({ Key key, this.value, @@ -28,13 +28,9 @@ class Radio extends StatefulComponent { final Object groupValue; final RadioValueChanged onChanged; - RadioState createState() => new RadioState(); -} - -class RadioState extends State { Color _getColor(BuildContext context) { ThemeData themeData = Theme.of(context); - if (config.value == config.groupValue) + if (value == groupValue) return themeData.accentColor; return themeData.brightness == ThemeBrightness.light ? _kLightOffColor : _kDarkOffColor; } @@ -44,7 +40,7 @@ class RadioState extends State { const double kOuterRadius = kDiameter / 2; const double kInnerRadius = 5.0; return new GestureDetector( - onTap: () => config.onChanged(config.value), + onTap: () => onChanged(value), child: new Container( margin: const EdgeDims.symmetric(horizontal: 5.0), width: kDiameter, @@ -60,7 +56,7 @@ class RadioState extends State { canvas.drawCircle(const Point(kOuterRadius, kOuterRadius), kOuterRadius, paint); // Draw the inner circle - if (config.value == config.groupValue) { + if (value == groupValue) { paint.setStyle(sky.PaintingStyle.fill); canvas.drawCircle(const Point(kOuterRadius, kOuterRadius), kInnerRadius, paint); } diff --git a/packages/flutter/lib/src/widgets/raised_button.dart b/packages/flutter/lib/src/widgets/raised_button.dart index 22c596511c..6d5e5487c2 100644 --- a/packages/flutter/lib/src/widgets/raised_button.dart +++ b/packages/flutter/lib/src/widgets/raised_button.dart @@ -22,10 +22,10 @@ class RaisedButton extends MaterialButton { assert(enabled != null); } - RaisedButtonState createState() => new RaisedButtonState(); + _RaisedButtonState createState() => new _RaisedButtonState(); } -class RaisedButtonState extends MaterialButtonState { +class _RaisedButtonState extends MaterialButtonState { Color getColor(BuildContext context) { if (config.enabled) { switch (Theme.of(context).brightness) { diff --git a/packages/flutter/lib/src/widgets/scaffold.dart b/packages/flutter/lib/src/widgets/scaffold.dart index 9e4b1e1dd5..bff2d0d8f1 100644 --- a/packages/flutter/lib/src/widgets/scaffold.dart +++ b/packages/flutter/lib/src/widgets/scaffold.dart @@ -9,7 +9,7 @@ import 'package:sky/rendering.dart'; import 'package:sky/src/widgets/framework.dart'; // Slots are painted in this order and hit tested in reverse of this order -enum ScaffoldSlots { +enum _ScaffoldSlots { body, statusBar, toolbar, @@ -18,9 +18,9 @@ enum ScaffoldSlots { drawer } -class RenderScaffold extends RenderBox { +class _RenderScaffold extends RenderBox { - RenderScaffold({ + _RenderScaffold({ RenderBox body, RenderBox statusBar, RenderBox toolbar, @@ -28,17 +28,17 @@ class RenderScaffold extends RenderBox { RenderBox floatingActionButton, RenderBox drawer }) { - this[ScaffoldSlots.body] = body; - this[ScaffoldSlots.statusBar] = statusBar; - this[ScaffoldSlots.toolbar] = toolbar; - this[ScaffoldSlots.snackBar] = snackBar; - this[ScaffoldSlots.floatingActionButton] = floatingActionButton; - this[ScaffoldSlots.drawer] = drawer; + this[_ScaffoldSlots.body] = body; + this[_ScaffoldSlots.statusBar] = statusBar; + this[_ScaffoldSlots.toolbar] = toolbar; + this[_ScaffoldSlots.snackBar] = snackBar; + this[_ScaffoldSlots.floatingActionButton] = floatingActionButton; + this[_ScaffoldSlots.drawer] = drawer; } - Map _slots = new Map(); - RenderBox operator[] (ScaffoldSlots slot) => _slots[slot]; - void operator[]= (ScaffoldSlots slot, RenderBox value) { + Map<_ScaffoldSlots, RenderBox> _slots = new Map<_ScaffoldSlots, RenderBox>(); + RenderBox operator[] (_ScaffoldSlots slot) => _slots[slot]; + void operator[]= (_ScaffoldSlots slot, RenderBox value) { RenderBox old = _slots[slot]; if (old == value) return; @@ -54,7 +54,7 @@ class RenderScaffold extends RenderBox { } void attachChildren() { - for (ScaffoldSlots slot in ScaffoldSlots.values) { + for (_ScaffoldSlots slot in _ScaffoldSlots.values) { RenderBox box = _slots[slot]; if (box != null) box.attach(); @@ -62,7 +62,7 @@ class RenderScaffold extends RenderBox { } void detachChildren() { - for (ScaffoldSlots slot in ScaffoldSlots.values) { + for (_ScaffoldSlots slot in _ScaffoldSlots.values) { RenderBox box = _slots[slot]; if (box != null) box.detach(); @@ -70,16 +70,16 @@ class RenderScaffold extends RenderBox { } void visitChildren(RenderObjectVisitor visitor) { - for (ScaffoldSlots slot in ScaffoldSlots.values) { + for (_ScaffoldSlots slot in _ScaffoldSlots.values) { RenderBox box = _slots[slot]; if (box != null) visitor(box); } } - ScaffoldSlots remove(RenderBox child) { + _ScaffoldSlots remove(RenderBox child) { assert(child != null); - for (ScaffoldSlots slot in ScaffoldSlots.values) { + for (_ScaffoldSlots slot in _ScaffoldSlots.values) { if (_slots[slot] == child) { this[slot] = null; return slot; @@ -103,15 +103,15 @@ class RenderScaffold extends RenderBox { double bodyHeight = size.height; double bodyPosition = 0.0; double fabOffset = 0.0; - if (_slots[ScaffoldSlots.statusBar] != null) { - RenderBox statusBar = _slots[ScaffoldSlots.statusBar]; + if (_slots[_ScaffoldSlots.statusBar] != null) { + RenderBox statusBar = _slots[_ScaffoldSlots.statusBar]; statusBar.layout(new BoxConstraints.tight(new Size(size.width, kStatusBarHeight))); assert(statusBar.parentData is BoxParentData); statusBar.parentData.position = new Point(0.0, size.height - kStatusBarHeight); bodyHeight -= kStatusBarHeight; } - if (_slots[ScaffoldSlots.toolbar] != null) { - RenderBox toolbar = _slots[ScaffoldSlots.toolbar]; + if (_slots[_ScaffoldSlots.toolbar] != null) { + RenderBox toolbar = _slots[_ScaffoldSlots.toolbar]; double toolbarHeight = kToolBarHeight + sky.view.paddingTop; toolbar.layout(new BoxConstraints.tight(new Size(size.width, toolbarHeight))); assert(toolbar.parentData is BoxParentData); @@ -119,14 +119,14 @@ class RenderScaffold extends RenderBox { bodyPosition += toolbarHeight; bodyHeight -= toolbarHeight; } - if (_slots[ScaffoldSlots.body] != null) { - RenderBox body = _slots[ScaffoldSlots.body]; + if (_slots[_ScaffoldSlots.body] != null) { + RenderBox body = _slots[_ScaffoldSlots.body]; body.layout(new BoxConstraints.tight(new Size(size.width, bodyHeight))); assert(body.parentData is BoxParentData); body.parentData.position = new Point(0.0, bodyPosition); } - if (_slots[ScaffoldSlots.snackBar] != null) { - RenderBox snackBar = _slots[ScaffoldSlots.snackBar]; + if (_slots[_ScaffoldSlots.snackBar] != null) { + RenderBox snackBar = _slots[_ScaffoldSlots.snackBar]; // TODO(jackson): On tablet/desktop, minWidth = 288, maxWidth = 568 snackBar.layout( new BoxConstraints(minWidth: size.width, maxWidth: size.width, minHeight: 0.0, maxHeight: bodyHeight), @@ -136,15 +136,15 @@ class RenderScaffold extends RenderBox { snackBar.parentData.position = new Point(0.0, bodyPosition + bodyHeight - snackBar.size.height); fabOffset += snackBar.size.height; } - if (_slots[ScaffoldSlots.floatingActionButton] != null) { - RenderBox floatingActionButton = _slots[ScaffoldSlots.floatingActionButton]; + if (_slots[_ScaffoldSlots.floatingActionButton] != null) { + RenderBox floatingActionButton = _slots[_ScaffoldSlots.floatingActionButton]; Size area = new Size(size.width - kButtonX, size.height - kButtonY); floatingActionButton.layout(new BoxConstraints.loose(area), parentUsesSize: true); assert(floatingActionButton.parentData is BoxParentData); floatingActionButton.parentData.position = (area - floatingActionButton.size).toPoint() + new Offset(0.0, -fabOffset); } - if (_slots[ScaffoldSlots.drawer] != null) { - RenderBox drawer = _slots[ScaffoldSlots.drawer]; + if (_slots[_ScaffoldSlots.drawer] != null) { + RenderBox drawer = _slots[_ScaffoldSlots.drawer]; drawer.layout(new BoxConstraints(minWidth: 0.0, maxWidth: size.width, minHeight: size.height, maxHeight: size.height)); assert(drawer.parentData is BoxParentData); drawer.parentData.position = Point.origin; @@ -152,7 +152,7 @@ class RenderScaffold extends RenderBox { } void paint(PaintingContext context, Offset offset) { - for (ScaffoldSlots slot in ScaffoldSlots.values) { + for (_ScaffoldSlots slot in _ScaffoldSlots.values) { RenderBox box = _slots[slot]; if (box != null) { assert(box.parentData is BoxParentData); @@ -162,7 +162,7 @@ class RenderScaffold extends RenderBox { } void hitTestChildren(HitTestResult result, { Point position }) { - for (ScaffoldSlots slot in ScaffoldSlots.values.reversed) { + for (_ScaffoldSlots slot in _ScaffoldSlots.values.reversed) { RenderBox box = _slots[slot]; if (box != null) { assert(box.parentData is BoxParentData); @@ -187,30 +187,30 @@ class Scaffold extends RenderObjectWidget { Widget floatingActionButton, Widget drawer }) : super(key: key) { - _children[ScaffoldSlots.body] = body; - _children[ScaffoldSlots.statusBar] = statusBar; - _children[ScaffoldSlots.toolbar] = toolbar; - _children[ScaffoldSlots.snackBar] = snackBar; - _children[ScaffoldSlots.floatingActionButton] = floatingActionButton; - _children[ScaffoldSlots.drawer] = drawer; + _children[_ScaffoldSlots.body] = body; + _children[_ScaffoldSlots.statusBar] = statusBar; + _children[_ScaffoldSlots.toolbar] = toolbar; + _children[_ScaffoldSlots.snackBar] = snackBar; + _children[_ScaffoldSlots.floatingActionButton] = floatingActionButton; + _children[_ScaffoldSlots.drawer] = drawer; } - final Map _children = new Map(); + final Map<_ScaffoldSlots, Widget> _children = new Map<_ScaffoldSlots, Widget>(); - RenderScaffold createRenderObject() => new RenderScaffold(); + _RenderScaffold createRenderObject() => new _RenderScaffold(); - ScaffoldElement createElement() => new ScaffoldElement(this); + _ScaffoldElement createElement() => new _ScaffoldElement(this); } -class ScaffoldElement extends RenderObjectElement { - ScaffoldElement(Scaffold widget) : super(widget); +class _ScaffoldElement extends RenderObjectElement { + _ScaffoldElement(Scaffold widget) : super(widget); - Map _children; + Map<_ScaffoldSlots, Element> _children; - RenderScaffold get renderObject => super.renderObject; + _RenderScaffold get renderObject => super.renderObject; void visitChildren(ElementVisitor visitor) { - for (ScaffoldSlots slot in ScaffoldSlots.values) { + for (_ScaffoldSlots slot in _ScaffoldSlots.values) { Element element = _children[slot]; if (element != null) visitor(element); @@ -219,8 +219,8 @@ class ScaffoldElement extends RenderObjectElement { void mount(Element parent, dynamic newSlot) { super.mount(parent, newSlot); - _children = new Map(); - for (ScaffoldSlots slot in ScaffoldSlots.values) { + _children = new Map<_ScaffoldSlots, Element>(); + for (_ScaffoldSlots slot in _ScaffoldSlots.values) { Element newChild = widget._children[slot]?.createElement(); _children[slot] = newChild; newChild?.mount(this, slot); @@ -230,13 +230,13 @@ class ScaffoldElement extends RenderObjectElement { void update(Scaffold newWidget) { super.update(newWidget); assert(widget == newWidget); - for (ScaffoldSlots slot in ScaffoldSlots.values) { + for (_ScaffoldSlots slot in _ScaffoldSlots.values) { _children[slot] = updateChild(_children[slot], widget._children[slot], slot); assert((_children[slot] == null) == (widget._children[slot] == null)); } } - void insertChildRenderObject(RenderObject child, ScaffoldSlots slot) { + void insertChildRenderObject(RenderObject child, _ScaffoldSlots slot) { renderObject[slot] = child; } diff --git a/packages/flutter/lib/src/widgets/snack_bar.dart b/packages/flutter/lib/src/widgets/snack_bar.dart index 9e72a0d8fb..cf2d55d24f 100644 --- a/packages/flutter/lib/src/widgets/snack_bar.dart +++ b/packages/flutter/lib/src/widgets/snack_bar.dart @@ -15,7 +15,6 @@ import 'package:sky/src/widgets/placeholder.dart'; import 'package:sky/src/widgets/theme.dart'; import 'package:sky/src/widgets/transitions.dart'; -const Duration _kSlideInDuration = const Duration(milliseconds: 200); const double _kSnackHeight = 52.0; const double _kSideMargins = 24.0; const double _kVerticalPadding = 14.0; @@ -108,7 +107,7 @@ class _SnackBarRoute extends Route { bool get hasContent => false; bool get ephemeral => true; bool get modal => false; - Duration get transitionDuration => _kSlideInDuration; + Duration get transitionDuration => const Duration(milliseconds: 200); Widget build(NavigatorState navigator, PerformanceView nextRoutePerformance) => null; } diff --git a/packages/flutter/lib/src/widgets/tabs.dart b/packages/flutter/lib/src/widgets/tabs.dart index bcee5e115e..e5dc0f7dce 100644 --- a/packages/flutter/lib/src/widgets/tabs.dart +++ b/packages/flutter/lib/src/widgets/tabs.dart @@ -19,8 +19,8 @@ import 'package:sky/src/widgets/scrollable.dart'; import 'package:sky/src/widgets/theme.dart'; import 'package:sky/src/widgets/transitions.dart'; -typedef void SelectedIndexChanged(int selectedIndex); -typedef void LayoutChanged(Size size, List widths); +typedef void TabSelectedIndexChanged(int selectedIndex); +typedef void TabLayoutChanged(Size size, List widths); // See https://www.google.com/design/spec/components/tabs.html#tabs-specs const double _kTabHeight = 46.0; @@ -33,14 +33,14 @@ const int _kTabIconSize = 24; const double _kTabBarScrollDrag = 0.025; const Duration _kTabBarScroll = const Duration(milliseconds: 200); -class TabBarParentData extends BoxParentData with +class _TabBarParentData extends BoxParentData with ContainerParentDataMixin { } -class RenderTabBar extends RenderBox with - ContainerRenderObjectMixin, - RenderBoxContainerDefaultsMixin { +class _RenderTabBar extends RenderBox with + ContainerRenderObjectMixin, + RenderBoxContainerDefaultsMixin { - RenderTabBar(this.onLayoutChanged); + _RenderTabBar(this.onLayoutChanged); int _selectedIndex; int get selectedIndex => _selectedIndex; @@ -97,8 +97,8 @@ class RenderTabBar extends RenderBox with } void setupParentData(RenderBox child) { - if (child.parentData is! TabBarParentData) - child.parentData = new TabBarParentData(); + if (child.parentData is! _TabBarParentData) + child.parentData = new _TabBarParentData(); } double getMinIntrinsicWidth(BoxConstraints constraints) { @@ -109,7 +109,7 @@ class RenderTabBar extends RenderBox with RenderBox child = firstChild; while (child != null) { maxWidth = math.max(maxWidth, child.getMinIntrinsicWidth(widthConstraints)); - assert(child.parentData is TabBarParentData); + assert(child.parentData is _TabBarParentData); child = child.parentData.nextSibling; } double width = isScrollable ? maxWidth : maxWidth * childCount; @@ -124,7 +124,7 @@ class RenderTabBar extends RenderBox with RenderBox child = firstChild; while (child != null) { maxWidth = math.max(maxWidth, child.getMaxIntrinsicWidth(widthConstraints)); - assert(child.parentData is TabBarParentData); + assert(child.parentData is _TabBarParentData); child = child.parentData.nextSibling; } double width = isScrollable ? maxWidth : maxWidth * childCount; @@ -148,7 +148,7 @@ class RenderTabBar extends RenderBox with RenderBox child = firstChild; while (child != null) { child.layout(tabConstraints); - assert(child.parentData is TabBarParentData); + assert(child.parentData is _TabBarParentData); child.parentData.position = new Point(x, 0.0); x += tabWidth; child = child.parentData.nextSibling; @@ -166,7 +166,7 @@ class RenderTabBar extends RenderBox with RenderBox child = firstChild; while (child != null) { child.layout(tabConstraints, parentUsesSize: true); - assert(child.parentData is TabBarParentData); + assert(child.parentData is _TabBarParentData); child.parentData.position = new Point(x, 0.0); x += child.size.width; child = child.parentData.nextSibling; @@ -176,7 +176,7 @@ class RenderTabBar extends RenderBox with Size layoutSize; List layoutWidths; - LayoutChanged onLayoutChanged; + TabLayoutChanged onLayoutChanged; void reportLayoutChangedIfNeeded() { assert(onLayoutChanged != null); @@ -250,7 +250,7 @@ class RenderTabBar extends RenderBox with int index = 0; RenderBox child = firstChild; while (child != null) { - assert(child.parentData is TabBarParentData); + assert(child.parentData is _TabBarParentData); context.paintChild(child, child.parentData.position + offset); if (index++ == selectedIndex) _paintIndicator(context.canvas, child, offset); @@ -278,15 +278,15 @@ class _TabBarWrapper extends MultiChildRenderObjectWidget { final Rect indicatorRect; final bool textAndIcons; final bool isScrollable; - final LayoutChanged onLayoutChanged; + final TabLayoutChanged onLayoutChanged; - RenderTabBar createRenderObject() { - RenderTabBar result = new RenderTabBar(onLayoutChanged); + _RenderTabBar createRenderObject() { + _RenderTabBar result = new _RenderTabBar(onLayoutChanged); updateRenderObject(result, null); return result; } - void updateRenderObject(RenderTabBar renderObject, _TabBarWrapper oldWidget) { + void updateRenderObject(_RenderTabBar renderObject, _TabBarWrapper oldWidget) { renderObject.selectedIndex = selectedIndex; renderObject.backgroundColor = backgroundColor; renderObject.indicatorColor = indicatorColor; @@ -399,13 +399,13 @@ class TabBar extends Scrollable { final Iterable labels; final int selectedIndex; - final SelectedIndexChanged onChanged; + final TabSelectedIndexChanged onChanged; final bool isScrollable; - TabBarState createState() => new TabBarState(); + _TabBarState createState() => new _TabBarState(); } -class TabBarState extends ScrollableState { +class _TabBarState extends ScrollableState { void initState() { super.initState(); _indicatorAnimation = new ValuePerformance() @@ -598,7 +598,7 @@ class TabNavigator extends StatelessComponent { final List views; final int selectedIndex; - final SelectedIndexChanged onChanged; + final TabSelectedIndexChanged onChanged; final bool isScrollable; void _handleSelectedIndexChanged(int tabIndex) { diff --git a/packages/flutter/lib/src/widgets/transitions.dart b/packages/flutter/lib/src/widgets/transitions.dart index 4f00c3694d..5f3d52bf01 100644 --- a/packages/flutter/lib/src/widgets/transitions.dart +++ b/packages/flutter/lib/src/widgets/transitions.dart @@ -21,10 +21,10 @@ abstract class TransitionComponent extends StatefulComponent { Widget build(BuildContext context); - TransitionState createState() => new TransitionState(); + _TransitionState createState() => new _TransitionState(); } -class TransitionState extends State { +class _TransitionState extends State { void initState() { super.initState(); config.performance.addListener(_performanceChanged);