Widget build()

in experimental/linting_tool/lib/pages/home_page.dart [15:71]


  Widget build(BuildContext context) {
    return Consumer<RuleStore>(
      builder: (context, rulesStore, child) {
        if (rulesStore.isLoading) {
          return const CircularProgressIndicator.adaptive();
        }

        if (!rulesStore.isLoading) {
          if (rulesStore.rules.isNotEmpty) {
            final isDesktop = isDisplayLarge(context);
            final isTablet = isDisplayMedium(context);
            final startPadding = isTablet
                ? 60.0
                : isDesktop
                    ? 120.0
                    : 16.0;
            final endPadding = isTablet
                ? 60.0
                : isDesktop
                    ? 120.0
                    : 16.0;

            return ListView.separated(
              padding: EdgeInsetsDirectional.only(
                start: startPadding,
                end: endPadding,
                top: isDesktop ? 28 : 16,
                bottom: isDesktop ? kToolbarHeight : 16,
              ),
              itemCount: rulesStore.rules.length,
              cacheExtent: 5,
              itemBuilder: (context, index) {
                return LintExpansionTile(
                  rule: rulesStore.rules[index],
                );
              },
              separatorBuilder: (context, index) => const SizedBox(height: 4),
            );
          }
        }

        return Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(rulesStore.error ?? 'Failed to load rules.'),
            const SizedBox(
              height: 16.0,
            ),
            IconButton(
              onPressed: () => rulesStore.fetchRules(),
              icon: const Icon(Icons.refresh),
            ),
          ],
        );
      },
    );
  }