FirebaseUI-Flutter icon indicating copy to clipboard operation
FirebaseUI-Flutter copied to clipboard

FirestoreDataTable Page Not Resetting

Open Mahender-Kumar opened this issue 1 year ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues and found no duplicates.

What plugin is this bug for?

Firebase UI Firestore

What platform(s) does this bug affect?

No response

List of dependencies used.

flutter pub deps -s list
  

Steps to reproduce

class MyWidget extends ConsumerWidget { const MyWidget({super.key});

@override Widget build(BuildContext context, ref) { final usersQuery = FirebaseFirestore.instance .collection( 'users/${userId}/calls') .orderBy('timestamp', descending: true); return ListView( children: [ FirestoreDataTable( rowsPerPage: 20, dataRowMaxHeight: 40, dataRowMinHeight: 24, headingRowHeight: 40.0, columnSpacing: 24.0, showCheckboxColumn: false, query: usersQuery, showFirstLastButtons: true, columnLabels: { 'timestamp': const Text('Added On'), }, ), ], ); } }

Expected Behavior

if the query is changing the page should reset i.e. _rowindex should be set to 0

Actual Behavior

if the query is changing the page is not reseting i.e. _firstRowIndex is not setting to 0

Additional Information

No response

Mahender-Kumar avatar Jun 29 '24 08:06 Mahender-Kumar

pass the query to PaginatedDatatable and check if query is changed if it changes, jump to page no. 0


@override
  void didUpdateWidget(PaginatedTable oldWidget) {
    super.didUpdateWidget(oldWidget);

    if (oldWidget.queryCHanged != widget.queryCHanged) {
      // print('quwey changed');
      oldWidget.source.removeListener(_handleDataSourceChanged);
      widget.source.addListener(_handleDataSourceChanged);
      _updateCaches();
      pageTo(0);
    }
    if (oldWidget.source != widget.source) {
      // print('source changed');
      oldWidget.source.removeListener(_handleDataSourceChanged);
      widget.source.addListener(_handleDataSourceChanged);
      _updateCaches();
    }
  }

please advise for a better solution and if it is wrong

Mahender-Kumar avatar Jun 29 '24 09:06 Mahender-Kumar

Hi @Mahender-Kumar - could you provide more information on what the issue is? It might help if you provide a full reproducible code repo and steps for how to reproduce as I'm not sure what the bug is.

russellwheatley avatar Oct 25 '24 15:10 russellwheatley

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar Nov 26 '24 14:11 github-actions[bot]