Exception caught by rendering library
RenderBox was not laid out: RenderSemanticsGestureHandler#5a90d relayoutBoundary=up8 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
‘package:flutter/src/rendering/box.dart’:
Failed assertion: line 1972 pos 12: ‘hasSize’
The relevant error-causing widget was:
Exception caught by gestures library
Cannot hit test a render box with no size.
double deviceHeight = MediaQuery.of(context).size.height;
return Scaffold(
backgroundColor: const Color(0xFF101d25),
body: Center(
child: Container(
height: deviceHeight,
color: const Color(0xFF101d25),
child: Column(
children: [
const Padding(
padding: EdgeInsets.only(top: 110),
child: Text(
'Welcome to WhatsApp',
style: TextStyle(
fontSize: 35,
color: Colors.white,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
),
Padding(
padding: const EdgeInsets.only(top: 70, bottom: 70),
child: Expanded(
child: SizedBox(
child: Image.asset(
'images/image_whatsapp.jpg',
height: 260,
width: 260,
),
),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 22),
child: RichText(
textAlign: TextAlign.center,
text: TextSpan(children: [
const TextSpan(
text: 'Read our ',
style: TextStyle(color: Colors.white, fontSize: 16)),
TextSpan(
text: 'Privicy Police',
style:
const TextStyle(color: Colors.blue, fontSize: 16),
recognizer: TapGestureRecognizer()
..onTap = () {
// print('CLICK TAP ');
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Privicy Police'),
content: const Text(
'This is a test to show a Alert dialog...'),
actions: <Widget>[
TextButton(
child: const Text('Agree'),
onPressed: () {
Navigator.of(context).pop();
},
),
TextButton(
child: const Text('Disagree'),
onPressed: () {
Navigator.of(context).pop();
},
)
],
);
});
}),
const TextSpan(
text: ' Tap "Agree and continue" to accept the ',
style: TextStyle(color: Colors.white, fontSize: 16),
),
TextSpan(
text: 'Terms of Service',
style:
const TextStyle(color: Colors.blue, fontSize: 16),
recognizer: TapGestureRecognizer()
..onTap = () {
//print('CLICK AGREE');
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Terms of Service'),
content: const Text(
'This is a test to show a Alert dialog...'),
actions: <Widget>[
TextButton(
child: const Text('Agree'),
onPressed: () {
Navigator.of(context).pop();
},
),
TextButton(
child: const Text('Disagree'),
onPressed: () {
Navigator.of(context).pop();
},
)
],
);
});
}),
const TextSpan(
text: '.',
style: TextStyle(color: Colors.white, fontSize: 16),
),
]),
),
),
const SizedBox(height: 20),
SizedBox(
height: 50,
width: 480,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 50),
child: ElevatedButton(
onPressed: () {
_dialogBuilder(context);
//('AGREE AND CONTINUE');
},
style: ElevatedButton.styleFrom(
shape: BeveledRectangleBorder(
borderRadius: BorderRadius.circular(2)),
backgroundColor: const Color(0xFF0ca886)),
child: const Padding(
padding: EdgeInsets.symmetric(vertical: 12),
child: Text(
'AGREE AND CONTINUE',
style: TextStyle(
color: Color(0xFF121a21), fontSize: 16),
),
)),
),
),
const Expanded(
child: SizedBox(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
"From",
style: TextStyle(color: Colors.white),
textAlign: TextAlign.center,
),
Text("FACEBOOK",
style: TextStyle(
letterSpacing: 3,
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16,
),
textAlign: TextAlign.center)
],
),
),
),
],
),
),
),
);
}
2
Answers
Here's what I did, but it's still not good.
}
Base on the code you shared, it looks like you’ve used the Expanded widget wrongly in one of the items. Here is the corrected version below. Let me know if this solved your issue.