我正在创建一个带有博客的电子商务应用程序。我正在使用 singlechildscrollview 来实现滚动功能。但是滚动不起作用。但是没有渲染溢出错误。
我正在使用 singlechildscrollview 来实现滚动功能。但是滚动不起作用。但是没有渲染溢出错误。
class ProfileEditScreen extends StatelessWidget {
static String navKey = 'ProfileEditScreen';
@override
Widget build(BuildContext context) {
final height = MediaQuery.of(context).size.height;
final width = MediaQuery.of(context).size.width;
return Scaffold(
body: SingleChildScrollView(
child: Container(
height: height,
width: width,
child: Stack(
alignment: Alignment.center,
children: [
// Done
Positioned(
top: height / 14,
right: width / 16,
child: InkWell(
onTap: () {
Navigator.pushNamed(context, PhotoScreen.navKey);
},
child: Text(
'Done',
style: GoogleFonts.poppins(
textStyle: txt1,
),
),
),
),
// Edit
Positioned(
top: height / 8,
child: RichText(
textAlign: TextAlign.center,
text: TextSpan(
text: 'Edit your\n',
style: txt2,
children: [
TextSpan(
text: 'Profile',
style: txt3,
),
],
),
),
),
// background photo
Positioned(
top: height / 3.3,
height: height / 4,
left: width / 16,
right: width / 16,
child: Container(
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(24),
gradient: RadialGradient(
center: Alignment.topRight,
radius: 2,
colors: [
Colorpalettes.gr1.withOpacity(0.5),
Colorpalettes.gr2.withOpacity(0.5),
Colorpalettes.gr3.withOpacity(0.5),
],
),
),
child: TextButton(
onPressed: () {},
style: ButtonStyle(
padding: MaterialStateProperty.all(
EdgeInsets.symmetric(horizontal: 18, vertical: 6)),
shape: MaterialStateProperty.all(StadiumBorder()),
backgroundColor: MaterialStateProperty.all(
Colorpalettes.clr2.withOpacity(0.5)),
),
child: Text(
'COVER IMAGE',
style: GoogleFonts.poppins(
textStyle: TextStyle(
color: Colorpalettes.clr3,
),
),
),
),
),
),
Positioned(
top: height / 2.1,
child: Container(
padding: EdgeInsets.all(18.0),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Color(0xffD4D7E0),
blurRadius: 5,
),
],
shape: BoxShape.circle,
color: Colors.white,
),
child: Image(
fit: BoxFit.contain,
image: AssetImage('images/person.png'),
),
),
),
// TextField1
Positioned(
top: height / 1.78,
left: width / 16,
right: width / 16,
height: height - (height / 1.78),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'NAME',
style: GoogleFonts.poppins(
textStyle: txt4,
),
),
TextField(
decoration: InputDecoration(
hintText: 'Type something',
hintStyle: GoogleFonts.poppins(
textStyle: txt5,
),
filled: true,
fillColor: Colorpalettes.clr4,
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide(
color: Colors.transparent,
width: 0,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide(
color: Colors.transparent,
width: 0,
),
),
),
),
Text(
'USER',
style: GoogleFonts.poppins(
textStyle: txt4,
),
),
TextField(
decoration: InputDecoration(
prefixIcon: Icon(Icons.alternate_email_rounded),
hintText: 'Type something',
hintStyle: GoogleFonts.poppins(
textStyle: txt5,
),
filled: true,
fillColor: Colorpalettes.clr4,
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide(
color: Colors.transparent,
width: 0,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide(
color: Colors.transparent,
width: 0,
),
),
),
),
Text(
'EMAIL',
style: GoogleFonts.poppins(
textStyle: txt4,
),
),
TextField(
decoration: InputDecoration(
hintText: 'Type something',
hintStyle: GoogleFonts.poppins(
textStyle: txt5,
),
filled: true,
fillColor: Colorpalettes.clr4,
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide(
color: Colors.transparent,
width: 0,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide(
color: Colors.transparent,
width: 0,
),
),
),
),
Text(
'SHORT BIO',
style: GoogleFonts.poppins(
textStyle: txt4,
),
),
TextField(
decoration: InputDecoration(
hintText: 'Type something',
hintStyle: GoogleFonts.poppins(
textStyle: txt5,
),
filled: true,
fillColor: Colorpalettes.clr4,
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide(
color: Colors.transparent,
width: 0,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide(
color: Colors.transparent,
width: 0,
),
),
),
),
],
),
),
// TextField2
// TextField3
],
),
),
),
);
}
}class ProfileEditScreen extends StatelessWidget {
static String navKey = 'ProfileEditScreen';
@override
Widget build(BuildContext context) {
final height = MediaQuery.of(context).size.height;
final width = MediaQuery.of(context).size.width;
return Scaffold(
body: SingleChildScrollView(
child: Container(
height: height,
width: width,
child: Stack(
alignment: Alignment.center,
children: [
// Done
Positioned(
top: height / 14,
right: width / 16,
child: InkWell(
onTap: () {
Navigator.pushNamed(context, PhotoScreen.navKey);
},
child: Text(
'Done',
style: GoogleFonts.poppins(
textStyle: txt1,
),
),
),
),
// Edit
Positioned(
top: height / 8,
child: RichText(
textAlign: TextAlign.center,
text: TextSpan(
text: 'Edit your\n',
style: txt2,
children: [
TextSpan(
text: 'Profile',
style: txt3,
),
],
),
),
),
// background photo
Positioned(
top: height / 3.3,
height: height / 4,
left: width / 16,
right: width / 16,
child: Container(
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(24),
gradient: RadialGradient(
center: Alignment.topRight,
radius: 2,
colors: [
Colorpalettes.gr1.withOpacity(0.5),
Colorpalettes.gr2.withOpacity(0.5),
Colorpalettes.gr3.withOpacity(0.5),
],
),
),
child: TextButton(
onPressed: () {},
style: ButtonStyle(
padding: MaterialStateProperty.all(
EdgeInsets.symmetric(horizontal: 18, vertical: 6)),
shape: MaterialStateProperty.all(StadiumBorder()),
backgroundColor: MaterialStateProperty.all(
Colorpalettes.clr2.withOpacity(0.5)),
),
child: Text(
'COVER IMAGE',
style: GoogleFonts.poppins(
textStyle: TextStyle(
color: Colorpalettes.clr3,
),
),
),
),
),
),
Positioned(
top: height / 2.1,
child: Container(
padding: EdgeInsets.all(18.0),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Color(0xffD4D7E0),
blurRadius: 5,
),
],
shape: BoxShape.circle,
color: Colors.white,
),
child: Image(
fit: BoxFit.contain,
image: AssetImage('images/person.png'),
),
),
),
// TextField1
Positioned(
top: height / 1.78,
left: width / 16,
right: width / 16,
height: height - (height / 1.78),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'NAME',
style: GoogleFonts.poppins(
textStyle: txt4,
),
),
TextField(
decoration: InputDecoration(
hintText: 'Type something',
hintStyle: GoogleFonts.poppins(
textStyle: txt5,
),
filled: true,
fillColor: Colorpalettes.clr4,
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide(
color: Colors.transparent,
width: 0,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide(
color: Colors.transparent,
width: 0,
),
),
),
),
Text(
'USER',
style: GoogleFonts.poppins(
textStyle: txt4,
),
),
TextField(
decoration: InputDecoration(
prefixIcon: Icon(Icons.alternate_email_rounded),
hintText: 'Type something',
hintStyle: GoogleFonts.poppins(
textStyle: txt5,
),
filled: true,
fillColor: Colorpalettes.clr4,
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide(
color: Colors.transparent,
width: 0,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide(
color: Colors.transparent,
width: 0,
),
),
),
),
Text(
'EMAIL',
style: GoogleFonts.poppins(
textStyle: txt4,
),
),
TextField(
decoration: InputDecoration(
hintText: 'Type something',
hintStyle: GoogleFonts.poppins(
textStyle: txt5,
),
filled: true,
fillColor: Colorpalettes.clr4,
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide(
color: Colors.transparent,
width: 0,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide(
color: Colors.transparent,
width: 0,
),
),
),
),
Text(
'SHORT BIO',
style: GoogleFonts.poppins(
textStyle: txt4,
),
),
TextField(
decoration: InputDecoration(
hintText: 'Type something',
hintStyle: GoogleFonts.poppins(
textStyle: txt5,
),
filled: true,
fillColor: Colorpalettes.clr4,
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide(
color: Colors.transparent,
width: 0,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(24),
borderSide: BorderSide(
color: Colors.transparent,
width: 0,
),
),
),
),
],
),
),
// TextField2
// TextField3
],
),
),
),
);
}
}
我什至尝试添加容器,但它不滚动