When to use Davi
Flutter developers often struggle with large, scrollable tables that need to stay responsive on web and desktop platforms. Traditional widgets like DataTable render every cell at once, which quickly becomes a performance bottleneck when dealing with thousands of rows or columns. Davi solves this problem by constructing cells only when they enter the viewport, dramatically reducing memory usage and keeping frame rates smooth. Its architecture is built around a virtualized grid that supports both horizontal and vertical scrolling, making it ideal for data‑intensive applications such as admin dashboards, financial analytics, and inventory management tools.
At its core, Davi offers lazy cell building, meaning each cell is created on demand using a builder callback you provide. This gives you full control over the appearance and behavior of individual cells, from simple text to complex widgets like progress bars or interactive buttons. The package also includes native bidirectional scrollbars that automatically appear when the content exceeds the available width or height, eliminating the need for custom scroll logic. Styling is highly flexible – you can define row heights, column widths, header decorations, and even custom scroll physics to match the look and feel of your app.
Integrating Davi into a Flutter architecture is straightforward. Because the widget is self‑contained, it works with any state‑management solution, whether you prefer Provider, Riverpod, Bloc, or a simple setState approach. The data source can be a plain List, a Stream, or even a paginated API, allowing you to plug Davi into clean‑architecture layers, MVVM view models, or Redux‑style stores without friction. Compatibility spans Flutter stable releases on web, Windows, macOS, and Linux; mobile platforms are technically supported but may not benefit from the same performance gains due to smaller screen real estate.
Getting started with Davi takes only a few minutes. After adding the dependency with `flutter pub add davi`, you can drop a `Davi` widget into your UI and supply a column definition and a cell builder. The builder receives the row and column indices, letting you fetch data from a list, a database, or a remote service on the fly. A minimal example is provided below, showing a 100‑row table with three columns that display simple text values. The example also demonstrates how to customize header style and enable the built‑in scrollbars.
When moving to production, keep a few considerations in mind. Because cells are built lazily, any heavy computation inside the builder should be cached or off‑loaded to avoid jank during fast scrolling. Davi does not currently provide built‑in pagination, so you may need to combine it with a paging strategy if your dataset exceeds memory limits. Testing on target platforms is essential, as scroll physics can differ between browsers and desktop window managers. Finally, stay up‑to‑date with the package’s changelog – version 4.1.0 introduced improved scrollbar synchronization and bug fixes for column resizing on macOS.
Overall, Davi fills a niche that many Flutter developers have been missing: a performant, fully customizable data grid that feels native on web and desktop. Its lazy‑loading approach, bidirectional scrolling, and straightforward API make it a strong candidate for any project that needs to display large tabular data without sacrificing UI responsiveness. The community around Davi is active, with regular contributions and clear documentation, ensuring that you can rely on it for both prototypes and production‑grade applications.
Pros
- lazy loading reduces memory footprint
- full cell customization
- built‑in bidirectional scrollbars
- works on all major desktop OSes
- compatible with any state‑management solution
Watch outs
- no built‑in pagination
- mobile performance gains are limited
- requires careful builder optimization for heavy widgets
Setup notes
Add the package to your project with the following command: ``` flutter pub add davi ``` Then run `flutter pub get` and import the library: ```dart import 'package:davi/davi.dart'; ```
Compatible with Flutter stable (2.10+). Fully supported on web, Windows, macOS, and Linux. Mobile platforms work but may not gain the same performance benefits due to limited screen size.
```dart
import 'package:flutter/material.dart';
import 'package:davi/davi.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Davi Demo',
home: Scaffold(
appBar: AppBar(title: const Text('Davi DataView')),
body: Davi<String>(
columns: const [
DaviColumn(name: 'ID'),
DaviColumn(name: 'Name'),
DaviColumn(name: 'Status'),
],
source: DaviSimpleDataSource<String>(
rows: List.generate(100, (i) => 'Row $i'),
),
cellBuilder: (context, column, row) {
final value = row.item;
switch (column.name) {
case 'ID':
return Text(row.index.toString());
case 'Name':
return Text(value);
case 'Status':
return const Icon(Icons.check, color: Colors.green);
default:
return const SizedBox.shrink();
}
},
),
),
);
}
}
```