I'm trying to create a list of tasks inside a circle, when the user taps on it, the list is showed. The problem is that the list of tasks is dynamic, I need to use a ListView.builder but it keeps giving out errors.
I've checked the following:
- If instead of a
.builder, I use aListView, it works fine. - The
itemCountandshrinkWraphave noting to do with it.
════════ Exception caught by rendering library ═════════════════════════════════ RenderBox was not laid out: RenderViewport#1d072 NEEDS-PAINT 'package:flutter/src/rendering/box.dart': Failed assertion: line 1785 pos 12: 'hasSize' The relevant error-causing widget was ListView lib/TaskBubble.dart:43 ════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by scheduler library ═════════════════════════════════ Null check operator used on a null value ════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by Flutter framework ═════════════════════════════════ Bad state: Future already completed ════════════════════════════════════════════════════════════════════════════════
And here is the code
class _TaskBubbleState extends State<TaskBubble> {
double yOffset = 175.0;
double xOffset = 50.0;
bool hide = true;
List<Task> tasks = [
new Task(name: "Laundry", done: false),
new Task(name: "hide", done: false)
];
@override
Widget build(BuildContext context) {
return Positioned(
top: yOffset,
left: xOffset,
child: Draggable<Widget>(
onDraggableCanceled: (velocity, offset) {
setState(() {
yOffset = offset.dy;
xOffset = offset.dx;
});
},
feedback: FloatingActionButton(
onPressed: () {},
),
childWhenDragging: Opacity(
opacity: 0.1,
child: FloatingActionButton(
onPressed: () {},
),
),
child: Stack(
children: [
ListView.builder(
itemCount: tasks.length,
shrinkWrap: true ,
itemBuilder: (context, index) => ListTile(
title: Text(tasks[index].name),
),
),
FloatingActionButton(
onPressed: () {
setState(() {
hide = !hide;
});
},
),
],
),
),
);
}
}
Positionedto set the position when the user drags the object, andStackbecause I need theListto go together with theFloatingActionButton. Would you have done something else? I'm quite new to Flutter and I appreciate any feedback ^^