line method

String line({
  1. required String text,
  2. required String fill,
  3. required int longText,
})

Implementation

String line(
    {required String text, required String fill, required int longText}) {
  final fillCount = longText - text.length;
  List<String> left = List.generate(fillCount ~/ 2, (index) => fill);
  List<String> right =
      List.generate(fillCount - left.length, (index) => fill);
  // final left = List.filled(fillCount ~/ 2, fill);
  // final right = List.filled(fillCount - left.length, fill);
  return left.join() + text + right.join();
}