Rich text editor for Flutter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

60 lines
1.4 KiB

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,
});
}