How to detect change on container height ? then after reached the height of 300 it will show other widget
(assume : the child of container dynamicaly populated, or delayed populated)
I try code from How to use SizeChangedLayoutNotifier? it's work only when child of container already populated.
class Example extends StatefulWidget {
@override
State<StatefulWidget> createState() => ExampleState();
}
class ExampleState extends State<Example> {
GlobalKey containerKey = GlobalKey();
bool showText = false;
@override
void initState() {
super.initState();
}
void onChange(Size value) {
if (value.height >= 300) {
setState(() {
showText = true;
});
}
}
@override
Widget build(BuildContext context) {
WidgetsBinding.instance.addPostFrameCallback(
(_) => onChange(containerKey.currentContext.size));
return Stack(alignment: Alignment.bottomCenter, children: <Widget>[
Container(
key: containerKey,
constraints: BoxConstraints(maxHeight: 300),
child: Wrap(
children: <Widget>[
Column(
children: <Widget>[
//########### example: assume -> dynamic widget or delayed
Text(
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."),
Center(
child: Image.network(
'https://i.ytimg.com/vi/d1FZGpv2-Q4/maxresdefault.jpg',
),
)
],
)
],
),
),
//############ show this when height of container > 300
showText
? Container(
color: Colors.red,
child: Text("SHOW TEXT"),
)
: Container()
]);
}
}