I'm trying to create a custom Scaffold extending the original class. With a default AppBar if not passed a new one.
class CommonScaffold extends Scaffold {
final AppBar? appBar;
final Widget body;
CommonScaffold({
Key? key,
this.appBar,
required this.body,
}) : super(
key: key,
body: body,
appBar: appBar ??
AppBar(
title: const Text("Default Text"),
),
);
}
If I call the class avoiding pass the appBar parameter the AppBar will not appear. But should appear.
@override
Widget build(BuildContext context) {
return CommonScaffold(
body: _createContent(),
);
}
If I call the class passing an AppBar to the appBar parameter the AppBar will appear.
@override
Widget build(BuildContext context) {
return CommonScaffold(
body: _createContent(),
appBar: AppBar(
title: const Text("TEST"),
),
);
}