mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

Factor out a reusable interface called Decoration from BoxDecoration. Make all the consumers of BoxDecoration and the erstwhile BoxPainter into consumers of Decoration. Make a BoxPainter be something you get from a Decoration, rather than something to which you pass a BoxDecoration. Rename Shape to BoxShape now that it's documented specifically as applying to boxes. Move EdgeDims to its own file. Move FractionalOffset up so that it's with the other helper classes in its file rather than alone at the end. Minor change to RenderClipOval's hit testing to avoid taking an unnecessary square root. Rename BoxDecorationPosition to DecorationPosition since RenderDecoratedBox now takes any Decoration. Implement hit testing for rounded rects. Rename AnimatedBoxDecorationValue to AnimatedDecorationValue, and make it support lerping across any Decoration (by deferring to the objects involved).
53 lines
1.3 KiB
Dart
53 lines
1.3 KiB
Dart
// Copyright 2015 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
class Circle extends StatelessComponent {
|
|
Circle({ this.margin: EdgeDims.zero });
|
|
|
|
final EdgeDims margin;
|
|
|
|
Widget build(BuildContext context) {
|
|
return new Container(
|
|
width: 50.0,
|
|
margin: margin + new EdgeDims.symmetric(horizontal: 2.0),
|
|
decoration: new BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
backgroundColor: const Color(0xFF00FF00)
|
|
)
|
|
);
|
|
}
|
|
}
|
|
|
|
class HorizontalScrollingApp extends StatelessComponent {
|
|
Widget build(BuildContext context) {
|
|
List<Widget> circles = <Widget>[
|
|
new Circle(margin: new EdgeDims.only(left: 10.0)),
|
|
new Circle(),
|
|
new Circle(),
|
|
new Circle(),
|
|
new Circle(),
|
|
new Circle(),
|
|
new Circle(),
|
|
new Circle(),
|
|
new Circle(),
|
|
new Circle(),
|
|
new Circle(),
|
|
new Circle(margin: new EdgeDims.only(right: 10.0)),
|
|
];
|
|
|
|
return new Center(
|
|
child: new Container(
|
|
height: 50.0,
|
|
child: new Block(circles, scrollDirection: ScrollDirection.horizontal)
|
|
)
|
|
);
|
|
}
|
|
}
|
|
|
|
void main() {
|
|
runApp(new HorizontalScrollingApp());
|
|
}
|