mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-08-25 06:21:52 +00:00
45 lines
1 KiB
Dart
45 lines
1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class ListTileOnSurfaceVariant extends StatelessWidget {
|
|
const ListTileOnSurfaceVariant({
|
|
required this.title,
|
|
this.subtitle,
|
|
this.leadingIcon,
|
|
this.onTap,
|
|
this.disableSubtitleOverflow = false,
|
|
final super.key,
|
|
});
|
|
|
|
final String title;
|
|
final String? subtitle;
|
|
final IconData? leadingIcon;
|
|
final Function()? onTap;
|
|
final bool disableSubtitleOverflow;
|
|
|
|
Widget? getSubtitle() {
|
|
if (subtitle == null) {
|
|
return null;
|
|
}
|
|
if (disableSubtitleOverflow) {
|
|
return Text(
|
|
subtitle!,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
);
|
|
}
|
|
return Text(
|
|
subtitle!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(final BuildContext context) => ListTile(
|
|
title: Text(title),
|
|
subtitle: getSubtitle(),
|
|
onTap: onTap,
|
|
textColor: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
leading: leadingIcon != null ? Icon(leadingIcon) : null,
|
|
iconColor: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
);
|
|
}
|