Which is the correct usage? Also I'm confused about if we should do "extract method" or "extract widget"? Flutter recommends to extract widgets. But I'm not sure where should I extract widget?
class TopBarTitle extends StatelessWidget {
const TopBarTitle();
static const String title = 'FLASHCARDS';
static const String fontFamily = 'Itim';
@override
Widget build(BuildContext context) {
return Text(
title,
style: TextStyle(
fontSize: 18.sp,
color: Theme.of(context).iconTheme.color,
fontWeight: FontWeight.w500,
fontFamily: fontFamily,
),
);
}
}
or
class TopBarTitle extends StatelessWidget {
const TopBarTitle();
@override
Widget build(BuildContext context) {
const String title = 'FLASHCARDS';
const String fontFamily = 'Itim';
return Text(
title,
style: TextStyle(
fontSize: 18.sp,
color: Theme.of(context).iconTheme.color,
fontWeight: FontWeight.w500,
fontFamily: fontFamily,
),
);
}
}