Skip to content

Instantly share code, notes, and snippets.

@perymerdeka
Created July 13, 2021 04:07
Show Gist options
  • Save perymerdeka/6dc0d140594e97e0f85d6fc3d9a32149 to your computer and use it in GitHub Desktop.
Save perymerdeka/6dc0d140594e97e0f85d6fc3d9a32149 to your computer and use it in GitHub Desktop.
// login page dart
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Container(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height,
maxWidth: MediaQuery.of(context).size.width),
decoration: BoxDecoration(
color: Colors.white,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
flex: 2,
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 36.0, horizontal: 24.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
color: Colors.blue, shape: BoxShape.rectangle),
child: Image.asset('assets/logo.png')),
SizedBox(height: 10.0),
Text(
"Elekronik Pemantauan Indikator Kinerja",
style: TextStyle(fontSize: 18),
)
],
),
),
),
Expanded(
flex: 5,
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
),
child: Padding(
padding: EdgeInsets.all(24.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
TextField(
controller: nikController,
keyboardType: TextInputType.number,
decoration:
InputDecoration(filled: true, hintText: "NIK"),
),
SizedBox(
height: 20.0,
),
TextField(
controller: kodePelatihanController,
keyboardType: TextInputType.text,
decoration: InputDecoration(
filled: true, hintText: "Kode Pelatihan"),
),
SizedBox(height: 35.0),
Container(
width: double.infinity,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colorsys.orange),
onPressed: () {
if (userModel == null ||
userModel!.data == null) {
UserModel.getLoginData(
nik: nikController.text,
kodePelatihan:
kodePelatihanController.text,
apiUrl: apiUrl)
.then((value) {
userModel = value;
MySharedPreferences.instance.setStringValue(
key: 'token',
value: userModel!
.data!.attributes!.token
.toString());
setState(() {});
MySharedPreferences.instance
.getStringValue(key: 'token')
.then((value) {
setState(() {
print('current active token: ' +
value.toString());
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => Home()));
});
});
}).catchError((error) {
print('error Found: ' + error.toString());
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
NotfoundPage()));
});
}
},
child: Text(
"Masuk",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16.0),
),
),
),
SizedBox(
height: 25.0,
),
Image.asset('assets/images/logo_kementan.png'),
SizedBox(
height: 10.5,
),
Text(
"PUSLATAN",
style: TextStyle(
fontWeight: FontWeight.w800, fontSize: 19.0),
textAlign: TextAlign.center,
),
Text("BPPSDMP - KEMENTAN",
style: TextStyle(
fontWeight: FontWeight.w800, fontSize: 19.0),
textAlign: TextAlign.center),
Text("@2021",
style: TextStyle(
fontWeight: FontWeight.w800, fontSize: 19.0),
textAlign: TextAlign.center)
],
),
)),
)
],
),
),
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment