made tasks dismissible
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class TaskDismissible extends StatelessWidget {
|
||||
const TaskDismissible({
|
||||
required super.key,
|
||||
this.onDismissedRight,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
final VoidCallback? onDismissedRight;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dismissible(
|
||||
key: key!,
|
||||
direction: DismissDirection.startToEnd,
|
||||
background: Container(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
child: Align(
|
||||
alignment: AlignmentGeometry.centerLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Icon(
|
||||
Icons.delete,
|
||||
color: Theme.of(context).colorScheme.onError,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
onDismissed: onDismissed,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
void onDismissed(DismissDirection direction) {
|
||||
if (direction == DismissDirection.startToEnd && onDismissedRight != null) {
|
||||
onDismissedRight!();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user