Skip to content

Commit 7b5a816

Browse files
committedAug 28, 2022
first commit
1 parent 8f3e3bf commit 7b5a816

5 files changed

+69
-97
lines changed
 

‎analysis_options.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ linter:
2222
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
2323
# producing the lint.
2424
rules:
25-
prefer_const_constructors: false
26-
use_key_in_widget_constructors: false
27-
avoid_print: false # Uncomment to disable the `avoid_print` rule
25+
# prefer_const_constructors: false
26+
# use_key_in_widget_constructors: false
27+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
2828
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
2929

3030
# Additional information about this file can be found at

‎lib/main.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import '/screens/login_screen.dart';
21
import 'package:firebase_core/firebase_core.dart';
32
import 'package:flutter/material.dart';
3+
import '/screens/login_screen.dart';
44

55
Future<void> main() async {
66
WidgetsFlutterBinding.ensureInitialized();
77
await Firebase.initializeApp();
88

9-
runApp(MyApp());
9+
runApp(const MyApp());
1010
}
1111

1212
class MyApp extends StatelessWidget {
@@ -20,7 +20,7 @@ class MyApp extends StatelessWidget {
2020
theme: ThemeData(
2121
primarySwatch: Colors.red,
2222
),
23-
home: LoginScreen(),
23+
home: const LoginScreen(),
2424
);
2525
}
2626
}

‎lib/screens/home_screen.dart

+13-21
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
// ignore_for_file: use_build_context_synchronously, library_private_types_in_public_api, unnecessary_this
1+
// ignore_for_file: unnecessary_this, use_build_context_synchronously
22

33
import 'package:cloud_firestore/cloud_firestore.dart';
4-
import '/model/user_model.dart';
54
import 'package:firebase_auth/firebase_auth.dart';
65
import 'package:flutter/material.dart';
76
import '/screens/login_screen.dart';
7+
import '/model/user_model.dart';
88

99
class HomeScreen extends StatefulWidget {
1010
const HomeScreen({Key? key}) : super(key: key);
1111

1212
@override
13-
_HomeScreenState createState() => _HomeScreenState();
13+
State<HomeScreen> createState() => _HomeScreenState();
1414
}
1515

