mirror of
https://github.com/encounter/engine.git
synced 2026-03-30 11:09:55 -07:00
Mark most State subclasses private
In the vast majority of cases, folks should be interacting with the Widget rather than its State. Fixes #267
This commit is contained in:
@@ -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<AnimatedContainer> {
|
||||
class _AnimatedContainerState extends State<AnimatedContainer> {
|
||||
AnimatedBoxConstraintsValue _constraints;
|
||||
AnimatedBoxDecorationValue _decoration;
|
||||
AnimatedBoxDecorationValue _foregroundDecoration;
|
||||
|
||||
@@ -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<String, RouteBuilder> routes;
|
||||
final RouteGenerator onGenerateRoute;
|
||||
|
||||
AppState createState() => new AppState();
|
||||
_AppState createState() => new _AppState();
|
||||
}
|
||||
|
||||
class AppState extends State<App> {
|
||||
class _AppState extends State<App> {
|
||||
|
||||
GlobalObjectKey _navigator;
|
||||
|
||||
|
||||
@@ -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<ImageListener> {
|
||||
class _ImageListenerState extends State<ImageListener> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
config.image.addListener(_handleImageChanged);
|
||||
|
||||
@@ -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<DatePicker> {
|
||||
class _DatePickerState extends State<DatePicker> {
|
||||
DatePickerMode _mode = DatePickerMode.day;
|
||||
|
||||
void _handleModeChanged(DatePickerMode mode) {
|
||||
@@ -70,7 +70,7 @@ class DatePickerState extends State<DatePicker> {
|
||||
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<DatePicker> {
|
||||
}
|
||||
|
||||
// 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<MonthPicker> {
|
||||
class _MonthPickerState extends ScrollableWidgetListState<MonthPicker> {
|
||||
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<YearPicker> {
|
||||
class _YearPickerState extends ScrollableWidgetListState<YearPicker> {
|
||||
int get itemCount => config.lastDate.year - config.firstDate.year + 1;
|
||||
|
||||
List<Widget> buildItems(BuildContext context, int start, int count) {
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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<Dismissable> {
|
||||
class _DismissableState extends State<Dismissable> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
_fadePerformance = new Performance(duration: _kCardDismissFadeout);
|
||||
|
||||
@@ -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<Draggable> {
|
||||
class _DraggableState extends State<Draggable> {
|
||||
DragRoute _route;
|
||||
|
||||
void _startDrag(sky.PointerEvent event) {
|
||||
|
||||
@@ -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<DrawerItem> {
|
||||
class _DrawerItemState extends ButtonState<DrawerItem> {
|
||||
TextStyle _getTextStyle(ThemeData themeData) {
|
||||
TextStyle result = themeData.text.body2;
|
||||
if (config.selected)
|
||||
|
||||
@@ -20,10 +20,10 @@ class FlatButton extends MaterialButton {
|
||||
enabled: enabled,
|
||||
onPressed: onPressed);
|
||||
|
||||
FlatButtonState createState() => new FlatButtonState();
|
||||
_FlatButtonState createState() => new _FlatButtonState();
|
||||
}
|
||||
|
||||
class FlatButtonState extends MaterialButtonState<FlatButton> {
|
||||
class _FlatButtonState extends MaterialButtonState<FlatButton> {
|
||||
Color getColor(BuildContext context) {
|
||||
if (!config.enabled || !highlight)
|
||||
return null;
|
||||
|
||||
@@ -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<FloatingActionButton> {
|
||||
class _FloatingActionButtonState extends ButtonState<FloatingActionButton> {
|
||||
Widget buildContent(BuildContext context) {
|
||||
IconThemeColor iconThemeColor = IconThemeColor.white;
|
||||
Color materialColor = config.backgroundColor;
|
||||
|
||||
@@ -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<GestureDetector> {
|
||||
class _GestureDetectorState extends State<GestureDetector> {
|
||||
final PointerRouter _router = FlutterBinding.instance.pointerRouter;
|
||||
|
||||
TapGestureRecognizer _tap;
|
||||
|
||||
@@ -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<HomogeneousViewport> {
|
||||
HomogeneousViewportElement(HomogeneousViewport widget) : super(widget);
|
||||
class _HomogeneousViewportElement extends RenderObjectElement<HomogeneousViewport> {
|
||||
_HomogeneousViewportElement(HomogeneousViewport widget) : super(widget);
|
||||
|
||||
List<Element> _children = const <Element>[];
|
||||
int _layoutFirstIndex;
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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<double>(
|
||||
_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<InkSplash> _splashes = new List<InkSplash>();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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<Input> {
|
||||
class _InputState extends ScrollableState<Input> {
|
||||
String _value;
|
||||
EditableString _editableValue;
|
||||
KeyboardHandle _keyboardHandle = KeyboardHandle.unattached;
|
||||
|
||||
@@ -12,7 +12,7 @@ import 'package:sky/src/widgets/theme.dart';
|
||||
|
||||
enum MaterialType { canvas, card, circle, button }
|
||||
|
||||
const Map<MaterialType, double> edges = const {
|
||||
const Map<MaterialType, double> _kEdges = const <MaterialType, double>{
|
||||
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
|
||||
),
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<Mimicable> {
|
||||
class _MimicableState extends State<Mimicable> {
|
||||
Size _size;
|
||||
bool _beingMimicked = false;
|
||||
|
||||
|
||||
@@ -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<MixedViewport> {
|
||||
MixedViewportElement(MixedViewport widget) : super(widget) {
|
||||
class _MixedViewportElement extends RenderObjectElement<MixedViewport> {
|
||||
_MixedViewportElement(MixedViewport widget) : super(widget) {
|
||||
if (widget.onInvalidatorAvailable != null)
|
||||
widget.onInvalidatorAvailable(invalidate);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user