render method

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

Implementation

@override
Widget render(NudgeCarousel node, BuildContext context) {
  final scope = VariableScopeProvider.of(context);
  final images =
      node.images.map(scope.resolve).where((url) => url.isNotEmpty).toList();
  if (images.isEmpty) {
    return NudgePlaceholder(label: 'No images', height: node.height);
  }
  final radius = node.box.borderRadius > 0
      ? BorderRadius.circular(node.box.borderRadius)
      : BorderRadius.zero;

  final slides = images
      .map((url) => ClipRRect(
            borderRadius: radius,
            child: CachedNetworkImage(
              imageUrl: url,
              fit: BoxFit.cover,
              width: double.infinity,
              errorWidget: (_, __, ___) => const SizedBox.shrink(),
            ),
          ))
      .toList();

  // One full-width slide per view (viewportFraction 1.0) to match the
  // dashboard's snap carousel.
  return InternalCarousel(
    height: node.height,
    autoPlay: node.autoPlay,
    autoPlayInterval: node.autoPlayInterval,
    infiniteScroll: node.loop,
    viewportFraction: 1,
    showIndicator: node.showIndicator,
    dotColor: const Color(0xFFCBD5E1),
    activeDotColor: const Color(0xFF4945FF),
    children: slides,
  );
}