dart:ui library

Built-in types and core primitives for a Flutter application.

To use, import dart:ui.

This library exposes the lowest-level services that Flutter frameworks use to bootstrap applications, such as classes for driving the input, graphics text, layout, and rendering subsystems.

Classes

AccessibilityFeatures
Additional accessibility features that may be enabled by the platform.
BackdropFilterEngineLayer
An opaque handle to a backdrop filter engine layer.
CallbackHandle
A wrapper for a raw callback handle.
Canvas
An interface for recording graphical operations.
ChannelBuffers
The buffering and dispatch mechanism for messages sent by plugins on the engine side to their corresponding plugin code on the framework side.
ClipPathEngineLayer
An opaque handle to a clip path engine layer.
ClipRectEngineLayer
An opaque handle to a clip rect engine layer.
ClipRRectEngineLayer
An opaque handle to a clip rounded rect engine layer.
Codec
A handle to an image codec.
Color
An immutable 32 bit color value in ARGB format.
ColorFilter
A description of a color filter to apply when drawing a shape or compositing a layer with a particular Paint. A color filter is a function that takes two colors, and outputs one color. When applied during compositing, it is independently applied to each pixel of the layer being drawn before the entire layer is merged with the destination.
ColorFilterEngineLayer
An opaque handle to a color filter engine layer.
DartPluginRegistrant
Helper functions for Dart Plugin Registrants.
Display
A configurable display that a FlutterView renders on.
DisplayFeature
Area of the display that may be obstructed by a hardware feature.
EngineLayer
A handle for the framework to hold and retain an engine layer across frames.
FlutterView
A view into which a Flutter Scene is drawn.
FontFeature
A feature tag and value that affect the selection of glyphs in a font.
FontVariation
An axis tag and value that can be used to customize variable fonts.
FontWeight
The thickness of the glyphs used to draw the text.
FragmentProgram
An instance of FragmentProgram creates Shader objects (as used by Paint.shader).
FragmentShader
A Shader generated from a FragmentProgram.
FrameData
Additional data available on each flutter frame.
FrameInfo
Information for a single frame of an animation.
FrameTiming
Time-related performance metrics of a frame.
GestureSettings
Platform specific configuration for gesture behavior, such as touch slop.
GlyphInfo
The measurements of a character (or a sequence of visually connected characters) within a paragraph.
Gradient
A shader (as used by Paint.shader) that renders a color gradient.
Image
Opaque handle to raw decoded image data (pixels).
ImageDescriptor
A descriptor of data that can be turned into an Image via a Codec.
ImageFilter
A filter operation to apply to a raster image.
ImageFilterEngineLayer
An opaque handle to an image filter engine layer.
ImageShader
A shader (as used by Paint.shader) that tiles an image.
ImmutableBuffer
A handle to a read-only byte buffer that is managed by the engine.
IsolateNameServer
Static methods to allow for simple sharing of SendPorts across Isolates.
KeyData
Information about a key event.
LineMetrics
LineMetrics stores the measurements and statistics of a single line in the paragraph.
Locale
An identifier used to select a user's language and formatting preferences.
LocaleStringAttribute
A string attribute that causes the assistive technologies, e.g. VoiceOver, to treat string as a certain language.
MaskFilter
A mask filter to apply to shapes as they are painted. A mask filter is a function that takes a bitmap of color pixels, and returns another bitmap of color pixels.
Offset
An immutable 2D floating-point offset.
OffsetBase
Base class for Size and Offset, which are both ways to describe a distance as a two-dimensional axis-aligned vector.
OffsetEngineLayer
An opaque handle to an offset engine layer.
OpacityEngineLayer
An opaque handle to an opacity engine layer.
Paint
A description of the style to use when drawing on a Canvas.
Paragraph
A paragraph of text.
ParagraphBuilder
Builds a Paragraph containing text with the given styling information.
ParagraphConstraints
Layout constraints for Paragraph objects.
ParagraphStyle
An opaque object that determines the configuration used by ParagraphBuilder to position lines within a Paragraph of text.
Path
A complex, one-dimensional subset of a plane.
PathMetric
Utilities for measuring a Path and extracting sub-paths.
PathMetricIterator
Used by PathMetrics to track iteration from one segment of a path to the next for measurement.
PathMetrics
An iterable collection of PathMetric objects describing a Path.
Picture
An object representing a sequence of recorded graphical operations.
PictureRecorder
Records a Picture containing a sequence of graphical operations.
PlatformDispatcher
Platform event dispatcher singleton.
PluginUtilities
Functionality for Flutter plugin authors.
PointerData
Information about the state of a pointer.
PointerDataPacket
A sequence of reports about the state of pointers.
Radius
A radius for either circular or elliptical shapes.
Rect
An immutable, 2D, axis-aligned, floating-point rectangle whose coordinates are relative to a given origin.
RootIsolateToken
A token that represents a root isolate.
RRect
An immutable rounded rectangle with the custom radii for all four corners.
RSTransform
A transform consisting of a translation, a rotation, and a uniform scale.
Scene
An opaque object representing a composited scene.
SceneBuilder
Builds a Scene containing the given visuals.
SemanticsAction
The possible actions that can be conveyed from the operating system accessibility APIs to a semantics node.
SemanticsActionEvent
An event to request a SemanticsAction of type to be performed on the SemanticsNode identified by nodeId owned by the FlutterView identified by viewId.
SemanticsFlag
A Boolean value that can be associated with a semantics node.
SemanticsUpdate
An opaque object representing a batch of semantics updates.
SemanticsUpdateBuilder
An object that creates SemanticsUpdate objects.
Shader
Base class for objects such as Gradient and ImageShader which correspond to shaders as used by Paint.shader.
ShaderMaskEngineLayer
An opaque handle to a shader mask engine layer.
Shadow
A single shadow.
SingletonFlutterWindow
Deprecated. Will be removed in a future version of Flutter.
Size
Holds a 2D floating-point size.
SpellOutStringAttribute
A string attribute that causes the assistive technologies, e.g. VoiceOver, to spell out the string character by character.
StringAttribute
An abstract interface for string attributes that affects how assistive technologies, e.g. VoiceOver or TalkBack, treat the text.
StrutStyle
See also:
Tangent
The geometric description of a tangent: the angle at a point.
TargetImageSize
A specification of the size to which an image should be decoded.
TextBox
A rectangle enclosing a run of text.
TextDecoration
A linear decoration to draw near the text.
TextHeightBehavior
Defines how to apply TextStyle.height over and under text.
TextPosition
A position in a string of text.
TextRange
A range of characters in a string of text.
TextStyle
An opaque object that determines the size, position, and rendering of text.
TransformEngineLayer
An opaque handle to a transform engine layer.
Vertices
A set of vertex data used by Canvas.drawVertices.
ViewConstraints
Immutable layout constraints for FlutterViews.
ViewPadding
A representation of distances for each of the four edges of a rectangle, used to encode the view insets and padding that applications should place around their user interface, as exposed by FlutterView.viewInsets and FlutterView.padding. View insets and padding are preferably read via MediaQuery.of.

