0

In this screenshot, I've got a ListView with three empty ListTiles. However, in the iOS version, the ListTiles have large horizontal margins (shown in purple), which I don't want. I've tried adding negative content padding, but nothing is working. How do I get rid of them? Thanks.

Flutter screenshot

class TasksPane extends StatelessWidget with WatchItMixin {
  const TasksPane({super.key});

  @override
  Widget build(BuildContext context) {
    final controller = watchIt<RpmTodoController>();
    final log = Logger(graphicPrinter);
    return Column(
      children: [
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: [
            IconButton(
              onPressed: controller.all,
              icon: const FaIcon(Icons.filter_list_off),
              tooltip: 'View all tasks',
              iconSize: 18.0,
              // color: Theme.of(context).highlightColor,
            ),
            IconButton(
              onPressed: controller.soon,
              icon: const FaIcon(Icons.timer),
              tooltip: 'View tasks for this week',
              iconSize: 18.0,
            ),
            IconButton(
              onPressed: controller.urgent,
              icon: const FaIcon(Icons.priority_high),
              tooltip: 'View tasks for this week',
              iconSize: 18.0,
            ),
            IconButton(
              onPressed: controller.today,
              icon: const FaIcon(Icons.today),
              tooltip: 'View urgent tasks',
              iconSize: 18.0,
            ),
          ],
        ),
        Expanded(
          child: ListView.builder(
              itemCount: controller.todos.length,
              itemBuilder: (context, index) {
                final todo = controller.todos[index];
                const child = ListTile();

                return Draggable<CVEvent>(
                    data: todo,
                    feedback: ConstrainedBox(
                      constraints: BoxConstraints.loose(const Size(500, 60)),
                      child: const Material(
                        child: Opacity(
                          opacity: 0.75,
                          child: child,
                        ),
                      ),
                    ),
                    childWhenDragging:
                        const Opacity(opacity: 0.5, child: child),
                    onDragEnd: (x) =>
                        log.i('$todo Drag ended with ${x.wasAccepted}'),
                    child: child);
              }),
        ),
      ],
    );
  }
}
3
  • try adding the visualDensity: VisualDensity.minimumDensity, in the ListTile Commented Jul 2 at 6:29
  • Thanks, but that only affects the layout of the ListTile children. It appears to have no effect on the extra padding.
    – BerkoBob
    Commented Jul 2 at 14:18
  • Ok then apply zero padding to the ListView.builder widget after itemCount: controller.todos.length, add padding: EdgeInsets.zero,. Commented Jul 3 at 19:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.