import 'package:flutter_login/flutter_login.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'register.dart'; import 'package:http/http.dart' as http; class ProfilePage extends StatefulWidget{ ProfilePage({Key key, this.title}) : super(key: key); final String title; @override _ProfilePageState createState() => _ProfilePageState(); } class _ProfilePageState extends State{ TextEditingController first_name = new TextEditingController(); TextEditingController last_name = new TextEditingController() ; TextEditingController country = new TextEditingController(); TextEditingController city = new TextEditingController(); TextEditingController phone = new TextEditingController(); TextEditingController healthcare = new TextEditingController(); // trying to create a an array of controllers // final List controllers = List(); // controllers.add(first_name); Future clear_controllers() async { first_name.text = ""; last_name.text = ""; country.text = ""; city.text = ""; phone.text = ""; healthcare.text = ""; } _Notice(BuildContext context, String message, int r, int g, int b){ showDialog( context: context, barrierDismissible: false, barrierColor: Colors.transparent, builder: (BuildContext context){ Future.delayed(Duration(seconds: 3), () { Navigator.of(context).pop(true); }); return Material( color: Colors.transparent, child: InkResponse( child: Container( alignment: Alignment.bottomCenter, padding: EdgeInsets.only(bottom: 130), child: Text( message, style: TextStyle(fontSize: 20, color: Color.fromARGB(255, r, g, b)),), ), ) ); } ); } Future send_data() async { var url = 'https://ada.uprrp.edu/~hector.sierra/FastMed/UpdateProfile.php'; final data = await http.post(url, body: { "first_name": first_name.text, "last_name": last_name.text, "country": country.text, "city": city.text, "phone": phone.text, "healthcare": healthcare.text, }); print(data.body); if("User not registered" == data.body){ _Notice(context, "Error, unable to update profile", 255, 0, 0); } else{ _Notice(context, "Profile Updated", 0, 255, 0); } } Widget _BackButton(BuildContext context) { return InkWell( onTap: () { Navigator.pop(context); }, child: Row( children: [ Container( padding: EdgeInsets.only(left: 0, top: 10, bottom: 10), child: Icon(Icons.arrow_back_ios, color: Colors.black), ), Text("Back", style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500)) ] ), ); } Widget _SubmitButton(BuildContext context) { return InkResponse( onTap: () { send_data(); // clear_controllers(); }, child: Material( borderRadius: BorderRadius.circular(30), elevation: 3, child: Container( padding: EdgeInsets.symmetric(vertical: 10), width: 250, alignment: Alignment.center, decoration: BoxDecoration( color: Colors.red, borderRadius: BorderRadius.circular(30), ), child: Text( "Update", style: TextStyle(fontSize: 22, color: Colors.white), ), ), ), ); } Widget _Fills() { return Column( children: [ _EntryField("First Name", first_name), _EntryField("Last Name", last_name), _EntryField("Country", country), _EntryField("City", city), _EntryField("Phone Number", phone), _EntryField("Healthcare Provider", healthcare), ] ); } Widget _EntryField(String title, TextEditingController controller, {bool pass = false}) { return Container( padding: EdgeInsets.only(left: 0, top: 10, bottom: 10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( title, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), ), SizedBox( height: 30 ), TextField( controller: controller, obscureText: pass, decoration: InputDecoration( border: ( UnderlineInputBorder() ), ), ) ] ), ); } @override Widget build(BuildContext context) { final height = MediaQuery.of(context).size.height; return Scaffold( body: Container( height: height, child: Stack( children: [ Container( padding: EdgeInsets.symmetric(horizontal: 20), child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( height: 60, ), _Fills(), //Add code to verify if password and confirm password match SizedBox( height: 80, ), _SubmitButton(context), SizedBox( height: 50, ), // ElevatedButton( // onPressed: send_data, child: Text("Register")), ], ), ) ), // Positioned( // top: 15, left: 20, child: _BackButton(context), // ), ], ), ) ); } }