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:
Yatendra Kumar
2023-06-07 13:55:37 +05:30
committed by GitHub
parent cb7bb390e6
commit 95d620931f
65 changed files with 142 additions and 138 deletions

View File

@ -30,6 +30,10 @@ linter:
rules: rules:
- require_trailing_commas - require_trailing_commas
- prefer_final_fields
- prefer_final_in_for_each
- prefer_final_locals
# Additional information about this file can be found at # Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options # https://dart.dev/guides/language/analysis-options

View File

@ -45,7 +45,7 @@ void main() {
final TestPointer pointer = TestPointer(1, PointerDeviceKind.mouse); final TestPointer pointer = TestPointer(1, PointerDeviceKind.mouse);
final imageFinder = find.byType(Image); final imageFinder = find.byType(Image);
Offset offset = tester.getCenter(imageFinder); final Offset offset = tester.getCenter(imageFinder);
pointer.hover(offset); pointer.hover(offset);
expect(find.byType(RoundedTextButton), findsOneWidget); expect(find.byType(RoundedTextButton), findsOneWidget);

View File

@ -38,7 +38,7 @@ class CellCache {
} }
void remove(CellCacheKey key) { void remove(CellCacheKey key) {
var map = _cellDataByFieldId[key.fieldId]; final map = _cellDataByFieldId[key.fieldId];
if (map != null) { if (map != null) {
map.remove(key.rowId); map.remove(key.rowId);
} }

View File

@ -46,7 +46,7 @@ class DateCellDataPersistence implements CellDataPersistence<DateCellData> {
@override @override
Future<Option<FlowyError>> save(DateCellData data) { Future<Option<FlowyError>> save(DateCellData data) {
var payload = DateChangesetPB.create() final payload = DateChangesetPB.create()
..cellPath = _makeCellPath(cellContext); ..cellPath = _makeCellPath(cellContext);
if (data.dateTime != null) { if (data.dateTime != null) {
final date = (data.dateTime!.millisecondsSinceEpoch ~/ 1000).toString(); final date = (data.dateTime!.millisecondsSinceEpoch ~/ 1000).toString();

View File

@ -35,7 +35,7 @@ class DatabaseViewBackendService {
String? groupId, String? groupId,
Map<String, String>? cellDataByFieldId, Map<String, String>? cellDataByFieldId,
}) { }) {
var payload = CreateRowPayloadPB.create()..viewId = viewId; final payload = CreateRowPayloadPB.create()..viewId = viewId;
payload.startRowId = startRowId ?? ""; payload.startRowId = startRowId ?? "";
if (groupId != null) { if (groupId != null) {
@ -54,7 +54,7 @@ class DatabaseViewBackendService {
required String toGroupId, required String toGroupId,
RowId? toRowId, RowId? toRowId,
}) { }) {
var payload = MoveGroupRowPayloadPB.create() final payload = MoveGroupRowPayloadPB.create()
..viewId = viewId ..viewId = viewId
..fromRowId = fromRowId ..fromRowId = fromRowId
..toGroupId = toGroupId; ..toGroupId = toGroupId;
@ -70,7 +70,7 @@ class DatabaseViewBackendService {
required String fromRowId, required String fromRowId,
required String toRowId, required String toRowId,
}) { }) {
var payload = MoveRowPayloadPB.create() final payload = MoveRowPayloadPB.create()
..viewId = viewId ..viewId = viewId
..fromRowId = fromRowId ..fromRowId = fromRowId
..toRowId = toRowId; ..toRowId = toRowId;
@ -93,7 +93,7 @@ class DatabaseViewBackendService {
Future<Either<List<FieldPB>, FlowyError>> getFields({ Future<Either<List<FieldPB>, FlowyError>> getFields({
List<FieldIdPB>? fieldIds, List<FieldIdPB>? fieldIds,
}) { }) {
var payload = GetFieldPayloadPB.create()..viewId = viewId; final payload = GetFieldPayloadPB.create()..viewId = viewId;
if (fieldIds != null) { if (fieldIds != null) {
payload.fieldIds = RepeatedFieldIdPB(items: fieldIds); payload.fieldIds = RepeatedFieldIdPB(items: fieldIds);

View File

@ -418,7 +418,7 @@ class FieldController {
void _updateFieldInfos() { void _updateFieldInfos() {
if (_fieldNotifier != null) { if (_fieldNotifier != null) {
for (var field in _fieldNotifier!.fieldInfos) { for (final field in _fieldNotifier!.fieldInfos) {
field._isGroupField = _groupConfigurationByFieldId[field.id] != null; field._isGroupField = _groupConfigurationByFieldId[field.id] != null;
field._hasFilter = _filterPBByFieldId[field.id] != null; field._hasFilter = _filterPBByFieldId[field.id] != null;
field._hasSort = _sortPBByFieldId[field.id] != null; field._hasSort = _sortPBByFieldId[field.id] != null;

View File

@ -33,7 +33,7 @@ class FieldBackendService {
bool? visibility, bool? visibility,
double? width, double? width,
}) { }) {
var payload = FieldChangesetPB.create() final payload = FieldChangesetPB.create()
..viewId = viewId ..viewId = viewId
..fieldId = fieldId; ..fieldId = fieldId;
@ -61,7 +61,7 @@ class FieldBackendService {
required String fieldId, required String fieldId,
required List<int> typeOptionData, required List<int> typeOptionData,
}) { }) {
var payload = TypeOptionChangesetPB.create() final payload = TypeOptionChangesetPB.create()
..viewId = viewId ..viewId = viewId
..fieldId = fieldId ..fieldId = fieldId
..typeOptionData = typeOptionData; ..typeOptionData = typeOptionData;

View File

@ -97,7 +97,7 @@ class FilterBackendService {
].contains(fieldType), ].contains(fieldType),
); );
var filter = DateFilterPB(); final filter = DateFilterPB();
if (timestamp != null) { if (timestamp != null) {
filter.timestamp = $fixnum.Int64(timestamp); filter.timestamp = $fixnum.Int64(timestamp);
} else { } else {
@ -178,7 +178,7 @@ class FilterBackendService {
required FieldType fieldType, required FieldType fieldType,
required List<int> data, required List<int> data,
}) { }) {
var insertFilterPayload = UpdateFilterPayloadPB.create() final insertFilterPayload = UpdateFilterPayloadPB.create()
..fieldId = fieldId ..fieldId = fieldId
..fieldType = fieldType ..fieldType = fieldType
..viewId = viewId ..viewId = viewId

View File

@ -13,7 +13,7 @@ class DatabaseLayoutBackendService {
required String fieldId, required String fieldId,
required DatabaseLayoutPB layout, required DatabaseLayoutPB layout,
}) { }) {
var payload = UpdateViewPayloadPB.create() final payload = UpdateViewPayloadPB.create()
..viewId = viewId ..viewId = viewId
..layout = _viewLayoutFromDatabaseLayout(layout); ..layout = _viewLayoutFromDatabaseLayout(layout);

View File

@ -39,7 +39,7 @@ class RowCache {
final RowChangesetNotifier _rowChangeReasonNotifier; final RowChangesetNotifier _rowChangeReasonNotifier;
UnmodifiableListView<RowInfo> get rowInfos { UnmodifiableListView<RowInfo> get rowInfos {
var visibleRows = [..._rowList.rows]; final visibleRows = [..._rowList.rows];
return UnmodifiableListView(visibleRows); return UnmodifiableListView(visibleRows);
} }
@ -138,7 +138,7 @@ class RowCache {
void _updateRows(List<UpdatedRowPB> updatedRows) { void _updateRows(List<UpdatedRowPB> updatedRows) {
if (updatedRows.isEmpty) return; if (updatedRows.isEmpty) return;
List<RowPB> rowPBs = []; final List<RowPB> rowPBs = [];
for (final updatedRow in updatedRows) { for (final updatedRow in updatedRows) {
for (final fieldId in updatedRow.fieldIds) { for (final fieldId in updatedRow.fieldIds) {
final key = CellCacheKey( final key = CellCacheKey(
@ -242,7 +242,7 @@ class RowCache {
CellContextByFieldId _makeGridCells(RowId rowId, RowPB? row) { CellContextByFieldId _makeGridCells(RowId rowId, RowPB? row) {
// ignore: prefer_collection_literals // ignore: prefer_collection_literals
var cellDataMap = CellContextByFieldId(); final cellDataMap = CellContextByFieldId();
for (final field in _delegate.fields) { for (final field in _delegate.fields) {
if (field.visibility) { if (field.visibility) {
cellDataMap[field.id] = DatabaseCellContext( cellDataMap[field.id] = DatabaseCellContext(

View File

@ -75,7 +75,7 @@ class RowList {
List<InsertedRowPB> insertedRows, List<InsertedRowPB> insertedRows,
RowInfo Function(RowPB) builder, RowInfo Function(RowPB) builder,
) { ) {
InsertedIndexs insertIndexs = []; final InsertedIndexs insertIndexs = [];
for (final insertRow in insertedRows) { for (final insertRow in insertedRows) {
final isContains = contains(insertRow.row.id); final isContains = contains(insertRow.row.id);

View File

@ -29,7 +29,7 @@ class SortBackendService {
required FieldType fieldType, required FieldType fieldType,
required SortConditionPB condition, required SortConditionPB condition,
}) { }) {
var insertSortPayload = UpdateSortPayloadPB.create() final insertSortPayload = UpdateSortPayloadPB.create()
..fieldId = fieldId ..fieldId = fieldId
..fieldType = fieldType ..fieldType = fieldType
..viewId = viewId ..viewId = viewId
@ -55,7 +55,7 @@ class SortBackendService {
required FieldType fieldType, required FieldType fieldType,
required SortConditionPB condition, required SortConditionPB condition,
}) { }) {
var insertSortPayload = UpdateSortPayloadPB.create() final insertSortPayload = UpdateSortPayloadPB.create()
..fieldId = fieldId ..fieldId = fieldId
..fieldType = fieldType ..fieldType = fieldType
..viewId = viewId ..viewId = viewId

View File

@ -176,7 +176,7 @@ class BoardBloc extends Bloc<BoardEvent, BoardState> {
} }
void initializeGroups(List<GroupPB> groups) { void initializeGroups(List<GroupPB> groups) {
for (var controller in groupControllers.values) { for (final controller in groupControllers.values) {
controller.dispose(); controller.dispose();
} }
groupControllers.clear(); groupControllers.clear();

View File

@ -71,7 +71,7 @@ class CalendarBloc extends Bloc<CalendarEvent, CalendarState> {
await _updateCalendarLayoutSetting(layoutSetting); await _updateCalendarLayoutSetting(layoutSetting);
}, },
didUpdateEvent: (CalendarEventData<CalendarDayEvent> eventData) { didUpdateEvent: (CalendarEventData<CalendarDayEvent> eventData) {
var allEvents = [...state.allEvents]; final allEvents = [...state.allEvents];
final index = allEvents.indexWhere( final index = allEvents.indexWhere(
(element) => element.event!.eventId == eventData.event!.eventId, (element) => element.event!.eventId == eventData.event!.eventId,
); );
@ -81,7 +81,7 @@ class CalendarBloc extends Bloc<CalendarEvent, CalendarState> {
emit(state.copyWith(allEvents: allEvents, updateEvent: eventData)); emit(state.copyWith(allEvents: allEvents, updateEvent: eventData));
}, },
didDeleteEvents: (List<RowId> deletedRowIds) { didDeleteEvents: (List<RowId> deletedRowIds) {
var events = [...state.allEvents]; final events = [...state.allEvents];
events.retainWhere( events.retainWhere(
(element) => !deletedRowIds.contains(element.event!.eventId), (element) => !deletedRowIds.contains(element.event!.eventId),
); );

View File

@ -201,9 +201,9 @@ class _DayBadge extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Color dayTextColor = Theme.of(context).colorScheme.onBackground; Color dayTextColor = Theme.of(context).colorScheme.onBackground;
String monthString = final String monthString =
DateFormat("MMM ", context.locale.toLanguageTag()).format(date); DateFormat("MMM ", context.locale.toLanguageTag()).format(date);
String dayString = date.day.toString(); final String dayString = date.day.toString();
if (!isInMonth) { if (!isInMonth) {
dayTextColor = Theme.of(context).disabledColor; dayTextColor = Theme.of(context).disabledColor;

View File

@ -129,7 +129,7 @@ class _CalendarLayoutSettingState extends State<CalendarLayoutSetting> {
List<CalendarLayoutSettingAction> _availableCalendarSettings( List<CalendarLayoutSettingAction> _availableCalendarSettings(
CalendarLayoutSettingPB layoutSettings, CalendarLayoutSettingPB layoutSettings,
) { ) {
List<CalendarLayoutSettingAction> settings = [ final List<CalendarLayoutSettingAction> settings = [
CalendarLayoutSettingAction.layoutField, CalendarLayoutSettingAction.layoutField,
// CalendarLayoutSettingAction.layoutType, // CalendarLayoutSettingAction.layoutType,
// CalendarLayoutSettingAction.showWeekNumber, // CalendarLayoutSettingAction.showWeekNumber,

View File

@ -41,7 +41,7 @@ class SelectOptionFilterListBloc<T>
); );
}, },
didReceiveOptions: (newOptions) { didReceiveOptions: (newOptions) {
List<SelectOptionPB> options = List.from(newOptions); final List<SelectOptionPB> options = List.from(newOptions);
options.retainWhere( options.retainWhere(
(element) => element.name.contains(state.predicate), (element) => element.name.contains(state.predicate),
); );
@ -91,7 +91,7 @@ class SelectOptionFilterListBloc<T>
String predicate, String predicate,
Set<String> selectedOptionIds, 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)); options.retainWhere((element) => element.name.contains(predicate));
return options.map((option) { return options.map((option) {

View File

@ -95,7 +95,7 @@ class _SelectOptionFilterEditorState extends State<SelectOptionFilterEditor> {
child: BlocBuilder<SelectOptionFilterEditorBloc, child: BlocBuilder<SelectOptionFilterEditorBloc,
SelectOptionFilterEditorState>( SelectOptionFilterEditorState>(
builder: (context, state) { builder: (context, state) {
List<Widget> slivers = [ final List<Widget> slivers = [
SliverToBoxAdapter(child: _buildFilterPanel(context, state)), SliverToBoxAdapter(child: _buildFilterPanel(context, state)),
]; ];

View File

@ -67,7 +67,7 @@ class _GridCreateFilterListState extends State<GridCreateFilterList> {
); );
}).toList(); }).toList();
List<Widget> slivers = [ final List<Widget> slivers = [
SliverPersistentHeader( SliverPersistentHeader(
pinned: true, pinned: true,
delegate: _FilterTextFieldDelegate(), delegate: _FilterTextFieldDelegate(),

View File

@ -51,7 +51,7 @@ class _FieldEditorState extends State<FieldEditor> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
List<Widget> children = [ final List<Widget> children = [
_FieldNameTextField(popoverMutex: popoverMutex), _FieldNameTextField(popoverMutex: popoverMutex),
if (widget.onDeleted != null) _addDeleteFieldButton(), if (widget.onDeleted != null) _addDeleteFieldButton(),
if (widget.onHidden != null) _addHideFieldButton(), if (widget.onHidden != null) _addHideFieldButton(),
@ -226,7 +226,7 @@ class _DeleteFieldButton extends StatelessWidget {
buildWhen: (previous, current) => previous != current, buildWhen: (previous, current) => previous != current,
builder: (context, state) { builder: (context, state) {
final enable = !state.canDelete && !state.isGroupField; final enable = !state.canDelete && !state.isGroupField;
Widget button = FlowyButton( final Widget button = FlowyButton(
disable: !enable, disable: !enable,
text: FlowyText.medium( text: FlowyText.medium(
LocaleKeys.grid_field_delete.tr(), LocaleKeys.grid_field_delete.tr(),
@ -261,7 +261,7 @@ class _HideFieldButton extends StatelessWidget {
return BlocBuilder<FieldEditorBloc, FieldEditorState>( return BlocBuilder<FieldEditorBloc, FieldEditorState>(
buildWhen: (previous, current) => previous != current, buildWhen: (previous, current) => previous != current,
builder: (context, state) { builder: (context, state) {
Widget button = FlowyButton( final Widget button = FlowyButton(
text: FlowyText.medium( text: FlowyText.medium(
LocaleKeys.grid_field_hide.tr(), LocaleKeys.grid_field_hide.tr(),
), ),

View File

@ -47,7 +47,7 @@ class FieldTypeOptionEditor extends StatelessWidget {
state: state, state: state,
); );
List<Widget> children = [ final List<Widget> children = [
_SwitchFieldButton(popoverMutex: popoverMutex), _SwitchFieldButton(popoverMutex: popoverMutex),
if (typeOptionWidget != null) typeOptionWidget if (typeOptionWidget != null) typeOptionWidget
]; ];

View File

@ -38,7 +38,7 @@ class SelectOptionTypeOptionWidget extends StatelessWidget {
child: child:
BlocBuilder<SelectOptionTypeOptionBloc, SelectOptionTypeOptionState>( BlocBuilder<SelectOptionTypeOptionBloc, SelectOptionTypeOptionState>(
builder: (context, state) { builder: (context, state) {
List<Widget> children = [ final List<Widget> children = [
const TypeOptionSeparator(), const TypeOptionSeparator(),
const OptionTitle(), const OptionTitle(),
if (state.isEditingOption) if (state.isEditingOption)
@ -70,7 +70,7 @@ class OptionTitle extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocBuilder<SelectOptionTypeOptionBloc, SelectOptionTypeOptionState>( return BlocBuilder<SelectOptionTypeOptionBloc, SelectOptionTypeOptionState>(
builder: (context, state) { builder: (context, state) {
List<Widget> children = [ final List<Widget> children = [
Padding( Padding(
padding: const EdgeInsets.only(left: 9), padding: const EdgeInsets.only(left: 9),
child: FlowyText.medium( child: FlowyText.medium(

View File

@ -54,7 +54,7 @@ class SelectOptionTypeOptionEditor extends StatelessWidget {
], ],
child: BlocBuilder<EditSelectOptionBloc, EditSelectOptionState>( child: BlocBuilder<EditSelectOptionBloc, EditSelectOptionState>(
builder: (context, state) { builder: (context, state) {
List<Widget> cells = [ final List<Widget> cells = [
_OptionNameTextField( _OptionNameTextField(
name: state.option.name, name: state.option.name,
autoFocus: autoFocus, autoFocus: autoFocus,

View File

@ -269,7 +269,7 @@ class RowContent extends StatelessWidget {
cellContainerNotifier: CellContainerNotifier(child), cellContainerNotifier: CellContainerNotifier(child),
accessoryBuilder: (buildContext) { accessoryBuilder: (buildContext) {
final builder = child.accessoryBuilder; final builder = child.accessoryBuilder;
List<GridCellAccessoryBuilder> accessories = []; final List<GridCellAccessoryBuilder> accessories = [];
if (cellId.fieldInfo.isPrimary) { if (cellId.fieldInfo.isPrimary) {
accessories.add( accessories.add(
GridCellAccessoryBuilder( GridCellAccessoryBuilder(

View File

@ -66,7 +66,7 @@ class _GridCreateSortListState extends State<GridCreateSortList> {
); );
}).toList(); }).toList();
List<Widget> slivers = [ final List<Widget> slivers = [
SliverPersistentHeader( SliverPersistentHeader(
pinned: true, pinned: true,
delegate: _FilterTextFieldDelegate(), delegate: _FilterTextFieldDelegate(),

View File

@ -91,7 +91,7 @@ List<DatabaseCellContext> _makeCells(
String? groupFieldId, String? groupFieldId,
CellContextByFieldId originalCellMap, CellContextByFieldId originalCellMap,
) { ) {
List<DatabaseCellContext> cells = []; final List<DatabaseCellContext> cells = [];
for (final entry in originalCellMap.entries) { for (final entry in originalCellMap.entries) {
// Filter out the cell if it's fieldId equal to the groupFieldId // Filter out the cell if it's fieldId equal to the groupFieldId
if (groupFieldId != null) { if (groupFieldId != null) {

View File

@ -44,7 +44,7 @@ class _DateCardCellState extends State<DateCardCell> {
if (state.dateStr.isEmpty) { if (state.dateStr.isEmpty) {
return const SizedBox(); return const SizedBox();
} else { } else {
Widget? custom = widget.renderHook?.call( final Widget? custom = widget.renderHook?.call(
state.data, state.data,
widget.cardData, widget.cardData,
context, context,

View File

@ -53,7 +53,7 @@ class _NumberCardCellState extends State<NumberCardCell> {
if (state.content.isEmpty) { if (state.content.isEmpty) {
return const SizedBox(); return const SizedBox();
} else { } else {
Widget? custom = widget.renderHook?.call( final Widget? custom = widget.renderHook?.call(
state.content, state.content,
widget.cardData, widget.cardData,
context, context,

View File

@ -55,7 +55,7 @@ class _SelectOptionCardCellState extends State<SelectOptionCardCell> {
return previous.selectedOptions != current.selectedOptions; return previous.selectedOptions != current.selectedOptions;
}, },
builder: (context, state) { builder: (context, state) {
Widget? custom = widget.renderHook?.call( final Widget? custom = widget.renderHook?.call(
state.selectedOptions, state.selectedOptions,
widget.cardData, widget.cardData,
context, context,

View File

@ -107,7 +107,7 @@ class _TextCardCellState extends State<TextCardCell> {
}, },
builder: (context, state) { builder: (context, state) {
// Returns a custom render widget // Returns a custom render widget
Widget? custom = widget.renderHook?.call( final Widget? custom = widget.renderHook?.call(
state.content, state.content,
widget.cardData, widget.cardData,
context, context,

View File

@ -71,7 +71,7 @@ class _CardEnterRegion extends StatelessWidget {
return Selector<_CardContainerNotifier, bool>( return Selector<_CardContainerNotifier, bool>(
selector: (context, notifier) => notifier.onEnter, selector: (context, notifier) => notifier.onEnter,
builder: (context, onEnter, _) { builder: (context, onEnter, _) {
List<Widget> children = [child]; final List<Widget> children = [child];
if (onEnter) { if (onEnter) {
children.add( children.add(
Positioned( Positioned(

View File

@ -121,7 +121,7 @@ class _AccessoryHoverState extends State<AccessoryHover> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
List<Widget> children = [ final List<Widget> children = [
Padding(padding: widget.contentPadding, child: widget.child), Padding(padding: widget.contentPadding, child: widget.child),
]; ];

View File

@ -98,7 +98,7 @@ class _GridCellEnterRegion extends StatelessWidget {
!cellNotifier.isFocus && !cellNotifier.isFocus &&
(cellNotifier.onEnter || regionNotifier.onEnter && isPrimary), (cellNotifier.onEnter || regionNotifier.onEnter && isPrimary),
builder: (context, showAccessory, _) { builder: (context, showAccessory, _) {
List<Widget> children = [child]; final List<Widget> children = [child];
if (showAccessory) { if (showAccessory) {
children.add( children.add(
CellAccessoryContainer(accessories: accessories).positioned( CellAccessoryContainer(accessories: accessories).positioned(

View File

@ -81,7 +81,7 @@ class DateCellCalendarBloc
date == null && time != null || date == null && time != null ||
date != null && time == null, date != null && time == null,
); );
String? newTime = time ?? state.time; final String? newTime = time ?? state.time;
DateTime? newDate = _utcToLocalAddTime(date); DateTime? newDate = _utcToLocalAddTime(date);
if (time != null && time.isNotEmpty) { if (time != null && time.isNotEmpty) {
newDate = state.dateTime ?? DateTime.now(); newDate = state.dateTime ?? DateTime.now();
@ -295,7 +295,7 @@ DateCellData _dateDataFromCellData(DateCellDataPB? cellData) {
dateTime = DateTime.fromMillisecondsSinceEpoch(timestamp.toInt()); dateTime = DateTime.fromMillisecondsSinceEpoch(timestamp.toInt());
time = cellData.time; time = cellData.time;
} }
bool includeTime = cellData.includeTime; final bool includeTime = cellData.includeTime;
return DateCellData(dateTime: dateTime, time: time, includeTime: includeTime); return DateCellData(dateTime: dateTime, time: time, includeTime: includeTime);
} }

View File

@ -106,7 +106,7 @@ class _CellCalendarWidgetState extends State<_CellCalendarWidget> {
)..add(const DateCellCalendarEvent.initial()), )..add(const DateCellCalendarEvent.initial()),
child: BlocBuilder<DateCellCalendarBloc, DateCellCalendarState>( child: BlocBuilder<DateCellCalendarBloc, DateCellCalendarState>(
builder: (context, state) { builder: (context, state) {
List<Widget> children = [ final List<Widget> children = [
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0), padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: _buildCalendar(context), child: _buildCalendar(context),
@ -403,7 +403,7 @@ class _CalDateTimeSettingState extends State<_CalDateTimeSetting> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
List<Widget> children = [ final List<Widget> children = [
AppFlowyPopover( AppFlowyPopover(
mutex: timeSettingPopoverMutex, mutex: timeSettingPopoverMutex,
triggerActions: PopoverTriggerFlags.hover | PopoverTriggerFlags.click, triggerActions: PopoverTriggerFlags.hover | PopoverTriggerFlags.click,

View File

@ -167,7 +167,7 @@ class SelectOptionWrap extends StatefulWidget {
class _SelectOptionWrapState extends State<SelectOptionWrap> { class _SelectOptionWrapState extends State<SelectOptionWrap> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Widget child = _buildOptions(context); final Widget child = _buildOptions(context);
final constraints = BoxConstraints.loose( final constraints = BoxConstraints.loose(
Size( Size(

View File

@ -75,7 +75,7 @@ class _OptionList extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocBuilder<SelectOptionCellEditorBloc, SelectOptionEditorState>( return BlocBuilder<SelectOptionCellEditorBloc, SelectOptionEditorState>(
builder: (context, state) { builder: (context, state) {
List<Widget> cells = []; final List<Widget> cells = [];
cells.add(const _Title()); cells.add(const _Title());
cells.addAll( cells.addAll(
state.options.map((option) { state.options.map((option) {

View File

@ -199,7 +199,7 @@ class _SelectOptionTextFieldState extends State<SelectOptionTextField> {
@visibleForTesting @visibleForTesting
List splitInput(String input, List<String> textSeparators) { List splitInput(String input, List<String> textSeparators) {
List<String> splits = []; final List<String> splits = [];
String currentString = ''; String currentString = '';
// split the string into tokens // split the string into tokens

View File

@ -8,7 +8,7 @@ extension BuildContextExtension on BuildContext {
if (box == null) { if (box == null) {
return false; return false;
} }
var result = BoxHitTestResult(); final result = BoxHitTestResult();
box.hitTest(result, position: box.globalToLocal(offset)); box.hitTest(result, position: box.globalToLocal(offset));
return result.path.any((entry) => entry.target == box); return result.path.any((entry) => entry.target == box);
} }

View File

@ -282,9 +282,9 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
// Copy from flutter.highlight package. // Copy from flutter.highlight package.
// https://github.com/git-touch/highlight.dart/blob/master/flutter_highlight/lib/flutter_highlight.dart // https://github.com/git-touch/highlight.dart/blob/master/flutter_highlight/lib/flutter_highlight.dart
List<TextSpan> _convert(List<highlight.Node> nodes) { List<TextSpan> _convert(List<highlight.Node> nodes) {
List<TextSpan> spans = []; final List<TextSpan> spans = [];
var currentSpans = spans; var currentSpans = spans;
List<List<TextSpan>> stack = []; final List<List<TextSpan>> stack = [];
void traverse(highlight.Node node) { void traverse(highlight.Node node) {
if (node.value != null) { if (node.value != null) {
@ -297,7 +297,7 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
), ),
); );
} else if (node.children != null) { } else if (node.children != null) {
List<TextSpan> tmp = []; final List<TextSpan> tmp = [];
currentSpans.add( currentSpans.add(
TextSpan( TextSpan(
children: tmp, children: tmp,
@ -307,7 +307,7 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
stack.add(currentSpans); stack.add(currentSpans);
currentSpans = tmp; currentSpans = tmp;
for (var n in node.children!) { for (final n in node.children!) {
traverse(n); traverse(n);
if (n == node.children!.last) { if (n == node.children!.last) {
currentSpans = stack.isEmpty ? spans : stack.removeLast(); 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); traverse(node);
} }

View File

@ -237,7 +237,7 @@ class _ChangeCoverPopoverState extends State<ChangeCoverPopover> {
return BlocBuilder<ChangeCoverPopoverBloc, ChangeCoverPopoverState>( return BlocBuilder<ChangeCoverPopoverBloc, ChangeCoverPopoverState>(
builder: (context, state) { builder: (context, state) {
if (state is Loaded) { if (state is Loaded) {
List<String> images = state.imageNames; final List<String> images = state.imageNames;
return GridView.builder( return GridView.builder(
shrinkWrap: true, shrinkWrap: true,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(

View File

@ -82,8 +82,8 @@ class CoverImagePickerBloc
} }
_saveToGallery(CoverImagePickerState state) async { _saveToGallery(CoverImagePickerState state) async {
SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs = await SharedPreferences.getInstance();
List<String> imagePaths = prefs.getStringList(kLocalImagesKey) ?? []; final List<String> imagePaths = prefs.getStringList(kLocalImagesKey) ?? [];
final directory = await _coverPath(); final directory = await _coverPath();
if (state is FileImagePicked) { if (state is FileImagePicked) {

View File

@ -39,7 +39,7 @@ class DefaultEmojiPickerViewState extends State<DefaultEmojiPickerView>
_emojiFocusNode.requestFocus(); _emojiFocusNode.requestFocus();
_emojiController.addListener(() { _emojiController.addListener(() {
String query = _emojiController.text.toLowerCase(); final String query = _emojiController.text.toLowerCase();
if (query.isEmpty) { if (query.isEmpty) {
searchEmojiList.emoji.clear(); searchEmojiList.emoji.clear();
_pageController!.jumpToPage( _pageController!.jumpToPage(
@ -47,7 +47,7 @@ class DefaultEmojiPickerViewState extends State<DefaultEmojiPickerView>
); );
} else { } else {
searchEmojiList.emoji.clear(); searchEmojiList.emoji.clear();
for (var element in widget.state.categoryEmoji) { for (final element in widget.state.categoryEmoji) {
searchEmojiList.emoji.addAll( searchEmojiList.emoji.addAll(
element.emoji.where((item) { element.emoji.where((item) {
return item.name.toLowerCase().contains(query); return item.name.toLowerCase().contains(query);
@ -86,7 +86,7 @@ class DefaultEmojiPickerViewState extends State<DefaultEmojiPickerView>
} }
bool isEmojiSearching() { bool isEmojiSearching() {
bool result = final bool result =
searchEmojiList.emoji.isNotEmpty || _emojiController.text.isNotEmpty; searchEmojiList.emoji.isNotEmpty || _emojiController.text.isNotEmpty;
return result; return result;
@ -182,7 +182,7 @@ class DefaultEmojiPickerViewState extends State<DefaultEmojiPickerView>
// ); // );
// }, // },
itemBuilder: (context, index) { itemBuilder: (context, index) {
CategoryEmoji catEmoji = isEmojiSearching() final CategoryEmoji catEmoji = isEmojiSearching()
? searchEmojiList ? searchEmojiList
: widget.state.categoryEmoji[index]; : widget.state.categoryEmoji[index];
return _buildPage(emojiSize, catEmoji); return _buildPage(emojiSize, catEmoji);

View File

@ -151,7 +151,7 @@ class EmojiPickerState extends State<EmojiPicker> {
recentEmoji.map((e) => e.emoji).toList().cast<Emoji>(); recentEmoji.map((e) => e.emoji).toList().cast<Emoji>();
} }
var state = EmojiViewState( final state = EmojiViewState(
categoryEmoji, categoryEmoji,
_getOnEmojiListener(), _getOnEmojiListener(),
widget.onBackspacePressed, widget.onBackspacePressed,
@ -239,13 +239,13 @@ class EmojiPickerState extends State<EmojiPicker> {
Map<String, String> emoji,) async { Map<String, String> emoji,) async {
if (Platform.isAndroid) { if (Platform.isAndroid) {
Map<String, String>? filtered = {}; Map<String, String>? filtered = {};
var delimiter = '|'; const delimiter = '|';
try { try {
var entries = emoji.values.join(delimiter); final entries = emoji.values.join(delimiter);
var keys = emoji.keys.join(delimiter); final keys = emoji.keys.join(delimiter);
var result = (await platform.invokeMethod<String>('checkAvailability', final result = (await platform.invokeMethod<String>('checkAvailability',
{'emojiKeys': keys, 'emojiEntries': entries},)) as String; {'emojiKeys': keys, 'emojiEntries': entries},)) as String;
var resultKeys = result.split(delimiter); final resultKeys = result.split(delimiter);
for (var i = 0; i < resultKeys.length; i++) { for (var i = 0; i < resultKeys.length; i++) {
filtered[resultKeys[i]] = emoji[resultKeys[i]]!; filtered[resultKeys[i]] = emoji[resultKeys[i]]!;
} }
@ -261,11 +261,11 @@ class EmojiPickerState extends State<EmojiPicker> {
// Restore locally cached emoji // Restore locally cached emoji
Future<Map<String, String>?> _restoreFilteredEmojis(String title) async { Future<Map<String, String>?> _restoreFilteredEmojis(String title) async {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
var emojiJson = prefs.getString(title); final emojiJson = prefs.getString(title);
if (emojiJson == null) { if (emojiJson == null) {
return null; return null;
} }
var emojis = final emojis =
Map<String, String>.from(jsonDecode(emojiJson) as Map<String, dynamic>); Map<String, String>.from(jsonDecode(emojiJson) as Map<String, dynamic>);
return emojis; return emojis;
} }
@ -274,25 +274,25 @@ class EmojiPickerState extends State<EmojiPicker> {
Future<void> _cacheFilteredEmojis( Future<void> _cacheFilteredEmojis(
String title, Map<String, String> emojis,) async { String title, Map<String, String> emojis,) async {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
var emojiJson = jsonEncode(emojis); final emojiJson = jsonEncode(emojis);
prefs.setString(title, emojiJson); prefs.setString(title, emojiJson);
} }
// Returns list of recently used emoji from cache // Returns list of recently used emoji from cache
Future<List<RecentEmoji>> _getRecentEmojis() async { Future<List<RecentEmoji>> _getRecentEmojis() async {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
var emojiJson = prefs.getString('recent'); final emojiJson = prefs.getString('recent');
if (emojiJson == null) { if (emojiJson == null) {
return []; return [];
} }
var json = jsonDecode(emojiJson) as List<dynamic>; final json = jsonDecode(emojiJson) as List<dynamic>;
return json.map<RecentEmoji>(RecentEmoji.fromJson).toList(); return json.map<RecentEmoji>(RecentEmoji.fromJson).toList();
} }
// Add an emoji to recently used list or increase its counter // Add an emoji to recently used list or increase its counter
Future<void> _addEmojiToRecentlyUsed(Emoji emoji) async { Future<void> _addEmojiToRecentlyUsed(Emoji emoji) async {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
var recentEmojiIndex = final recentEmojiIndex =
recentEmoji.indexWhere((element) => element.emoji.emoji == emoji.emoji); recentEmoji.indexWhere((element) => element.emoji.emoji == emoji.emoji);
if (recentEmojiIndex != -1) { if (recentEmojiIndex != -1) {
// Already exist in recent list // Already exist in recent list

View File

@ -54,11 +54,11 @@ AppFlowyEnv getAppFlowyEnv() {
Future<Directory> appFlowyDocumentDirectory() async { Future<Directory> appFlowyDocumentDirectory() async {
switch (integrationEnv()) { switch (integrationEnv()) {
case IntegrationMode.develop: case IntegrationMode.develop:
Directory documentsDir = await getApplicationSupportDirectory() final Directory documentsDir = await getApplicationSupportDirectory()
..create(); ..create();
return Directory(path.join(documentsDir.path, 'data_dev')).create(); return Directory(path.join(documentsDir.path, 'data_dev')).create();
case IntegrationMode.release: case IntegrationMode.release:
Directory documentsDir = await getApplicationSupportDirectory(); final Directory documentsDir = await getApplicationSupportDirectory();
return Directory(path.join(documentsDir.path, 'data')).create(); return Directory(path.join(documentsDir.path, 'data')).create();
case IntegrationMode.test: case IntegrationMode.test:
return Directory(path.join(Directory.current.path, '.sandbox')); return Directory(path.join(Directory.current.path, '.sandbox'));

View File

@ -27,7 +27,7 @@ class UserBackendService {
String? iconUrl, String? iconUrl,
String? openAIKey, String? openAIKey,
}) { }) {
var payload = UpdateUserProfilePayloadPB.create()..id = userId; final payload = UpdateUserProfilePayloadPB.create()..id = userId;
if (name != null) { if (name != null) {
payload.name = name; payload.name = name;

View File

@ -107,7 +107,7 @@ class Body extends StatelessWidget {
const Body({Key? key}) : super(key: key); const Body({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var size = MediaQuery.of(context).size; final size = MediaQuery.of(context).size;
return Container( return Container(
alignment: Alignment.center, alignment: Alignment.center,

View File

@ -3,9 +3,9 @@ import 'dart:ui';
class ColorGenerator { class ColorGenerator {
Color generateColorFromString(String string) { Color generateColorFromString(String string) {
final hash = string.hashCode; final hash = string.hashCode;
int r = (hash & 0xFF0000) >> 16; final int r = (hash & 0xFF0000) >> 16;
int g = (hash & 0x00FF00) >> 8; final int g = (hash & 0x00FF00) >> 8;
int b = hash & 0x0000FF; final int b = hash & 0x0000FF;
return Color.fromRGBO(r, g, b, 0.5); return Color.fromRGBO(r, g, b, 0.5);
} }
} }

View File

@ -41,7 +41,7 @@ class HomeSettingBloc extends Bloc<HomeSettingEvent, HomeSettingState> {
emit(state.copyWith(workspaceSetting: value.setting)); emit(state.copyWith(workspaceSetting: value.setting));
}, },
collapseMenu: (_CollapseMenu e) { collapseMenu: (_CollapseMenu e) {
var isMenuCollapsed = !state.isMenuCollapsed; final isMenuCollapsed = !state.isMenuCollapsed;
_appearanceSettingsCubit.saveIsMenuCollapsed(isMenuCollapsed); _appearanceSettingsCubit.saveIsMenuCollapsed(isMenuCollapsed);
emit(state.copyWith(isMenuCollapsed: isMenuCollapsed)); emit(state.copyWith(isMenuCollapsed: isMenuCollapsed));
}, },

View File

@ -71,7 +71,7 @@ class SettingsFileExporterCubit extends Cubit<SettingsFileExportState> {
Map<String, List<String>> fetchSelectedPages() { Map<String, List<String>> fetchSelectedPages() {
final apps = state.views; final apps = state.views;
final selectedItems = state.selectedItems; final selectedItems = state.selectedItems;
Map<String, List<String>> result = {}; final Map<String, List<String>> result = {};
for (var i = 0; i < selectedItems.length; i++) { for (var i = 0; i < selectedItems.length; i++) {
final selectedItem = selectedItems[i]; final selectedItem = selectedItems[i];
final ids = <String>[]; final ids = <String>[];

View File

@ -35,9 +35,9 @@ extension FlowyPluginExtension on FlowyPlugin {
extension ViewExtension on ViewPB { extension ViewExtension on ViewPB {
Widget renderThumbnail({Color? iconColor}) { Widget renderThumbnail({Color? iconColor}) {
String thumbnail = "file_icon"; const String thumbnail = "file_icon";
final Widget widget = FlowySvg(name: thumbnail); const Widget widget = FlowySvg(name: thumbnail);
return widget; return widget;
} }

View File

@ -96,7 +96,7 @@ class ViewBackendService {
required String viewId, required String viewId,
String? name, String? name,
}) { }) {
var payload = UpdateViewPayloadPB.create()..viewId = viewId; final payload = UpdateViewPayloadPB.create()..viewId = viewId;
if (name != null) { if (name != null) {
payload.name = name; payload.name = name;
@ -125,7 +125,7 @@ class ViewBackendService {
final workspaces = value.getLeftOrNull<WorkspaceSettingPB>(); final workspaces = value.getLeftOrNull<WorkspaceSettingPB>();
if (workspaces != null) { if (workspaces != null) {
final views = workspaces.workspace.views; final views = workspaces.workspace.views;
for (var view in views) { for (final view in views) {
final childViews = await getViews(viewId: view.id).then( final childViews = await getViews(viewId: view.id).then(
(value) => value (value) => value
.getLeftOrNull<List<ViewPB>>() .getLeftOrNull<List<ViewPB>>()

View File

@ -11,7 +11,7 @@ class HomeHotKeys extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
HotKey hotKey = HotKey( final HotKey hotKey = HotKey(
KeyCode.backslash, KeyCode.backslash,
modifiers: [Platform.isMacOS ? KeyModifier.meta : KeyModifier.control], modifiers: [Platform.isMacOS ? KeyModifier.meta : KeyModifier.control],
// Set hotkey scope (default is HotKeyScope.system) // Set hotkey scope (default is HotKeyScope.system)

View File

@ -74,7 +74,7 @@ class ViewSectionItem extends StatelessWidget {
bool onHover, bool onHover,
ViewState state, ViewState state,
) { ) {
List<Widget> children = [ final List<Widget> children = [
SizedBox( SizedBox(
width: 16, width: 16,
height: 16, height: 16,

View File

@ -131,7 +131,7 @@ class HomeMenu extends StatelessWidget {
// expect: oldIndex: 0, newIndex: 1 // expect: oldIndex: 0, newIndex: 1
// receive: oldIndex: 0, newIndex: 2 // receive: oldIndex: 0, newIndex: 2
// Workaround: if newIndex > oldIndex, we just minus one // Workaround: if newIndex > oldIndex, we just minus one
int index = newIndex > oldIndex ? newIndex - 1 : newIndex; final int index = newIndex > oldIndex ? newIndex - 1 : newIndex;
context context
.read<MenuBloc>() .read<MenuBloc>()
.add(MenuEvent.moveApp(oldIndex, index)); .add(MenuEvent.moveApp(oldIndex, index));

View File

@ -86,7 +86,7 @@ class MenuUser extends StatelessWidget {
} }
Widget _renderUserName(BuildContext context) { Widget _renderUserName(BuildContext context) {
String name = userName(context.read<MenuUserBloc>().state.userProfile); final String name = userName(context.read<MenuUserBloc>().state.userProfile);
return FlowyText.medium( return FlowyText.medium(
name, name,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,

View File

@ -104,10 +104,10 @@ class FlowyNavigation extends StatelessWidget {
return []; return [];
} }
List<NavigationItem> newItems = _filter(items); final List<NavigationItem> newItems = _filter(items);
Widget last = NaviItemWidget(newItems.removeLast()); final Widget last = NaviItemWidget(newItems.removeLast());
List<Widget> widgets = List.empty(growable: true); final List<Widget> widgets = List.empty(growable: true);
// widgets.addAll(newItems.map((item) => NaviItemDivider(child: NaviItemWidget(item))).toList()); // widgets.addAll(newItems.map((item) => NaviItemDivider(child: NaviItemWidget(item))).toList());
for (final item in newItems) { for (final item in newItems) {

View File

@ -157,7 +157,7 @@ class _ExpandedListState extends State<_ExpandedList> {
List<Widget> _buildChildren(BuildContext context) { List<Widget> _buildChildren(BuildContext context) {
final apps = context.read<SettingsFileExporterCubit>().state.views; final apps = context.read<SettingsFileExporterCubit>().state.views;
List<Widget> children = []; final List<Widget> children = [];
for (var i = 0; i < apps.length; i++) { for (var i = 0; i < apps.length; i++) {
children.add(_buildExpandedItem(context, i)); children.add(_buildExpandedItem(context, i));
} }
@ -170,7 +170,7 @@ class _ExpandedListState extends State<_ExpandedList> {
final expanded = state.expanded; final expanded = state.expanded;
final selectedItems = state.selectedItems; final selectedItems = state.selectedItems;
final isExpanded = expanded[index] == true; final isExpanded = expanded[index] == true;
List<Widget> expandedChildren = []; final List<Widget> expandedChildren = [];
if (isExpanded) { if (isExpanded) {
for (var i = 0; i < selectedItems[index].length; i++) { for (var i = 0; i < selectedItems[index].length; i++) {
final name = apps[index].childViews[i].name; final name = apps[index].childViews[i].name;

View File

@ -43,7 +43,7 @@ class SettingsUserView extends StatelessWidget {
} }
Widget _renderUserNameInput(BuildContext context) { Widget _renderUserNameInput(BuildContext context) {
String name = context.read<SettingsUserViewBloc>().state.userProfile.name; final String name = context.read<SettingsUserViewBloc>().state.userProfile.name;
return UserNameInput(name); return UserNameInput(name);
} }
@ -57,7 +57,7 @@ class SettingsUserView extends StatelessWidget {
} }
Widget _renderCurrentOpenaiKey(BuildContext context) { Widget _renderCurrentOpenaiKey(BuildContext context) {
String openAIKey = final String openAIKey =
context.read<SettingsUserViewBloc>().state.userProfile.openaiKey; context.read<SettingsUserViewBloc>().state.userProfile.openaiKey;
return _OpenaiKeyInput(openAIKey); return _OpenaiKeyInput(openAIKey);
} }

View File

@ -27,8 +27,8 @@ class AnimatedPanelState extends State<AnimatedPanel> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Offset closePos = Offset(widget.closedX, widget.closedY); final Offset closePos = Offset(widget.closedX, widget.closedY);
double duration = _isHidden && widget.isClosed ? 0 : widget.duration; final double duration = _isHidden && widget.isClosed ? 0 : widget.duration;
return TweenAnimationBuilder( return TweenAnimationBuilder(
curve: widget.curve ?? Curves.easeOut, curve: widget.curve ?? Curves.easeOut,
tween: Tween<Offset>( tween: Tween<Offset>(

View File

@ -46,7 +46,7 @@ class DefaultEmojiPickerViewState extends State<DefaultEmojiPickerView>
_emojiFocusNode.requestFocus(); _emojiFocusNode.requestFocus();
_emojiController.addListener(() { _emojiController.addListener(() {
String query = _emojiController.text.toLowerCase(); final String query = _emojiController.text.toLowerCase();
if (query.isEmpty) { if (query.isEmpty) {
searchEmojiList.emoji.clear(); searchEmojiList.emoji.clear();
_pageController!.jumpToPage( _pageController!.jumpToPage(
@ -54,7 +54,7 @@ class DefaultEmojiPickerViewState extends State<DefaultEmojiPickerView>
); );
} else { } else {
searchEmojiList.emoji.clear(); searchEmojiList.emoji.clear();
for (var element in widget.state.categoryEmoji) { for (final element in widget.state.categoryEmoji) {
searchEmojiList.emoji.addAll( searchEmojiList.emoji.addAll(
element.emoji.where((item) { element.emoji.where((item) {
return item.name.toLowerCase().contains(query); return item.name.toLowerCase().contains(query);
@ -94,7 +94,7 @@ class DefaultEmojiPickerViewState extends State<DefaultEmojiPickerView>
} }
bool isEmojiSearching() { bool isEmojiSearching() {
bool result = final bool result =
searchEmojiList.emoji.isNotEmpty || _emojiController.text.isNotEmpty; searchEmojiList.emoji.isNotEmpty || _emojiController.text.isNotEmpty;
return result; return result;
@ -198,7 +198,7 @@ class DefaultEmojiPickerViewState extends State<DefaultEmojiPickerView>
// ); // );
// }, // },
itemBuilder: (context, index) { itemBuilder: (context, index) {
CategoryEmoji catEmoji = isEmojiSearching() final CategoryEmoji catEmoji = isEmojiSearching()
? searchEmojiList ? searchEmojiList
: widget.state.categoryEmoji[index]; : widget.state.categoryEmoji[index];
return _buildPage(emojiSize, catEmoji); return _buildPage(emojiSize, catEmoji);

View File

@ -151,7 +151,7 @@ class EmojiPickerState extends State<EmojiPicker> {
recentEmoji.map((e) => e.emoji).toList().cast<Emoji>(); recentEmoji.map((e) => e.emoji).toList().cast<Emoji>();
} }
var state = EmojiViewState( final state = EmojiViewState(
categoryEmoji, categoryEmoji,
_getOnEmojiListener(), _getOnEmojiListener(),
widget.onBackspacePressed, widget.onBackspacePressed,
@ -259,15 +259,15 @@ class EmojiPickerState extends State<EmojiPicker> {
) async { ) async {
if (Platform.isAndroid) { if (Platform.isAndroid) {
Map<String, String>? filtered = {}; Map<String, String>? filtered = {};
var delimiter = '|'; const delimiter = '|';
try { try {
var entries = emoji.values.join(delimiter); final entries = emoji.values.join(delimiter);
var keys = emoji.keys.join(delimiter); final keys = emoji.keys.join(delimiter);
var result = (await platform.invokeMethod<String>( final result = (await platform.invokeMethod<String>(
'checkAvailability', 'checkAvailability',
{'emojiKeys': keys, 'emojiEntries': entries}, {'emojiKeys': keys, 'emojiEntries': entries},
)) as String; )) as String;
var resultKeys = result.split(delimiter); final resultKeys = result.split(delimiter);
for (var i = 0; i < resultKeys.length; i++) { for (var i = 0; i < resultKeys.length; i++) {
filtered[resultKeys[i]] = emoji[resultKeys[i]]!; filtered[resultKeys[i]] = emoji[resultKeys[i]]!;
} }
@ -283,11 +283,11 @@ class EmojiPickerState extends State<EmojiPicker> {
// Restore locally cached emoji // Restore locally cached emoji
Future<Map<String, String>?> _restoreFilteredEmojis(String title) async { Future<Map<String, String>?> _restoreFilteredEmojis(String title) async {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
var emojiJson = prefs.getString(title); final emojiJson = prefs.getString(title);
if (emojiJson == null) { if (emojiJson == null) {
return null; return null;
} }
var emojis = final emojis =
Map<String, String>.from(jsonDecode(emojiJson) as Map<String, dynamic>); Map<String, String>.from(jsonDecode(emojiJson) as Map<String, dynamic>);
return emojis; return emojis;
} }
@ -298,25 +298,25 @@ class EmojiPickerState extends State<EmojiPicker> {
Map<String, String> emojis, Map<String, String> emojis,
) async { ) async {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
var emojiJson = jsonEncode(emojis); final emojiJson = jsonEncode(emojis);
prefs.setString(title, emojiJson); prefs.setString(title, emojiJson);
} }
// Returns list of recently used emoji from cache // Returns list of recently used emoji from cache
Future<List<RecentEmoji>> _getRecentEmojis() async { Future<List<RecentEmoji>> _getRecentEmojis() async {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
var emojiJson = prefs.getString('recent'); final emojiJson = prefs.getString('recent');
if (emojiJson == null) { if (emojiJson == null) {
return []; return [];
} }
var json = jsonDecode(emojiJson) as List<dynamic>; final json = jsonDecode(emojiJson) as List<dynamic>;
return json.map<RecentEmoji>(RecentEmoji.fromJson).toList(); return json.map<RecentEmoji>(RecentEmoji.fromJson).toList();
} }
// Add an emoji to recently used list or increase its counter // Add an emoji to recently used list or increase its counter
Future<void> _addEmojiToRecentlyUsed(Emoji emoji) async { Future<void> _addEmojiToRecentlyUsed(Emoji emoji) async {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
var recentEmojiIndex = final recentEmojiIndex =
recentEmoji.indexWhere((element) => element.emoji.emoji == emoji.emoji); recentEmoji.indexWhere((element) => element.emoji.emoji == emoji.emoji);
if (recentEmojiIndex != -1) { if (recentEmojiIndex != -1) {
// Already exist in recent list // Already exist in recent list

View File

@ -136,9 +136,9 @@ class FlowyVersionDescription extends CustomActionCell {
); );
} }
PackageInfo packageInfo = snapshot.data; final PackageInfo packageInfo = snapshot.data;
String appName = packageInfo.appName; final String appName = packageInfo.appName;
String version = packageInfo.version; final String version = packageInfo.version;
return SizedBox( return SizedBox(
height: 30, height: 30,

View File

@ -684,10 +684,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: intl name: intl
sha256: a3715e3bc90294e971cb7dc063fbf3cd9ee0ebf8604ffeafabd9e6f16abbdbe6 sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.18.0" version: "0.18.1"
intl_utils: intl_utils:
dependency: transitive dependency: transitive
description: description:
@ -812,10 +812,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: material_color_utilities name: material_color_utilities
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 sha256: "586678f20e112219ed0f73215f01bcdf1d769824ba2ebae45ad918a9bfde9bdb"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.2.0" version: "0.3.0"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@ -1329,10 +1329,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: source_span name: source_span
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.9.1" version: "1.10.0"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
@ -1425,26 +1425,26 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: test name: test
sha256: "3dac9aecf2c3991d09b9cdde4f98ded7b30804a88a0d7e4e7e1678e78d6b97f4" sha256: "4f92f103ef63b1bbac6f4bd1930624fca81b2574464482512c4f0896319be575"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.24.1" version: "1.24.2"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb sha256: daadc9baabec998b062c9091525aa95786508b1c48e9c30f1f891b8bf6ff2e64
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.5.1" version: "0.5.2"
test_core: test_core:
dependency: transitive dependency: transitive
description: description:
name: test_core name: test_core
sha256: "5138dbffb77b2289ecb12b81c11ba46036590b72a64a7a90d6ffb880f1a29e93" sha256: "3642b184882f79e76ca57a9230fb971e494c3c1fd09c21ae3083ce891bcc0aa1"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.5.1" version: "0.5.2"
textfield_tags: textfield_tags:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1617,10 +1617,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: vm_service name: vm_service
sha256: f6deed8ed625c52864792459709183da231ebf66ff0cf09e69b573227c377efe sha256: "518254c0d3ee20667a1feef39eefe037df87439851e4b3cb277e5b3f37afa2f0"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "11.3.0" version: "11.4.0"
watcher: watcher:
dependency: transitive dependency: transitive
description: description:

View File

@ -46,7 +46,7 @@ void main() {
bloc.add(const SelectOptionEditorEvent.newOption("A")); bloc.add(const SelectOptionEditorEvent.newOption("A"));
await gridResponseFuture(); await gridResponseFuture();
SelectOptionPB optionUpdate = bloc.state.options[0] final SelectOptionPB optionUpdate = bloc.state.options[0]
..color = SelectOptionColorPB.Aqua ..color = SelectOptionColorPB.Aqua
..name = "B"; ..name = "B";
bloc.add(SelectOptionEditorEvent.updateOption(optionUpdate)); bloc.add(SelectOptionEditorEvent.updateOption(optionUpdate));