1616
class _HomeScreenState extends State<HomeScreen> {
@@ -34,15 +34,13 @@ class _HomeScreenState extends State<HomeScreen> {
3434
Widget build(BuildContext context) {
3535
return Scaffold(
3636
appBar: AppBar(
37-
elevation: 0,
38-
title: Text(
39-
"Welcome",
40-
),
37+
title: const Text("Welcome"),
4138
centerTitle: true,
39+
elevation: 0,
4240
),
4341
body: Center(
4442
child: Padding(
45-
padding: EdgeInsets.all(20),
43+
padding: const EdgeInsets.all(20),
4644
child: Column(
4745
mainAxisAlignment: MainAxisAlignment.center,
4846
crossAxisAlignment: CrossAxisAlignment.center,
@@ -54,37 +52,31 @@ class _HomeScreenState extends State<HomeScreen> {
5452
fit: BoxFit.contain,
5553
),
5654
),
57-
Text(
55+
const Text(
5856
"Welcome Back",
5957
style: TextStyle(
6058
fontSize: 20,
6159
fontWeight: FontWeight.bold,
6260
),
6361
),
64-
SizedBox(
65-
height: 10,
66-
),
62+
const SizedBox(height: 10),
6763
Text(
6864
"${loggedInUser.firstName} ${loggedInUser.secondName}",
69-
style: TextStyle(
65+
style: const TextStyle(
7066
color: Colors.black54,
7167
fontWeight: FontWeight.w500,
7268
),
7369
),
7470
Text(
7571
"${loggedInUser.email}",
76-
style: TextStyle(
72+
style: const TextStyle(
7773
color: Colors.black54,
7874
fontWeight: FontWeight.w500,
7975
),
8076
),
81-
SizedBox(
82-
height: 15,
83-
),
77+
const SizedBox(height: 15),
8478
ActionChip(
85-
label: Text(
86-
"Logout",
87-
),
79+
label: const Text("Logout"),
8880
onPressed: () {
8981
logout(context);
9082
},
@@ -102,7 +94,7 @@ class _HomeScreenState extends State<HomeScreen> {
10294
await FirebaseAuth.instance.signOut();
10395
Navigator.of(context).pushReplacement(
10496
MaterialPageRoute(
105-
builder: (context) => LoginScreen(),
97+
builder: (context) => const LoginScreen(),
10698
),
10799
);
108100
}

‎lib/screens/login_screen.dart

+20-29
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
// ignore_for_file: unnecessary_new, library_private_types_in_public_api
1+
// ignore_for_file: unnecessary_new, avoid_print
22

3-
import '/screens/home_screen.dart';
4-
import '/screens/registration_screen.dart';
53
import 'package:firebase_auth/firebase_auth.dart';
64
import 'package:flutter/material.dart';
75
import 'package:fluttertoast/fluttertoast.dart';
6+
import '/screens/home_screen.dart';
7+
import '/screens/registration_screen.dart';
88

99
class LoginScreen extends StatefulWidget {
1010
const LoginScreen({Key? key}) : super(key: key);
1111

1212
@override
13-
_LoginScreenState createState() => _LoginScreenState();
13+
State<LoginScreen> createState() => _LoginScreenState();
1414
}
1515

1616
class _LoginScreenState extends State<LoginScreen> {
@@ -53,8 +53,8 @@ class _LoginScreenState extends State<LoginScreen> {
5353
},
5454
textInputAction: TextInputAction.next,
5555
decoration: InputDecoration(
56-
prefixIcon: Icon(Icons.mail),
57-
contentPadding: EdgeInsets.fromLTRB(20, 15, 20, 15),
56+
prefixIcon: const Icon(Icons.mail),
57+
contentPadding: const EdgeInsets.fromLTRB(20, 15, 20, 15),
5858
hintText: "Email",
5959
border: OutlineInputBorder(
6060
borderRadius: BorderRadius.circular(10),
@@ -83,8 +83,8 @@ class _LoginScreenState extends State<LoginScreen> {
8383
},
8484
textInputAction: TextInputAction.done,
8585
decoration: InputDecoration(
86-
prefixIcon: Icon(Icons.vpn_key),
87-
contentPadding: EdgeInsets.fromLTRB(20, 15, 20, 15),
86+
prefixIcon: const Icon(Icons.vpn_key),
87+
contentPadding: const EdgeInsets.fromLTRB(20, 15, 20, 15),
8888
hintText: "Password",
8989
border: OutlineInputBorder(
9090
borderRadius: BorderRadius.circular(10),
@@ -99,12 +99,12 @@ class _LoginScreenState extends State<LoginScreen> {
9999
borderRadius: BorderRadius.circular(30),
100100
color: Colors.redAccent,
101101
child: MaterialButton(
102-
padding: EdgeInsets.fromLTRB(20, 15, 20, 15),
102+
padding: const EdgeInsets.fromLTRB(20, 15, 20, 15),
103103
minWidth: MediaQuery.of(context).size.width,
104104
onPressed: () {
105105
signIn(emailController.text, passwordController.text);
106106
},
107-
child: Text(
107+
child: const Text(
108108
"Login",
109109
textAlign: TextAlign.center,
110110
style: TextStyle(
@@ -123,7 +123,7 @@ class _LoginScreenState extends State<LoginScreen> {
123123
child: Container(
124124
color: Colors.white,
125125
child: Padding(
126-
padding: EdgeInsets.all(36.0),
126+
padding: const EdgeInsets.all(36),
127127
child: Form(
128128
key: _formKey,
129129
child: Column(
@@ -137,37 +137,28 @@ class _LoginScreenState extends State<LoginScreen> {
137137
fit: BoxFit.contain,
138138
),
139139
),
140-
SizedBox(
141-
height: 45,
142-
),
140+
const SizedBox(height: 45),
143141
emailField,
144-
SizedBox(
145-
height: 25,
146-
),
142+
const SizedBox(height: 25),
147143
passwordField,
148-
SizedBox(
149-
height: 35,
150-
),
144+
const SizedBox(height: 35),
151145
loginButton,
152-
SizedBox(
153-
height: 15,
154-
),
146+
const SizedBox(height: 15),
155147
Row(
156148
mainAxisAlignment: MainAxisAlignment.center,
157149
children: [
158-
Text(
159-
"Don't have an account? ",
160-
),
150+
const Text("Don't have an account? "),
161151
GestureDetector(
162152
onTap: () {
163153
Navigator.push(
164154
context,
165155
MaterialPageRoute(
166-
builder: (context) => RegistrationScreen(),
156+
builder: (context) =>
157+
const RegistrationScreen(),
167158
),
168159
);
169160
},
170-
child: Text(
161+
child: const Text(
171162
"SignUp",
172163
style: TextStyle(
173164
color: Colors.redAccent,
@@ -200,7 +191,7 @@ class _LoginScreenState extends State<LoginScreen> {
200191
Fluttertoast.showToast(msg: "Login Successful"),
201192
Navigator.of(context).pushReplacement(
202193
MaterialPageRoute(
203-
builder: (context) => HomeScreen(),
194+
builder: (context) => const HomeScreen(),
204195
),
205196
),
206197
},

‎lib/screens/registration_screen.dart

+30-41
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
// ignore_for_file: unnecessary_new, library_private_types_in_public_api
1+
// ignore_for_file: unnecessary_new, avoid_print
22

33
import 'package:cloud_firestore/cloud_firestore.dart';
4-
import '/model/user_model.dart';
5-
import '/screens/home_screen.dart';
64
import 'package:firebase_auth/firebase_auth.dart';
75
import 'package:flutter/material.dart';
86
import 'package:fluttertoast/fluttertoast.dart';
7+
import '/model/user_model.dart';
8+
import '/screens/home_screen.dart';
99

1010
class RegistrationScreen extends StatefulWidget {
1111
const RegistrationScreen({Key? key}) : super(key: key);
1212

1313
@override
14-
_RegistrationScreenState createState() => _RegistrationScreenState();
14+
State<RegistrationScreen> createState() => _RegistrationScreenState();
1515
}
1616

1717
class _RegistrationScreenState extends State<RegistrationScreen> {
@@ -58,8 +58,8 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
5858
},
5959
textInputAction: TextInputAction.next,
6060
decoration: InputDecoration(
61-
prefixIcon: Icon(Icons.account_circle),
62-
contentPadding: EdgeInsets.fromLTRB(20, 15, 20, 15),
61+
prefixIcon: const Icon(Icons.account_circle),
62+
contentPadding: const EdgeInsets.fromLTRB(20, 15, 20, 15),
6363
hintText: "First Name",
6464
border: OutlineInputBorder(
6565
borderRadius: BorderRadius.circular(10),
@@ -84,8 +84,8 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
8484
},
8585
textInputAction: TextInputAction.next,
8686
decoration: InputDecoration(
87-
prefixIcon: Icon(Icons.account_circle),
88-
contentPadding: EdgeInsets.fromLTRB(20, 15, 20, 15),
87+
prefixIcon: const Icon(Icons.account_circle),
88+
contentPadding: const EdgeInsets.fromLTRB(20, 15, 20, 15),
8989
hintText: "Second Name",
9090
border: OutlineInputBorder(
9191
borderRadius: BorderRadius.circular(10),
@@ -113,8 +113,8 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
113113
},
114114
textInputAction: TextInputAction.next,
115115
decoration: InputDecoration(
116-
prefixIcon: Icon(Icons.mail),
117-
contentPadding: EdgeInsets.fromLTRB(20, 15, 20, 15),
116+
prefixIcon: const Icon(Icons.mail),
117+
contentPadding: const EdgeInsets.fromLTRB(20, 15, 20, 15),
118118
hintText: "Email",
119119
border: OutlineInputBorder(
120120
borderRadius: BorderRadius.circular(10),
@@ -143,8 +143,8 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
143143
},
144144
textInputAction: TextInputAction.next,
145145
decoration: InputDecoration(
146-
prefixIcon: Icon(Icons.vpn_key),
147-
contentPadding: EdgeInsets.fromLTRB(20, 15, 20, 15),
146+
prefixIcon: const Icon(Icons.vpn_key),
147+
contentPadding: const EdgeInsets.fromLTRB(20, 15, 20, 15),
148148
hintText: "Password",
149149
border: OutlineInputBorder(
150150
borderRadius: BorderRadius.circular(10),
@@ -170,8 +170,8 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
170170
},
171171
textInputAction: TextInputAction.done,
172172
decoration: InputDecoration(
173-
prefixIcon: Icon(Icons.vpn_key),
174-
contentPadding: EdgeInsets.fromLTRB(20, 15, 20, 15),
173+
prefixIcon: const Icon(Icons.vpn_key),
174+
contentPadding: const EdgeInsets.fromLTRB(20, 15, 20, 15),
175175
hintText: "Confirm Password",
176176
border: OutlineInputBorder(
177177
borderRadius: BorderRadius.circular(10),
@@ -186,12 +186,15 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
186186
borderRadius: BorderRadius.circular(30),
187187
color: Colors.redAccent,
188188
child: MaterialButton(
189-
padding: EdgeInsets.fromLTRB(20, 15, 20, 15),
189+
padding: const EdgeInsets.fromLTRB(20, 15, 20, 15),
190190
minWidth: MediaQuery.of(context).size.width,
191191
onPressed: () {
192-
signUp(emailEditingController.text, passwordEditingController.text);
192+
signUp(
193+
emailEditingController.text,
194+
passwordEditingController.text,
195+
);
193196
},
194-
child: Text(
197+
child: const Text(
195198
"SignUp",
196199
textAlign: TextAlign.center,
197200
style: TextStyle(
@@ -209,7 +212,7 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
209212
elevation: 0,
210213
backgroundColor: Colors.transparent,
211214
leading: IconButton(
212-
icon: Icon(
215+
icon: const Icon(
213216
Icons.arrow_back,
214217
color: Colors.red,
215218
),
@@ -223,7 +226,7 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
223226
child: Container(
224227
color: Colors.white,
225228
child: Padding(
226-
padding: EdgeInsets.all(36.0),
229+
padding: const EdgeInsets.all(36.0),
227230
child: Form(
228231
key: _formKey,
229232
child: Column(
@@ -237,33 +240,19 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
237240
fit: BoxFit.contain,
238241
),
239242
),
240-
SizedBox(
241-
height: 45,
242-
),
243+
const SizedBox(height: 45),
243244
firstNameField,
244-
SizedBox(
245-
height: 20,
246-
),
245+
const SizedBox(height: 20),
247246
secondNameField,
248-
SizedBox(
249-
height: 20,
250-
),
247+
const SizedBox(height: 20),
251248
emailField,
252-
SizedBox(
253-
height: 20,
254-
),
249+
const SizedBox(height: 20),
255250
passwordField,
256-
SizedBox(
257-
height: 20,
258-
),
251+
const SizedBox(height: 20),
259252
confirmPasswordField,
260-
SizedBox(
261-
height: 20,
262-
),
253+
const SizedBox(height: 20),
263254
signUpButton,
264-
SizedBox(
265-
height: 15,
266-
),
255+
const SizedBox(height: 15),
267256
],
268257
),
269258
),
@@ -342,7 +331,7 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
342331
Navigator.pushAndRemoveUntil(
343332
(context),
344333
MaterialPageRoute(
345-
builder: (context) => HomeScreen(),
334+
builder: (context) => const HomeScreen(),
346335
),
347336
(route) => false);
348337
}

0 commit comments

Comments
 (0)
Please sign in to comment.