I have this function and flutter have a problem becouse go to be null
Widget getPicker() {
if (Platform.isIOS) {
return iOSPicker();
} else if (Platform.isAndroid) {
return androidDropdown();
}
}
I try to make it async
Future<Widget> getPicker() async {
if (Platform.isIOS) {
return iOSPicker();
} else if (Platform.isAndroid) {
return androidDropdown();
}
}
But problem still here. How i can solve it?
CodePudding user response:
Try tweaking your if statement this way :
Widget getPicker() {
if (Platform.isIOS) {
return iOSPicker();
}
return androidDropdown();
}
You can also use ternary
operator:
Widget getPicker() {
return Platform.isIOS ? iOSPicker() : androidDropdown();
}