Surface constructor
- double? width,
- double? height,
- EdgeInsets margin = const EdgeInsets.all(0),
- EdgeInsets padding = const EdgeInsets.all(0),
- Color? color,
- Color? baseColor,
- Gradient? gradient,
- Gradient? baseGradient,
- Shape shape = const Shape(),
- Peek peek = Peek.DEFAULT,
- TapSpec tapSpec = const TapSpec(),
- Filter filter = Filter.DEFAULT,
- Duration duration = const Duration(milliseconds: 500),
- Curve curve = Curves.easeIn,
- Widget? child,
- Clip clipBehavior = Clip.hardEdge,
- Key? key,
๐ Surface
A shapeable, layered, intrinsincally animated container Widget offering convenient access to blurring ImageFilters, Material InkResponse, and HapticFeedback.
Property ๐ฒ Peek.peekAlignment has hard-coded recognition of all nine Alignment geometries and will determine which side(s) receive a special border treatment according to property ๐ฒ Peek.peekRatio.
- defaults at
peekRatio: 2
which makes the ๐ฒ Peek.peekAlignment sides twice as thick, but - these borders made be made thinner than the others by passing
0 > peekRatio > 1
.
Considering:
- ๐ CornerSpec property
corners
and global ๐radius
; - ๐ TapSpec parameters
tappable
,onTap
,providesFeedback
&inkHighlightColor
,inkSplashColor
; - ๐
padLayer
initialized ๐ SurfaceLayer.MATERIAL for three effective container layers - ๐
SurfaceFilter
passed as ๐filterStyle
andMap<SurfaceLayer, double>
๐radiusMap
- duration & curve properties for intrinsic property-change animations;
A ๐ Surface is robustly customizable and, watch out, could also be expensive.
- If ๐ gradient or ๐ baseGradient is initialized, then respective ๐จ color or ๐จ baseColor parameter is ignored.
If not initialized, then default as follows:
-
If
corners
is passed ๐ CornerSpec.SQUARED then ๐radius
is ignored. -
If
corners
is passed ๐ CornerSpec.BEVELED thenbool
๐flipBevels
can mirror the cut corners horizontally. Ignored otherwise. -
Passing ๐ฒ Peek.peekRatio a value of
1
will negate any passed value topeekAlignment
. -
Similarly, passing
peekRatio
in the range0..1
will actually make the ๐ฒ Peek.peekAlignment aligned side(s) thinner than the others. -
By default ๐ TapSpec.tappable is true and ๐ TapSpec.providesFeedback is false.
- The former includes an InkResponse that calls ๐ TapSpec.onTap and the latter enables HapticFeedback.
โ CAUTION
With default ๐คนโโ๏ธ SurfaceFX ๐ง Fx.blurry
, only provide
๐ Filter.filteredLayers value for which you intend on
passing each relevant ๐ง Filter.radiusMap map parameter.
- Not only are the blurry BackdropFilters expensive, but the inheritance/ancestry behavior is strange.
- If all three filters are active via ๐ Filter.filteredLayers, passing
๐
baseRadius: 0
eliminates the remaining children filters, regardless of their passed ๐radius
.- This behavior can be worked-around by setting any parent ๐
Layer
'sradius
to just above0
, specificallyradius > (_MINIMUM_BLUR == 0.0003)
๐ BASE > ๐ MATERIAL > ๐ CHILD
- But in this case a different ๐
FilterSpec.filteredLayers
Set
should be passed anyway that only activates the correct ๐Layer
(s).
- This behavior can be worked-around by setting any parent ๐
Simple Example
// Surface with a border that's thicker on bottom & right, with rounded corners
final surface = Surface(
radius: 10,
peek: const Peek(
peekAlignment: Alignment.bottomRight,
peekRatio: 20,
),
);
Implementation
const Surface({
this.width,
this.height,
this.margin = const EdgeInsets.all(0),
this.padding = const EdgeInsets.all(0),
this.color,
this.baseColor,
this.gradient,
this.baseGradient,
this.shape = const Shape(),
this.peek = Peek.DEFAULT,
this.tapSpec = const TapSpec(),
this.filter = Filter.DEFAULT,
this.duration = const Duration(milliseconds: 500),
this.curve = Curves.easeIn,
this.child,
this.clipBehavior = Clip.hardEdge,
Key? key,
}) : super(key: key);