mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: added analysis options + formatted complete code (#2725)
* feat: added analysis options + formatted complete code * fix: formatted code --------- Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io>
This commit is contained in:
@ -38,7 +38,7 @@ class CellCache {
|
||||
}
|
||||
|
||||
void remove(CellCacheKey key) {
|
||||
var map = _cellDataByFieldId[key.fieldId];
|
||||
final map = _cellDataByFieldId[key.fieldId];
|
||||
if (map != null) {
|
||||
map.remove(key.rowId);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class DateCellDataPersistence implements CellDataPersistence<DateCellData> {
|
||||
|
||||
@override
|
||||
Future<Option<FlowyError>> save(DateCellData data) {
|
||||
var payload = DateChangesetPB.create()
|
||||
final payload = DateChangesetPB.create()
|
||||
..cellPath = _makeCellPath(cellContext);
|
||||
if (data.dateTime != null) {
|
||||
final date = (data.dateTime!.millisecondsSinceEpoch ~/ 1000).toString();
|
||||
|
@ -35,7 +35,7 @@ class DatabaseViewBackendService {
|
||||
String? groupId,
|
||||
Map<String, String>? cellDataByFieldId,
|
||||
}) {
|
||||
var payload = CreateRowPayloadPB.create()..viewId = viewId;
|
||||
final payload = CreateRowPayloadPB.create()..viewId = viewId;
|
||||
payload.startRowId = startRowId ?? "";
|
||||
|
||||
if (groupId != null) {
|
||||
@ -54,7 +54,7 @@ class DatabaseViewBackendService {
|
||||
required String toGroupId,
|
||||
RowId? toRowId,
|
||||
}) {
|
||||
var payload = MoveGroupRowPayloadPB.create()
|
||||
final payload = MoveGroupRowPayloadPB.create()
|
||||
..viewId = viewId
|
||||
..fromRowId = fromRowId
|
||||
..toGroupId = toGroupId;
|
||||
@ -70,7 +70,7 @@ class DatabaseViewBackendService {
|
||||
required String fromRowId,
|
||||
required String toRowId,
|
||||
}) {
|
||||
var payload = MoveRowPayloadPB.create()
|
||||
final payload = MoveRowPayloadPB.create()
|
||||
..viewId = viewId
|
||||
..fromRowId = fromRowId
|
||||
..toRowId = toRowId;
|
||||
@ -93,7 +93,7 @@ class DatabaseViewBackendService {
|
||||
Future<Either<List<FieldPB>, FlowyError>> getFields({
|
||||
List<FieldIdPB>? fieldIds,
|
||||
}) {
|
||||
var payload = GetFieldPayloadPB.create()..viewId = viewId;
|
||||
final payload = GetFieldPayloadPB.create()..viewId = viewId;
|
||||
|
||||
if (fieldIds != null) {
|
||||
payload.fieldIds = RepeatedFieldIdPB(items: fieldIds);
|
||||
|
@ -418,7 +418,7 @@ class FieldController {
|
||||
|
||||
void _updateFieldInfos() {
|
||||
if (_fieldNotifier != null) {
|
||||
for (var field in _fieldNotifier!.fieldInfos) {
|
||||
for (final field in _fieldNotifier!.fieldInfos) {
|
||||
field._isGroupField = _groupConfigurationByFieldId[field.id] != null;
|
||||
field._hasFilter = _filterPBByFieldId[field.id] != null;
|
||||
field._hasSort = _sortPBByFieldId[field.id] != null;
|
||||
|
@ -33,7 +33,7 @@ class FieldBackendService {
|
||||
bool? visibility,
|
||||
double? width,
|
||||
}) {
|
||||
var payload = FieldChangesetPB.create()
|
||||
final payload = FieldChangesetPB.create()
|
||||
..viewId = viewId
|
||||
..fieldId = fieldId;
|
||||
|
||||
@ -61,7 +61,7 @@ class FieldBackendService {
|
||||
required String fieldId,
|
||||
required List<int> typeOptionData,
|
||||
}) {
|
||||
var payload = TypeOptionChangesetPB.create()
|
||||
final payload = TypeOptionChangesetPB.create()
|
||||
..viewId = viewId
|
||||
..fieldId = fieldId
|
||||
..typeOptionData = typeOptionData;
|
||||
|
@ -97,7 +97,7 @@ class FilterBackendService {
|
||||
].contains(fieldType),
|
||||
);
|
||||
|
||||
var filter = DateFilterPB();
|
||||
final filter = DateFilterPB();
|
||||
if (timestamp != null) {
|
||||
filter.timestamp = $fixnum.Int64(timestamp);
|
||||
} else {
|
||||
@ -178,7 +178,7 @@ class FilterBackendService {
|
||||
required FieldType fieldType,
|
||||
required List<int> data,
|
||||
}) {
|
||||
var insertFilterPayload = UpdateFilterPayloadPB.create()
|
||||
final insertFilterPayload = UpdateFilterPayloadPB.create()
|
||||
..fieldId = fieldId
|
||||
..fieldType = fieldType
|
||||
..viewId = viewId
|
||||
|
@ -13,7 +13,7 @@ class DatabaseLayoutBackendService {
|
||||
required String fieldId,
|
||||
required DatabaseLayoutPB layout,
|
||||
}) {
|
||||
var payload = UpdateViewPayloadPB.create()
|
||||
final payload = UpdateViewPayloadPB.create()
|
||||
..viewId = viewId
|
||||
..layout = _viewLayoutFromDatabaseLayout(layout);
|
||||
|
||||
|
@ -39,7 +39,7 @@ class RowCache {
|
||||
final RowChangesetNotifier _rowChangeReasonNotifier;
|
||||
|
||||
UnmodifiableListView<RowInfo> get rowInfos {
|
||||
var visibleRows = [..._rowList.rows];
|
||||
final visibleRows = [..._rowList.rows];
|
||||
return UnmodifiableListView(visibleRows);
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ class RowCache {
|
||||
|
||||
void _updateRows(List<UpdatedRowPB> updatedRows) {
|
||||
if (updatedRows.isEmpty) return;
|
||||
List<RowPB> rowPBs = [];
|
||||
final List<RowPB> rowPBs = [];
|
||||
for (final updatedRow in updatedRows) {
|
||||
for (final fieldId in updatedRow.fieldIds) {
|
||||
final key = CellCacheKey(
|
||||
@ -242,7 +242,7 @@ class RowCache {
|
||||
|
||||
CellContextByFieldId _makeGridCells(RowId rowId, RowPB? row) {
|
||||
// ignore: prefer_collection_literals
|
||||
var cellDataMap = CellContextByFieldId();
|
||||
final cellDataMap = CellContextByFieldId();
|
||||
for (final field in _delegate.fields) {
|
||||
if (field.visibility) {
|
||||
cellDataMap[field.id] = DatabaseCellContext(
|
||||
|
@ -75,7 +75,7 @@ class RowList {
|
||||
List<InsertedRowPB> insertedRows,
|
||||
RowInfo Function(RowPB) builder,
|
||||
) {
|
||||
InsertedIndexs insertIndexs = [];
|
||||
final InsertedIndexs insertIndexs = [];
|
||||
for (final insertRow in insertedRows) {
|
||||
final isContains = contains(insertRow.row.id);
|
||||
|
||||
|
@ -29,7 +29,7 @@ class SortBackendService {
|
||||
required FieldType fieldType,
|
||||
required SortConditionPB condition,
|
||||
}) {
|
||||
var insertSortPayload = UpdateSortPayloadPB.create()
|
||||
final insertSortPayload = UpdateSortPayloadPB.create()
|
||||
..fieldId = fieldId
|
||||
..fieldType = fieldType
|
||||
..viewId = viewId
|
||||
@ -55,7 +55,7 @@ class SortBackendService {
|
||||
required FieldType fieldType,
|
||||
required SortConditionPB condition,
|
||||
}) {
|
||||
var insertSortPayload = UpdateSortPayloadPB.create()
|
||||
final insertSortPayload = UpdateSortPayloadPB.create()
|
||||
..fieldId = fieldId
|
||||
..fieldType = fieldType
|
||||
..viewId = viewId
|
||||
|
@ -176,7 +176,7 @@ class BoardBloc extends Bloc<BoardEvent, BoardState> {
|
||||
}
|
||||
|
||||
void initializeGroups(List<GroupPB> groups) {
|
||||
for (var controller in groupControllers.values) {
|
||||
for (final controller in groupControllers.values) {
|
||||
controller.dispose();
|
||||
}
|
||||
groupControllers.clear();
|
||||
|
@ -71,7 +71,7 @@ class CalendarBloc extends Bloc<CalendarEvent, CalendarState> {
|
||||
await _updateCalendarLayoutSetting(layoutSetting);
|
||||
},
|
||||
didUpdateEvent: (CalendarEventData<CalendarDayEvent> eventData) {
|
||||
var allEvents = [...state.allEvents];
|
||||
final allEvents = [...state.allEvents];
|
||||
final index = allEvents.indexWhere(
|
||||
(element) => element.event!.eventId == eventData.event!.eventId,
|
||||
);
|
||||
@ -81,7 +81,7 @@ class CalendarBloc extends Bloc<CalendarEvent, CalendarState> {
|
||||
emit(state.copyWith(allEvents: allEvents, updateEvent: eventData));
|
||||
},
|
||||
didDeleteEvents: (List<RowId> deletedRowIds) {
|
||||
var events = [...state.allEvents];
|
||||
final events = [...state.allEvents];
|
||||
events.retainWhere(
|
||||
(element) => !deletedRowIds.contains(element.event!.eventId),
|
||||
);
|
||||
|
@ -201,9 +201,9 @@ class _DayBadge extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Color dayTextColor = Theme.of(context).colorScheme.onBackground;
|
||||
String monthString =
|
||||
final String monthString =
|
||||
DateFormat("MMM ", context.locale.toLanguageTag()).format(date);
|
||||
String dayString = date.day.toString();
|
||||
final String dayString = date.day.toString();
|
||||
|
||||
if (!isInMonth) {
|
||||
dayTextColor = Theme.of(context).disabledColor;
|
||||
|
@ -129,7 +129,7 @@ class _CalendarLayoutSettingState extends State<CalendarLayoutSetting> {
|
||||
List<CalendarLayoutSettingAction> _availableCalendarSettings(
|
||||
CalendarLayoutSettingPB layoutSettings,
|
||||
) {
|
||||
List<CalendarLayoutSettingAction> settings = [
|
||||
final List<CalendarLayoutSettingAction> settings = [
|
||||
CalendarLayoutSettingAction.layoutField,
|
||||
// CalendarLayoutSettingAction.layoutType,
|
||||
// CalendarLayoutSettingAction.showWeekNumber,
|
||||
|
@ -41,7 +41,7 @@ class SelectOptionFilterListBloc<T>
|
||||
);
|
||||
},
|
||||
didReceiveOptions: (newOptions) {
|
||||
List<SelectOptionPB> options = List.from(newOptions);
|
||||
final List<SelectOptionPB> options = List.from(newOptions);
|
||||
options.retainWhere(
|
||||
(element) => element.name.contains(state.predicate),
|
||||
);
|
||||
@ -91,7 +91,7 @@ class SelectOptionFilterListBloc<T>
|
||||
String predicate,
|
||||
Set<String> selectedOptionIds,
|
||||
) {
|
||||
List<SelectOptionPB> options = List.from(state.options);
|
||||
final List<SelectOptionPB> options = List.from(state.options);
|
||||
options.retainWhere((element) => element.name.contains(predicate));
|
||||
|
||||
return options.map((option) {
|
||||
|
@ -95,7 +95,7 @@ class _SelectOptionFilterEditorState extends State<SelectOptionFilterEditor> {
|
||||
child: BlocBuilder<SelectOptionFilterEditorBloc,
|
||||
SelectOptionFilterEditorState>(
|
||||
builder: (context, state) {
|
||||
List<Widget> slivers = [
|
||||
final List<Widget> slivers = [
|
||||
SliverToBoxAdapter(child: _buildFilterPanel(context, state)),
|
||||
];
|
||||
|
||||
|
@ -67,7 +67,7 @@ class _GridCreateFilterListState extends State<GridCreateFilterList> {
|
||||
);
|
||||
}).toList();
|
||||
|
||||
List<Widget> slivers = [
|
||||
final List<Widget> slivers = [
|
||||
SliverPersistentHeader(
|
||||
pinned: true,
|
||||
delegate: _FilterTextFieldDelegate(),
|
||||
|
@ -51,7 +51,7 @@ class _FieldEditorState extends State<FieldEditor> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> children = [
|
||||
final List<Widget> children = [
|
||||
_FieldNameTextField(popoverMutex: popoverMutex),
|
||||
if (widget.onDeleted != null) _addDeleteFieldButton(),
|
||||
if (widget.onHidden != null) _addHideFieldButton(),
|
||||
@ -226,7 +226,7 @@ class _DeleteFieldButton extends StatelessWidget {
|
||||
buildWhen: (previous, current) => previous != current,
|
||||
builder: (context, state) {
|
||||
final enable = !state.canDelete && !state.isGroupField;
|
||||
Widget button = FlowyButton(
|
||||
final Widget button = FlowyButton(
|
||||
disable: !enable,
|
||||
text: FlowyText.medium(
|
||||
LocaleKeys.grid_field_delete.tr(),
|
||||
@ -261,7 +261,7 @@ class _HideFieldButton extends StatelessWidget {
|
||||
return BlocBuilder<FieldEditorBloc, FieldEditorState>(
|
||||
buildWhen: (previous, current) => previous != current,
|
||||
builder: (context, state) {
|
||||
Widget button = FlowyButton(
|
||||
final Widget button = FlowyButton(
|
||||
text: FlowyText.medium(
|
||||
LocaleKeys.grid_field_hide.tr(),
|
||||
),
|
||||
|
@ -47,7 +47,7 @@ class FieldTypeOptionEditor extends StatelessWidget {
|
||||
state: state,
|
||||
);
|
||||
|
||||
List<Widget> children = [
|
||||
final List<Widget> children = [
|
||||
_SwitchFieldButton(popoverMutex: popoverMutex),
|
||||
if (typeOptionWidget != null) typeOptionWidget
|
||||
];
|
||||
|
@ -38,7 +38,7 @@ class SelectOptionTypeOptionWidget extends StatelessWidget {
|
||||
child:
|
||||
BlocBuilder<SelectOptionTypeOptionBloc, SelectOptionTypeOptionState>(
|
||||
builder: (context, state) {
|
||||
List<Widget> children = [
|
||||
final List<Widget> children = [
|
||||
const TypeOptionSeparator(),
|
||||
const OptionTitle(),
|
||||
if (state.isEditingOption)
|
||||
@ -70,7 +70,7 @@ class OptionTitle extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<SelectOptionTypeOptionBloc, SelectOptionTypeOptionState>(
|
||||
builder: (context, state) {
|
||||
List<Widget> children = [
|
||||
final List<Widget> children = [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 9),
|
||||
child: FlowyText.medium(
|
||||
|
@ -54,7 +54,7 @@ class SelectOptionTypeOptionEditor extends StatelessWidget {
|
||||
],
|
||||
child: BlocBuilder<EditSelectOptionBloc, EditSelectOptionState>(
|
||||
builder: (context, state) {
|
||||
List<Widget> cells = [
|
||||
final List<Widget> cells = [
|
||||
_OptionNameTextField(
|
||||
name: state.option.name,
|
||||
autoFocus: autoFocus,
|
||||
|
@ -269,7 +269,7 @@ class RowContent extends StatelessWidget {
|
||||
cellContainerNotifier: CellContainerNotifier(child),
|
||||
accessoryBuilder: (buildContext) {
|
||||
final builder = child.accessoryBuilder;
|
||||
List<GridCellAccessoryBuilder> accessories = [];
|
||||
final List<GridCellAccessoryBuilder> accessories = [];
|
||||
if (cellId.fieldInfo.isPrimary) {
|
||||
accessories.add(
|
||||
GridCellAccessoryBuilder(
|
||||
|
@ -66,7 +66,7 @@ class _GridCreateSortListState extends State<GridCreateSortList> {
|
||||
);
|
||||
}).toList();
|
||||
|
||||
List<Widget> slivers = [
|
||||
final List<Widget> slivers = [
|
||||
SliverPersistentHeader(
|
||||
pinned: true,
|
||||
delegate: _FilterTextFieldDelegate(),
|
||||
|
@ -91,7 +91,7 @@ List<DatabaseCellContext> _makeCells(
|
||||
String? groupFieldId,
|
||||
CellContextByFieldId originalCellMap,
|
||||
) {
|
||||
List<DatabaseCellContext> cells = [];
|
||||
final List<DatabaseCellContext> cells = [];
|
||||
for (final entry in originalCellMap.entries) {
|
||||
// Filter out the cell if it's fieldId equal to the groupFieldId
|
||||
if (groupFieldId != null) {
|
||||
|
@ -44,7 +44,7 @@ class _DateCardCellState extends State<DateCardCell> {
|
||||
if (state.dateStr.isEmpty) {
|
||||
return const SizedBox();
|
||||
} else {
|
||||
Widget? custom = widget.renderHook?.call(
|
||||
final Widget? custom = widget.renderHook?.call(
|
||||
state.data,
|
||||
widget.cardData,
|
||||
context,
|
||||
|
@ -53,7 +53,7 @@ class _NumberCardCellState extends State<NumberCardCell> {
|
||||
if (state.content.isEmpty) {
|
||||
return const SizedBox();
|
||||
} else {
|
||||
Widget? custom = widget.renderHook?.call(
|
||||
final Widget? custom = widget.renderHook?.call(
|
||||
state.content,
|
||||
widget.cardData,
|
||||
context,
|
||||
|
@ -55,7 +55,7 @@ class _SelectOptionCardCellState extends State<SelectOptionCardCell> {
|
||||
return previous.selectedOptions != current.selectedOptions;
|
||||
},
|
||||
builder: (context, state) {
|
||||
Widget? custom = widget.renderHook?.call(
|
||||
final Widget? custom = widget.renderHook?.call(
|
||||
state.selectedOptions,
|
||||
widget.cardData,
|
||||
context,
|
||||
|
@ -107,7 +107,7 @@ class _TextCardCellState extends State<TextCardCell> {
|
||||
},
|
||||
builder: (context, state) {
|
||||
// Returns a custom render widget
|
||||
Widget? custom = widget.renderHook?.call(
|
||||
final Widget? custom = widget.renderHook?.call(
|
||||
state.content,
|
||||
widget.cardData,
|
||||
context,
|
||||
|
@ -71,7 +71,7 @@ class _CardEnterRegion extends StatelessWidget {
|
||||
return Selector<_CardContainerNotifier, bool>(
|
||||
selector: (context, notifier) => notifier.onEnter,
|
||||
builder: (context, onEnter, _) {
|
||||
List<Widget> children = [child];
|
||||
final List<Widget> children = [child];
|
||||
if (onEnter) {
|
||||
children.add(
|
||||
Positioned(
|
||||
|
@ -121,7 +121,7 @@ class _AccessoryHoverState extends State<AccessoryHover> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> children = [
|
||||
final List<Widget> children = [
|
||||
Padding(padding: widget.contentPadding, child: widget.child),
|
||||
];
|
||||
|
||||
|
@ -98,7 +98,7 @@ class _GridCellEnterRegion extends StatelessWidget {
|
||||
!cellNotifier.isFocus &&
|
||||
(cellNotifier.onEnter || regionNotifier.onEnter && isPrimary),
|
||||
builder: (context, showAccessory, _) {
|
||||
List<Widget> children = [child];
|
||||
final List<Widget> children = [child];
|
||||
if (showAccessory) {
|
||||
children.add(
|
||||
CellAccessoryContainer(accessories: accessories).positioned(
|
||||
|
@ -81,7 +81,7 @@ class DateCellCalendarBloc
|
||||
date == null && time != null ||
|
||||
date != null && time == null,
|
||||
);
|
||||
String? newTime = time ?? state.time;
|
||||
final String? newTime = time ?? state.time;
|
||||
DateTime? newDate = _utcToLocalAddTime(date);
|
||||
if (time != null && time.isNotEmpty) {
|
||||
newDate = state.dateTime ?? DateTime.now();
|
||||
@ -295,7 +295,7 @@ DateCellData _dateDataFromCellData(DateCellDataPB? cellData) {
|
||||
dateTime = DateTime.fromMillisecondsSinceEpoch(timestamp.toInt());
|
||||
time = cellData.time;
|
||||
}
|
||||
bool includeTime = cellData.includeTime;
|
||||
final bool includeTime = cellData.includeTime;
|
||||
|
||||
return DateCellData(dateTime: dateTime, time: time, includeTime: includeTime);
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ class _CellCalendarWidgetState extends State<_CellCalendarWidget> {
|
||||
)..add(const DateCellCalendarEvent.initial()),
|
||||
child: BlocBuilder<DateCellCalendarBloc, DateCellCalendarState>(
|
||||
builder: (context, state) {
|
||||
List<Widget> children = [
|
||||
final List<Widget> children = [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||
child: _buildCalendar(context),
|
||||
@ -403,7 +403,7 @@ class _CalDateTimeSettingState extends State<_CalDateTimeSetting> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> children = [
|
||||
final List<Widget> children = [
|
||||
AppFlowyPopover(
|
||||
mutex: timeSettingPopoverMutex,
|
||||
triggerActions: PopoverTriggerFlags.hover | PopoverTriggerFlags.click,
|
||||
|
@ -167,7 +167,7 @@ class SelectOptionWrap extends StatefulWidget {
|
||||
class _SelectOptionWrapState extends State<SelectOptionWrap> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget child = _buildOptions(context);
|
||||
final Widget child = _buildOptions(context);
|
||||
|
||||
final constraints = BoxConstraints.loose(
|
||||
Size(
|
||||
|
@ -75,7 +75,7 @@ class _OptionList extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<SelectOptionCellEditorBloc, SelectOptionEditorState>(
|
||||
builder: (context, state) {
|
||||
List<Widget> cells = [];
|
||||
final List<Widget> cells = [];
|
||||
cells.add(const _Title());
|
||||
cells.addAll(
|
||||
state.options.map((option) {
|
||||
|
@ -199,7 +199,7 @@ class _SelectOptionTextFieldState extends State<SelectOptionTextField> {
|
||||
|
||||
@visibleForTesting
|
||||
List splitInput(String input, List<String> textSeparators) {
|
||||
List<String> splits = [];
|
||||
final List<String> splits = [];
|
||||
String currentString = '';
|
||||
|
||||
// split the string into tokens
|
||||
|
@ -8,7 +8,7 @@ extension BuildContextExtension on BuildContext {
|
||||
if (box == null) {
|
||||
return false;
|
||||
}
|
||||
var result = BoxHitTestResult();
|
||||
final result = BoxHitTestResult();
|
||||
box.hitTest(result, position: box.globalToLocal(offset));
|
||||
return result.path.any((entry) => entry.target == box);
|
||||
}
|
||||
|
@ -282,9 +282,9 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
|
||||
// Copy from flutter.highlight package.
|
||||
// https://github.com/git-touch/highlight.dart/blob/master/flutter_highlight/lib/flutter_highlight.dart
|
||||
List<TextSpan> _convert(List<highlight.Node> nodes) {
|
||||
List<TextSpan> spans = [];
|
||||
final List<TextSpan> spans = [];
|
||||
var currentSpans = spans;
|
||||
List<List<TextSpan>> stack = [];
|
||||
final List<List<TextSpan>> stack = [];
|
||||
|
||||
void traverse(highlight.Node node) {
|
||||
if (node.value != null) {
|
||||
@ -297,7 +297,7 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
|
||||
),
|
||||
);
|
||||
} else if (node.children != null) {
|
||||
List<TextSpan> tmp = [];
|
||||
final List<TextSpan> tmp = [];
|
||||
currentSpans.add(
|
||||
TextSpan(
|
||||
children: tmp,
|
||||
@ -307,7 +307,7 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
|
||||
stack.add(currentSpans);
|
||||
currentSpans = tmp;
|
||||
|
||||
for (var n in node.children!) {
|
||||
for (final n in node.children!) {
|
||||
traverse(n);
|
||||
if (n == node.children!.last) {
|
||||
currentSpans = stack.isEmpty ? spans : stack.removeLast();
|
||||
@ -316,7 +316,7 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
|
||||
}
|
||||
}
|
||||
|
||||
for (var node in nodes) {
|
||||
for (final node in nodes) {
|
||||
traverse(node);
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ class _ChangeCoverPopoverState extends State<ChangeCoverPopover> {
|
||||
return BlocBuilder<ChangeCoverPopoverBloc, ChangeCoverPopoverState>(
|
||||
builder: (context, state) {
|
||||
if (state is Loaded) {
|
||||
List<String> images = state.imageNames;
|
||||
final List<String> images = state.imageNames;
|
||||
return GridView.builder(
|
||||
shrinkWrap: true,
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
|
@ -82,8 +82,8 @@ class CoverImagePickerBloc
|
||||
}
|
||||
|
||||
_saveToGallery(CoverImagePickerState state) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
List<String> imagePaths = prefs.getStringList(kLocalImagesKey) ?? [];
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
final List<String> imagePaths = prefs.getStringList(kLocalImagesKey) ?? [];
|
||||
final directory = await _coverPath();
|
||||
|
||||
if (state is FileImagePicked) {
|
||||
|
@ -39,7 +39,7 @@ class DefaultEmojiPickerViewState extends State<DefaultEmojiPickerView>
|
||||
_emojiFocusNode.requestFocus();
|
||||
|
||||
_emojiController.addListener(() {
|
||||
String query = _emojiController.text.toLowerCase();
|
||||
final String query = _emojiController.text.toLowerCase();
|
||||
if (query.isEmpty) {
|
||||
searchEmojiList.emoji.clear();
|
||||
_pageController!.jumpToPage(
|
||||
@ -47,7 +47,7 @@ class DefaultEmojiPickerViewState extends State<DefaultEmojiPickerView>
|
||||
);
|
||||
} else {
|
||||
searchEmojiList.emoji.clear();
|
||||
for (var element in widget.state.categoryEmoji) {
|
||||
for (final element in widget.state.categoryEmoji) {
|
||||
searchEmojiList.emoji.addAll(
|
||||
element.emoji.where((item) {
|
||||
return item.name.toLowerCase().contains(query);
|
||||
@ -86,7 +86,7 @@ class DefaultEmojiPickerViewState extends State<DefaultEmojiPickerView>
|
||||
}
|
||||
|
||||
bool isEmojiSearching() {
|
||||
bool result =
|
||||
final bool result =
|
||||
searchEmojiList.emoji.isNotEmpty || _emojiController.text.isNotEmpty;
|
||||
|
||||
return result;
|
||||
@ -182,7 +182,7 @@ class DefaultEmojiPickerViewState extends State<DefaultEmojiPickerView>
|
||||
// );
|
||||
// },
|
||||
itemBuilder: (context, index) {
|
||||
CategoryEmoji catEmoji = isEmojiSearching()
|
||||
final CategoryEmoji catEmoji = isEmojiSearching()
|
||||
? searchEmojiList
|
||||
: widget.state.categoryEmoji[index];
|
||||
return _buildPage(emojiSize, catEmoji);
|
||||
|
@ -151,7 +151,7 @@ class EmojiPickerState extends State<EmojiPicker> {
|
||||
recentEmoji.map((e) => e.emoji).toList().cast<Emoji>();
|
||||
}
|
||||
|
||||
var state = EmojiViewState(
|
||||
final state = EmojiViewState(
|
||||
categoryEmoji,
|
||||
_getOnEmojiListener(),
|
||||
widget.onBackspacePressed,
|
||||
@ -239,13 +239,13 @@ class EmojiPickerState extends State<EmojiPicker> {
|
||||
Map<String, String> emoji,) async {
|
||||
if (Platform.isAndroid) {
|
||||
Map<String, String>? filtered = {};
|
||||
var delimiter = '|';
|
||||
const delimiter = '|';
|
||||
try {
|
||||
var entries = emoji.values.join(delimiter);
|
||||
var keys = emoji.keys.join(delimiter);
|
||||
var result = (await platform.invokeMethod<String>('checkAvailability',
|
||||
final entries = emoji.values.join(delimiter);
|
||||
final keys = emoji.keys.join(delimiter);
|
||||
final result = (await platform.invokeMethod<String>('checkAvailability',
|
||||
{'emojiKeys': keys, 'emojiEntries': entries},)) as String;
|
||||
var resultKeys = result.split(delimiter);
|
||||
final resultKeys = result.split(delimiter);
|
||||
for (var i = 0; i < resultKeys.length; i++) {
|
||||
filtered[resultKeys[i]] = emoji[resultKeys[i]]!;
|
||||
}
|
||||
@ -261,11 +261,11 @@ class EmojiPickerState extends State<EmojiPicker> {
|
||||
// Restore locally cached emoji
|
||||
Future<Map<String, String>?> _restoreFilteredEmojis(String title) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
var emojiJson = prefs.getString(title);
|
||||
final emojiJson = prefs.getString(title);
|
||||
if (emojiJson == null) {
|
||||
return null;
|
||||
}
|
||||
var emojis =
|
||||
final emojis =
|
||||
Map<String, String>.from(jsonDecode(emojiJson) as Map<String, dynamic>);
|
||||
return emojis;
|
||||
}
|
||||
@ -274,25 +274,25 @@ class EmojiPickerState extends State<EmojiPicker> {
|
||||
Future<void> _cacheFilteredEmojis(
|
||||
String title, Map<String, String> emojis,) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
var emojiJson = jsonEncode(emojis);
|
||||
final emojiJson = jsonEncode(emojis);
|
||||
prefs.setString(title, emojiJson);
|
||||
}
|
||||
|
||||
// Returns list of recently used emoji from cache
|
||||
Future<List<RecentEmoji>> _getRecentEmojis() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
var emojiJson = prefs.getString('recent');
|
||||
final emojiJson = prefs.getString('recent');
|
||||
if (emojiJson == null) {
|
||||
return [];
|
||||
}
|
||||
var json = jsonDecode(emojiJson) as List<dynamic>;
|
||||
final json = jsonDecode(emojiJson) as List<dynamic>;
|
||||
return json.map<RecentEmoji>(RecentEmoji.fromJson).toList();
|
||||
}
|
||||
|
||||
// Add an emoji to recently used list or increase its counter
|
||||
Future<void> _addEmojiToRecentlyUsed(Emoji emoji) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
var recentEmojiIndex =
|
||||
final recentEmojiIndex =
|
||||
recentEmoji.indexWhere((element) => element.emoji.emoji == emoji.emoji);
|
||||
if (recentEmojiIndex != -1) {
|
||||
// Already exist in recent list
|
||||
|
Reference in New Issue
Block a user