In my flutter project, I've used ExpansionPanel and in it there are star icon, text, checkbox, popup window as shown in the picture. But when I insert more text it is overflowing. And here you can see three dots (...) and it's fixed. I did it manually when text lenght more than 15, then, It cuts the substring and adds ... at the end and full title can be shown when expansion panel expanded.
I want to do it dynamic, according to different width of screen. In this case how can I determine free space for the text widget?
import 'package:flutter/material.dart';
import '../blocs/multi_blocs.dart';
import '../models/task.dart';
import '../widgets/task_tile.dart';
class TasksList extends StatelessWidget {
final List<Task> tasks;
const TasksList({
Key? key,
required this.tasks,
}) : super(key: key);
void _cancelOrDeleteCallBack(BuildContext ctx, Task task) {
task.isCancelled == false
? ctx.read<TodosBloc>().add(CancelTask(task: task))
: ctx.read<TodosBloc>().add(DeleteTask(task: task));
}
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: GestureDetector(
// behavior: HitTestBehavior.translucent,
child: ExpansionPanelList.radio(
elevation: 3,
children: tasks
.map(
(task) => ExpansionPanelRadio(
headerBuilder: (context, isOpen) => Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: TaskTile(
task: task,
checkboxCallback: (checkboxState) {
context.read<TodosBloc>().add(UpdateTask(task: task));
},
cancelOrDeleteCallback: () =>
_cancelOrDeleteCallBack(context, task),
likeCallback: () => context
.read<TodosBloc>()
.add(LikeOrDislikeTask(task: task)),
restoreCallback: () => context
.read<TodosBloc>()
.add(RestoreTask(task: task)),
),
),
body: ListTile(
title: SelectableText(
'Task:\n${task.title}\n\nDescription:\n${task.description}',
toolbarOptions: const ToolbarOptions(
copy: true,
selectAll: true,
cut: true,
),
),
),
value: Text(task.id),
),
)
.toList(),
),
),
);
}
}

