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
9cb12086
Commit
9cb12086
authored
May 09, 2017
by
Ian Hickson
Committed by
GitHub
May 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Samples for BoxDecoration and some related classes (#9902)
parent
9935b307
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
353 additions
and
38 deletions
+353
-38
box_painter.dart
packages/flutter/lib/src/painting/box_painter.dart
+268
-34
proxy_box.dart
packages/flutter/lib/src/rendering/proxy_box.dart
+35
-0
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+24
-2
container.dart
packages/flutter/lib/src/widgets/container.dart
+26
-2
No files found.
packages/flutter/lib/src/painting/box_painter.dart
View file @
9cb12086
This diff is collapsed.
Click to expand it.
packages/flutter/lib/src/rendering/proxy_box.dart
View file @
9cb12086
...
...
@@ -1811,6 +1811,41 @@ class RenderFractionalTranslation extends RenderProxyBox {
///
/// The [hitTest] method is called when the user interacts with the underlying
/// render object, to determine if the user hit the object or missed it.
///
/// ## Sample code
///
/// This sample extends the same code shown for [RadialGradient] to create a
/// custom painter that paints a sky.
///
/// ```dart
/// class Sky extends CustomPainter {
/// @override
/// void paint(Canvas canvas, Size size) {
/// var rect = Offset.zero & size;
/// var gradient = new RadialGradient(
/// center: const FractionalOffset(0.7, 0.2),
/// radius: 0.2,
/// colors: [const Color(0xFFFFFF00), const Color(0xFF0099FF)],
/// stops: [0.4, 1.0],
/// );
/// canvas.drawRect(
/// rect,
/// new Paint()..shader = gradient.createShader(rect),
/// );
/// }
///
/// @override
/// bool shouldRepaint(CustomPainter oldDelegate) => false;
/// }
/// ```
///
/// See also:
///
/// * [Canvas], the class that a custom painter uses to paint.
/// * [CustomPaint], the widget that uses [CustomPainter], and whose sample
/// code shows how to use the above `Sky` class.
/// * [RadialGradient], whose sample code section shows a different take
/// on the sample code above.
abstract
class
CustomPainter
extends
Listenable
{
/// Creates a custom painter.
///
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
9cb12086
...
...
@@ -198,10 +198,32 @@ class BackdropFilter extends SingleChildRenderObjectWidget {
/// a child, they attempt to size themselves to the [size], which defaults to
/// [Size.zero].
///
/// ## Sample code
///
/// This example shows how the sample custom painter shown at [CustomPainter]
/// could be used in a [CustomPaint] widget to display a background to some
/// text.
///
/// ```dart
/// new CustomPaint(
/// painter: new Sky(),
/// child: new Center(
/// child: new Text(
/// 'Once upon a time...',
/// style: const TextStyle(
/// fontSize: 40.0,
/// fontWeight: FontWeight.w900,
/// color: const Color(0xFFFFFFFF),
/// ),
/// ),
/// ),
/// ),
/// ```
///
/// See also:
///
/// * [CustomPainter].
/// * [Canvas].
/// * [CustomPainter]
, the class to extend when creating custom painters
.
/// * [Canvas]
, the class that a custom painter uses to paint
.
class
CustomPaint
extends
SingleChildRenderObjectWidget
{
/// Creates a widget that delegates its painting.
const
CustomPaint
({
Key
key
,
this
.
painter
,
this
.
foregroundPainter
,
this
.
size
:
Size
.
zero
,
Widget
child
})
...
...
packages/flutter/lib/src/widgets/container.dart
View file @
9cb12086
...
...
@@ -16,10 +16,34 @@ import 'image.dart';
/// not.
///
/// Commonly used with [BoxDecoration].
///
///
/// ## Sample code
///
/// This sample shows a radial gradient that draws a moon on a night sky:
///
/// ```dart
/// new DecoratedBox(
/// decoration: new BoxDecoration(
/// gradient: new RadialGradient(
/// center: const FractionalOffset(0.25, 0.3),
/// radius: 0.15,
/// colors: <Color>[
/// const Color(0xFFEEEEEE),
/// const Color(0xFF111133),
/// ],
/// stops: <double>[0.9, 1.0],
/// ),
/// ),
/// ),
/// ```
///
/// See also:
///
/// * [DecoratedBoxTransition], the version of this class that animates on the [decoration] property.
/// * [DecoratedBoxTransition], the version of this class that animates on the
/// [decoration] property.
/// * [Decoration], which you can extend to provide other effects with
/// [DecoratedBox].
/// * [CustomPaint], another way to draw custom effects from the widget layer.
class
DecoratedBox
extends
SingleChildRenderObjectWidget
{
/// Creates a widget that paints a [Decoration].
///
...
...
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