Files
GitJournal/lib/widgets/icon_dismissable.dart
Vishesh Handa 531eb6f3ae Dismissable: Increase threshold to 60%
A number of users have complained that they currently land up deleting
note accidentally because of the swipe gesture.
2020-04-06 17:14:50 +02:00

47 lines
1.4 KiB
Dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
class IconDismissable extends Dismissible {
final Color backgroundColor;
final IconData iconData;
IconDismissable({
@required Key key,
@required this.backgroundColor,
@required this.iconData,
@required Function onDismissed,
@required Widget child,
}) : super(
key: key,
child: child,
onDismissed: onDismissed,
background: Container(
color: backgroundColor,
alignment: AlignmentDirectional.centerStart,
child: Padding(
padding: const EdgeInsets.fromLTRB(16.0, 0.0, 0.0, 0.0),
child: Icon(
Icons.delete,
color: Colors.white,
),
),
),
secondaryBackground: Container(
color: backgroundColor,
alignment: AlignmentDirectional.centerEnd,
child: Padding(
padding: const EdgeInsets.fromLTRB(0.0, 0.0, 16.0, 0.0),
child: Icon(
Icons.delete,
color: Colors.white,
),
),
),
dismissThresholds: {
DismissDirection.horizontal: 0.60,
DismissDirection.endToStart: 0.60,
DismissDirection.startToEnd: 0.60,
},
);
}