You can use Stack with fake placeholder for time (or another info) on first layer and real positioned text on the second layer.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | class CustomCard extends StatelessWidget { final String msg; final String additionalInfo; CustomCard({ @required this.msg, this.additionalInfo = "" }); @override Widget build(BuildContext context) { return Card( child: Stack( children: <Widget>[ Padding( padding: const EdgeInsets.all(8.0), child: RichText( text: TextSpan( children: <TextSpan>[ //real message TextSpan( text: msg + " ", style: Theme.of(context).textTheme.subtitle, ), //fake additionalInfo as placeholder TextSpan( text: additionalInfo, style: TextStyle( color: Color.fromRGBO(255, 255, 255, 1) ) ), ], ), ), ), //real additionalInfo Positioned( child: Text( additionalInfo, style: TextStyle( fontSize: 12.0, ), ), right: 8.0, bottom: 4.0, ) ], ), ); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.