I am working on an app with layoutbuilder and i have different visuals of the app i want to show when the user goes from portrait to landscape mode a spinner should display and after 2 seconds that spinner should vanish.
I got the functionality to work i have used ( WidgetsBinding.instance.addPostFrameCallback((_) { )), but every time I change the orientation the loading spinner comes and then after it goes away my screen flickers and does not stop flickering or flashing
I understand the reason is that the loading spinner is showing and then my other widgets are rebuilding, but I have a format which I need all to be Stateful widget, unless someone has another idea?
- user changes portrait to landscape
- spinner displays for 2 seconds
- user sees screen in landscape.
Loadingshimmer is the class with the loader singlechildscrollview is landscape mode...
bool loading = false;
child: LayoutBuilder(builder: (context, constraints) {
if (constraints.maxWidth > 600 && constraints.maxHeight < 1000) {
WidgetsBinding.instance.addPostFrameCallback((_) {
setState((){
loading = true;
});
});
Timer(Duration(seconds: 1), () {
setState(() {
loading = false;
});
});
// child: OrientationBuilder(
// builder: (BuildContext context, Orientation orientation) {
// if (orientation == Orientation.portrait) {
// (constraints.maxWidth > 600) {
print(height);
print(width);
return loading
? LoadingShimmer()
: SingleChildScrollView(