Constants

keepToString → const pragma
Annotation used by Flutter's Dart compiler to indicate that an Object.toString override should not be replaced with a supercall.

Properties

channelBuffers ChannelBuffers
ChannelBuffers that allow the storage of messages between the Engine and the Framework. Typically messages that can't be delivered are stored here until the Framework is able to process them.
final
window SingletonFlutterWindow
Deprecated. Will be removed in a future version of Flutter.
final

Functions

clampDouble(double x, double min, double max) double
Same as num.clamp but optimized for a non-null double.
decodeImageFromList(Uint8List list, ImageDecoderCallback callback) → void
Loads a single image frame from a byte array into an Image object.
decodeImageFromPixels(Uint8List pixels, int width, int height, PixelFormat format, ImageDecoderCallback callback, {int? rowBytes, int? targetWidth, int? targetHeight, bool allowUpscaling = true}) → void
Convert an array of pixel values into an Image object.
hashList(Iterable<Object?>? arguments) int
Combine the Object.hashCode values of an arbitrary number of objects from an Iterable into one value. This function will return the same value if given null as if given an empty list.
hashValues(Object? arg01, Object? arg02, [Object? arg03 = _hashEnd, Object? arg04 = _hashEnd, Object? arg05 = _hashEnd, Object? arg06 = _hashEnd, Object? arg07 = _hashEnd, Object? arg08 = _hashEnd, Object? arg09 = _hashEnd, Object? arg10 = _hashEnd, Object? arg11 = _hashEnd, Object? arg12 = _hashEnd, Object? arg13 = _hashEnd, Object? arg14 = _hashEnd, Object? arg15 = _hashEnd, Object? arg16 = _hashEnd, Object? arg17 = _hashEnd, Object? arg18 = _hashEnd, Object? arg19 = _hashEnd, Object? arg20 = _hashEnd]) int
Combine up to twenty objects' hash codes into one value.
instantiateImageCodec(Uint8List list, {int? targetWidth, int? targetHeight, bool allowUpscaling = true}) Future<Codec>
Instantiates an image Codec.
instantiateImageCodecFromBuffer(ImmutableBuffer buffer, {int? targetWidth, int? targetHeight, bool allowUpscaling = true}) Future<Codec>
Instantiates an image Codec.
instantiateImageCodecWithSize(ImmutableBuffer buffer, {TargetImageSizeCallback? getTargetSize}) Future<Codec>
Instantiates an image Codec.
lerpDouble(num? a, num? b, double t) double?
Linearly interpolate between two numbers, a and b, by an extrapolation factor t.
loadFontFromList(Uint8List list, {String? fontFamily}) Future<void>
Loads a font from a buffer and makes it available for rendering text.

