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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
65 changed files with 142 additions and 138 deletions

View File

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

View File

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

View File

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

View File

@ -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();

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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(

View File

@ -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);

View File

@ -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

View File

@ -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();

View File

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

View File

@ -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;

View File

@ -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,

View File

@ -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) {

View File

@ -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)),
];

View File

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

View File

@ -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(),
),

View File

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

View File

@ -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(

View File

@ -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,

View File

@ -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(

View File

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

View File

@ -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) {

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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(

View File

@ -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),
];

View File

@ -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(

View File

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

View File

@ -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,

View File

@ -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(

View File

@ -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) {

View File

@ -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

View File

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

View File

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

View File

@ -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(

View File

@ -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) {

View File

@ -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);

View File

@ -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

View File

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

View File

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

View File

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

View File

@ -3,9 +3,9 @@ import 'dart:ui';
class ColorGenerator {
Color generateColorFromString(String string) {
final hash = string.hashCode;
int r = (hash & 0xFF0000) >> 16;
int g = (hash & 0x00FF00) >> 8;
int b = hash & 0x0000FF;
final int r = (hash & 0xFF0000) >> 16;
final int g = (hash & 0x00FF00) >> 8;
final int b = hash & 0x0000FF;
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));
},
collapseMenu: (_CollapseMenu e) {
var isMenuCollapsed = !state.isMenuCollapsed;
final isMenuCollapsed = !state.isMenuCollapsed;
_appearanceSettingsCubit.saveIsMenuCollapsed(isMenuCollapsed);
emit(state.copyWith(isMenuCollapsed: isMenuCollapsed));
},

View File

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

View File

@ -35,9 +35,9 @@ extension FlowyPluginExtension on FlowyPlugin {
extension ViewExtension on ViewPB {
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;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -104,10 +104,10 @@ class FlowyNavigation extends StatelessWidget {
return [];
}
List<NavigationItem> newItems = _filter(items);
Widget last = NaviItemWidget(newItems.removeLast());
final List<NavigationItem> newItems = _filter(items);
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());
for (final item in newItems) {

View File

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

View File

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

View File

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

View File

@ -46,7 +46,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(
@ -54,7 +54,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);
@ -94,7 +94,7 @@ class DefaultEmojiPickerViewState extends State<DefaultEmojiPickerView>
}
bool isEmojiSearching() {
bool result =
final bool result =
searchEmojiList.emoji.isNotEmpty || _emojiController.text.isNotEmpty;
return result;
@ -198,7 +198,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);

View File

@ -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,
@ -259,15 +259,15 @@ class EmojiPickerState extends State<EmojiPicker> {
) 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>(
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]]!;
}
@ -283,11 +283,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;
}
@ -298,25 +298,25 @@ class EmojiPickerState extends State<EmojiPicker> {
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

View File

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

View File

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

View File

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