perf: optimize home screen rendering with ListView.builder and improve image loading performance by persisting disk cache

This commit is contained in:
pradeepkumar
2026-04-10 20:18:21 +05:30
parent cdb918fae8
commit 1abcc2416f
3 changed files with 25 additions and 32 deletions

View File

@@ -21,31 +21,25 @@ class HomeScreen extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final scrollController = ref.watch(homeScrollControllerProvider);
return SingleChildScrollView(
// Use ListView.builder for lazy rendering — only builds sections as
// they scroll into view, instead of rendering all 5 heavy sections at
// once in a Column (which causes jank on initial load).
final sections = <Widget>[
const RepaintBoundary(child: HeroSection()),
const SizedBox(height: 40),
const RepaintBoundary(child: FeaturesSection()),
const SizedBox(height: 40),
const RepaintBoundary(child: TopProfessionalsSection()),
const SizedBox(height: 40),
const RepaintBoundary(child: TrustStatsSection()),
const SizedBox(height: 24),
const RepaintBoundary(child: TestimonialsSection()),
const SizedBox(height: 40),
];
return ListView.builder(
controller: scrollController,
child: Column(
children: [
// Hero Section with Search
const HeroSection(),
const SizedBox(height: 40),
// Features Section
const FeaturesSection(),
const SizedBox(height: 40),
// Top Professionals Section (Agents/Lenders tabs)
const TopProfessionalsSection(),
const SizedBox(height: 40),
// Trust & Stats Section
const TrustStatsSection(),
const SizedBox(height: 24),
// Testimonials Section
const TestimonialsSection(),
const SizedBox(height: 40),
],
),
itemCount: sections.length,
itemBuilder: (_, i) => sections[i],
);
}