generateWidget method
Widget
generateWidget(
- BuildContext context,
- String widgetName, {
- Map<
String, dynamic> arguments = const {}, - Widget? child,
Generate widget You can use the widget of other modules without import module
Implementation
Widget generateWidget(
BuildContext context,
String widgetName, {
Map<String, dynamic> arguments = const {},
Widget? child,
}) {
BlocWidgetBuilder? widgetBuilder = widgetMap['$widgetName@$pageLayoutType'];
widgetBuilder ??= widgetMap[widgetName];
if (widgetBuilder != null) {
String? parentModelName = ModelNameProvider.of(context);
Widget? realChild = child;
if (parentModelName != null && parentModelName.isNotEmpty && child != null) {
realChild = ModelNameProvider(
blocName: parentModelName,
child: Builder(
builder: (BuildContext context) {
return child;
},
),
);
}
return ModelNameProvider(
blocName: widgetName.split('/')[0],
child: widgetBuilder(arguments, realChild),
);
} else {
return Container(
color: Colors.yellow,
child: Center(
child: Text(
'Wrong Widget',
style: TextStyle(fontSize: 14.0),
),
),
);
}
}