Closed KennethMurugu closed 1 year ago
I am attempting to find the PinCodeTextField by key and then setting its text value.
PinCodeTextField in my screen
PinCodeTextField( key: Key('otp-field'), animationType: AnimationType.scale, keyboardType: TextInputType.number, appContext: context, autoFocus: true, validator: (value) { if (value!.length < 6) { return 'Please enter a valid OTP'; } return null; }, errorTextSpace: 20, pinTheme: PinTheme( shape: PinCodeFieldShape.box, borderRadius: BorderRadius.circular(8), fieldHeight: 50, fieldWidth: 40, errorBorderColor: Theme.of(context).colorScheme.error, activeFillColor: Theme.of(context).colorScheme.secondary, selectedFillColor: Theme.of(context).colorScheme.primary, selectedColor: Theme.of(context).colorScheme.primary, activeColor: Theme.of(context).colorScheme.secondary, inactiveColor: Theme.of(context).dividerColor, ), length: 6, onCompleted: (value) { //onCompleted }, onChanged: (value) { }, ),
Widget test code
// ... Finder findExpect(String key, {bool many = false}) { var finder = find.byKey(ValueKey(key)); expect(finder, many ? findsWidgets : findsOneWidget); return finder; } // ... var fieldOtp = findExpect('otp-field'); await tester.tap(fieldOtp); await tester.pumpAndSettle(); await tester.enterText(fieldOtp, '000111'); await tester.pumpAndSettle();
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I am attempting to find the PinCodeTextField by key and then setting its text value.
PinCodeTextField in my screen
Widget test code