Flutter getx first null value
The best way I could find on how to realize this, was a mix of getx and rx_widgets
You can grab the code here on github
Text cannot be given a null value, you should use ?.name
to prevent this and provider a default value if null, example:
class DetailScreen extends StatelessWidget { final logger = LoggingService().logger; @override Widget build(BuildContext context) { final dataService = Get.find<DataService>(); final _identity = dataService.identity(); return Scaffold( appBar: AppBar( title: Obx(() => Text('' + (_identity.value.profile?.name ?? ''))), // here leading: IconButton( icon: Icon(Icons.arrow_back), onPressed: () { Get.back(); }, ), ), ); }}
or add default value to prevent null:
Rx<UserDataProfile> _userDataProfile = UserDataProfile(name: '').obs;