как сделать логин и зарегистрироваться в флаттере в SQLite в этом классе, когда я делаю запустить его, вызвать имя в employee.db
class LoginPage extends StatefulWidget {
final Employee employee;
LoginPage(this.employee);
@override
_LoginPageState createState() => new _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
TextEditingController _nameController = TextEditingController();
TextEditingController _ageController = TextEditingController();
List<Employee> items = new List();
DatabaseHelper db = new DatabaseHelper();
String path = "employees.db";
Employee respons;
void getUser(String user , String pass){
print("0000000000000000000000000000000000");
db.open().then((onValue){ db.getEmployee(1).then((onValue){
respons =onValue;
print(onValue);
}).catchError((onError){
print(onError);
}); }).catchError((onError){
print(onError);
});
}
String age = '12345';
String name = 'nssna17@gmail.com';
@override
void initState() {
super.initState();
_ageController = TextEditingController(text: widget.employee.age);
_nameController = TextEditingController(text: widget.employee.name);
age = widget.employee.age;
name = widget.employee.name;
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: Center(
child: ListView(
shrinkWrap: true,
padding: EdgeInsets.only(left: 24.0, right: 24.0),
children: <Widget>[
SizedBox(height: 48.0),
TextFormField(
controller: _nameController,
decoration: InputDecoration(
labelText: 'Enter Email:',
),
),
SizedBox(height: 8.0),
TextFormField(
controller: _ageController,
decoration: InputDecoration(
labelText: 'Enter Password:',
),
),
SizedBox(height: 24.0),
Padding(
padding: EdgeInsets.symmetric(vertical: 16.0),
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
// ignore: missing_return
onPressed: () {
setState(() {
ignore: unrelated_type_equality_checks
if( _nameController == name && _ageController == age) {
return ListViewEmployees();
}else{
return Text("erorr");
}
как сделать логин и зарегистрироваться в флаттере в SQLite в этом классехочу, чтобы я запустил его по имени employee.db
getUser(_nameController.text==name? null:_nameController.text,_ageController.text== age?null:_ageController.text);
getUser(_nameController.text==null?"nssna17@gmail.com":_nameController.text,_ageController.text==null?"12345":_ageController.text);{
return ListViewEmployees();
}
});
},
padding: EdgeInsets.all(12),
color: Colors.lightBlueAccent,
child: Text('Log In', style: TextStyle(color: Colors.white)),
),
),
Padding(
padding: EdgeInsets.symmetric(vertical: 16.0),
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
onPressed: () => null,
padding: EdgeInsets.all(12),
color: Colors.lightBlueAccent,
child: Text('Log In', style: TextStyle(color: Colors.white)),
),
),
// how make login and rgister in flutter in sqlite in this class wan i make run itis call the //name in employee.db
],
),
),
);
}
}