Reputation: 1926
I want to use package_info to show the version number and build of my app in the about screen. On android phones it works well but on ios I have an error:
Receiver: null Tried calling: toUpperCase()
Part of my Code looks like
class _AboutState extends State<About> {
Future<PackageInfo> _getPackageInfo() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
return packageInfo;
}
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
var now = new DateTime.now();
String yearNow = DateFormat('yyyy').format(now);
return FutureBuilder<PackageInfo>(
future: _getPackageInfo(), // a previously-obtained Future<String> or null
builder: (BuildContext context, AsyncSnapshot<PackageInfo> snapshot) {
if (snapshot.hasData) {
return new Material(
color: HexToColor('#508bbb'),
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(snapshot.data.appName.toUpperCase(), style: new TextStyle(color: Colors.white, fontSize: 20.0)),
Any help is appreciated. If there is a better proposal do not hesitate ;)
Upvotes: 0
Views: 1526
Reputation: 1926
On IOS
snapshot.data.appName.toString().toUpperCase()
still returns NULL. I found following solution here saying that you have to add it in the Info.plist file
Upvotes: 0
Reputation: 12803
The reason is because snapshot.data.appName
is not String
.Change it to snapshot.data.appName.toString().toUpperCase()
instead.
Upvotes: 1