Here is my code in android studio(Windows system)
How to solve this, I have used singlechildscrollview but getting RenderFlex children have non-zero
error......?
also I have wrapped with widget but same issue........?
Below is my code:
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
fontFamily: 'ubuntu',
),
home: MyHomePage(),
routes: {
'/MainPage' : (context)=>MainPage(),
},
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: purple,
body: SingleChildScrollView(
child: Column(
children: [
Container(
width: 100,
height: 50,
margin: EdgeInsets.only(top: 40),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('asset/image/logo.png')
)
),
),
SizedBox(height: 30,),
Text("Clean Home\nClean Life", style: TextStyle(
fontSize: 40,
color: Colors.white,
fontWeight: FontWeight.w900
),textAlign: TextAlign.center,),
SizedBox(height: 30,),
Text("Book Cleans At The Comfort \nOf Your Home", style: TextStyle(
fontSize: 18,
color: Colors.white,
fontWeight: FontWeight.w400,
), textAlign: TextAlign.center,),
SizedBox(height: 60,),
Container(
height: 350,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('asset/image/splash.png'),
fit: BoxFit.cover
)
),
),
Expanded(
child: Container(),
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
InkWell(
onTap: openMainPage,
child: Container(
padding: EdgeInsets.symmetric(horizontal: 60, vertical: 30),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(topLeft: Radius.circular(20)),
color: Colors.white
),
child: Text('Continue..', style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w600,
color: purple
),),
),
)
],
)
],
),
),
);
}
void openMainPage()
{
Navigator.pushNamed(context, '/MainPage');
}
}
........
To make content scrollable it must overflow the viewport height. As you use Expanded
before Row
so your Column
is expanded to the maximum height and there is nothing to scroll. If you remove Expanded
from Container
and set for thos Container
height (eg.500.0) than your content will overflow the view port and become scrollable.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
fontFamily: 'ubuntu',
),
home: MyHomePage(),
// routes: {
// '/MainPage' : (context)=>MainPage(),
// },
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.purple,
body: SingleChildScrollView(
child: Column(
children: [
Container(
width: 100,
height: 50,
margin: EdgeInsets.only(top: 40),
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
'https://2.bp.blogspot.com/-3VnKmSv5FXg/XCc1YFehs-I/AAAAAAAAPt4/zxnpIVoYSvQFGtIVeNqTILDsCaIg8Ql-wCLcBGAs/s1600/Mirillis%2B-%2BSplash%2BPremium%2BFull%2Bversion.png'))),
),
SizedBox(
height: 30,
),
Text(
"Clean Home\nClean Life",
style: TextStyle(
fontSize: 40,
color: Colors.white,
fontWeight: FontWeight.w900),
textAlign: TextAlign.center,
),
SizedBox(
height: 30,
),
Text(
"Book Cleans At The Comfort \nOf Your Home",
style: TextStyle(
fontSize: 18,
color: Colors.white,
fontWeight: FontWeight.w400,
),
textAlign: TextAlign.center,
),
SizedBox(
height: 60,
),
Container(
height: 350,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
'https://2.bp.blogspot.com/-3VnKmSv5FXg/XCc1YFehs-I/AAAAAAAAPt4/zxnpIVoYSvQFGtIVeNqTILDsCaIg8Ql-wCLcBGAs/s1600/Mirillis%2B-%2BSplash%2BPremium%2BFull%2Bversion.png'),
fit: BoxFit.cover)),
),
//! Comment this
// Expanded(
// child: Container(),
// ),
//! Add height here
Container(
height: 500,
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
InkWell(
onTap: openMainPage,
child: Container(
padding: EdgeInsets.symmetric(horizontal: 60, vertical: 30),
decoration: BoxDecoration(
borderRadius:
BorderRadius.only(topLeft: Radius.circular(20)),
color: Colors.white),
child: Text(
'Continue..',
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w600,
color: Colors.purple),
),
),
)
],
)
],
),
),
);
}
void openMainPage() {
Navigator.pushNamed(context, '/MainPage');
}
}
PS I replaced AssetImage
with NetworkImage
because I have no your images.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.