Fix listtile bg overflowing the parent bound

This commit is contained in:
Ming Ming 2022-05-16 17:43:47 +08:00
parent 0a9256f0b0
commit fbe5f4b1dc

View file

@ -100,32 +100,36 @@ class DirPickerState extends State<DirPicker> {
],
alignment: Alignment.topLeft,
),
child: ListView.separated(
key: Key(_currentPath),
itemBuilder: (context, index) {
if (!isTopLevel && index == 0) {
return ListTile(
dense: true,
leading: const SizedBox(width: 24),
title: Text(L10n.global().rootPickerNavigateUpItemText),
onTap: () {
try {
_navigateInto(File(path: path_lib.dirname(_currentPath)));
} catch (e) {
SnackBarManager().showSnackBar(SnackBar(
content: Text(exception_util.toUserString(e)),
duration: k.snackBarDurationNormal,
));
}
},
);
} else {
return _buildItem(
context, state.items[index - (isTopLevel ? 0 : 1)]);
}
},
separatorBuilder: (context, index) => const Divider(),
itemCount: state.items.length + (isTopLevel ? 0 : 1),
// needed to prevent background color overflowing the parent bound, see:
// https://github.com/flutter/flutter/issues/86584
child: Material(
child: ListView.separated(
key: Key(_currentPath),
itemBuilder: (context, index) {
if (!isTopLevel && index == 0) {
return ListTile(
dense: true,
leading: const SizedBox(width: 24),
title: Text(L10n.global().rootPickerNavigateUpItemText),
onTap: () {
try {
_navigateInto(File(path: path_lib.dirname(_currentPath)));
} catch (e) {
SnackBarManager().showSnackBar(SnackBar(
content: Text(exception_util.toUserString(e)),
duration: k.snackBarDurationNormal,
));
}
},
);
} else {
return _buildItem(
context, state.items[index - (isTopLevel ? 0 : 1)]);
}
},
separatorBuilder: (context, index) => const Divider(),
itemCount: state.items.length + (isTopLevel ? 0 : 1),
),
),
);
}