diff --git a/examples/flutter_login/lib/login/view/login_form.dart b/examples/flutter_login/lib/login/view/login_form.dart index 8118604034c..d3b15e3cc37 100644 --- a/examples/flutter_login/lib/login/view/login_form.dart +++ b/examples/flutter_login/lib/login/view/login_form.dart @@ -83,7 +83,7 @@ class _LoginButton extends StatelessWidget { Widget build(BuildContext context) { return BlocBuilder( builder: (context, state) { - return state.status.isInProgress + return state.status.isInProgressOrSuccess ? const CircularProgressIndicator() : ElevatedButton( key: const Key('loginForm_continue_raisedButton'), diff --git a/examples/flutter_login/test/login/view/login_form_test.dart b/examples/flutter_login/test/login/view/login_form_test.dart index 36bed5a16b9..244a5f50645 100644 --- a/examples/flutter_login/test/login/view/login_form_test.dart +++ b/examples/flutter_login/test/login/view/login_form_test.dart @@ -103,6 +103,25 @@ void main() { expect(find.byType(CircularProgressIndicator), findsOneWidget); }); + testWidgets('loading indicator is shown when status is submission success', + (tester) async { + when(() => loginBloc.state).thenReturn( + const LoginState(status: FormzSubmissionStatus.success), + ); + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: BlocProvider.value( + value: loginBloc, + child: LoginForm(), + ), + ), + ), + ); + expect(find.byType(ElevatedButton), findsNothing); + expect(find.byType(CircularProgressIndicator), findsOneWidget); + }); + testWidgets('continue button is enabled when status is validated', (tester) async { when(() => loginBloc.state).thenReturn(const LoginState(isValid: true));