split file_viewer into focused sub-widgets

This commit is contained in:
2026-07-13 00:01:07 +02:00
parent 53bc6d5360
commit 2f5a6b4ce0
6 changed files with 512 additions and 479 deletions
+48
View File
@@ -0,0 +1,48 @@
import 'package:flutter/material.dart';
/// A single line of the text/code viewer: a right-aligned, non-selectable line
/// number gutter plus the selectable line content, with zebra striping.
class CodeLine extends StatelessWidget {
final int number;
final String text;
final double gutterWidth;
const CodeLine({
super.key,
required this.number,
required this.text,
required this.gutterWidth,
});
static const TextStyle _codeStyle = TextStyle(
fontFamily: 'monospace',
fontSize: 13,
height: 1.4,
);
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final isEven = number.isEven;
return Container(
color: isEven ? theme.colorScheme.surfaceContainerLow : null,
padding: const EdgeInsets.only(left: 4, right: 12),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SelectionContainer.disabled(
child: SizedBox(
width: gutterWidth,
child: Text(
'$number',
textAlign: TextAlign.right,
style: _codeStyle.copyWith(color: theme.hintColor),
),
),
),
const SizedBox(width: 8),
Expanded(child: Text(text.isEmpty ? ' ' : text, style: _codeStyle)),
],
),
);
}
}