Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
7dcdfe63
Unverified
Commit
7dcdfe63
authored
Nov 16, 2021
by
Taha Tesser
Committed by
GitHub
Nov 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `CupertinoButton` interactive example (#93625)
parent
e1a96b81
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
0 deletions
+83
-0
cupertino_button.0.dart
examples/api/lib/cupertino/button/cupertino_button.0.dart
+57
-0
cupertino_button.0_test.dart
...es/api/test/cupertino/button/cupertino_button.0_test.dart
+19
-0
button.dart
packages/flutter/lib/src/cupertino/button.dart
+7
-0
No files found.
examples/api/lib/cupertino/button/cupertino_button.0.dart
0 → 100644
View file @
7dcdfe63
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for CupertinoButton
import
'package:flutter/cupertino.dart'
;
void
main
(
)
=>
runApp
(
const
MyApp
());
class
MyApp
extends
StatelessWidget
{
const
MyApp
({
Key
?
key
})
:
super
(
key:
key
);
static
const
String
_title
=
'Flutter Code Sample'
;
@override
Widget
build
(
BuildContext
context
)
{
return
const
CupertinoApp
(
title:
_title
,
home:
MyStatelessWidget
(),
);
}
}
class
MyStatelessWidget
extends
StatelessWidget
{
const
MyStatelessWidget
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
return
Center
(
child:
Column
(
mainAxisSize:
MainAxisSize
.
min
,
children:
<
Widget
>[
const
CupertinoButton
(
onPressed:
null
,
child:
Text
(
'Disabled'
),
),
const
SizedBox
(
height:
30
),
const
CupertinoButton
.
filled
(
onPressed:
null
,
child:
Text
(
'Disabled'
),
),
const
SizedBox
(
height:
30
),
CupertinoButton
(
onPressed:
()
{},
child:
const
Text
(
'Enabled'
),
),
const
SizedBox
(
height:
30
),
CupertinoButton
.
filled
(
onPressed:
()
{},
child:
const
Text
(
'Enabled'
),
),
],
),
);
}
}
examples/api/test/cupertino/button/cupertino_button.0_test.dart
0 → 100644
View file @
7dcdfe63
// Copyright 2014 The Flutter 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_api_samples/cupertino/button/cupertino_button.0.dart'
as
example
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'Has 4 CupertinoButton variants'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
example
.
MyApp
(),
);
expect
(
find
.
byType
(
CupertinoButton
),
findsNWidgets
(
4
));
expect
(
find
.
ancestor
(
of:
find
.
text
(
'Enabled'
),
matching:
find
.
byType
(
CupertinoButton
)),
findsNWidgets
(
2
));
expect
(
find
.
ancestor
(
of:
find
.
text
(
'Disabled'
),
matching:
find
.
byType
(
CupertinoButton
)),
findsNWidgets
(
2
));
});
}
packages/flutter/lib/src/cupertino/button.dart
View file @
7dcdfe63
...
...
@@ -26,6 +26,13 @@ const EdgeInsets _kBackgroundButtonPadding = EdgeInsets.symmetric(
/// [EdgeInsets.zero], should be used to prevent clipping larger [child]
/// widgets.
///
/// {@tool dartpad}
/// This sample shows produces an enabled and disabled [CupertinoButton] and
/// [CupertinoButton.filled].
///
/// ** See code in examples/api/lib/cupertino/button/cupertino_button.0.dart **
/// {@end-tool}
///
/// See also:
///
/// * <https://developer.apple.com/ios/human-interface-guidelines/controls/buttons/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment