Skip to content

Instantly share code, notes, and snippets.

@birkir
Last active December 12, 2017 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save birkir/e921158239c324ab95bb0b174383a562 to your computer and use it in GitHub Desktop.
Save birkir/e921158239c324ab95bb0b174383a562 to your computer and use it in GitHub Desktop.
// 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 (
<Scaffold appBar={<AppBar title={<Text>Cupertino Buttons</Text>} />}>
<Column>
<Padding padding={EdgeInsets.all(16.0)} />
<Expanded>
<Column mainAxisAlignment={MainAxisAlignment.center}>
<Text>
{_pressedCount > 0 ? 'Button pressed $_pressedCount time${_pressedCount == 1 ? "" : "s"}' : ' '}
</Text>
<Padding padding={EdgeInsets.all(12.0)} />
<Align alignment={Alignment(0.0, -0.2)}>
<Row mainAxisSize={MainAxisSize.min}>
<CupertinoButton onPressed={() { setState(() { _pressedCount += 1; }); }}>
<Text>Cupertino Button</Text>
</CupertinoButton>
<CupertinoButton>
<Text>Disabled</Text>
</CupertinoButton>
</Row>
<Padding padding={EdgeInsets.all(12.0)} />
<CupertinoButton
color={CupertinoColors.activeBlue}
onPressed={() { setState(() { _pressedCount += 1; }); }}
>
<Text>With Background</Text>
</CupertinoButton>
<Padding padding={EdgeInsets.all(12.0)} />
<CupertinoButton
color={CupertinoColors.activeBlue}
onPressed={null}
>
<Text>Disabled</Text>
</CupertinoButton>
</Align>
</Column>
</Expanded>
</Column>
</Scaffold>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment