render method

  1. @override
Widget render(
  1. NudgeImage node,
  2. BuildContext context
)
override

Implementation

@override
Widget render(NudgeImage node, BuildContext context) {
  final url = VariableScopeProvider.of(context).resolve(node.url);
  if (url.isEmpty) {
    return _placeholder(node);
  }
  // Aspect ratio (when set) drives the height; otherwise use the box's fixed
  // height, then natural size.
  if (node.aspectRatio > 0) {
    return AspectRatio(
      aspectRatio: node.aspectRatio,
      child: Image.network(
        url,
        fit: node.fit,
        // width: double.maxFinite,
        // height: double.infinity,
        errorBuilder: (_, __, ___) => _placeholder(node),
      ),
    );
  }
  return Image.network(
    url,
    fit: node.fit,
    width: node.box.fillWidth ? double.infinity : null,
    height: node.box.fixedHeight,
    errorBuilder: (_, __, ___) => _placeholder(node),
  );
}