parent
7dcf0083e4
commit
b0437c4d3f
4 changed files with 18 additions and 62 deletions
@ -1,60 +0,0 @@ |
||||
import 'package:flutter/material.dart'; |
||||
|
||||
class QuillCheckbox extends StatelessWidget { |
||||
const QuillCheckbox({ |
||||
Key? key, |
||||
this.style, |
||||
this.width, |
||||
this.isChecked = false, |
||||
this.offset, |
||||
this.onTap, |
||||
this.uiBuilder, |
||||
}) : super(key: key); |
||||
final TextStyle? style; |
||||
final double? width; |
||||
final bool isChecked; |
||||
final int? offset; |
||||
final Function(int, bool)? onTap; |
||||
final QuillCheckboxBuilder? uiBuilder; |
||||
|
||||
void _onCheckboxClicked(bool? newValue) { |
||||
if (onTap != null && newValue != null && offset != null) { |
||||
onTap!(offset!, newValue); |
||||
} |
||||
} |
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
Widget child; |
||||
if (uiBuilder != null) { |
||||
child = uiBuilder!.build( |
||||
context: context, |
||||
isChecked: isChecked, |
||||
onChanged: _onCheckboxClicked, |
||||
); |
||||
} else { |
||||
child = Container( |
||||
alignment: AlignmentDirectional.topEnd, |
||||
width: width, |
||||
padding: const EdgeInsetsDirectional.only(end: 13), |
||||
child: GestureDetector( |
||||
onLongPress: () => _onCheckboxClicked(!isChecked), |
||||
child: Checkbox( |
||||
value: isChecked, |
||||
onChanged: _onCheckboxClicked, |
||||
), |
||||
), |
||||
); |
||||
} |
||||
|
||||
return child; |
||||
} |
||||
} |
||||
|
||||
abstract class QuillCheckboxBuilder { |
||||
Widget build({ |
||||
required BuildContext context, |
||||
required bool isChecked, |
||||
required void Function(bool?) onChanged, |
||||
}); |
||||
} |
||||
@ -1,3 +1,3 @@ |
||||
export 'bullet_point.dart'; |
||||
export 'checkbox.dart'; |
||||
export 'checkbox_point.dart'; |
||||
export 'number_point.dart'; |
||||
|
||||
Loading…
Reference in new issue