Skip to content

Commit a0fadd0

Browse files
authored
[css_colors] Adopt code excerpts in README (flutter#5478)
Updates the README to use a compiled excerpt source for its example of importing and using `CSSColors`. Part of [flutter/flutter#102679](flutter/flutter#102679)
1 parent 2c54697 commit a0fadd0

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

packages/css_colors/CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
## NEXT
1+
## 1.1.4
22

33
* Updates minimum supported SDK version to Flutter 3.10/Dart 3.0.
4+
* Improves README example and updates it to use code excerpts.
45

56
## 1.1.3
67

packages/css_colors/README.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,10 @@ This package defines color constants for the CSS colors. These color constants
55
use the [Color](https://api.flutter.dev/flutter/dart-ui/Color-class.html) class
66
from `dart:ui`, which means they're useful for Flutter apps.
77

8-
Import
9-
------
10-
11-
```dart
12-
import 'package:css_colors/css_colors.dart';
13-
```
14-
158
Use
169
---
1710

11+
<?code-excerpt "test/css_colors_test.dart (Usage)"?>
1812
```dart
19-
new Container(color: CSSColors.orange)
13+
final Container orange = Container(color: CSSColors.orange);
2014
```

packages/css_colors/pubspec.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: css_colors
22
description: Defines constant dart:ui Color objects for CSS colors (for use in Flutter code).
33
repository: https://github.com/flutter/packages/tree/main/packages/css_colors
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+css_colors%22
5-
version: 1.1.3
5+
version: 1.1.4
66

77
environment:
88
sdk: ">=3.0.0 <4.0.0"
@@ -11,6 +11,8 @@ environment:
1111
dependencies:
1212
flutter:
1313
sdk: flutter
14+
flutter_test:
15+
sdk: flutter
1416

1517
topics:
1618
- color
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:css_colors/css_colors.dart';
6+
import 'package:flutter/material.dart';
7+
import 'package:flutter_test/flutter_test.dart';
8+
9+
void main() {
10+
testWidgets('CSSColors.orange should be correct',
11+
(WidgetTester tester) async {
12+
// Create a Container widget using CSSColors.orange.
13+
// #docregion Usage
14+
final Container orange = Container(color: CSSColors.orange);
15+
// #enddocregion Usage
16+
17+
// Ensure the color of the container is the expected one.
18+
expect(orange.color, equals(const Color(0xFFFFA500)));
19+
});
20+
}

script/configs/temp_exclude_excerpt.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
# TODO(stuartmorgan): Remove everything from this list. See
77
# https://github.com/flutter/flutter/issues/102679
8-
- css_colors
98
- espresso
109
- extension_google_sign_in_as_googleapis_auth
1110
- go_router_builder

0 commit comments

Comments
 (0)