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

How do I set the component that is displayed when the itemsList is empty? #1

Closed
HyggeBo7 opened this issue Oct 16, 2019 · 2 comments
Closed
Labels
good first issue Good for newcomers

Comments

@HyggeBo7
Copy link

How do I set the component that is displayed when the itemsList is empty?

Can I add a adaptive height based on the itemsList data?

image

@HussainTaj-W
Copy link
Owner

How do I set the component that is displayed when the itemsList is empty?

Currently, a component for this specific task does not exist. When itemsList is empty an empty ListView is shown when DialogComponentsConfiguration or DropdownComponentsConfiguration is used.

You can use the ListViewComponent to achieve the required effect.

Widget _listViewBuilder(ListViewComponentData data) {
  if (data.itemCount == 0) {
    return Center(
      child: Text("There is nothing here."),
    );
  }
  return ListView.builder(
    itemBuilder: data.itemBuilder,
    itemCount: data.itemCount,
    padding: EdgeInsets.zero,
  );
}

Complete example here.
An empty list example

Can I add an adaptive height based on the itemsList data?

Yes.

Widget itemBuilder(
    BuildContext context, Rectangle rectangle, OnItemTapped onItemTapped) {
  return Container(
    height: rectangle.size,
    //...
  );
}

Complete example here.
A variable widget high list item example

@HyggeBo7
Copy link
Author

Thank you

@HussainTaj-W HussainTaj-W added the good first issue Good for newcomers label Oct 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants