tabs_demo.dart 1.22 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 8
class TabsDemo extends StatelessComponent {
  final List<String> iconNames = <String>["event", "home", "android", "alarm", "face", "language"];
9 10

  Widget build(_) {
11 12 13 14 15 16 17 18 19
    return new TabBarSelection(
      values: iconNames,
      child: new Scaffold(
        toolBar: new ToolBar(
          center: new Text("Scrollable Tabs"),
          tabBar: new TabBar<String>(
            isScrollable: true,
            labels: new Map.fromIterable(
              iconNames,
20
              value: (String iconName) => new TabLabel(text: iconName.toUpperCase(), icon: "action/$iconName")
21
            )
Hans Muller's avatar
Hans Muller committed
22
          )
23 24 25 26 27 28 29 30 31 32 33 34 35
        ),
        body: new TabBarView(
          children: iconNames.map((String iconName) {
            return new Container(
              key: new ValueKey<String>(iconName),
              padding: const EdgeDims.all(12.0),
              child: new Card(
                child: new Center(child: new Icon(icon: "action/$iconName", size:IconSize.s48))
              )
            );
          }).toList()
        )
      )
36 37 38
    );
  }
}