horizontal_scrolling.dart 1.25 KB
Newer Older
1 2 3 4
// 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.

5
import 'package:flutter/widgets.dart';
6

7
class Circle extends StatelessComponent {
8 9 10 11
  Circle({ this.margin: EdgeDims.zero });

  final EdgeDims margin;

12
  Widget build(BuildContext context) {
13 14
    return new Container(
      width: 50.0,
15
      margin: margin + new EdgeDims.symmetric(horizontal: 2.0),
16 17 18 19 20 21 22 23
      decoration: new BoxDecoration(
        shape: Shape.circle,
        backgroundColor: const Color(0xFF00FF00)
      )
    );
  }
}

24 25
class HorizontalScrollingApp extends StatelessComponent {
  Widget build(BuildContext context) {
26
    List<Widget> circles = [
27
      new Circle(margin: new EdgeDims.only(left: 10.0)),
28 29 30 31 32 33 34 35 36 37
      new Circle(),
      new Circle(),
      new Circle(),
      new Circle(),
      new Circle(),
      new Circle(),
      new Circle(),
      new Circle(),
      new Circle(),
      new Circle(),
38
      new Circle(margin: new EdgeDims.only(right: 10.0)),
39 40 41 42 43
    ];

    return new Center(
      child: new Container(
        height: 50.0,
44
        child: new Block(circles, scrollDirection: ScrollDirection.horizontal)
45 46 47 48 49 50 51 52
      )
    );
  }
}

void main() {
  runApp(new HorizontalScrollingApp());
}