title: Flutter: Filter products by categories in the app level?
body: <p>I am currently trying to develop an app in which products are categorically displayed in a separate screen or class with ListView.builder ().</p>
  
  <p>I have to select / favor a category or sub-category so that I can see products in the list view. I see nothin in the screen if i don't select one or more categorys OR subcategorys. I can also favor different categories and in the list view I see the products that match the favorite product. If I have favored a subcategory, I should only see in the list view the products that see in this favored subcategory and not the superordinate categories.
  If I prefer a higher category, all products of the subcategories should be shown in the list view.</p>
  
  <p>But I'm worried about the performance. My database will run on Firebase. Is firestore more suitable for this? I also read that relational databases are more suitable for such things. However, I have never worked with it and I want the favorites not only to be saved on the smartphone. I would like the favorites to be called up when the user logs in to the app with another phone.</p>
  
  <p>My question is more of a structural question. Is it better for the performance if there is a Category class in which all higher and lower categories each have a list with the products and which are then merged in the list view (if different categories are selected, of course)?</p>
  
  <p>I mean, if I list all the products in a single list and filter them afterwards in the code (at the app level), it is totally unperforming, right?</p>
  
  <p>Do I have to have a class category and a separate subcategory class? How would you go about it? I have total chaos in my brain</p>
  
  <p>class Product:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  
  class Product {
    final String id;
    final String title;
    final List&lt;String&gt; imagesPath;
    final String description;
    final Color categoryColor;
  
    Product({
      @required this.id,
      @required this.title,
      @required this.imagesPath,
      @required this.description,
      @required this.categoryColor,
    });
  }
  </code></pre>
  
  <p>class Category:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import '../models/Product.dart';
  
  class Category {
    final String title;
    final Color color;
    bool isFavourite;
    final List&lt;Product&gt; products;
  
    Category({@required this.title, @required this.color, this.isFavourite = false, this.products});
  }
  
  List&lt;Category&gt; categories = [
    Category(
      title: 'Automobile',
      color: Colors.lightBlue,
      isFavourite: false,
    ),
  ];
  </code></pre>
  
  <p>I no longer know which would be more correct in terms of how I should go on.</p>
  
  <p>Thanks :)</p>