build method
SubtitleView
SubtitleView widget is used to display the subtitles on top of the Video.
Implementation
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
// Calculate the visible text scale factor.
final nr = (constraints.maxWidth * constraints.maxHeight);
const dr =
kTextScaleFactorReferenceWidth * kTextScaleFactorReferenceHeight;
final textScaleFactor = sqrt((nr / dr).clamp(0.0, 1.0));
final textScaler = widget.configuration.textScaler ??
TextScaler.linear(textScaleFactor);
return Material(
color: Colors.transparent,
child: AnimatedContainer(
padding: padding,
duration: duration,
alignment: Alignment.bottomCenter,
child: Text(
[
for (final line in subtitle)
if (line.trim().isNotEmpty) line.trim(),
].join('\n'),
style: widget.configuration.style,
textAlign: widget.configuration.textAlign,
textScaler: textScaler,
),
),
);
},
);
}