Skip to content

Commit 44badd1

Browse files
authored
Fix line numbers not aligning with lines (akvelon#307)
* Update gutter.dart * fix: scroll not following
1 parent f348b69 commit 44badd1

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

lib/src/code_field/code_field.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ class _CodeFieldState extends State<CodeField> {
506506
return GutterWidget(
507507
codeController: widget.controller,
508508
style: gutterStyle,
509+
scrollController: _numberScroll,
509510
);
510511
}
511512

lib/src/gutter/gutter.dart

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,24 @@ class GutterWidget extends StatelessWidget {
1919
const GutterWidget({
2020
required this.codeController,
2121
required this.style,
22+
required this.scrollController,
2223
});
2324

2425
final CodeController codeController;
2526
final GutterStyle style;
27+
final ScrollController? scrollController;
2628

2729
@override
2830
Widget build(BuildContext context) {
29-
return AnimatedBuilder(
30-
animation: codeController,
31-
builder: _buildOnChange,
31+
return Padding(
32+
padding: const EdgeInsets.symmetric(vertical: 16),
33+
child: SingleChildScrollView(
34+
controller: scrollController,
35+
child: AnimatedBuilder(
36+
animation: codeController,
37+
builder: _buildOnChange,
38+
),
39+
),
3240
);
3341
}
3442

@@ -66,7 +74,7 @@ class GutterWidget extends StatelessWidget {
6674
}
6775

6876
return Container(
69-
padding: EdgeInsets.only(top: 12, bottom: 12, right: style.margin),
77+
padding: EdgeInsets.only(right: style.margin),
7078
width: style.showLineNumbers ? gutterWidth : null,
7179
child: Table(
7280
columnWidths: {

0 commit comments

Comments
 (0)