buildTopWidget method

  1. @override
Widget buildTopWidget(
  1. {required BuildContext context,
  2. required WidgetRef ref,
  3. required AppModel appModel,
  4. required CreatorModel creatorModel,
  5. required Orientation orientation}
)
override

Media fields are special and have a Widget that is shown at the top of the Card Creator.

Implementation

@override
Widget buildTopWidget({
  required BuildContext context,
  required WidgetRef ref,
  required AppModel appModel,
  required CreatorModel creatorModel,
  required Orientation orientation,
}) {
  if (isSearching) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        if (orientation == Orientation.landscape)
          Flexible(
            child: Container(
              color: Colors.transparent,
              height: double.infinity,
              width: double.infinity,
            ),
          )
        else
          AspectRatio(
            aspectRatio: 16 / 9,
            child: Container(
              color: Colors.transparent,
              height: double.infinity,
              width: double.infinity,
            ),
          ),
        const Space.normal(),
        buildFooterLoading(
          appModel: appModel,
          context: context,
        ),
      ],
    );
  }

  if (!showWidget) {
    return const SizedBox.shrink();
  }

  int itemCount = currentImageSuggestions!.length;

  return Column(
    mainAxisAlignment: MainAxisAlignment.center,
    children: [
      if (orientation == Orientation.landscape)
        Flexible(
          child: buildCarousel(
            itemCount: itemCount,
            appModel: appModel,
          ),
        )
      else
        buildCarousel(
          itemCount: itemCount,
          appModel: appModel,
        ),
      const Space.normal(),
      ValueListenableBuilder<int?>(
        valueListenable: indexNotifier,
        builder: (context, index, _) => buildFooterTextSpans(
          context: context,
          appModel: appModel,
          itemCount: itemCount,
        ),
      ),
    ],
  );
}