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
|
||||
|
Reference in New Issue
Block a user