buildWidgetContent method
- @override
- BuildContext context
override
Implementation
@override
Widget buildWidgetContent(BuildContext context) {
final Widget content;
if (errorMsg.isNotEmpty) {
content = Scaffold(
backgroundColor: Colors.black,
body: Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Text(
errorMsg,
style: const TextStyle(
color: Colors.red,
fontSize: 16.0,
fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
),
),
);
} else if (nclDocument == null && _cachedWidgets.isEmpty) {
content = Scaffold(
backgroundColor: Colors.transparent,
body: Center(
child: errorMsg.isNotEmpty
? Text(errorMsg, style: const TextStyle(color: Colors.red))
: const CircularProgressIndicator(),
),
);
} else {
final activeMedia = List<Media>.from(nclDocument?.getActiveMedia() ?? []);
activeMedia.sort((a, b) {
int getZIndex(Media media) {
final zIndexProp = media
.getProperties()
.where((p) => p.name == 'zIndex' || p.name == 'zOrder')
.firstOrNull;
if (zIndexProp != null && zIndexProp.value != null) {
return int.tryParse(zIndexProp.value!) ?? 0;
}
final resolvedZ = media.rawAttributes['resolvedZIndex'];
if (resolvedZ != null) {
return int.tryParse(resolvedZ) ?? 0;
}
return 0;
}
return getZIndex(a).compareTo(getZIndex(b));
});
final List<Widget> children = [];
for (var media in activeMedia) {
final widget = _cachedWidgets[media.id ?? ''];
if (widget != null) {
children.add(widget);
}
}
content = Scaffold(
backgroundColor: Colors.transparent,
body: Stack(
key: const Key('ncl_app_stack'),
fit: StackFit.expand,
children: children,
),
);
}
return _NclInheritedWidget(
state: this,
bounds: bounds,
child: content,
);
}