Enums

AppExitResponse
The possible responses to a request to exit the application.
AppExitType
The type of application exit to perform when calling ServicesBinding.exitApplication.
AppLifecycleState
States that an application can be in once it is running.
BlendMode
Algorithms to use when painting on the canvas.
BlurStyle
Styles to use for blurs in MaskFilter objects.
BoxHeightStyle
Defines various ways to vertically bound the boxes returned by Paragraph.getBoxesForRange.
BoxWidthStyle
Defines various ways to horizontally bound the boxes returned by Paragraph.getBoxesForRange.
Brightness
Describes the contrast of a theme or color palette.
Clip
Different ways to clip a widget's content.
ClipOp
Defines how a new clip region should be merged with the existing clip region.
ColorSpace
The color space describes the colors that are available to an Image.
DartPerformanceMode
Various performance modes for tuning the Dart VM's GC performance.
DisplayFeatureState
State of the display feature, which contains information about the posture for foldable features.
DisplayFeatureType
Type of DisplayFeature, describing the DisplayFeature behaviour and if it obstructs the display.
FilterQuality
Quality levels for image sampling in ImageFilter and Shader objects that sample images and for Canvas operations that render images.
FontStyle
Whether to use the italic type variation of glyphs in the font.
FramePhase
Various important time points in the lifetime of a frame.
ImageByteFormat
The format in which image bytes should be returned when using Image.toByteData.
KeyEventDeviceType
The source device for the key event.
KeyEventType
The type of a key event.
PaintingStyle
Strategies for painting shapes and paths on a canvas.
PathFillType
Determines the winding rule that decides how the interior of a Path is calculated.
PathOperation
Strategies for combining paths.
PixelFormat
The format of pixel data given to decodeImageFromPixels.
PlaceholderAlignment
Where to vertically align the placeholder relative to the surrounding text.
PointerChange
How the pointer has changed since the last report.
PointerDeviceKind
The kind of pointer device.
PointerSignalKind
The kind of pointer signal event.
PointMode
Defines how a list of points is interpreted when drawing a set of points.
StrokeCap
Styles to use for line endings.
StrokeJoin
Styles to use for line segment joins.
TextAffinity
A way to disambiguate a TextPosition when its offset could match two different locations in the rendered string.
TextAlign
Whether and how to align text horizontally.
TextBaseline
A horizontal line used for aligning text.
TextDecorationStyle
The style in which to draw a text decoration
TextDirection
A direction in which text flows.
TextLeadingDistribution
How the "leading" is distributed over and under the text.
TileMode
Defines what happens at the edge of a gradient or the sampling of a source image in an ImageFilter.
VertexMode
Defines how a list of points is interpreted when drawing a set of triangles.

Typedefs

ChannelCallback = void Function(ByteData? data, PlatformMessageResponseCallback callback)
Signature for ChannelBuffers.setListener's callback argument.
DrainChannelCallback = Future<void> Function(ByteData? data, PlatformMessageResponseCallback callback)
Deprecated. Migrate to ChannelCallback instead.
ErrorCallback = bool Function(Object exception, StackTrace stackTrace)
Signature for PlatformDispatcher.onError.
FrameCallback = void Function(Duration duration)
Signature for PlatformDispatcher.onBeginFrame.
ImageDecoderCallback = void Function(Image result)
Callback signature for decodeImageFromList.
ImageEventCallback = void Function(Image image)
Signature for Image lifecycle events.
KeyDataCallback = bool Function(KeyData data)
Signature for PlatformDispatcher.onKeyData.
PictureEventCallback = void Function(Picture picture)
Signature for Picture lifecycle events.
PlatformMessageCallback = void Function(String name, ByteData? data, PlatformMessageResponseCallback? callback)
Deprecated. Migrate to ChannelBuffers.setListener instead.
PlatformMessageResponseCallback = void Function(ByteData? data)
Signature for responses to platform messages.
PointerDataPacketCallback = void Function(PointerDataPacket packet)
Signature for PlatformDispatcher.onPointerDataPacket.
SemanticsActionEventCallback = void Function(SemanticsActionEvent action)
Signature for PlatformDispatcher.onSemanticsActionEvent.
TargetImageSizeCallback = TargetImageSize Function(int intrinsicWidth, int intrinsicHeight)
Signature for a callback that determines the size to which an image should be decoded given its intrinsic size.
TimingsCallback = void Function(List<FrameTiming> timings)
Signature for PlatformDispatcher.onReportTimings.
VoidCallback = void Function()
Signature of callbacks that have no arguments and return no data.
WindowPadding = ViewPadding
Deprecated. Will be removed in a future version of Flutter.

Exceptions / Errors

PictureRasterizationException
An exception thrown by Canvas.drawImage and related methods when drawing an Image created via Picture.toImageSync that is in an invalid state.