I am creating a profile and I want the text to be modified from Center to the start. I used mainAxisAlignment: MainAxisAlignment.start,crossAxisAlignment: CrossAxisAlignment.start,
but no help, this was the outcome:
Here it’s the code:
import 'package:flutter/material.dart';
class EditProfileBPage extends StatefulWidget {
@override
EditProfileBState createState() => EditProfileBState();
}
class EditProfileBState extends State<EditProfileBPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: Padding(
padding: EdgeInsets.only(top: 60),
child: Column(children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
BackButton(),
Text('Edit profile',
style: TextStyle(fontWeight: FontWeight.bold))
],
),
SizedBox(
height: 30,
),
Padding(
padding: const EdgeInsets.all(15.0),
child: Text(
'Keep your personal details private.Information you add here is visible to anyoane who can view your profile.',
style: TextStyle(color: Colors.grey, fontSize: 15),
),
),
SizedBox(
height: 10,
),
Center(
child: CircleAvatar(
radius: 60,
backgroundColor: Colors.white,
child: CircleAvatar(
radius: 46,
backgroundColor: Colors.grey.shade100,
child: Text('Pic')))),
FilledButton(
child: Text(
'EDIT AVATAR',
style: TextStyle(fontWeight: FontWeight.bold),
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => EditProfileBPage()));
},
style: ButtonStyle(
backgroundColor: MaterialStatePropertyAll(
Colors.black,
),
foregroundColor: MaterialStatePropertyAll(
Colors.white,
),
),
),
SizedBox(
height: 10,
),
Center(
child: Padding(
padding: const EdgeInsets.all(13.0),
child: Image.asset('assets/coverphoto.png'),
)),
FilledButton(
child: Text(
'EDIT COVER PHOTO',
style: TextStyle(fontWeight: FontWeight.bold),
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => EditProfileBPage()));
},
style: ButtonStyle(
backgroundColor: MaterialStatePropertyAll(
Colors.black,
),
foregroundColor: MaterialStatePropertyAll(
Colors.white,
),
),
),
SizedBox(
height: 10,
),
Padding(
padding: EdgeInsets.all(10),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Name',
style: TextStyle(fontSize: 15),
),
SizedBox(
height: 10,
),
Text(
'Name Influencer',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18),
),
SizedBox(
height: 10,
),
Text(
'Username',
style: TextStyle(fontSize: 15),
),
SizedBox(
height: 10,
),
Text(
'Username Influencer',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18),
),
]),
),
])));
}
}
I also want to add all the widgets and text under edit profile in a scrollview but I don’t know how , I want to be scrollable , and edit profile to be in the center ( not next to the back button)
2
Answers
Set this
crossAxisAlignment: CrossAxisAlignment.start
for both columns. The top column do not have any alignment set. You can also usecrossAxisAlignment: CrossAxisAlignment.stretch
to stretch elements horizontally to fill.And for making title in appbar center they set
centerTitle
property astrue
in AppBar.And to make this scrollable use custom scrollview Or you can just simply wrap the Top column with
SingleChildScrollView
try this:
just add the
crossAxisAlignment: CrossAxisAlignment.start
in the mainColumn
, and wrap all the other widgets you want to be in the center of the screen withCenter
widget.here is the result:
let me know if it helped