@@ -268,30 +268,28 @@ void main() {
268
268
maxHeight: 40 ,
269
269
);
270
270
271
- double getTextBottom () {
272
- return tester.getBottomRight (find.byType (SuperTextField )).dy;
273
- }
274
-
275
- double getViewportBottom () {
276
- return tester.getBottomRight (find.byType (SuperText )).dy;
277
- }
278
-
279
271
// Ensure the text field has not yet scrolled.
280
- expect (getTextBottom (), lessThan (getViewportBottom ()));
272
+ var textBottom = tester.getBottomRight (find.byType (SuperTextField )).dy;
273
+ var viewportBottom = tester.getBottomRight (find.byType (SuperText )).dy;
274
+ expect (textBottom, lessThan (viewportBottom));
281
275
282
276
// Scroll down to reveal the last line of text.
283
277
await tester.drag (find.byType (SuperTextField ), const Offset (0 , - 1000.0 ));
284
278
await tester.pumpAndSettle ();
285
279
286
280
// Ensure the text field has scrolled to the bottom.
287
- expect (getTextBottom (), equals (getViewportBottom ()));
281
+ textBottom = tester.getBottomRight (find.byType (SuperTextField )).dy;
282
+ viewportBottom = tester.getBottomRight (find.byType (SuperText )).dy;
283
+ expect (textBottom, moreOrLessEquals (viewportBottom));
288
284
289
285
// Scroll back up to the top of the text field.
290
286
await tester.drag (find.byType (SuperTextField ), const Offset (0 , 1000.0 ));
291
287
await tester.pumpAndSettle ();
292
288
293
289
// Ensure the text field has scrolled back to the top.
294
- expect (getTextBottom (), lessThan (getViewportBottom ()));
290
+ textBottom = tester.getBottomRight (find.byType (SuperTextField )).dy;
291
+ viewportBottom = tester.getBottomRight (find.byType (SuperText )).dy;
292
+ expect (textBottom, lessThan (viewportBottom));
295
293
});
296
294
297
295
testWidgetsOnDesktop ("multi-line is vertically scrollable when text spans more lines than maxLines" , (tester) async {
@@ -312,16 +310,10 @@ void main() {
312
310
maxHeight: 40 ,
313
311
);
314
312
315
- double getTextBottom () {
316
- return tester.getBottomRight (find.byType (SuperTextField )).dy;
317
- }
318
-
319
- double getViewportBottom () {
320
- return tester.getBottomRight (find.byType (SuperText )).dy;
321
- }
322
-
323
313
// Ensure the text field has not yet scrolled.
324
- expect (getTextBottom (), lessThan (getViewportBottom ()));
314
+ var textBottom = tester.getBottomRight (find.byType (SuperTextField )).dy;
315
+ var viewportBottom = tester.getBottomRight (find.byType (SuperText )).dy;
316
+ expect (textBottom, lessThan (viewportBottom));
325
317
326
318
// Scroll down to reveal the last line of text.
327
319
await tester.drag (
@@ -332,7 +324,9 @@ void main() {
332
324
await tester.pumpAndSettle ();
333
325
334
326
// Ensure the text field has scrolled to the bottom.
335
- expect (getTextBottom (), equals (getViewportBottom ()));
327
+ textBottom = tester.getBottomRight (find.byType (SuperTextField )).dy;
328
+ viewportBottom = tester.getBottomRight (find.byType (SuperText )).dy;
329
+ expect (textBottom, moreOrLessEquals (viewportBottom));
336
330
337
331
// Scroll back up to the top of the text field.
338
332
await tester.drag (
@@ -343,7 +337,9 @@ void main() {
343
337
await tester.pumpAndSettle ();
344
338
345
339
// Ensure the text field has scrolled back to the top.
346
- expect (getTextBottom (), lessThan (getViewportBottom ()));
340
+ textBottom = tester.getBottomRight (find.byType (SuperTextField )).dy;
341
+ viewportBottom = tester.getBottomRight (find.byType (SuperText )).dy;
342
+ expect (textBottom, lessThan (viewportBottom));
347
343
});
348
344
});
349
345
}
0 commit comments