I have the following text
// Flutter imports:
import 'package:flutter/material.dart';
@immutable
class StrokeText extends StatelessWidget {
final String text;
final Color color;
final Color strokeColor;
final double strokeWidth;
final TextAlign? textAlign;
final TextStyle? style;
final TextOverflow? overflow;
const StrokeText(
this.text, {
Key? key,
this.color = Colors.white,
this.strokeColor = Colors.black,
this.strokeWidth = 1,
this.textAlign,
this.style,
this.overflow,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Stack(
children: [
Text(
text,
overflow: overflow,
textAlign: textAlign,
style: TextStyle(
fontSize: style?.fontSize,
fontWeight: style?.fontWeight,
fontFamily: style?.fontFamily,
height: style?.height,
wordSpacing: style?.wordSpacing,
overflow: overflow,
foreground: Paint()
..strokeWidth = strokeWidth
..color = strokeColor
..style = PaintingStyle.stroke,
),
),
Text(
text,
overflow: overflow,
textAlign: textAlign,
style: TextStyle(
fontSize: style?.fontSize,
fontWeight: style?.fontWeight,
fontFamily: style?.fontFamily,
height: style?.height,
wordSpacing: style?.wordSpacing,
overflow: overflow,
foreground: Paint()..color = color,
),
),
],
);
}
}
But when it overflows, it the stoke seems to be cut off in certain parts
Where it normally show like this without overflow, which looks good
Example:
void main() {
runApp(
const MaterialApp(
home: TestPage(),
),
);
}
class TestPage extends StatefulWidget {
const TestPage({Key? key}) : super(key: key);
@override
State<TestPage> createState() => _TestPageState();
}
class _TestPageState extends State<TestPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
padding: const EdgeInsets.all(8.0),
width: 500,
height: 500,
color: Colors.red,
child: const Center(
child: StrokeText(
'ViQAQjlJXlaLeJMusUTNWAdjAkeTzneqAEbbIwCV',
overflow: TextOverflow.ellipsis,
strokeWidth: 4.0,
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.w700,
fontFamily: 'DePixel',
),
),
),
),
),
);
}
}

