Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FirestoreDataTable Page Not Resetting #365

Open
1 task done
Mahender-Kumar opened this issue Jun 29, 2024 · 2 comments
Open
1 task done

FirestoreDataTable Page Not Resetting #365

Mahender-Kumar opened this issue Jun 29, 2024 · 2 comments
Labels
blocked: customer response Waiting for customer response, e.g. more information was requested. firestore platform: all

Comments

@Mahender-Kumar
Copy link

Mahender-Kumar commented Jun 29, 2024

Is there an existing issue for this?

  • 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 Mahender-Kumar changed the title FirestoreDataTable Page Resetting FirestoreDataTable Page Not Resetting Jun 29, 2024
@Mahender-Kumar
Copy link
Author

Mahender-Kumar commented Jun 29, 2024

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

@russellwheatley
Copy link
Member

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 russellwheatley added firestore blocked: customer response Waiting for customer response, e.g. more information was requested. platform: all labels Oct 25, 2024
@github-actions github-actions bot added the Needs Attention OP created or responded to issue and it needs attention. label Oct 25, 2024
@russellwheatley russellwheatley removed the Needs Attention OP created or responded to issue and it needs attention. label Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked: customer response Waiting for customer response, e.g. more information was requested. firestore platform: all
Projects
None yet
Development

No branches or pull requests

2 participants