build method
Describes the part of the user interface represented by this widget.
The framework calls this method when this widget is inserted into the tree in a given BuildContext and when the dependencies of this widget change.
Implementation
@override
Widget build(BuildContext context) {
SingleChildRenderObjectWidget overlayWidget;
switch (editableItem.type) {
case ItemType.TEXT:
overlayWidget = SizedBox(
width: context.width - 72,
child: Stack(
children: [
Center(
child: Text(
editableItem.value,
textAlign: TextAlign.center,
style: GoogleFonts.getFont(
fontFamilyList[editableItem.fontFamily],
).copyWith(
color: editableItem.color,
fontSize: editableItem.fontSize,
background: Paint()
..strokeWidth = 24
..shader = createShader(
colors: gradientColors[editableItem.textStyle],
width: context.width,
height: context.height,
)
..style = PaintingStyle.stroke
..strokeJoin = StrokeJoin.round,
),
),
),
Center(
child: GestureDetector(
onTap: onItemTap,
child: Text(
editableItem.value,
textAlign: TextAlign.center,
style: GoogleFonts.getFont(
fontFamilyList[editableItem.fontFamily],
).copyWith(
color: editableItem.color,
fontSize: editableItem.fontSize,
background: Paint()
..shader = createShader(
colors: gradientColors[editableItem.textStyle],
width: context.width,
height: context.height,
),
),
),
),
),
],
),
);
case ItemType.IMAGE:
overlayWidget = const Center();
}
return Positioned(
top: editableItem.position.dy * context.height,
left: editableItem.position.dx * context.width,
child: Transform.scale(
scale: editableItem.scale,
child: Transform.rotate(
angle: editableItem.rotation,
child: Listener(
onPointerDown: onPointerDown,
onPointerUp: onPointerUp,
onPointerCancel: (details) {},
onPointerMove: onPointerMove,
child: overlayWidget,
),
),
),
);
}