Rather than checking all those variables, I'd make them optional parameters to the widget. If you do that, you can just check if they're null using null-safety inside it, whenever you actually need them.
class TestWidget extends StatelessWidget {
final String? testPar1;
final String? testPar2;
final String? testPar3;
final String? testPar4;
const TestWidget({
this.testPar1,
this.testPar2,
this.testPar3,
this.testPar4,
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
children: [
Text(testPar1 ?? 'nope'),
Text(testPar2 ?? 'nope'),
Text(testPar3 ?? 'nope'),
Text(testPar4 ?? 'nope'),
],
);
}
}
Keep in mind that your way of doing it isn't wrong.