I am a beginner in working with Flutter and ran into the following issue.
A Widget is built like below:
class WeatherMainPage extends StatefulWidget {
WeatherMainPage({super.key, required this.sensor});
final BMESensor sensor;
@override
_WeatherMainPageState createState() => _WeatherMainPageState();
}
class _WeatherMainPageState extends State<WeatherMainPage> {
MyAppState? appState;
@override
Widget build(BuildContext context) {
return Consumer<MyAppState>(builder: (context, appstate, child) => contentBuilder(context, appstate, child));
}
Future<bool> _initAsync() async {
await widget.sensor.acquireCurrentWeather();
await widget.sensor.acquireWeathreForecast();
return true;
}
Widget contentBuilder(BuildContext context, MyAppState state, Widget? child) {
appState = state;
return FutureBuilder<bool>(
future: _initAsync(),
builder: (context, snapshot) {
return Scaffold(
appBar: AppBar(title: Text("Weather details"), centerTitle: true),
body: Center(
child: Padding(
padding: EdgeInsets.all(8.0),
child:
snapshot.hasData
? ListView(
//physics: const BouncingScrollPhysics(),
children: [
CurrentWeather(sensor: widget.sensor),
BasicWeatherData(sensor: widget.sensor),
Sunrise(sensor: widget.sensor),
//HourlyData(),
DailyData(sensor: widget.sensor),
],
)
: Center(child: Stack(children: [Text("Loading data"), CircularProgressIndicator()])),
),
),
);
},
);
}
I run the app on Android and I realized that when I switch to a different application on the phone and then switch back, the app screen is not refreshed and gets fragmented like shown on this screenshot:
The Children widgets listed are all Stateful widgets simply presentig data of the passed sensor object
Where shall I search for the root of the problem ?
This was a bug that's been fixed in Flutter 3.29.1. Updating to this or newer Flutter version should do the trick.
[CP][Impeller] Fix text glitch when returning to foreground.