I'm relatively new to coding with flutter and using widgets and I have a simple query. Here are 2 code snippets that have my themeData that I want to return to the theme
property in my MaterialApp
. The snippet is in a different file to the main.dart
file and is imported in. Here's how it'll fit in.
void main() {
runApp(MaterialApp(
title: 'App Name',
theme: AppTheme(),
home: MyApp(),
));
}
Now my query is... Which is a better practice; Using a function to return a widget or creating another widget to parent that widget and return that?
ThemeData AppTheme(){
return ThemeData(
...
);
}
OR
class AppTheme extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ThemeData(
...
);
}
}