Chat perf: path-free running border, keystroke- and delta-quiet composer, spinners that do not relayout their list
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/status/app_spinner.dart';
|
||||
|
||||
@@ -17,4 +18,65 @@ void main() {
|
||||
expect(indicator.strokeWidth, 2);
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
});
|
||||
|
||||
testWidgets('a spinning row does not lay its list out again every frame', (
|
||||
tester,
|
||||
) async {
|
||||
final layouts = <int>[0];
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: ListView(
|
||||
children: [
|
||||
for (var i = 0; i < 3; i++)
|
||||
_LayoutCount(
|
||||
layouts: layouts,
|
||||
// A list row that picks its layout from its width, as
|
||||
// AppListRow does.
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) => Row(
|
||||
children: [
|
||||
if (i == 1)
|
||||
const SizedBox.square(
|
||||
dimension: 12,
|
||||
child: AppSpinner(strokeWidth: 2),
|
||||
),
|
||||
Text('row $i'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
final before = layouts[0];
|
||||
for (var frame = 0; frame < 10; frame++) {
|
||||
await tester.pump(const Duration(milliseconds: 16));
|
||||
}
|
||||
expect(layouts[0], before);
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
});
|
||||
}
|
||||
|
||||
/// Counts the layouts of a list row.
|
||||
class _LayoutCount extends SingleChildRenderObjectWidget {
|
||||
const _LayoutCount({required this.layouts, required super.child});
|
||||
|
||||
final List<int> layouts;
|
||||
|
||||
@override
|
||||
RenderObject createRenderObject(BuildContext context) =>
|
||||
_RenderLayoutCount(layouts);
|
||||
}
|
||||
|
||||
class _RenderLayoutCount extends RenderProxyBox {
|
||||
_RenderLayoutCount(this.layouts);
|
||||
|
||||
final List<int> layouts;
|
||||
|
||||
@override
|
||||
void performLayout() {
|
||||
layouts[0]++;
|
||||
super.performLayout();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user