-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[css_colors] Adopt code excerpts in README #5478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
8cb9288
79b947c
c28d548
07da910
815db67
8920da8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,13 +8,15 @@ from `dart:ui`, which means they're useful for Flutter apps. | |
| Import | ||
|
||
| ------ | ||
|
|
||
| <?code-excerpt "example/lib/readme_excerpts.dart (Import)"?> | ||
| ```dart | ||
| import 'package:css_colors/css_colors.dart'; | ||
| ``` | ||
|
|
||
| Use | ||
| --- | ||
|
|
||
| <?code-excerpt "example/lib/readme_excerpts.dart (Usage)"?> | ||
| ```dart | ||
| new Container(color: CSSColors.orange) | ||
| final Container orange = Container(color: CSSColors.orange); | ||
| ``` | ||
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // 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. | ||
|
|
||
| // #docregion Import | ||
| import 'package:css_colors/css_colors.dart'; | ||
| // #enddocregion Import | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| /// Demonstrates using CSS Colors for the README. | ||
| Container useCSSColors() { | ||
| // #docregion Usage | ||
| final Container orange = Container(color: CSSColors.orange); | ||
| // #enddocregion Usage | ||
|
|
||
| return orange; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| name: css_colors_example | ||
| description: Demonstrates how to use CSS Colors. | ||
| publish_to: none | ||
|
|
||
| environment: | ||
| sdk: ">=3.0.0 <4.0.0" | ||
|
|
||
| dependencies: | ||
| css_colors: | ||
| # When depending on this package from a real application you should use: | ||
| # css_colors: ^x.y.z | ||
| # See https://dart.dev/tools/pub/dependencies#version-constraints | ||
| # The example app is bundled with the plugin so we use a path dependency on | ||
| # the parent directory to use the current plugin's version. | ||
| path: ../ | ||
| flutter: | ||
| sdk: flutter | ||
|
|
||
| dev_dependencies: | ||
| flutter_test: | ||
| sdk: flutter |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // 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. | ||
|
|
||
| import 'package:css_colors/css_colors.dart'; | ||
| import 'package:css_colors_example/readme_excerpts.dart'; | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
|
|
||
| void main() { | ||
| testWidgets('Container uses CSSColors.orange', (WidgetTester tester) async { | ||
| // Build the container and trigger a frame. | ||
| await tester.pumpWidget(MaterialApp(home: Scaffold(body: useCSSColors()))); | ||
|
|
||
| // Verify that the Container has the correct color. | ||
| expect( | ||
| find.byWidgetPredicate( | ||
| (Widget widget) => | ||
| widget is Container && widget.color == CSSColors.orange, | ||
| ), | ||
| findsOneWidget); | ||
| }); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improves README example and updates it to use code excerpts.