gpt4 book ai didi

dart - 如何在 Flutter 测试中模拟 TextField 上的按 ENTER

转载 作者:IT老高 更新时间:2023-10-28 12:44:53 31 4
gpt4 key购买 nike

鉴于 tester.enterText 将允许我在 flutter 测试中在 TextField 上输入文本,我将如何模拟按下 DONE android 键盘上的键或在文本字段内按我的键盘上的 ENTER

这也相当于检查是否按下了 IOS/android 键盘上的 DONE 按钮

最佳答案

我在 flutter repo 测试中找到了实现@ https://github.com/flutter/flutter/blob/7e445a17324ee7e615ef2c886d0cb9407853f338/packages/flutter/test/widgets/editable_text_test.dart#L558 :

例如:await tester.testTextInput.receiveAction(TextInputAction.done);

// example
await tester.enterText(find.byKey(new Key('txtFieldKey')), 'Hello World!');
await tester.testTextInput.receiveAction(TextInputAction.done);
await tester.pump();

关于dart - 如何在 Flutter 测试中模拟 TextField 上的按 ENTER,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54538603/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com