cupertino_buttons_demo.dart 2.67 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
// Copyright 2017 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/cupertino.dart';
import 'package:flutter/material.dart';

class CupertinoButtonsDemo extends StatefulWidget {
  static const String routeName = '/cupertino/buttons';

  @override
  _CupertinoButtonDemoState createState() => new _CupertinoButtonDemoState();
}

class _CupertinoButtonDemoState extends State<CupertinoButtonsDemo> {
  int _pressedCount = 0;

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
22
        title: const Text('Cupertino Buttons'),
23 24 25
      ),
      body: new Column(
        children: <Widget> [
26
          const Padding(
27 28
            padding: EdgeInsets.all(16.0),
            child: Text(
29 30 31
              'iOS themed buttons are flat. They can have borders or backgrounds but '
              'only when necessary.'
            ),
32 33 34 35 36
          ),
          new Expanded(
            child: new Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget> [
37
                new Text(_pressedCount > 0
38
                    ? 'Button pressed $_pressedCount time${_pressedCount == 1 ? "" : "s"}'
39
                    : ' '),
40
                const Padding(padding: EdgeInsets.all(12.0)),
41
                new Align(
42
                  alignment: const Alignment(0.0, -0.2),
43 44 45 46
                  child: new Row(
                    mainAxisSize: MainAxisSize.min,
                    children: <Widget>[
                      new CupertinoButton(
47
                        child: const Text('Cupertino Button'),
48
                        onPressed: () {
49
                          setState(() { _pressedCount += 1; });
50 51
                        }
                      ),
52
                      const CupertinoButton(
53
                        child: Text('Disabled'),
54 55 56 57 58
                        onPressed: null,
                      ),
                    ],
                  ),
                ),
59
                const Padding(padding: EdgeInsets.all(12.0)),
60
                new CupertinoButton(
61
                  child: const Text('With Background'),
62
                  color: CupertinoColors.activeBlue,
63
                  onPressed: () {
64
                    setState(() { _pressedCount += 1; });
65 66
                  }
                ),
67
                const Padding(padding: EdgeInsets.all(12.0)),
68
                const CupertinoButton(
69
                  child: Text('Disabled'),
70
                  color: CupertinoColors.activeBlue,
71 72 73 74 75 76 77 78 79 80
                  onPressed: null,
                ),
              ],
            )
          ),
        ],
      )
    );
  }
}