Skip to content

Commit

Permalink
[cupertino_icons] Add example to cupertino icons (#5312)
Browse files Browse the repository at this point in the history
## Description of PR:

Adding an example app to showcase the usage of `cupertino_icons`. This addition will also increase the pub points of the package and will be helpful for other developers to quickly find relevant examples.

Fixes flutter/flutter#137682
  • Loading branch information
foxtrotravi authored Feb 12, 2024
1 parent 0a69259 commit d1f1f0f
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
3 changes: 2 additions & 1 deletion third_party/packages/cupertino_icons/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 1.0.7

* Adds example.md file to display usage.
* Updates minimum supported SDK version to Flutter 3.10/Dart 3.0.

## 1.0.6
Expand Down
14 changes: 14 additions & 0 deletions third_party/packages/cupertino_icons/example/example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?code-excerpt path-base="../test"?>

This package is used via [`CupertinoIcons`](https://api.flutter.dev/flutter/cupertino/CupertinoIcons-class.html):

<?code-excerpt "cupertino_icons_test.dart (CupertinoIcon)"?>
```dart
const Icon icon = Icon(
CupertinoIcons.heart_fill,
color: Colors.pink,
size: 24.0,
);
```

For a list of all icons, see [`CupertinoIcons`](https://api.flutter.dev/flutter/cupertino/CupertinoIcons-class.html#constants) [class documentation constants](https://api.flutter.dev/flutter/cupertino/CupertinoIcons-class.html#constants).
8 changes: 7 additions & 1 deletion third_party/packages/cupertino_icons/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ name: cupertino_icons
description: Default icons asset for Cupertino widgets based on Apple styled icons
repository: https://github.com/flutter/packages/tree/main/third_party/packages/cupertino_icons
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+cupertino_icons%22
version: 1.0.6
version: 1.0.7

environment:
sdk: ">=3.0.0 <4.0.0"

dev_dependencies:
flutter:
sdk: flutter
flutter_test:
sdk: flutter

flutter:
fonts:
- family: CupertinoIcons
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2013 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.

/// This test file is primarily here to serve as a source for code excerpts.
library;

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
testWidgets(
'Cupertino Icon Test',
(WidgetTester tester) async {
// #docregion CupertinoIcon
const Icon icon = Icon(
CupertinoIcons.heart_fill,
color: Colors.pink,
size: 24.0,
);
// #enddocregion CupertinoIcon

await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: icon,
),
),
);

expect(find.byType(Icon), findsOne);
},
);
}

0 comments on commit d1f1f0f

Please sign in to comment.