mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fix OutlineInputBorder crash (#30123)
This commit is contained in:
parent
d639883c5b
commit
14aa57b18d
@ -412,7 +412,7 @@ class OutlineInputBorder extends InputBorder {
|
||||
|
||||
const double cornerArcSweep = math.pi / 2.0;
|
||||
final double tlCornerArcSweep = start < center.tlRadiusX
|
||||
? math.asin(start / center.tlRadiusX)
|
||||
? math.asin((start / center.tlRadiusX).clamp(-1.0, 1.0))
|
||||
: math.pi / 2.0;
|
||||
|
||||
final Path path = Path()
|
||||
@ -474,12 +474,12 @@ class OutlineInputBorder extends InputBorder {
|
||||
final double extent = lerpDouble(0.0, gapExtent + gapPadding * 2.0, gapPercentage);
|
||||
switch (textDirection) {
|
||||
case TextDirection.rtl: {
|
||||
final Path path = _gapBorderPath(canvas, center, gapStart + gapPadding - extent, extent);
|
||||
final Path path = _gapBorderPath(canvas, center, math.max(0.0, gapStart + gapPadding - extent), extent);
|
||||
canvas.drawPath(path, paint);
|
||||
break;
|
||||
}
|
||||
case TextDirection.ltr: {
|
||||
final Path path = _gapBorderPath(canvas, center, gapStart - gapPadding, extent);
|
||||
final Path path = _gapBorderPath(canvas, center, math.max(0.0, gapStart - gapPadding), extent);
|
||||
canvas.drawPath(path, paint);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@ -2255,6 +2256,41 @@ void main() {
|
||||
expect(getBorderRadius(tester), BorderRadius.zero);
|
||||
});
|
||||
|
||||
testWidgets('OutlineInputBorder async lerp', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/28724
|
||||
|
||||
final Completer<void> completer = Completer<void>();
|
||||
bool waitIsOver = false;
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
setState(() { waitIsOver = true; });
|
||||
await completer.future;
|
||||
setState(() { waitIsOver = false; });
|
||||
},
|
||||
child: InputDecorator(
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Test',
|
||||
enabledBorder: !waitIsOver ? null : const OutlineInputBorder(borderSide: BorderSide(color: Colors.blue)),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.byType(StatefulBuilder));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
completer.complete();
|
||||
await tester.pumpAndSettle();
|
||||
});
|
||||
|
||||
test('InputBorder equality', () {
|
||||
// OutlineInputBorder's equality is defined by the borderRadius, borderSide, & gapPadding
|
||||
const OutlineInputBorder outlineInputBorder = OutlineInputBorder(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user