It is quite often to see people passing a widget class or call a function which return a widget to Body property of a widget.
What confuse me is that both are actually work. But I dont understand the reason behind when to choose which to implement
For example,
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
**body: _buildContents(context),**
),
);
}
}
vs
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
**body: HomePage(),**
),
);
}
}