-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.dart
130 lines (110 loc) · 4.15 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:furnitureshop/SecondPage.dart';
import 'register.dart';
import 'auth.dart';
import 'routes.dart';
class FirstPage extends StatefulWidget {
@override
_FirstPageState createState() => _FirstPageState();
}
class _FirstPageState extends State<FirstPage> {
final _formkey=GlobalKey<FormState>();
AuthService _auth=AuthService();
//Register r=Register();
String email=" ";
//email=r.createState();
String password=" ";
String error=" ";
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Scaffold(
appBar:AppBar(title: Text("Login"),
backgroundColor: Colors.pinkAccent,),
body:Container(
decoration:BoxDecoration(
image:DecorationImage(
//image:NetworkImage('https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcSGBu2B9Q2vkY7ZujovEz9AWysHLF5P4aXmROWcSj2fANHGTMie&usqp=CAU'),
image: NetworkImage('https://images.fineartamerica.com/images-medium-large-5/2-grey-and-brown-abstract-art-painting-carollynn-tice.jpg'),
),
),
//mainAxisAlignment:MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,
//children: <Widget>[
child:Form(
key:_formkey,
child:Column(
children:<Widget>
[
Text('Username' ,
style: new TextStyle(
color:Colors.black ,
fontSize: 30.0,
backgroundColor: Colors.pink,)
),
Padding(
padding:const EdgeInsets.all(8.0),
child:
TextFormField(
//validator: (val)=>val=val.isEmpty?'Enter valid email':null,
onChanged:(val){
setState(()=>email=val);{
}
},
decoration: InputDecoration(
labelText: 'Enter your username'
),
),
),
Text('Password' ,
style: new TextStyle(
color:Colors.black ,
fontSize: 30.0,
backgroundColor: Colors.pink,)
),
Padding(
padding:const EdgeInsets.all(8.0),
child:
TextFormField(
// validator: (val)=>val=val.length<=6?null:'password should not be greater than 5',
onChanged:(val){
setState(()=>password=val);{
}
},
obscureText: true,
decoration: InputDecoration(
labelText: 'Enter password'
),
),
),
FlatButton( splashColor:Colors.pinkAccent,highlightColor:Colors.yellowAccent,onPressed: () async {
//if(_formkey.currentState.validate()){
dynamic result= await _auth.signInEmailAndPass(email,password);
//dynamic result= await _auth.signInEmailAndPassword(email, password);
if(result==null){
setState(()=>error="not a registered user");
}
else{
Navigator.pushNamed(context,'/SecondPage');
}
//}
},
// icon: Icon(Icons.assignment_turned_in),
child:Text('SignIn'),
),
Text(error,
style: new TextStyle(color:Colors.red),),
Text('No account?,sign up here', style: new TextStyle(color:Colors.red),),
FlatButton( splashColor:Colors.pinkAccent,highlightColor:Colors.yellowAccent,onPressed: (){
Navigator.pushNamed(context, '/RegisterPage');
},
child:Text('SignUp'),
),
],
),
),
),
);
}
}