Related
I using this library keyboard_actions to display Done button on above keyboard when on click on textfield. Now the issue is keyboard displays but done portion is overlapping/ Above on textfield although textfield is inside SingleChildScrollView. I want to put padding when keyboard appear so that i can see textfield. I have an attached screenshot so that you can understand.
TestPage.dart
class TestPage extends StatefulWidget {
const TestPage({Key? key}) : super(key: key);
#override
_TestPageState createState() => _TestPageState();
}
class _TestPageState extends State<TestPage> {
final TextEditingController mobileNumber = TextEditingController();
final _formKey = GlobalKey<FormState>();
final FocusNode _nodeText1 = FocusNode();
late bool _passwordVisible;
final TextEditingController firstName = TextEditingController();
final TextEditingController lastName = TextEditingController();
final TextEditingController password = TextEditingController();
final TextEditingController confirmPassword = TextEditingController();
String pWord = "";
List gender = ["Male", "Female"];
late String genderChoose;
KeyboardActionsConfig _buildConfig(BuildContext context) {
return KeyboardActionsConfig(
keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
keyboardBarColor: Colors.grey[200],
nextFocus: false,
actions: [
KeyboardActionsItem(
focusNode: _nodeText1,
),
],
);
}
_TestPageState();
#override
void initState() {
genderChoose = gender[0];
_passwordVisible = false;
super.initState();
}
#override
Widget build(BuildContext context) {
var height = MediaQuery.of(context).size.height;
var width = MediaQuery.of(context).size.width;
var box = GetStorage();
var lang = translator.activeLanguageCode;
return MediaQuery(
data: MediaQueryData.fromWindow(WidgetsBinding.instance!.window)
.copyWith(boldText: false, textScaleFactor: 1.0),
child: Scaffold(
backgroundColor: Colors.red,
appBar: AppBar(
backgroundColor: Colors.red,
elevation: 0,
),
body: KeyboardActions(
config: _buildConfig(context),
child: Stack(
children: [
Padding(
padding:
const EdgeInsets.only(top: 10.0, left: 10.0, right: 10.0),
child: Center(
child: SingleChildScrollView(
child: Form(
key: _formKey,
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(
left: 90.0, right: 90.0, top: 25.0),
child: Image.asset(
'images/aa.png',
color: Colors.white,
),
),
Padding(
padding: const EdgeInsets.only(
left: 15.0, right: 15.0, top: 20.0),
child: Card(
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 30.0),
child: Text(
'SIGN UP',
style: TextStyle(
color: Colors.red, fontSize: 24.0),
),
),
Padding(
padding: const EdgeInsets.only(
left: 20.0, right: 20.0, top: 15.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text('First name'),
Row(
children: const [],
)
],
),
),
Padding(
padding: const EdgeInsets.only(
left: 20.0, right: 20.0, top: 10.0),
child: Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(6),
border:
Border.all(color: Colors.grey)),
child: Padding(
padding: const EdgeInsets.only(
left: 5.0,
right: 5.0,
top: 12.0,
bottom: 12.0),
child: TextFormField(
keyboardType: TextInputType.text,
controller: firstName,
),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 20.0, right: 20.0, top: 15.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text('Last name'),
Row(
children: const [],
)
],
),
),
Padding(
padding: const EdgeInsets.only(
left: 20.0, right: 20.0, top: 10.0),
child: Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(6),
border:
Border.all(color: Colors.grey)),
child: Padding(
padding: const EdgeInsets.only(
left: 5.0,
right: 5.0,
top: 12.0,
bottom: 12.0),
child: TextFormField(
keyboardType: TextInputType.text,
controller: lastName),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 20.0, right: 20.0, top: 15.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text('Mobile Number'),
Row(
children: const [],
)
],
),
),
Padding(
padding: const EdgeInsets.only(
left: 20.0, right: 20.0, top: 10.0),
child: Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(6),
border:
Border.all(color: Colors.grey)),
child: Padding(
padding: const EdgeInsets.only(
left: 5.0,
right: 5.0,
top: 12.0,
bottom: 12.0),
child: TextFormField(
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.allow(
RegExp("[0-9]")),
],
keyboardType: TextInputType.number,
focusNode: _nodeText1,
controller: mobileNumber,
decoration: InputDecoration.collapsed(
fillColor: Colors.white,
hintText: "5xxxxxxxx",
hintStyle: TextStyle(
color:
TuxedoColor.bodyColor)),
),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 20.0, right: 20.0, top: 20.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text('Gender'),
Row(
children: const [],
)
],
),
),
Padding(
padding: const EdgeInsets.only(
left: 20.0, right: 20.0, top: 10.0),
child: Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(6),
border:
Border.all(color: Colors.grey)),
child: Padding(
padding: const EdgeInsets.only(
left: 5.0,
right: 5.0,
),
child: DropdownButton(
hint: const Text('Select Gender'),
value: genderChoose,
isExpanded: true,
underline: const SizedBox(),
icon:
const Icon(Icons.arrow_drop_down),
onChanged: (newValue) {
setState(() {
genderChoose = newValue as String;
});
},
items: gender.map((valueItem) {
return DropdownMenuItem(
value: valueItem,
child: Text(valueItem));
}).toList(),
),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 20.0, right: 20.0, top: 20.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text('Password'),
Row(
children: const [],
)
],
),
),
Padding(
padding: const EdgeInsets.only(
left: 20.0, right: 20.0, top: 10.0),
child: Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(6),
border:
Border.all(color: Colors.grey)),
child: Padding(
padding: const EdgeInsets.only(
left: 5.0,
right: 5.0,
top: 12.0,
bottom: 12.0),
child: Stack(
children: [
TextFormField(
keyboardType:
TextInputType.visiblePassword,
controller: password,
obscureText: !_passwordVisible,
decoration:
InputDecoration.collapsed(
fillColor: Colors.white,
hintText: "*******",
hintStyle: TextStyle(
color: TuxedoColor
.bodyColor)),
),
Positioned(
right: 0,
top: -10,
bottom: 0,
child: IconButton(
icon: Icon(
_passwordVisible
? Icons.visibility
: Icons.visibility_off,
),
onPressed: () {
setState(() {
_passwordVisible =
!_passwordVisible;
});
},
),
)
],
),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 20.0, right: 20.0, top: 20.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text('Confirm Password'),
Row(
children: const [],
)
],
),
),
Padding(
padding: const EdgeInsets.only(
left: 15.0, right: 15.0, top: 10.0),
child: Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(6),
border:
Border.all(color: Colors.grey)),
child: Padding(
padding: const EdgeInsets.only(
left: 5.0,
right: 5.0,
top: 12.0,
bottom: 12.0),
child: Stack(
children: [
TextFormField(
keyboardType:
TextInputType.visiblePassword,
validator: (value) {
if (value!.trim().isEmpty) {
return "This Field is required";
}
if (value != pWord) {
return "Confirmation password does not match with the entered password";
}
return null;
},
controller: confirmPassword,
obscureText: !_passwordVisible,
decoration:
InputDecoration.collapsed(
fillColor: Colors.white,
hintText:
"Confirm Password",
hintStyle: TextStyle(
color: Colors.grey)),
),
Positioned(
right: 0,
top: -10,
bottom: 0,
child: IconButton(
icon: Icon(
_passwordVisible
? Icons.visibility
: Icons.visibility_off,
),
onPressed: () {
setState(() {
_passwordVisible =
!_passwordVisible;
});
},
),
)
],
),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 20.0,
right: 20.0,
top: 20.0,
bottom: 30.0),
child: ConstrainedBox(
constraints: BoxConstraints.tightFor(
height: height * 0.060, width: width),
child: ElevatedButton(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all(
Colors.red),
),
onPressed: () {},
child: Text(
'SIGN UP ',
style: TextStyle(
fontSize: 16.0,
color: Colors.white),
),
),
),
),
Padding(
padding:
const EdgeInsets.only(bottom: 30.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Text(
'Already have account? ',
style: TextStyle(),
),
GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: Text(
'Sign in',
style: TextStyle(
color: Colors.red,
decoration:
TextDecoration.underline,
),
),
)
],
),
)
],
),
),
),
],
),
),
),
),
),
],
),
),
),
);
}
}
I have a sidebar containing different items to open different screens. But i am only able to make image and textview clickable not whole item.
_myDrawer() => Drawer(
child: Column(
children: <Widget>[
Expanded(
child: ListView(
// Important: Remove any padding from the ListView.
padding: EdgeInsets.zero,
children: <Widget>[
DrawerHeader(
child: _myDrawerHeader(),
decoration: BoxDecoration(
color: const Color(0xFF0ea0aa),
),
),
Container(
width: double.infinity,
child: GestureDetector(
onTap: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) {
return TermNCondition();
}));
},
child: Row(
children: <Widget>[
_drawerItem('images/ic_tc.png', 'Terms &
Conditions'),
_addDivider(Colors.grey)
],
))),
],
));
_drawerItem(String imagePath, String title) =>
Row(children: <Widget>[
Container(
padding: EdgeInsets.only(left: 12, right: 8, top: 10,
bottom: 10),
child: Image(
image: AssetImage(imagePath),
height: 22,
width: 22,
),
),
Container(
padding: EdgeInsets.only(left: 8, right: 8, top: 10, bottom:
10),
child: Text(
title,
style: _textStyle,
),
),
]);
_addDivider(Color color) => Padding(
padding: EdgeInsets.only(left: 12, right: 12),
child: Divider(
height: 1,
color: color,
),
);
Click on icon and text"Terms & Conditions" is working fine, but whole view is not clickable.enter image description here
You need to Wrap GestureDector with FittedBox. this widget helps you for scaling child to parent's size
_myDrawer() => Drawer(
child: Column(
children: <Widget>[
Expanded(
child: ListView(
// Important: Remove any padding from the ListView.
padding: EdgeInsets.zero,
children: <Widget>[
DrawerHeader(
child: _myDrawerHeader(),
decoration: BoxDecoration(
color: const Color(0xFF0ea0aa),
),
),
Container(
width: double.infinity,
child: GestureDetector(
onTap: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) {
return TermNCondition();
}));
},
child: FittedBox( //
fit: BoxFit.cover // here is the magic
child:Row(
children: <Widget>[
_drawerItem('images/ic_tc.png', 'Terms &
Conditions'),
_addDivider(Colors.grey)
],
))
)),
],
));
_drawerItem(String imagePath, String title) =>
Row(children: <Widget>[
Container(
padding: EdgeInsets.only(left: 12, right: 8, top: 10,
bottom: 10),
child: Image(
image: AssetImage(imagePath),
height: 22,
width: 22,
),
),
Container(
padding: EdgeInsets.only(left: 8, right: 8, top: 10, bottom:
10),
child: Text(
title,
style: _textStyle,
),
),
]);
_addDivider(Color color) => Padding(
padding: EdgeInsets.only(left: 12, right: 12),
child: Divider(
height: 1,
color: color,
),
);
For more information about this Widget, please look for docs here
you just have to change the order of container and GesterDetector. I tried and it is working pretty well.
GestureDetector(
onTap: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) {
return TermNCondition();
}));
},
child: Container(
width: double.infinity,
child: Row(
children: <Widget>[
_drawerItem('images/ic_tc.png', 'Terms &
Conditions'),
_addDivider(Colors.grey)
],
),
),
),
I am trying to use ListView.builder to display a horizontal list in a Stack but am encountering this weird bug when scrolling ListView if I set itemCount: 10. If I set itemCount: 20 the ListView scrolls like normal.
I have tested in the emulator (Galaxy Nexus 720x1280 android 5.0) and on a real device (Nokia 7 plus, android 9.0). How can I fix this?
class BugPage extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Stack(
children: <Widget>[
Positioned(
left: 20.0,
right: 20.0,
height: 60.0,
bottom: 70.0,
child: Row(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Expanded(
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 10, // Overflow when scroll.
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: const EdgeInsets.symmetric(
horizontal: 3.0,
),
child: Container(
width: 40.0,
height: 40.0,
color: Colors.red,
child: Center(child: Text("$index")),
),
);
},
),
),
SizedBox(width: 10.0),
FloatingActionButton(
backgroundColor: Colors.blue,
onPressed: () {},
child: new Icon(
Icons.add,
color: Colors.black,
),
),
],
),
),
],
),
),
);
}
}
Expected output:
Actual output:
And a video of the problem
I tried your code and run with bigger intemcount too without problems, but i have an advice, change the
SizedBox(width: 10.0)
for a padding around the button
Padding(
padding: const EdgeInsets.only(left: 10),
child: FloatingActionButton(
backgroundColor: Colors.blue,
onPressed: () {},
child: new Icon(
Icons.add,
color: Colors.black,
),
)
)
It seems like this bug appears in old flutter version after I updated to newest version everything is ok.
I have a textfield inside a function:
Container header(int position) {
return Container(
height: 50.0,
decoration: new BoxDecoration(
border: new Border.all(color: Colors.black, width: 0.75)),
padding:
new EdgeInsets.only(top: 7.5, bottom: 7.5, left: 20.0, right: 20.0),
child: new Container(
child: new Row(
children: <Widget>[
//MEAL TF
mealNameTextField(position),
//TIME TF
timeTextField(),
],
),
),
);}
mealNameTextField():
Container mealNameTextField(int position) {
return new Container(
width: 160.0,
alignment: Alignment.centerLeft,
child: new TextField(
textAlign: TextAlign.center,
decoration: InputDecoration(
contentPadding: EdgeInsets.all(8.0),
hintText: "Meal Name #${position.toString()}",
border: border(),
hintStyle: new TextStyle(fontSize: 16.0),
fillColor: colorBackgroundTable,
filled: true,
),
));}
This text field (the header function) is inside a listView:
child: new ListView.builder(
controller: scrollController,
physics: NeverScrollableScrollPhysics(),
scrollDirection: Axis.horizontal,
padding: EdgeInsets.only(top: 15.0, left: 20.0),
itemCount: numMeals,
key: key,
itemBuilder: (BuildContext context, int position) => Padding(
padding: new EdgeInsets.only(right: 20.0),
child: new Container(
width: 320.0,
color: Colors.blueAccent,
child: new ListView(
children: <Widget>[
new Container(
height: double.maxFinite,
color: colorBackground,
child: new ListView(
children: <Widget>[
header(position),
bodyListFood(),
new SizedBox(height: 12.0),
buttonAddFood(),
new SizedBox(height: 12.0),
nutriInfo(),
new SizedBox(height: 24.0)
],
))
],
),
But, when I change de value of textfield the following error appears:
https://i.imgur.com/oGhOwcz.png
This error only happens when texfield is inside of the listview. Outside it, works perfectly.
Hi friends how to set the text value dynamically I am using the JSON to get the data but when I refresh the data is populating and I am calling the JSON at initstate to per load before the page of the app starts sorry friends I don't know much about the flutter so please help me out about it please find the code below
String name, userimage, birth, c_id, email, mobile_number;
class Profile extends StatefulWidget {
#override
State<StatefulWidget> createState() {
Profile_Customer profile_customer() => Profile_Customer();
return profile_customer();
}
}
class Profile_Customer extends State<Profile> {
#override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: new Text('Profile'),
backgroundColor: primarycolor,
leading: new IconButton(
icon: new Icon(Icons.arrow_back),
onPressed: () {
Navigator.pushReplacement(
context,
new MaterialPageRoute(
builder: (context) => new HomeScreen()));
}),
),
body: new Builder(builder: (BuildContext context) {
return new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Container(
child: new Image.asset('assets/rural_post_logo.png',
fit: BoxFit.cover),
margin: EdgeInsets.only(bottom: 15.0),
),
new Container(
child: new CircleAvatar(
child: new Image.network(userimage,
width: 100.0, height: 100.0, fit: BoxFit.cover),
),
margin: EdgeInsets.only(top: 10.0),
alignment: Alignment(0.0, 0.0),
),
new Container(
child: new Text(name),
margin: EdgeInsets.only(top: 10.0),
),
new Container(
child: new Divider(
height: 2.0,
color: primarycolor,
),
margin: EdgeInsets.only(right: 10.0, left: 10.0, top: 10.0),
),
new Container(
child: new Text(
'Birth Date',
style: new TextStyle(
fontWeight: FontWeight.bold, fontSize: 16.0),
),
alignment: Alignment(-1.0, 0.0),
margin: EdgeInsets.only(top: 10.0, left: 10.0),
),
new Container(
child: new Text(birth),
alignment: Alignment(-1.0, 0.0),
margin: EdgeInsets.only(top: 10.0, left: 10.0),
),
new Container(
child: new Divider(
height: 2.0,
color: primarycolor,
),
margin: EdgeInsets.only(right: 10.0, left: 10.0, top: 10.0),
),
new Container(
child: new Text(
'Customer ID',
style: new TextStyle(
fontWeight: FontWeight.bold, fontSize: 16.0),
),
alignment: Alignment(-1.0, 0.0),
margin: EdgeInsets.only(top: 10.0, left: 10.0),
),
new Container(
child: new Text(c_id),
alignment: Alignment(-1.0, 0.0),
margin: EdgeInsets.only(top: 10.0, left: 10.0),
),
new Container(
child: new Divider(
height: 2.0,
color: primarycolor,
),
margin: EdgeInsets.only(right: 10.0, left: 10.0, top: 10.0),
),
new Container(
child: new Text(
'Email',
style: new TextStyle(
fontWeight: FontWeight.bold, fontSize: 16.0),
),
alignment: Alignment(-1.0, 0.0),
margin: EdgeInsets.only(top: 10.0, left: 10.0),
),
new Container(
child: new Text(email),
alignment: Alignment(-1.0, 0.0),
margin: EdgeInsets.only(top: 10.0, left: 10.0),
),
new Container(
child: new Divider(
height: 2.0,
color: primarycolor,
),
margin: EdgeInsets.only(right: 10.0, left: 10.0, top: 10.0),
),
new Container(
child: new Text(
'Mobile number',
style: new TextStyle(
fontWeight: FontWeight.bold, fontSize: 16.0),
),
alignment: Alignment(-1.0, 0.0),
margin: EdgeInsets.only(top: 10.0, left: 10.0),
),
new Container(
child: new Text(mobile_number),
alignment: Alignment(-1.0, 0.0),
margin: EdgeInsets.only(top: 10.0, left: 10.0),
),
new Container(
child: new RaisedButton(
onPressed: () {
Navigator.push(
context,
new MaterialPageRoute(
builder: (context) => new HomeScreen()));
},
color: secondarycolor,
shape: new RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(5.0)),
child: new Text('Update Profile',
style: new TextStyle(color: Colors.white)),
),
width: 300.0,
height: 40.0,
margin: EdgeInsets.only(top: 10.0),
)
],
);
}),
),
);
}
#override
void initState() {
super.initState();
profilejson();
}
}
void profilejson() async {
SharedPreferences pref = await SharedPreferences.getInstance();
var profile_url = url + "view_profile&userid=" + pref.getString('userid');
print(profile_url);
http.Response profileresponse = await http.get(profile_url);
var profile_response_json = json.decode(profileresponse.body);
name = profile_response_json['username'];
userimage = profile_response_json['image'];
birth = profile_response_json['dob'];
c_id = profile_response_json['customerid'];
email = profile_response_json['email'];
mobile_number = profile_response_json['phone'];
}
You can accomplish that with a StatefulWidget and setState to make the layout change on the go. As you already have the widget in your code you should simply call setState were you set your variables. Also the profilejson() should we within the state:
...
profilejson() async {
SharedPreferences pref = await SharedPreferences.getInstance();
var profile_url = url + "view_profile&userid=" + pref.getString('userid');
print(profile_url);
http.Response profileresponse = await http.get(profile_url);
var profile_response_json = json.decode(profileresponse.body);
// the variables you want the layout to be updated with
setState(() {
name = profile_response_json['username'];
userimage = profile_response_json['image'];
birth = profile_response_json['dob'];
c_id = profile_response_json['customerid'];
email = profile_response_json['email'];
mobile_number = profile_response_json['phone'];
})
}
#override
void initState() {
super.initState();
profilejson();
}
...
Full code:
String name, userimage, birth, c_id, email, mobile_number;
class Profile extends StatefulWidget {
#override
State<StatefulWidget> createState() {
Profile_Customer profile_customer() => Profile_Customer();
return profile_customer();
}
}
class Profile_Customer extends State<Profile> {
#override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: new Text('Profile'),
backgroundColor: primarycolor,
leading: new IconButton(
icon: new Icon(Icons.arrow_back),
onPressed: () {
Navigator.pushReplacement(
context,
new MaterialPageRoute(
builder: (context) => new HomeScreen()));
}),
),
body: email != null ? new Builder(builder: (BuildContext context) {
return new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Container(
child: new Image.asset('assets/rural_post_logo.png',
fit: BoxFit.cover),
margin: EdgeInsets.only(bottom: 15.0),
),
new Container(
child: new CircleAvatar(
child: new Image.network(userimage,
width: 100.0, height: 100.0, fit: BoxFit.cover),
),
margin: EdgeInsets.only(top: 10.0),
alignment: Alignment(0.0, 0.0),
),
new Container(
child: new Text(name),
margin: EdgeInsets.only(top: 10.0),
),
new Container(
child: new Divider(
height: 2.0,
color: primarycolor,
),
margin: EdgeInsets.only(right: 10.0, left: 10.0, top: 10.0),
),
new Container(
child: new Text(
'Birth Date',
style: new TextStyle(
fontWeight: FontWeight.bold, fontSize: 16.0),
),
alignment: Alignment(-1.0, 0.0),
margin: EdgeInsets.only(top: 10.0, left: 10.0),
),
new Container(
child: new Text(birth),
alignment: Alignment(-1.0, 0.0),
margin: EdgeInsets.only(top: 10.0, left: 10.0),
),
new Container(
child: new Divider(
height: 2.0,
color: primarycolor,
),
margin: EdgeInsets.only(right: 10.0, left: 10.0, top: 10.0),
),
new Container(
child: new Text(
'Customer ID',
style: new TextStyle(
fontWeight: FontWeight.bold, fontSize: 16.0),
),
alignment: Alignment(-1.0, 0.0),
margin: EdgeInsets.only(top: 10.0, left: 10.0),
),
new Container(
child: new Text(c_id),
alignment: Alignment(-1.0, 0.0),
margin: EdgeInsets.only(top: 10.0, left: 10.0),
),
new Container(
child: new Divider(
height: 2.0,
color: primarycolor,
),
margin: EdgeInsets.only(right: 10.0, left: 10.0, top: 10.0),
),
new Container(
child: new Text(
'Email',
style: new TextStyle(
fontWeight: FontWeight.bold, fontSize: 16.0),
),
alignment: Alignment(-1.0, 0.0),
margin: EdgeInsets.only(top: 10.0, left: 10.0),
),
new Container(
child: new Text(email),
alignment: Alignment(-1.0, 0.0),
margin: EdgeInsets.only(top: 10.0, left: 10.0),
),
new Container(
child: new Divider(
height: 2.0,
color: primarycolor,
),
margin: EdgeInsets.only(right: 10.0, left: 10.0, top: 10.0),
),
new Container(
child: new Text(
'Mobile number',
style: new TextStyle(
fontWeight: FontWeight.bold, fontSize: 16.0),
),
alignment: Alignment(-1.0, 0.0),
margin: EdgeInsets.only(top: 10.0, left: 10.0),
),
new Container(
child: new Text(mobile_number),
alignment: Alignment(-1.0, 0.0),
margin: EdgeInsets.only(top: 10.0, left: 10.0),
),
new Container(
child: new RaisedButton(
onPressed: () {
Navigator.push(
context,
new MaterialPageRoute(
builder: (context) => new HomeScreen()));
},
color: secondarycolor,
shape: new RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(5.0)),
child: new Text('Update Profile',
style: new TextStyle(color: Colors.white)),
),
width: 300.0,
height: 40.0,
margin: EdgeInsets.only(top: 10.0),
)
],
);
}) : new Center(child: new CircularProgressIndicator()),
),
);
}
profilejson() async {
SharedPreferences pref = await SharedPreferences.getInstance();
var profile_url = url + "view_profile&userid=" + pref.getString('userid');
print(profile_url);
http.Response profileresponse = await http.get(profile_url);
var profile_response_json = json.decode(profileresponse.body);
// the variables you want the layout to be updated with
setState(() {
name = profile_response_json['username'];
userimage = profile_response_json['image'];
birth = profile_response_json['dob'];
c_id = profile_response_json['customerid'];
email = profile_response_json['email'];
mobile_number = profile_response_json['phone'];
})
}
#override
void initState() {
super.initState();
profilejson();
}
}