Surface constructor

const Surface({
  1. double? width,
  2. double? height,
  3. EdgeInsets margin = const EdgeInsets.all(0),
  4. EdgeInsets padding = const EdgeInsets.all(0),
  5. Color? color,
  6. Color? baseColor,
  7. Gradient? gradient,
  8. Gradient? baseGradient,
  9. Shape shape = const Shape(),
  10. Peek peek = Peek.DEFAULT,
  11. TapSpec tapSpec = const TapSpec(),
  12. Filter filter = Filter.DEFAULT,
  13. Duration duration = const Duration(milliseconds: 500),
  14. Curve curve = Curves.easeIn,
  15. Widget? child,
  16. Clip clipBehavior = Clip.hardEdge,
  17. Key? key,
})

🌟 Surface

A shapeable, layered, intrinsincally animated container Widget offering convenient access to blurring ImageFilters, Material InkResponse, and HapticFeedback.

Property 🔲 Peek.alignment has hard-coded recognition of all nine Alignment geometries and will determine which side(s) receive a special border treatment according to property 🔲 Peek.ratio.

  • defaults at ratio: 2 which makes the 🔲 Peek.alignment sides twice as thick, but
  • these borders made be made thinner than the others by passing 0 > ratio > 1.

Considering:

  1. 🔰 Shape by 📐 CornerSpec
  2. 👆 TapSpec
  3. 🔛 padLayer initialized 📚 SurfaceLayer.MATERIAL for three effective container layers
  4. 👓 Filter passed as 👓 filterStyle and Map<SurfaceLayer, double> 📊 radiusMap
  5. duration & curve properties for intrinsic property-change animations;

A 🌟 Surface is robustly customizable and, watch out, could also be expensive.

If not initialized, then default as follows:

  • 🎨 color - Theme.of(context).colorScheme.surface.withOpacity(0.3)
  • 🎨 baseColor - Theme.of(context).colorScheme.primaryVariant.withOpacity(0.3)

❗ See Consideration in library surface.dart

Regarding 👓 Filter.filteredLayers and 📊 Filter.radiusMap values.


❓ Example

// Surface with a BASE that exposed more on bottom & right, (child set upper-left)
// with rounded corners and Theme fallback colors; is tappable with InkResponse
// (also Theme colors) but no vibration & `BouncyBall` splashFactory
final surface = Surface(
  peek: const Peek(
    alignment: Alignment.bottomRight,
    ratio: 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);