What the title says. I have a freezed constructor tear-off that I'm trying to pass to a Widget and it's not returning null, and I'm trying to figure out what I'm doing wrong. Here is the freezed class:
@freezed
class PatientField with SetFieldOption, _$PatientField {
factory PatientField.firstName(String value) = PatientFirstName;
}
This is a simplified version of my initial Widget (which actually displays properly):
class SinglePatientView2 extends ConsumerWidget {
const SinglePatientView2({Key? key}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
print(PatientField.firstName('something'));
return Theme(
data: Theme.of(context).copyWith(dividerColor: Colors.transparent),
child: Expanded(
child: DefaultTabController(
length: 1,
child: Scaffold(
body: TabBarView(children: [
PersonTabContent<PatientField>(
PatientField.firstName,
)
])))));
}
}
Then Widget that's called above looks like (simplifed version anyway):
class PersonTabContent<T> extends StatelessWidget {
const PersonTabContent(
this.firstNameField, {
Key? key,
}) : super(key: key);
final T Function(String) firstNameField;
@override
Widget build(BuildContext context) {
print(firstNameField('something'));
return Padding(
padding: EdgeInsets.all(doubleBySize(context, 32)),
);
}
}
Looking at the output, the above prints:
PatientField.firstName(value: something)
null
I don't understand why I'm getting a null value in the second Widget's build method. Any insights as to what I'm doing wrong?