maxim-saplin / data_table_2

In-place substitute for Flutter's DataTable and PaginatedDataTable with fixed/sticky header and extra features
https://pub.dev/packages/data_table_2
BSD 3-Clause "New" or "Revised" License
202 stars 137 forks source link

I want the Loading Widget display to start before getRows. #224

Closed rapan931 closed 1 year ago

rapan931 commented 1 year ago

Thanks great package

Currently the Loadin Widget is displayed after getRows is called. https://github.com/maxim-saplin/data_table_2/blob/4c8c33b90aa9bd57259de50dd660b4ded828e309/lib/src/async_paginated_data_table_2.dart#L241-L279

If a slow API is called in getRows, it takes a long time before the Loading Widget is displayed and the screen looks frozen.

Is it possible to display the Loading Widget before calling getRows?

Thanks.

maxim-saplin commented 1 year ago

Are you sure? I don't see the problem you described neither in code nor in the demo: https://maxim-saplin.github.io/data_table_2/#/asyncpaginated2

rapan931 commented 1 year ago

Sorry.. I created a minimum configuration but could not reproduce it. Perhaps it is my environmental problem.

Details ```dart import 'package:data_table_2/data_table_2.dart'; import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title}); final String title; @override State createState() => _MyHomePageState(); } class _MyHomePageState extends State { @override Widget build(BuildContext context) { final columns = createDataColumn(); return Scaffold( appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.inversePrimary, title: Text(widget.title), ), body: AsyncPaginatedDataTable2( columns: columns, rowsPerPage: 2, source: TestSource(), ), ); } List createDataColumn() { return const [ DataColumn2(label: Center(child: Text('column1'))), DataColumn2(label: Center(child: Text('column2'))), ]; } } class TestSource extends AsyncDataTableSource { @override Future getRows(int startIndex, int count) async { await Future.delayed(const Duration(seconds: 10)); return AsyncRowsResponse(100, [ const DataRow(cells: [ DataCell(Text('1')), DataCell(Text('2')), ]), const DataRow(cells: [ DataCell(Text('1')), DataCell(Text('2')), ]), ]); } } ```

closed