How can I correct this code? That might have sparked the need to win another solution.
enter image description here This result is only after a hot reload, and at the first start it is empty.
class PageOnes extends StatefulWidget {
final String pageName;
const PageOnes({
required this.pageName,
Key? key,
}) : super(key: key);
@override
State<StatefulWidget> createState() => _PageOnesState();
}
class _PageOnesState extends State<PageOnes> {
List<String> items = [];
@override
Widget build(BuildContext context) {
deviceInfo();
return Scaffold(
appBar: AppBar(
title: Text(widget.pageName),
),
body: ListView.separated(
padding: const EdgeInsets.all(8),
itemCount: items.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(items[index],style: const TextStyle(fontFamily: 'Proximal', fontSize: 18),
),
);
},
separatorBuilder: (BuildContext context, int index) => const Divider(
thickness: 5,
endIndent: 10,
indent: 10,
)),
);
}
void deviceInfo() async {
const int MEGABYTE = 1024 * 1024;
DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
AndroidDeviceInfo androidDeviceInfo = await deviceInfoPlugin.androidInfo;
items.add('Brand: ${androidDeviceInfo.manufacturer}.');
}
}