tabs_demo.dart 1.42 KB
Newer Older
1 2 3 4 5 6
// 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/material.dart';

7
class TabsDemo extends StatelessComponent {
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
  final List<IconData> icons = <IconData>[
    Icons.event,
    Icons.home,
    Icons.android,
    Icons.alarm,
    Icons.face,
    Icons.language,
  ];

  final Map<IconData, String> labels = <IconData, String>{
    Icons.event: 'EVENT',
    Icons.home: 'HOME',
    Icons.android: 'ANDROID',
    Icons.alarm: 'ALARM',
    Icons.face: 'FACE',
    Icons.language: 'LANGUAGE',
  };
25 26

  Widget build(_) {
27
    return new TabBarSelection(
28
      values: icons,
29 30 31 32 33 34
      child: new Scaffold(
        toolBar: new ToolBar(
          center: new Text("Scrollable Tabs"),
          tabBar: new TabBar<String>(
            isScrollable: true,
            labels: new Map.fromIterable(
35 36
              icons,
              value: (IconData icon) => new TabLabel(text: labels[icon], icon: icon)
37
            )
Hans Muller's avatar
Hans Muller committed
38
          )
39 40
        ),
        body: new TabBarView(
41
          children: icons.map((IconData icon) {
42
            return new Container(
43
              key: new ObjectKey(icon),
44 45
              padding: const EdgeDims.all(12.0),
              child: new Card(
46
                child: new Center(child: new Icon(icon: icon, size: 48.0))
47 48 49 50 51
              )
            );
          }).toList()
        )
      )
52 53 54
    );
  }
}