How do i debug a custom widget in flutter flow when it compiles just fine but only shows a white window?

32 Views Asked by At

Hello im kinda new to dart and flutter but i´ve been building tutorial apps in flutter just fine.

I am now trying to adapt what i learn to flutterflow, because I find it easier to manage firebase databases through there, the thing is the widgets are kinda basic

I tried to adapt some code i had that worked just fine to a custom widget in flutterflow but even after compiling it just fine it wont show when i test run the app.

the widget is suposed to make a item list with 5 parameters and group by some of them to make an expansion kind of list with counters

I dont know what im doing wrong and cant debug it because there are no errors anywhere. Can someone help me with this. Thank you very much in advance

// Automatic FlutterFlow imports
import '/backend/backend.dart';
import '/backend/supabase/supabase.dart';
import '/actions/actions.dart' as action_blocks;
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/widgets/index.dart'; // Imports other custom widgets
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
import 'package:collection/collection.dart';


class Item {
  String name;
  String horas;
  String entrada;
  String saida;
  String maesaida;

  Item({
    required this.name,
    required this.horas,
    required this.entrada,
    required this.saida,
    required this.maesaida,
  });
}

class TransportesWidget extends StatelessWidget {
  const TransportesWidget({
    super.key,
    required this.width,
    required this.height,
    required this.horas,
    required this.entrada,
    required this.saida,
    required this.maesaida,
    required this.name,
  });

  final double? width;
  final double? height;
  final String horas;
  final String entrada;
  final String saida;
  final String maesaida;
  final String name;

  @override
  Widget build(BuildContext context) {
    // Create a list of 'Item' objects based on input parameters
    final List<Item> itemList = [
      Item(
        name: name,
        horas: horas,
        entrada: entrada,
        saida: saida,
        maesaida: maesaida,
      ),
    ];

    // Call the grouping function with the item list
    final Map<String, Map<String, List<Item>>> groupedItems =
        groupItemsBySaida(itemList);

    return Container(
      width: width,
      height: height,
      // Add any other container properties (color, padding, etc.)
      child: ListView.builder(
        itemCount: groupedItems.length,
        itemBuilder: (context, index) {
          String criteria = groupedItems.keys.elementAt(index);
          List<String> criteriaParts = criteria.split('-'); // Split criteria
          String horas = criteriaParts[0];
          String maesaida = criteriaParts[1]; // First saida
          Map<String, List<Item>> saidaMap = groupedItems[criteria]!;
          int totalItemCount = saidaMap.values
              .fold(0, (sum, items) => sum + items.length); // Total items count

          return ExpansionTile(
            title: Text(
              '$horas - Volta de $maesaida ($totalItemCount pessoas)',
              style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
            ),
            children: saidaMap.entries.map((saidaEntry) {
              String saida = saidaEntry.key;
              List<Item> itemsInSaida = saidaEntry.value;
              int saidaCount =
                  itemsInSaida.length; // Count of items with same saida

              return ExpansionTile(
                title: Padding(
                  padding: const EdgeInsets.all(2.0),
                  child: Text(
                    '${itemsInSaida.first.entrada} - $saida - $saidaCount pessoas',
                  ),
                ),
                children: itemsInSaida.map((item) {
                  return ListTile(
                    title: Padding(
                      padding: const EdgeInsets.all(3.0),
                      child: Text(item.name),
                    ),
                  );
                }).toList(),
              );
            }).toList(),
          );
        },
      ),
    );
  }

  // Ensure the grouping function returns a non-null value
  Map<String, Map<String, List<Item>>> groupItemsBySaida(List<Item> items) {
    // Implement your grouping logic here based on 'Item' properties
    // ... (your code)

    // Construct and return the grouped items map
    final Map<String, Map<String, List<Item>>> groupedItemsMap = {};
    // ... (your grouping logic to populate 'groupedItemsMap')
    return groupedItemsMap;
  }
}

i tried to debug it through the browser console, but i dont see any errors

0

There are 0 best solutions below