Skip to content

Commit 444099e

Browse files
committed
fix suggestions
1 parent 0d86fb4 commit 444099e

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

app/lib/presentation/resources/dim.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ class Dimen {
88
static const loadingSpinnerSizeS = 16.0;
99

1010
static const double loginFormMaxWidth = 400.0;
11-
static const double loginFormMaxHeight = 400.0;
12-
static const double loginFormMinHeight = 200.0;
1311

1412
static const spacingXxs = 2.0;
1513
static const spacingXs = 4.0;

app/lib/presentation/ui/pages/auth/login/login_form.dart

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:app/main/init.dart';
21
import 'package:app/presentation/resources/locale/generated/l10n.dart';
32
import 'package:app/presentation/resources/resources.dart';
43
import 'package:app/presentation/ui/components/primary_button.dart';
@@ -17,14 +16,19 @@ class LoginForm extends StatefulWidget {
1716
}
1817

1918
class _LoginFormState extends State<LoginForm> {
20-
AuthCubit get _authCubit => getIt();
21-
2219
TextEditingController emailController = TextEditingController();
2320
TextEditingController passwordController = TextEditingController();
2421
bool agreeToTerms = false;
2522

2623
final _formKey = GlobalKey<FormState>();
2724

25+
@override
26+
void dispose() {
27+
emailController.dispose();
28+
passwordController.dispose();
29+
super.dispose();
30+
}
31+
2832
@override
2933
Widget build(BuildContext context) {
3034
return Form(
@@ -50,10 +54,6 @@ class _LoginFormState extends State<LoginForm> {
5054
keyboardType: TextInputType.emailAddress,
5155
controller: emailController,
5256
validator: (value) {
53-
if (value == null || value.isEmpty) {
54-
return S.of(context).errorEmailRequired;
55-
}
56-
5757
if (!FormValidator.isEmail(value)) {
5858
return S.of(context).errorEmailInvalid;
5959
}
@@ -69,10 +69,6 @@ class _LoginFormState extends State<LoginForm> {
6969
obscureText: true,
7070
controller: passwordController,
7171
validator: (value) {
72-
if (value == null || value.isEmpty) {
73-
return S.of(context).errorPasswordRequired;
74-
}
75-
7672
if (!FormValidator.isStrongPassword(value)) {
7773
return S.of(context).errorPasswordWeak;
7874
}
@@ -135,11 +131,12 @@ class _LoginFormState extends State<LoginForm> {
135131
PrimaryButton(
136132
label: S.of(context).ctaLogin,
137133
onPressed: () {
138-
if (_formKey.currentState?.validate() ?? false) {
139-
_authCubit.login(
140-
email: emailController.text,
141-
password: passwordController.text,
142-
);
134+
if ((_formKey.currentState?.validate() ?? false) &&
135+
agreeToTerms) {
136+
context.read<AuthCubit>().login(
137+
email: emailController.text,
138+
password: passwordController.text,
139+
);
143140
}
144141
},
145142
isEnabled: agreeToTerms,

0 commit comments

Comments
 (0)