diff --git a/easel/analysis_options.yaml b/easel/analysis_options.yaml index 482edcd397..ec2661122f 100644 --- a/easel/analysis_options.yaml +++ b/easel/analysis_options.yaml @@ -1,30 +1,121 @@ -# This file configures the analyzer, which statically analyzes Dart code to -# check for errors, warnings, and lints. -# -# The issues identified by the analyzer are surfaced in the UI of Dart-enabled -# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be -# invoked from the command line by running `flutter analyze`. +include: package:lint/analysis_options.yaml -# The following line activates a set of recommended lints for Flutter apps, -# packages, and plugins designed to encourage good coding practices. -include: package:flutter_lints/flutter.yaml +analyzer: + exclude: + # - build/** + # - lib/**.freezed.dart + - lib/**.g.dart + # - lib/**.gr.dart + # - lib/**.config.dart + # - lib/generated/**.dart +# - lib/modules/*/* +# - test/*/* +# strong-mode: +# implicit-dynamic: true + errors: + avoid_setters_without_getters: ignore + import_of_legacy_library_into_null_safe: error + avoid_single_cascade_in_expression_statements: ignore + null_aware_in_logical_operator: error + missing_required_param: error +# implicit_dynamic_map_literal: ignore + prefer_single_quotes: ignore + sort_unnamed_constructors_first: ignore + prefer_constructors_over_static_methods: ignore + no_leading_underscores_for_local_identifiers: ignore + directives_ordering: ignore + always_use_package_imports: ignore + avoid_classes_with_only_static_members: ignore + missing_return: error + always_declare_return_types: error + override_on_non_overriding_member: error + annotate_overrides: error + avoid_relative_lib_imports: error + avoid_empty_else: error + avoid_returning_null_for_future: error + empty_statements: error + always_put_control_body_on_new_line: error + always_require_non_null_named_parameters: error + avoid_renaming_method_parameters: error + avoid_void_async: error + parameter_assignments: error + constant_identifier_names: ignore + unawaited_futures: error + prefer_expression_function_bodies: error + non_constant_identifier_names: ignore + only_throw_errors: error + exhaustive_cases: error +# always_use_package_imports: error + missing_enum_constant_in_switch: error + require_trailing_commas: ignore + avoid_dynamic_calls: ignore + depend_on_referenced_packages: ignore + implementation_imports: ignore + sort_pub_dependencies: error linter: - # The lint rules applied to this project can be customized in the - # section below to disable rules from the `package:flutter_lints/flutter.yaml` - # included above or to enable additional rules. A list of all available lints - # and their documentation is published at - # https://dart-lang.github.io/linter/lints/index.html. - # - # Instead of disabling a lint rule for the entire project in the - # section below, it can also be suppressed for a single line of code - # or a specific dart file by using the `// ignore: name_of_lint` and - # `// ignore_for_file: name_of_lint` syntax on the line or in the file - # producing the lint. rules: - sort_pub_dependencies: true - # avoid_print: false # Uncomment to disable the `avoid_print` rule - # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options + - annotate_overrides + - await_only_futures +# - camel_case_types +# - cancel_subscriptions +# - close_sinks +# - comment_references +# - control_flow_in_finally +# - empty_statements +# - always_declare_return_types +# - avoid_empty_else + - avoid_relative_lib_imports +# - avoid_returning_null_for_future +# - always_put_control_body_on_new_line +# - always_require_non_null_named_parameters +# - avoid_renaming_method_parameters +# - avoid_unnecessary_containers +# - avoid_void_async +# - parameter_assignments +# - file_names +# - empty_constructor_bodies +# - unnecessary_parenthesis +# - unnecessary_overrides +# - use_rethrow_when_possible +# - always_use_package_imports +# - avoid_init_to_null +# - avoid_null_checks_in_equality_operators +# - avoid_return_types_on_setters +# - avoid_shadowing_type_parameters +# - avoid_types_as_parameter_names +# - camel_case_extensions +# - curly_braces_in_flow_control_structures +# - empty_catches +# - library_names +# - library_prefixes +# - no_duplicate_case_values +# - null_closures +# - omit_local_variable_types +# - prefer_adjacent_string_concatenation +# - prefer_collection_literals +# - prefer_conditional_assignment +# - prefer_contains +# - prefer_equal_for_default_values +# - prefer_final_fields +# - prefer_for_elements_to_map_fromIterable +# - prefer_generic_function_type_aliases +# - prefer_if_null_operators +# - prefer_is_empty +# - prefer_is_not_empty +# - prefer_iterable_whereType +# - prefer_single_quotes +# - prefer_spread_collections +# - recursive_getters +# - slash_for_doc_comments +# - type_init_formals +# # - unawaited_futures # we don't rely on pedantic package, thus no unawaited() function +# - unnecessary_const +# - unnecessary_new +# - unnecessary_null_in_if_null_operators +# - unnecessary_this +# - unrelated_type_equality_checks +# - use_function_type_syntax_for_parameters +# - valid_regexps +# - exhaustive_cases +# - require_trailing_commas \ No newline at end of file diff --git a/easel/lib/easel_provider.dart b/easel/lib/easel_provider.dart index 4385ea2fa7..ea521219ca 100644 --- a/easel/lib/easel_provider.dart +++ b/easel/lib/easel_provider.dart @@ -2,12 +2,12 @@ import 'dart:async'; import 'dart:io'; import 'package:easel_flutter/main.dart'; -import 'package:easel_flutter/models/api_response.dart'; import 'package:easel_flutter/models/denom.dart'; import 'package:easel_flutter/models/nft.dart'; import 'package:easel_flutter/models/nft_format.dart'; import 'package:easel_flutter/models/picked_file_model.dart'; import 'package:easel_flutter/models/save_nft.dart'; +import 'package:easel_flutter/models/storage_response_model.dart'; import 'package:easel_flutter/models/upload_progress.dart'; import 'package:easel_flutter/repository/repository.dart'; import 'package:easel_flutter/screens/creator_hub/creator_hub_view_model.dart'; @@ -43,13 +43,14 @@ class EaselProvider extends ChangeNotifier { final Repository repository; final MediaInfo mediaInfo; - EaselProvider( - {required this.videoPlayerHelper, - required this.audioPlayerHelperForFile, - required this.audioPlayerHelperForUrl, - required this.fileUtilsHelper, - required this.repository, - required this.mediaInfo}); + EaselProvider({ + required this.videoPlayerHelper, + required this.audioPlayerHelperForFile, + required this.audioPlayerHelperForUrl, + required this.fileUtilsHelper, + required this.repository, + required this.mediaInfo, + }); File? _file; NftFormat _nftFormat = NftFormat.supportedFormats[0]; @@ -61,7 +62,7 @@ class EaselProvider extends ChangeNotifier { int _fileDuration = 0; String? _cookbookId; String _recipeId = ""; - var stripeAccountExists = false; + bool stripeAccountExists = false; FreeDrop isFreeDrop = FreeDrop.unselected; Denom _selectedDenom = Denom.availableDenoms.first; @@ -187,7 +188,7 @@ class EaselProvider extends ChangeNotifier { late ValueNotifier audioProgressNotifier; late ValueNotifier buttonNotifier; - initStore() { + void initStore() { _file = null; _nftFormat = NftFormat.supportedFormats[0]; _fileName = ""; @@ -265,10 +266,9 @@ class EaselProvider extends ChangeNotifier { } Future resolveNftFormat(BuildContext context, String ext) async { - for (var format in NftFormat.supportedFormats) { + for (final format in NftFormat.supportedFormats) { if (format.extensions.contains(ext)) { - _nftFormat = format; - return _nftFormat; + return _nftFormat = format; } } notifyListeners(); @@ -276,7 +276,7 @@ class EaselProvider extends ChangeNotifier { } /// VIDEO PLAYER FUNCTIONS - void initializeVideoPlayerWithFile() async { + Future initializeVideoPlayerWithFile() async { videoLoadingError = ""; isVideoLoading = true; videoPlayerHelper.initializeVideoPlayerWithFile(file: _file!); @@ -292,13 +292,13 @@ class EaselProvider extends ChangeNotifier { }); } - delayLoading() { + void delayLoading() { Future.delayed(const Duration(seconds: 2)); isVideoLoading = false; notifyListeners(); } - void initializeVideoPlayerWithUrl({required String publishedNftUrl}) async { + Future initializeVideoPlayerWithUrl({required String publishedNftUrl}) async { videoLoadingError = ""; isVideoLoading = true; videoPlayerHelper.initializeVideoPlayerWithUrl(videoUrl: publishedNftUrl); @@ -338,7 +338,7 @@ class EaselProvider extends ChangeNotifier { notifyListeners(); } - Future initializeAudioPlayer({required publishedNFTUrl}) async { + Future initializeAudioPlayer({required String publishedNFTUrl}) async { audioProgressNotifier = ValueNotifier( ProgressBarState( current: Duration.zero, @@ -403,7 +403,7 @@ class EaselProvider extends ChangeNotifier { }); } - void playAudio(bool forFile) { + void playAudio({required bool forFile}) { if (forFile) { audioPlayerHelperForFile.playAudio(); } else { @@ -411,7 +411,7 @@ class EaselProvider extends ChangeNotifier { } } - void pauseAudio(bool forFile) { + void pauseAudio({required bool forFile}) { if (forFile) { audioPlayerHelperForFile.pauseAudio(); } else { @@ -419,7 +419,7 @@ class EaselProvider extends ChangeNotifier { } } - void seekAudio(Duration position, bool forFile) { + void seekAudio(Duration position, {required bool forFile}) { if (forFile) { audioPlayerHelperForFile.seekAudio(position: position); } else { @@ -427,7 +427,7 @@ class EaselProvider extends ChangeNotifier { } } - void disposeAudioController() async { + Future disposeAudioController() async { audioProgressNotifier = ValueNotifier( ProgressBarState( current: Duration.zero, @@ -460,7 +460,7 @@ class EaselProvider extends ChangeNotifier { Future populateUserName() async { isPylonsInstalled = await PylonsWallet.instance.exists(); if (currentUsername.isEmpty) { - String savedArtistName = repository.getArtistName(); + final String savedArtistName = repository.getArtistName(); currentUsername = savedArtistName; } @@ -496,12 +496,12 @@ class EaselProvider extends ChangeNotifier { switch (_nftFormat.format) { case NFTTypes.image: - _fileWidth = info['width']; - _fileHeight = info['height']; + _fileWidth = info['width'] as int; + _fileHeight = info['height'] as int; break; case NFTTypes.video: case NFTTypes.audio: - _fileDuration = info['durationMs']; + _fileDuration = info['durationMs'] as int; break; case NFTTypes.threeD: break; @@ -519,10 +519,18 @@ class EaselProvider extends ChangeNotifier { /// return true or false depending on the response from the wallet app Future createCookbook() async { _cookbookId = await repository.autoGenerateCookbookId(); - var cookBook1 = Cookbook( - creator: "", id: _cookbookId, name: cookbookName, description: cookbookDesc, developer: artistNameController.text, version: kVersionCookboox, supportEmail: supportedEmail, enabled: true); + final cookBook1 = Cookbook( + creator: "", + id: _cookbookId, + name: cookbookName, + description: cookbookDesc, + developer: artistNameController.text, + version: kVersionCookboox, + supportEmail: supportedEmail, + enabled: true, + ); - var response = await PylonsWallet.instance.txCreateCookbook(cookBook1); + final response = await PylonsWallet.instance.txCreateCookbook(cookBook1); if (response.success) { repository.saveCookBookGeneratorUsername(currentUsername); return true; @@ -532,12 +540,12 @@ class EaselProvider extends ChangeNotifier { return false; } - void saveArtistName(name) { + void saveArtistName(String name) { repository.saveArtistName(name); } void toCheckSavedArtistName() { - String savedArtistName = repository.getArtistName(); + final String savedArtistName = repository.getArtistName(); if (savedArtistName.isNotEmpty) { artistNameController.text = savedArtistName; @@ -552,16 +560,17 @@ class EaselProvider extends ChangeNotifier { final isPylonsExist = await PylonsWallet.instance.exists(); if (!isPylonsExist) { - ShowWalletInstallDialog showWalletInstallDialog = ShowWalletInstallDialog( - context: navigatorKey.currentState!.overlay!.context, - errorMessage: LocaleKeys.download_pylons_description.tr(), - buttonMessage: LocaleKeys.download_pylons_app.tr(), - onButtonPressed: () { - PylonsWallet.instance.goToInstall(); - }, - onClose: () { - Navigator.of(navigatorKey.currentState!.overlay!.context).pop(); - }); + final ShowWalletInstallDialog showWalletInstallDialog = ShowWalletInstallDialog( + context: navigatorKey.currentState!.overlay!.context, + errorMessage: LocaleKeys.download_pylons_description.tr(), + buttonMessage: LocaleKeys.download_pylons_app.tr(), + onButtonPressed: () { + PylonsWallet.instance.goToInstall(); + }, + onClose: () { + Navigator.of(navigatorKey.currentState!.overlay!.context).pop(); + }, + ); showWalletInstallDialog.show(); @@ -571,46 +580,48 @@ class EaselProvider extends ChangeNotifier { final response = await getProfile(); if (response.errorCode == kErrProfileNotExist) { - ShowWalletInstallDialog showWalletInstallDialog = ShowWalletInstallDialog( - context: navigatorKey.currentState!.overlay!.context, - errorMessage: LocaleKeys.create_username_description.tr(), - buttonMessage: LocaleKeys.open_pylons_app.tr(), - onButtonPressed: () { - PylonsWallet.instance.goToPylons(); - }, - onClose: () { - Navigator.of(navigatorKey.currentState!.overlay!.context).pop(); - }); + final ShowWalletInstallDialog showWalletInstallDialog = ShowWalletInstallDialog( + context: navigatorKey.currentState!.overlay!.context, + errorMessage: LocaleKeys.create_username_description.tr(), + buttonMessage: LocaleKeys.open_pylons_app.tr(), + onButtonPressed: () { + PylonsWallet.instance.goToPylons(); + }, + onClose: () { + Navigator.of(navigatorKey.currentState!.overlay!.context).pop(); + }, + ); showWalletInstallDialog.show(); return false; } if (showStripeDialog()) { - ShowWalletInstallDialog showWalletInstallDialog = ShowWalletInstallDialog( - context: navigatorKey.currentState!.overlay!.context, - errorMessage: LocaleKeys.create_stripe_description.tr(), - buttonMessage: LocaleKeys.start.tr(), - onButtonPressed: () async { - Navigator.pop(navigatorKey.currentState!.overlay!.context); - await PylonsWallet.instance.showStripe(); - }, - onClose: () { - Navigator.of(navigatorKey.currentState!.overlay!.context).pop(); - }); + final ShowWalletInstallDialog showWalletInstallDialog = ShowWalletInstallDialog( + context: navigatorKey.currentState!.overlay!.context, + errorMessage: LocaleKeys.create_stripe_description.tr(), + buttonMessage: LocaleKeys.start.tr(), + onButtonPressed: () async { + Navigator.pop(navigatorKey.currentState!.overlay!.context); + await PylonsWallet.instance.showStripe(); + }, + onClose: () { + Navigator.of(navigatorKey.currentState!.overlay!.context).pop(); + }, + ); showWalletInstallDialog.show(); return false; } if (response.success) { - return await createRecipe(nft: nft); + return createRecipe(nft: nft); } return false; } - showStripeDialog() => !stripeAccountExists && _selectedDenom.symbol == kUsdSymbol && isFreeDrop == FreeDrop.no; + bool showStripeDialog() => !stripeAccountExists && _selectedDenom.symbol == kUsdSymbol && isFreeDrop == FreeDrop.no; /// sends a createRecipe Tx message to the wallet /// return true or false depending on the response from the wallet app @@ -618,7 +629,7 @@ class EaselProvider extends ChangeNotifier { final scaffoldMessengerState = navigatorKey.getState(); // get device cookbook id _cookbookId = repository.getCookbookId(); - String savedUserName = repository.getCookBookGeneratorUsername(); + final String savedUserName = repository.getCookBookGeneratorUsername(); if (_cookbookId == null || isDifferentUserName(savedUserName)) { // create cookbook @@ -637,10 +648,10 @@ class EaselProvider extends ChangeNotifier { disposePlayers(assetType: nft.assetType); - String tradePercentage = BigInt.from(int.parse(nft.tradePercentage.trim()) * kRoyaltyPrecision).toString(); + final String tradePercentage = BigInt.from(int.parse(nft.tradePercentage.trim()) * kRoyaltyPrecision).toString(); - String price = isFreeDrop == FreeDrop.yes ? "0" : _selectedDenom.formatAmount(price: priceController.text); - var recipe = Recipe( + final String price = isFreeDrop == FreeDrop.yes ? "0" : _selectedDenom.formatAmount(price: priceController.text); + final recipe = Recipe( cookbookId: _cookbookId, id: _recipeId, nodeVersion: Int64(1), @@ -648,27 +659,43 @@ class EaselProvider extends ChangeNotifier { description: nft.description.trim(), version: kVersion, coinInputs: [ - isFreeDrop == FreeDrop.yes ? CoinInput() : CoinInput(coins: [Coin(amount: price, denom: _selectedDenom.symbol)]) + if (isFreeDrop == FreeDrop.yes) + CoinInput() + else + CoinInput( + coins: [Coin(amount: price, denom: _selectedDenom.symbol)], + ) ], itemInputs: [], costPerBlock: Coin(denom: kUpylon, amount: costPerBlock), - entries: EntriesList(coinOutputs: [], itemOutputs: [ - ItemOutput( + entries: EntriesList( + coinOutputs: [], + itemOutputs: [ + ItemOutput( id: kEaselNFT, doubles: [ - DoubleParam(key: kResidual, weightRanges: [ - DoubleWeightRange( - lower: tradePercentage, - upper: tradePercentage, - weight: Int64(1), - ) - ]) + DoubleParam( + key: kResidual, + weightRanges: [ + DoubleWeightRange( + lower: tradePercentage, + upper: tradePercentage, + weight: Int64(1), + ) + ], + ) ], longs: [ - LongParam(key: kQuantity, weightRanges: [ - IntWeightRange( - lower: Int64(int.parse(nft.quantity.toString().replaceAll(",", "").trim())), upper: Int64(int.parse(nft.quantity.toString().replaceAll(",", "").trim())), weight: Int64(1)) - ]), + LongParam( + key: kQuantity, + weightRanges: [ + IntWeightRange( + lower: Int64(int.parse(nft.quantity.replaceAll(",", "").trim())), + upper: Int64(int.parse(nft.quantity.replaceAll(",", "").trim())), + weight: Int64(1), + ) + ], + ), LongParam(key: kWidth, weightRanges: [buildIntWeightRange(upperRange: nft.width, lowerRange: nft.width)]), LongParam(key: kHeight, weightRanges: [buildIntWeightRange(upperRange: nft.height, lowerRange: nft.height)]), LongParam(key: kDuration, weightRanges: [buildIntWeightRange(upperRange: nft.duration, lowerRange: nft.duration)]), @@ -693,18 +720,21 @@ class EaselProvider extends ChangeNotifier { transferFee: [Coin(denom: kPylonSymbol, amount: transferFeeAmount)], tradePercentage: tradePercentage, tradeable: true, - amountMinted: Int64(0), - quantity: Int64(int.parse(nft.quantity.toString().replaceAll(",", "").trim()))), - ], itemModifyOutputs: []), + amountMinted: Int64(), + quantity: Int64(int.parse(nft.quantity.replaceAll(",", "").trim())), + ), + ], + itemModifyOutputs: [], + ), outputs: [ WeightedOutputs(entryIds: [kEaselNFT], weight: Int64(1)) ], - blockInterval: Int64(0), + blockInterval: Int64(), enabled: true, extraInfo: kExtraInfo, ); - var response = await PylonsWallet.instance.txCreateRecipe(recipe, requestResponse: false); + final response = await PylonsWallet.instance.txCreateRecipe(recipe, requestResponse: false); if (!response.success) { scaffoldMessengerState?.show(message: "$kErrRecipe ${response.error}"); @@ -723,31 +753,33 @@ class EaselProvider extends ChangeNotifier { weight: Int64(1), ); - bool isDifferentUserName(String savedUserName) => (currentUsername.isNotEmpty && savedUserName != currentUsername); + bool isDifferentUserName(String savedUserName) => currentUsername.isNotEmpty && savedUserName != currentUsername; Future shareNFT(Size size) async { - String url = repository.generateEaselLinkForShare( + final String url = repository.generateEaselLinkForShare( cookbookId: _cookbookId ?? '', recipeId: _recipeId, ); Share.share("$kMyEaselNFT\n\n$url", subject: kMyEaselNFT, sharePositionOrigin: Rect.fromLTWH(0, 0, size.width, size.height / 2)); } - void onVideoThumbnailPicked() async { + Future onVideoThumbnailPicked() async { videoPlayerController.pause(); final pickedFile = await repository.pickFile(NftFormat.supportedFormats[0]); - final result = pickedFile.getOrElse(() => PickedFileModel( - path: "", - fileName: "", - extension: "", - )); + final result = pickedFile.getOrElse( + () => PickedFileModel( + path: "", + fileName: "", + extension: "", + ), + ); if (result.path.isEmpty) return; setVideoThumbnail(File(result.path)); } - void onPdfThumbnailPicked() async { + Future onPdfThumbnailPicked() async { final pickedFile = await repository.pickFile(NftFormat.supportedFormats[0]); final result = pickedFile.getOrElse( @@ -781,7 +813,7 @@ class EaselProvider extends ChangeNotifier { } Future> getProfile() async { - var sdkResponse = await PylonsWallet.instance.getProfile(); + final sdkResponse = await PylonsWallet.instance.getProfile(); if (sdkResponse.success) { currentUsername = sdkResponse.data!.username; @@ -896,9 +928,6 @@ class EaselProvider extends ChangeNotifier { videoPlayerController.pause(); } - ApiResponse uploadThumbnailResponse = ApiResponse.error(errorMessage: ""); - ApiResponse uploadUrlResponse = ApiResponse.error(errorMessage: ""); - int id = 0; if (!_file!.existsSync()) { navigatorKey.currentState!.overlay!.context.show(message: LocaleKeys.err_pick_file.tr()); @@ -907,6 +936,8 @@ class EaselProvider extends ChangeNotifier { final loading = LoadingProgress()..showLoadingWithProgress(message: LocaleKeys.uploading.tr()); initializeTextEditingControllerWithEmptyValues(); + StorageResponseModel uploadThumbnailResponse = StorageResponseModel.initial(); + if (isThumbnailPresent()) { final uploadResponse = await repository.uploadFile(file: getThumbnailType(nftFormat.format), onUploadProgressCallback: (value) {}); if (uploadResponse.isLeft()) { @@ -914,40 +945,30 @@ class EaselProvider extends ChangeNotifier { LocaleKeys.something_wrong_while_uploading.tr().show(); return false; } - uploadThumbnailResponse = uploadResponse.getOrElse(() => uploadThumbnailResponse); - if (uploadThumbnailResponse.status == Status.error) { - loading.dismiss(); - scaffoldMessengerOptionalState?.show(message: uploadThumbnailResponse.errorMessage ?? LocaleKeys.upload_error_occurred.tr()); - return false; - } + uploadThumbnailResponse = uploadResponse.getOrElse(() => StorageResponseModel.initial()); } final response = await repository.uploadFile( - file: _file!, - onUploadProgressCallback: (value) { - _uploadProgressController.sink.add(value); - }); + file: _file!, + onUploadProgressCallback: (value) { + _uploadProgressController.sink.add(value); + }, + ); if (response.isLeft()) { loading.dismiss(); LocaleKeys.something_wrong_while_uploading.tr().show(); return false; } - final fileUploadResponse = response.getOrElse(() => uploadUrlResponse); + final fileUploadResponse = response.getOrElse(() => StorageResponseModel.initial()); loading.dismiss(); - if (fileUploadResponse.status == Status.error) { - scaffoldMessengerOptionalState?.show(message: fileUploadResponse.errorMessage ?? LocaleKeys.upload_error_occurred.tr()); - return false; - } nft = NFT( - id: null, type: NftType.TYPE_ITEM.name, ibcCoins: IBCCoins.upylon.name, assetType: nftFormat.format.getTitle(), cookbookID: cookbookId ?? "", width: fileWidth.toString(), creator: repository.getArtistName(), - denom: "", tradePercentage: royaltyController.text, height: fileHeight.toString(), duration: fileDuration.toString(), @@ -955,11 +976,11 @@ class EaselProvider extends ChangeNotifier { fileSize: _fileSize, recipeID: recipeId, fileName: _file!.path.split("/").last, - cid: fileUploadResponse.data?.value?.cid, + cid: fileUploadResponse.value?.cid ?? "", step: step.name, - thumbnailUrl: (isThumbnailPresent()) ? "$ipfsDomain/${uploadThumbnailResponse.data?.value?.cid}" : "", + thumbnailUrl: (isThumbnailPresent()) ? "$ipfsDomain/${uploadThumbnailResponse.value?.cid}" : "", name: artistNameController.text, - url: "$ipfsDomain/${fileUploadResponse.data?.value?.cid}", + url: "$ipfsDomain/${fileUploadResponse.value?.cid}", price: priceController.text, dateTime: DateTime.now().millisecondsSinceEpoch, ); @@ -974,14 +995,13 @@ class EaselProvider extends ChangeNotifier { id = saveNftResponse.getOrElse(() => 0); - NFT newNFT = NFT( + final NFT newNFT = NFT( id: id, type: NftType.TYPE_ITEM.name, ibcCoins: IBCCoins.upylon.name, assetType: nftFormat.format.getTitle(), cookbookID: cookbookId ?? "", width: fileWidth.toString(), - denom: "", tradePercentage: royaltyController.text, height: fileHeight.toString(), duration: fileDuration.toString(), @@ -989,10 +1009,10 @@ class EaselProvider extends ChangeNotifier { recipeID: recipeId, step: step.name, fileName: _file!.path.split("/").last, - cid: fileUploadResponse.data?.value?.cid, - thumbnailUrl: (isThumbnailPresent()) ? "$ipfsDomain/${uploadThumbnailResponse.data?.value?.cid}" : "", + cid: fileUploadResponse.value?.cid ?? "", + thumbnailUrl: (isThumbnailPresent()) ? "$ipfsDomain/${uploadThumbnailResponse.value?.cid}" : "", name: artistNameController.text, - url: "$ipfsDomain/${fileUploadResponse.data?.value?.cid}", + url: "$ipfsDomain/${fileUploadResponse.value?.cid}", price: priceController.text, ); @@ -1014,7 +1034,7 @@ class EaselProvider extends ChangeNotifier { if (hashtagsList.isNotEmpty) { hashtags = hashtagsList.join(','); } - SaveNft saveNftForDescription = SaveNft( + final SaveNft saveNftForDescription = SaveNft( id: id, nftDescription: descriptionController.text, nftName: artNameController.text, @@ -1040,7 +1060,7 @@ class EaselProvider extends ChangeNotifier { Future updateNftFromPrice(int id) async { final navigatorState = navigatorKey.getState(); - SaveNft saveNftForPrice = SaveNft( + final SaveNft saveNftForPrice = SaveNft( id: id, tradePercentage: royaltyController.text, price: priceController.text, diff --git a/easel/lib/models/denom.dart b/easel/lib/models/denom.dart index 2fb7401f9f..17720e308f 100644 --- a/easel/lib/models/denom.dart +++ b/easel/lib/models/denom.dart @@ -24,7 +24,7 @@ class Denom { TextInputFormatter getFormatter() { if (symbol == kPylonSymbol) { - return AmountFormatter(maxDigits: kMaxPriceLength, isDecimal: false); + return AmountFormatter(maxDigits: kMaxPriceLength); } return AmountFormatter(maxDigits: kMaxPriceLength, isDecimal: true); } diff --git a/easel/lib/models/nft.dart b/easel/lib/models/nft.dart index 99c26c8bc1..a0c42622db 100644 --- a/easel/lib/models/nft.dart +++ b/easel/lib/models/nft.dart @@ -113,7 +113,6 @@ class NFT extends Equatable { factory NFT.fromRecipe(Recipe recipe) { final royalties = recipe.entries.itemOutputs.firstOrNull?.tradePercentage.fromBigInt().toInt().toString(); return NFT( - id: null, type: NftType.TYPE_RECIPE.name, recipeID: recipe.id, cookbookID: recipe.cookbookId, diff --git a/easel/lib/models/nft_format.dart b/easel/lib/models/nft_format.dart index 314130975d..87c5caac49 100644 --- a/easel/lib/models/nft_format.dart +++ b/easel/lib/models/nft_format.dart @@ -13,14 +13,14 @@ class NftFormat { NftFormat({required this.format, required this.extensions, required this.badge, required this.color}); String getExtensionsList() { - var ret = ''; + final buffer = StringBuffer(); for (var i = 0; i < extensions.length; i++) { - if (ret.isNotEmpty) { - ret += ', '; + if (buffer.isNotEmpty) { + buffer.write(", "); } - ret += extensions[i].toUpperCase(); + buffer.write(extensions[i].toUpperCase()); } - return ret; + return buffer.toString(); } static List get supportedFormats => [ @@ -51,14 +51,14 @@ class NftFormat { NftFormat( format: NFTTypes.pdf, extensions: ['pdf'], - badge:SVGUtils.kSvgNftFormatPDF, + badge: SVGUtils.kSvgNftFormatPDF, color: EaselAppTheme.kDarkPurple, ), ]; static List getAllSupportedExts() { List allExts = []; - for (var format in supportedFormats) { + for (final format in supportedFormats) { allExts += format.extensions; } return allExts; diff --git a/easel/lib/models/storage_response_model.dart b/easel/lib/models/storage_response_model.dart index 7bae0b8742..d6516eae3c 100644 --- a/easel/lib/models/storage_response_model.dart +++ b/easel/lib/models/storage_response_model.dart @@ -4,19 +4,23 @@ class StorageResponseModel { StorageResponseModel({this.ok, this.value}); - StorageResponseModel.fromJson(dynamic json) { - ok = json['ok']; - value = json['value'] != null ? Value.fromJson(json['value']) : null; + StorageResponseModel.fromJson(Map json) { + ok = json['ok'] as bool?; + value = json['value'] != null ? Value.fromJson(json['value'] as Map) : null; } Map toJson() { - var map = {}; + final map = {}; map['ok'] = ok; if (value != null) { map['value'] = value?.toJson(); } return map; } + + factory StorageResponseModel.initial() { + return StorageResponseModel(); + } } class Value { @@ -36,17 +40,17 @@ class Value { this.pin, }); - Value.fromJson(dynamic json) { - cid = json['cid']; - created = json['created']; - type = json['type']; - scope = json['scope']; - size = json['size']; - pin = json['pin'] != null ? Pin.fromJson(json['pin']) : null; + Value.fromJson(Map json) { + cid = json['cid'] as String?; + created = json['created'] as String?; + type = json['type'] as String?; + scope = json['scope'] as String?; + size = json['size'] as int?; + pin = json['pin'] != null ? Pin.fromJson(json['pin'] as Map) : null; } Map toJson() { - var map = {}; + final map = {}; map['cid'] = cid; map['created'] = created; map['type'] = type; @@ -67,15 +71,15 @@ class Pin { Pin({this.cid, this.created, this.size, this.status}); - Pin.fromJson(dynamic json) { - cid = json['cid']; - created = json['created']; - size = json['size']; - status = json['status']; + Pin.fromJson(Map json) { + cid = json['cid'] as String?; + created = json['created'] as String?; + size = json['size'] as int?; + status = json['status'] as String?; } Map toJson() { - var map = {}; + final map = {}; map['cid'] = cid; map['created'] = created; map['size'] = size; diff --git a/easel/lib/repository/repository.dart b/easel/lib/repository/repository.dart index e75f4eeb77..5e7ec6f395 100644 --- a/easel/lib/repository/repository.dart +++ b/easel/lib/repository/repository.dart @@ -8,6 +8,7 @@ import 'package:easel_flutter/models/nft.dart'; import 'package:easel_flutter/models/nft_format.dart'; import 'package:easel_flutter/models/picked_file_model.dart'; import 'package:easel_flutter/models/save_nft.dart'; +import 'package:easel_flutter/models/storage_response_model.dart'; import 'package:easel_flutter/services/datasources/local_datasource.dart'; import 'package:easel_flutter/services/datasources/remote_datasource.dart'; import 'package:easel_flutter/services/third_party_services/crashlytics_helper.dart'; @@ -108,7 +109,7 @@ abstract class Repository { /// This method is used uploading provided file to the server using [httpClient] /// Input : [file] which needs to be uploaded , [onUploadProgressCallback] a callback method which needs to be call on each progress /// Output : [ApiResponse] the ApiResponse which can contain [success] or [error] response - Future> uploadFile({required File file, required OnUploadProgressCallback onUploadProgressCallback}); + Future> uploadFile({required File file, required OnUploadProgressCallback onUploadProgressCallback}); /// This method will get the drafts List from the local database /// Output: [List] returns that contains a number of [NFT] @@ -180,7 +181,7 @@ class RepositoryImp implements Repository { } try { - var sdkResponse = await remoteDataSource.getRecipesByCookbookID(cookBookId); + final sdkResponse = await remoteDataSource.getRecipesByCookbookID(cookBookId); log(sdkResponse.toString(), name: 'pylons_sdk'); return Right(sdkResponse); @@ -211,7 +212,7 @@ class RepositoryImp implements Repository { } @override - bool setCacheDynamicType({required String key, required value}) { + bool setCacheDynamicType({required String key, required dynamic value}) { return localDataSource.setCacheDynamicType(key: key, value: value); } @@ -222,7 +223,7 @@ class RepositoryImp implements Repository { @override Future autoGenerateCookbookId() async { - return await localDataSource.autoGenerateCookbookId(); + return localDataSource.autoGenerateCookbookId(); } @override @@ -258,7 +259,7 @@ class RepositoryImp implements Repository { @override Future> saveNft(NFT nft) async { try { - int id = await localDataSource.saveNft(nft); + final int id = await localDataSource.saveNft(nft); return Right(id); } on Exception catch (_) { crashlyticsHelper.recordFatalError(error: _.toString()); @@ -269,7 +270,7 @@ class RepositoryImp implements Repository { @override Future> updateNftFromDescription({required SaveNft saveNft}) async { try { - bool result = await localDataSource.updateNftFromDescription(saveNft); + final bool result = await localDataSource.updateNftFromDescription(saveNft); if (!result) { return Left(CacheFailure(LocaleKeys.upload_error.tr())); @@ -284,7 +285,7 @@ class RepositoryImp implements Repository { @override Future> updateNFTDialogShown({required int id}) async { try { - bool result = await localDataSource.updateNFTDialogShown(id); + final bool result = await localDataSource.updateNFTDialogShown(id); if (!result) { return Left(CacheFailure(LocaleKeys.upload_error.tr())); @@ -299,7 +300,7 @@ class RepositoryImp implements Repository { @override Future> updateNftFromPrice({required SaveNft saveNft}) async { try { - bool result = await localDataSource.updateNftFromPrice(saveNft); + final bool result = await localDataSource.updateNftFromPrice(saveNft); return Right(result); } on Exception catch (_) { @@ -309,11 +310,15 @@ class RepositoryImp implements Repository { } @override - Future> uploadFile({required File file, required OnUploadProgressCallback onUploadProgressCallback}) async { + Future> uploadFile({required File file, required OnUploadProgressCallback onUploadProgressCallback}) async { + if (!await networkInfo.isConnected) { + return Left(NoInternetFailure(LocaleKeys.no_internet.tr())); + } + try { - ApiResponse apiResponse = await remoteDataSource.uploadFile(file: file, uploadProgressCallback: onUploadProgressCallback); + final storageResponseModel = await remoteDataSource.uploadFile(file: file, uploadProgressCallback: onUploadProgressCallback); - return Right(apiResponse); + return Right(storageResponseModel); } on Exception catch (_) { crashlyticsHelper.recordFatalError(error: _.toString()); return Left(CacheFailure(LocaleKeys.update_failed.tr())); @@ -335,7 +340,7 @@ class RepositoryImp implements Repository { @override Future> deleteNft(int id) async { try { - bool result = await localDataSource.deleteNft(id); + final bool result = await localDataSource.deleteNft(id); return Right(result); } on Exception catch (_) { crashlyticsHelper.recordFatalError(error: _.toString()); @@ -346,7 +351,7 @@ class RepositoryImp implements Repository { @override Future> getNft(int id) async { try { - NFT? data = await localDataSource.getNft(id); + final NFT? data = await localDataSource.getNft(id); if (data == null) { return Left(CacheFailure(LocaleKeys.something_wrong.tr())); } @@ -360,7 +365,7 @@ class RepositoryImp implements Repository { @override Future> pickFile(NftFormat format) async { try { - PickedFileModel pickedFileModel = await fileUtilsHelper.pickFile(format); + final PickedFileModel pickedFileModel = await fileUtilsHelper.pickFile(format); return Right(pickedFileModel); } on Exception catch (_) { diff --git a/easel/lib/screens/choose_format_screen.dart b/easel/lib/screens/choose_format_screen.dart index c49fa09d8e..720ce09b1e 100644 --- a/easel/lib/screens/choose_format_screen.dart +++ b/easel/lib/screens/choose_format_screen.dart @@ -28,8 +28,8 @@ class ChooseFormatScreen extends StatefulWidget { class _ChooseFormatScreenState extends State { ValueNotifier errorText = ValueNotifier(LocaleKeys.err_pic_file.tr()); - void proceedToNext({required PickedFileModel result, required EaselProvider easelProvider}) async { - EaselProvider provider = context.read(); + Future proceedToNext({required PickedFileModel result, required EaselProvider easelProvider}) async { + final EaselProvider provider = context.read(); final navigator = Navigator.of(context); if (result.path.isEmpty) { @@ -42,7 +42,7 @@ class _ChooseFormatScreenState extends State { return; } - NftFormat? nftFormat = await provider.resolveNftFormat(context, result.extension); + final NftFormat? nftFormat = await provider.resolveNftFormat(context, result.extension); if (nftFormat == null) { return; @@ -80,7 +80,7 @@ class _ChooseFormatScreenState extends State { @override void initState() { super.initState(); - EaselProvider provider = context.read(); + final EaselProvider provider = context.read(); provider.setLog(screenName: AnalyticsScreenEvents.chooseFormatScreen); } @@ -88,7 +88,7 @@ class _ChooseFormatScreenState extends State { Widget build(BuildContext context) { final homeViewModel = context.watch(); - EaselProvider provider = context.read(); + final EaselProvider provider = context.read(); return Scaffold( body: Column( children: [ @@ -200,7 +200,7 @@ class _CardWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( + return ColoredBox( color: EaselAppTheme.kBlack, child: Column( mainAxisSize: MainAxisSize.min, @@ -210,7 +210,7 @@ class _CardWidget extends StatelessWidget { padding: EdgeInsets.only(top: topPadding, bottom: bottomPadding), child: GestureDetector( onTap: () async { - EaselProvider provider = context.read(); + final EaselProvider provider = context.read(); provider.setFormat(context, NftFormat.supportedFormats[typeIdx]); final pickedFile = await provider.repository.pickFile(provider.nftFormat); final result = pickedFile.getOrElse(() => PickedFileModel(path: "", fileName: "", extension: "")); @@ -223,7 +223,6 @@ class _CardWidget extends StatelessWidget { child: Stack( children: [ Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ SizedBox( width: 10.0.w, @@ -299,7 +298,7 @@ class _ErrorMessageWidget extends StatelessWidget { Padding buildTablet(BuildContext context) { return Padding( padding: EdgeInsets.symmetric(horizontal: 0.17.sw), - child: Container( + child: DecoratedBox( decoration: const BoxDecoration(image: DecorationImage(image: svg_provider.Svg(SVGUtils.kSvgUploadErrorBG))), child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -354,7 +353,7 @@ class _ErrorMessageWidget extends StatelessWidget { Padding buildMobile(BuildContext context) { return Padding( padding: EdgeInsets.symmetric(horizontal: 0.10.sw), - child: Container( + child: DecoratedBox( decoration: const BoxDecoration(image: DecorationImage(image: svg_provider.Svg(SVGUtils.kSvgUploadErrorBG))), child: Column( mainAxisAlignment: MainAxisAlignment.center, diff --git a/easel/lib/screens/creator_hub/creator_hub_screen.dart b/easel/lib/screens/creator_hub/creator_hub_screen.dart index bc62143964..419aebc005 100644 --- a/easel/lib/screens/creator_hub/creator_hub_screen.dart +++ b/easel/lib/screens/creator_hub/creator_hub_screen.dart @@ -49,7 +49,7 @@ class _CreatorHubScreenState extends State { @override Widget build(BuildContext context) { - return Container( + return ColoredBox( color: EaselAppTheme.kBgWhite, child: SafeArea( child: Scaffold( @@ -100,13 +100,13 @@ class _CreatorHubContentState extends State { EaselProvider get easelProvider => sl(); - void onRefreshPressed() async { + Future onRefreshPressed() async { GetIt.I.get().getDraftsList(); GetIt.I.get().getRecipesList(); GetIt.I.get().getTotalForSale(); } - Widget getRefreshButton(viewModel) { + Widget getRefreshButton(CreatorHubViewModel viewModel) { if (easelProvider.isPylonsInstalled) { switch (viewModel.selectedCollectionType) { case CollectionType.published: @@ -132,7 +132,7 @@ class _CreatorHubContentState extends State { @override Widget build(BuildContext context) { final viewModel = context.watch(); - return Container( + return ColoredBox( color: EaselAppTheme.kWhite, child: SafeArea( child: Scaffold( @@ -151,10 +151,10 @@ class _CreatorHubContentState extends State { getRefreshButton(viewModel), InkWell( onTap: () => Navigator.of(context).pushNamed(RouteUtil.kRouteHome), - child: Container( + child: DecoratedBox( decoration: BoxDecoration( color: EaselAppTheme.kpurpleDark, - boxShadow: [BoxShadow(color: EaselAppTheme.kpurpleDark.withOpacity(0.6), offset: const Offset(0, 0), blurRadius: 8.0)], + boxShadow: [BoxShadow(color: EaselAppTheme.kpurpleDark.withOpacity(0.6), blurRadius: 8.0)], ), child: Icon(Icons.add, size: 27.h, color: EaselAppTheme.kWhite), ), @@ -168,7 +168,6 @@ class _CreatorHubContentState extends State { Padding( padding: EdgeInsets.symmetric(horizontal: 20.w), child: RichText( - textAlign: TextAlign.start, text: TextSpan( children: [ TextSpan( @@ -305,7 +304,7 @@ class _CreatorHubContentState extends State { return Expanded( child: InkWell( onTap: () => viewModel.changeSelectedCollection(collectionType), - child: Container( + child: DecoratedBox( decoration: BoxDecoration( border: Border.all(width: 1.7.sp), ), diff --git a/easel/lib/screens/creator_hub/creator_hub_view_model.dart b/easel/lib/screens/creator_hub/creator_hub_view_model.dart index c39ece495b..8a8cc9cf93 100644 --- a/easel/lib/screens/creator_hub/creator_hub_view_model.dart +++ b/easel/lib/screens/creator_hub/creator_hub_view_model.dart @@ -24,7 +24,7 @@ class CreatorHubViewModel extends ChangeNotifier { int get publishedRecipesLength => nftPublishedList.length; - changeSelectedCollection(CollectionType collectionType) { + void changeSelectedCollection(CollectionType collectionType) { switch (collectionType) { case CollectionType.draft: selectedCollectionType = CollectionType.draft; @@ -84,7 +84,7 @@ class CreatorHubViewModel extends ChangeNotifier { void getTotalForSale() { _nftForSaleList = []; - for (NFT nft in nftPublishedList) { + for (final NFT nft in nftPublishedList) { if (nft.isEnabled && nft.amountMinted < int.parse(nft.quantity)) { _nftForSaleList.add(nft); } diff --git a/easel/lib/screens/creator_hub/widgets/draft_list_tile.dart b/easel/lib/screens/creator_hub/widgets/draft_list_tile.dart index 2376656975..9afa2b3c1d 100644 --- a/easel/lib/screens/creator_hub/widgets/draft_list_tile.dart +++ b/easel/lib/screens/creator_hub/widgets/draft_list_tile.dart @@ -34,7 +34,7 @@ class DraftListTile extends StatefulWidget { class _DraftListTileState extends State { String getThumbnailUrl() { - AssetType assetType = widget.nft.assetType.toAssetTypeEnum(); + final AssetType assetType = widget.nft.assetType.toAssetTypeEnum(); switch (assetType) { case AssetType.Audio: @@ -109,7 +109,7 @@ class _DraftListTileState extends State { } Widget getDraftCard() { - return Container( + return DecoratedBox( decoration: BoxDecoration( color: Colors.white, boxShadow: [ @@ -133,7 +133,7 @@ class _DraftListTileState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "nft_name".tr(args: [widget.nft.name.isNotEmpty ? widget.nft.name : 'Nft Name']), + "nft_name".tr(args: [if (widget.nft.name.isNotEmpty) widget.nft.name else 'Nft Name']), style: titleStyle.copyWith(fontSize: isTablet ? 13.sp : 18.sp), maxLines: 1, overflow: TextOverflow.ellipsis, @@ -226,8 +226,7 @@ class _DraftListTileState extends State { ) : getDraftCard(), ), - (widget.nft.assetType.toAssetTypeEnum() != AssetType.ThreeD) - ? IgnorePointer( + if (widget.nft.assetType.toAssetTypeEnum() != AssetType.ThreeD) IgnorePointer( child: SizedBox( height: 85.0.h, width: double.infinity, @@ -242,8 +241,7 @@ class _DraftListTileState extends State { }, ), ), - ) - : const IgnorePointer( + ) else const IgnorePointer( child: SizedBox(), ), ], @@ -291,7 +289,7 @@ class _DraftListTileState extends State { ); } - void onViewOnIPFSPressed({required BuildContext context, required NFT nft}) async { + Future onViewOnIPFSPressed({required BuildContext context, required NFT nft}) async { switch (nft.assetType) { case k3dText: case kPdfText: diff --git a/easel/lib/screens/creator_hub/widgets/drafts_more_bottomsheet.dart b/easel/lib/screens/creator_hub/widgets/drafts_more_bottomsheet.dart index 5ba406d3ab..3fcc66e6c4 100644 --- a/easel/lib/screens/creator_hub/widgets/drafts_more_bottomsheet.dart +++ b/easel/lib/screens/creator_hub/widgets/drafts_more_bottomsheet.dart @@ -53,7 +53,7 @@ class DraftsMoreBottomSheet extends StatelessWidget { EaselProvider get easelProvider => sl(); - void onViewOnIPFSPressed({required BuildContext context, required NFT nft}) async { + Future onViewOnIPFSPressed({required BuildContext context, required NFT nft}) async { final easelProvider = Provider.of(context, listen: false); await easelProvider.repository.launchMyUrl(url: nft.url.changeDomain()); } @@ -135,8 +135,8 @@ class DraftsMoreBottomSheet extends StatelessWidget { } } -Widget moreOptionTile({required String title, required String image, required VoidCallback onPressed, final bool isSvg = true}) { - TextStyle titleStyle = TextStyle(fontSize: isTablet ? 13.sp : 16.sp, fontWeight: FontWeight.w800, fontFamily: kUniversalFontFamily, color: EaselAppTheme.kBlack); +Widget moreOptionTile({required String title, required String image, required VoidCallback onPressed, bool isSvg = true}) { + final TextStyle titleStyle = TextStyle(fontSize: isTablet ? 13.sp : 16.sp, fontWeight: FontWeight.w800, fontFamily: kUniversalFontFamily, color: EaselAppTheme.kBlack); return Padding( padding: EdgeInsets.symmetric(vertical: 8.h), @@ -144,7 +144,7 @@ Widget moreOptionTile({required String title, required String image, required Vo onTap: onPressed, child: Row( children: [ - isSvg ? SvgPicture.asset(image) : Image.asset(image), + if (isSvg) SvgPicture.asset(image) else Image.asset(image), SizedBox( width: 30.w, ), diff --git a/easel/lib/screens/creator_hub/widgets/nfts_list_tile.dart b/easel/lib/screens/creator_hub/widgets/nfts_list_tile.dart index dee98f6a8c..9ea0ca1a8a 100644 --- a/easel/lib/screens/creator_hub/widgets/nfts_list_tile.dart +++ b/easel/lib/screens/creator_hub/widgets/nfts_list_tile.dart @@ -31,7 +31,7 @@ class NFTsListTile extends StatelessWidget { } Widget getPublishedCard({required BuildContext context}) { - return Container( + return DecoratedBox( decoration: BoxDecoration( color: EaselAppTheme.kWhite, boxShadow: [ @@ -118,8 +118,7 @@ class NFTsListTile extends StatelessWidget { Widget build(BuildContext context) { return Stack( children: [ - (publishedNFT.price.isNotEmpty && double.parse(publishedNFT.price) > 0) - ? Padding( + if (publishedNFT.price.isNotEmpty && double.parse(publishedNFT.price) > 0) Padding( padding: EdgeInsets.symmetric(horizontal: 20.w), child: Card( elevation: 5, @@ -134,13 +133,11 @@ class NFTsListTile extends StatelessWidget { ), ), ), - ) - : Padding( + ) else Padding( padding: EdgeInsets.symmetric(horizontal: 20.w), child: getPublishedCard(context: context), ), - (publishedNFT.assetType.toAssetTypeEnum() != AssetType.ThreeD) - ? IgnorePointer( + if (publishedNFT.assetType.toAssetTypeEnum() != AssetType.ThreeD) IgnorePointer( child: SizedBox( height: 85.0.h, width: double.infinity, @@ -217,8 +214,7 @@ class NFTsListTile extends StatelessWidget { }, ), ), - ) - : const IgnorePointer( + ) else const IgnorePointer( child: SizedBox(), ), ], diff --git a/easel/lib/screens/creator_hub/widgets/published_nfts_bottom_sheet.dart b/easel/lib/screens/creator_hub/widgets/published_nfts_bottom_sheet.dart index 1bfab15ef0..d476998df9 100644 --- a/easel/lib/screens/creator_hub/widgets/published_nfts_bottom_sheet.dart +++ b/easel/lib/screens/creator_hub/widgets/published_nfts_bottom_sheet.dart @@ -21,14 +21,14 @@ class BuildPublishedNFTsBottomSheet { BuildPublishedNFTsBottomSheet({required this.context, required this.nft, required this.easelProvider}); - Widget moreOptionTile({required String title, required String image, required VoidCallback onPressed, final bool isSvg = true}) { + Widget moreOptionTile({required String title, required String image, required VoidCallback onPressed, bool isSvg = true}) { return Padding( padding: EdgeInsets.symmetric(vertical: 8.h), child: InkWell( onTap: () => onPressed(), child: Row( children: [ - isSvg ? SvgPicture.asset(image) : Image.asset(image), + if (isSvg) SvgPicture.asset(image) else Image.asset(image), SizedBox(width: 30.w), Text( title, @@ -42,12 +42,12 @@ class BuildPublishedNFTsBottomSheet { ); } - void onViewOnIPFSPressed({required NFT nft}) async { + Future onViewOnIPFSPressed({required NFT nft}) async { await easelProvider.repository.launchMyUrl(url: nft.url.changeDomain()); } - void onViewOnPylonsPressed({required NFT nft}) async { - String url = nft.recipeID.generateEaselLinkForOpeningInPylonsApp(cookbookId: nft.cookbookID); + Future onViewOnPylonsPressed({required NFT nft}) async { + final String url = nft.recipeID.generateEaselLinkForOpeningInPylonsApp(cookbookId: nft.cookbookID); await easelProvider.repository.launchMyUrl(url: url); } diff --git a/easel/lib/screens/creator_hub/widgets/video_placeholder.dart b/easel/lib/screens/creator_hub/widgets/video_placeholder.dart index 061400164b..6c3b87204b 100644 --- a/easel/lib/screens/creator_hub/widgets/video_placeholder.dart +++ b/easel/lib/screens/creator_hub/widgets/video_placeholder.dart @@ -19,7 +19,7 @@ class VideoPlaceHolder extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( + return ColoredBox( color: EaselAppTheme.kWhite, child: Stack( children: [ @@ -30,7 +30,7 @@ class VideoPlaceHolder extends StatelessWidget { child: const SizedBox.expand(), ), errorWidget: (context, url, error) => - Align(child: Container(color: EaselAppTheme.kWhite)), + const Align(child: ColoredBox(color: EaselAppTheme.kWhite)), imageUrl: thumbnailUrl, fit: BoxFit.cover)), Align( diff --git a/easel/lib/screens/custom_widgets/initial_draft_detail_dialog.dart b/easel/lib/screens/custom_widgets/initial_draft_detail_dialog.dart index 9d233caad9..f46e78190f 100644 --- a/easel/lib/screens/custom_widgets/initial_draft_detail_dialog.dart +++ b/easel/lib/screens/custom_widgets/initial_draft_detail_dialog.dart @@ -43,7 +43,7 @@ class DraftDetailDialog { ); } - dialogAlreadyShown(EaselProvider provider) => provider.nft.isDialogShown; + bool dialogAlreadyShown(EaselProvider provider) => provider.nft.isDialogShown; } class _DraftDetailDialog extends StatefulWidget { @@ -67,7 +67,7 @@ class _DraftDetailDialogState extends State<_DraftDetailDialog> { } void selectPreviewWidgetBasedOnType() { - EaselProvider easelProvider = context.read(); + final EaselProvider easelProvider = context.read(); if (easelProvider.nft.assetType == k3dText) { previewWidget = ModelViewer( src: easelProvider.nft.url.changeDomain(), @@ -122,7 +122,7 @@ class _DraftDetailDialogState extends State<_DraftDetailDialog> { @override Widget build(BuildContext context) { - EaselProvider easelProvider = context.watch(); + final EaselProvider easelProvider = context.watch(); return WillPopScope( onWillPop: () async => false, @@ -142,7 +142,7 @@ class _DraftDetailDialogState extends State<_DraftDetailDialog> { width: 60.h, child: ClipPath( clipper: RightTriangleClipper(orientation: clipper.Orientation.orientationNW), - child: Container( + child: const ColoredBox( color: EaselAppTheme.kLightRed, ), ), @@ -156,7 +156,7 @@ class _DraftDetailDialogState extends State<_DraftDetailDialog> { width: 60.h, child: ClipPath( clipper: RightTriangleClipper(orientation: clipper.Orientation.orientationSE), - child: Container( + child: const ColoredBox( color: EaselAppTheme.kLightRed, ), ), @@ -277,7 +277,7 @@ class _DraftDetailDialogState extends State<_DraftDetailDialog> { return LocaleKeys.failed.tr(); } - void onViewOnIPFSPressed({required EaselProvider provider}) async { + Future onViewOnIPFSPressed({required EaselProvider provider}) async { await provider.repository.launchMyUrl(url: provider.nft.url.changeDomain()); } @@ -315,7 +315,7 @@ class _DraftDetailDialogState extends State<_DraftDetailDialog> { ); } - Widget buildRow({required String title, required String subtitle, final color = Colors.white, final bool canCopy = false}) { + Widget buildRow({required String title, required String subtitle, Color color = Colors.white, bool canCopy = false}) { return Padding( padding: EdgeInsets.symmetric( horizontal: isTablet ? 20.w : 40.w, diff --git a/easel/lib/screens/custom_widgets/step_labels.dart b/easel/lib/screens/custom_widgets/step_labels.dart index 82c6bdb7d5..aae4e79347 100644 --- a/easel/lib/screens/custom_widgets/step_labels.dart +++ b/easel/lib/screens/custom_widgets/step_labels.dart @@ -22,7 +22,7 @@ class StepLabels extends StatelessWidget { child: Row( children: List.generate(stepLabels.length, (index) { return SizedBox( - width: (0.8.sw / stepLabels.length), + width: 0.8.sw / stepLabels.length, child: ValueListenableBuilder( valueListenable: currentPage, builder: (_, int currentPage, __) => Row( diff --git a/easel/lib/screens/custom_widgets/steps_indicator.dart b/easel/lib/screens/custom_widgets/steps_indicator.dart index a6298dcb9e..74dab820d7 100644 --- a/easel/lib/screens/custom_widgets/steps_indicator.dart +++ b/easel/lib/screens/custom_widgets/steps_indicator.dart @@ -1,4 +1,3 @@ - import 'package:easel_flutter/utils/easel_app_theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -8,11 +7,8 @@ class MyStepsIndicator extends StatelessWidget { final ValueNotifier currentStep; const MyStepsIndicator({ - Key? key, required this.currentStep, - }) : super(key: key); - - final int _numSteps = 3; + }); @override Widget build(BuildContext context) { @@ -21,8 +17,8 @@ class MyStepsIndicator extends StatelessWidget { builder: (_, int value, __) { return StepsIndicator( selectedStep: currentStep.value, - nbSteps: _numSteps, - lineLength: 0.68.sw / _numSteps, + nbSteps: 3, + lineLength: 0.68.sw / 3, doneLineColor: EaselAppTheme.kBlue, undoneLineColor: EaselAppTheme.kLightGrey, doneLineThickness: 1.5, @@ -35,19 +31,9 @@ class MyStepsIndicator extends StatelessWidget { enableLineAnimation: true, enableStepAnimation: true, lineLengthCustomStep: const [], - doneStepWidget: Container( - width: 10.w, - height: 10.h, - decoration: const BoxDecoration(color: EaselAppTheme.kBlue)), - unselectedStepWidget: Container( - width: 10.w, - height: 10.h, - decoration: - const BoxDecoration(color: EaselAppTheme.kLightGrey)), - selectedStepWidget: Container( - width: 15.w, - height: 15.h, - decoration: const BoxDecoration(color: EaselAppTheme.kBlue)), + doneStepWidget: Container(width: 10.w, height: 10.h, decoration: const BoxDecoration(color: EaselAppTheme.kBlue)), + unselectedStepWidget: Container(width: 10.w, height: 10.h, decoration: const BoxDecoration(color: EaselAppTheme.kLightGrey)), + selectedStepWidget: Container(width: 15.w, height: 15.h, decoration: const BoxDecoration(color: EaselAppTheme.kBlue)), ); }); } diff --git a/easel/lib/screens/describe_screen.dart b/easel/lib/screens/describe_screen.dart index 139b1b4908..f55a8b1ba8 100644 --- a/easel/lib/screens/describe_screen.dart +++ b/easel/lib/screens/describe_screen.dart @@ -22,6 +22,7 @@ import 'package:get_it/get_it.dart'; import 'package:provider/provider.dart'; import '../generated/locale_keys.g.dart'; +import '../models/nft.dart'; class DescribeScreen extends StatefulWidget { const DescribeScreen({Key? key}) : super(key: key); @@ -31,7 +32,7 @@ class DescribeScreen extends StatefulWidget { } class _DescribeScreenState extends State { - var repository = GetIt.I.get(); + Repository repository = GetIt.I.get(); EaselProvider provider = GetIt.I.get(); final _formKey = GlobalKey(); @@ -49,7 +50,7 @@ class _DescribeScreenState extends State { void initState() { super.initState(); - provider.nft = repository.getCacheDynamicType(key: nftKey); + provider.nft = repository.getCacheDynamicType(key: nftKey) as NFT; repository.logUserJourney(screenName: AnalyticsScreenEvents.describeScreen); String from = ""; from = context.read().from!; @@ -253,7 +254,7 @@ class _DescribeScreenState extends State { bgColor: EaselAppTheme.kBlue, textColor: EaselAppTheme.kWhite, onPressed: () { - validateAndUpdateDescription(true); + validateAndUpdateDescription(moveNextPage: true); }, cuttingHeight: 15.h, clipperType: ClipperType.bottomLeftTopRight, @@ -265,7 +266,7 @@ class _DescribeScreenState extends State { child: InkWell( key: const Key(kSaveAsDraftDescKey), onTap: () { - validateAndUpdateDescription(false); + validateAndUpdateDescription(moveNextPage: false); }, child: Text( LocaleKeys.save_as_draft.tr(), @@ -285,12 +286,12 @@ class _DescribeScreenState extends State { ); } - void validateAndUpdateDescription(moveNextPage) { + void validateAndUpdateDescription({required bool moveNextPage}) { FocusScope.of(context).unfocus(); if (!_formKey.currentState!.validate()) { return; } - if ((_artNameFieldError.value.isNotEmpty || _artistNameFieldError.value.isNotEmpty || _descriptionFieldError.value.isNotEmpty)) { + if (_artNameFieldError.value.isNotEmpty || _artistNameFieldError.value.isNotEmpty || _descriptionFieldError.value.isNotEmpty) { return; } GetIt.I.get().changeSelectedCollection(CollectionType.draft); diff --git a/easel/lib/screens/home_screen.dart b/easel/lib/screens/home_screen.dart index 7b7a3f751e..daf4ff3bfc 100644 --- a/easel/lib/screens/home_screen.dart +++ b/easel/lib/screens/home_screen.dart @@ -1,4 +1,3 @@ - import 'package:easel_flutter/easel_provider.dart'; import 'package:easel_flutter/repository/repository.dart'; import 'package:easel_flutter/screens/describe_screen.dart'; @@ -24,7 +23,7 @@ class HomeScreen extends StatefulWidget { class HomeScreenState extends State { late EaselProvider easelProvider; - var repository = GetIt.I.get(); + Repository repository = GetIt.I.get(); HomeViewModel get homeViewModel => GetIt.I.get(); @@ -40,15 +39,17 @@ class HomeScreenState extends State { homeViewModel.init( setTextField: () { easelProvider.setTextFieldValuesDescription( - artName: homeViewModel.nft?.name, - description: homeViewModel.nft?.description, - hashtags: homeViewModel.nft?.hashtags); + artName: homeViewModel.nft?.name, + description: homeViewModel.nft?.description, + hashtags: homeViewModel.nft?.hashtags, + ); easelProvider.setTextFieldValuesPrice( - royalties: homeViewModel.nft?.tradePercentage, - price: homeViewModel.nft?.price, - edition: homeViewModel.nft?.quantity.toString(), - denom: homeViewModel.nft?.denom, - freeDrop: homeViewModel.nft!.isFreeDrop.toFreeDropEnum()); + royalties: homeViewModel.nft?.tradePercentage, + price: homeViewModel.nft?.price, + edition: homeViewModel.nft?.quantity, + denom: homeViewModel.nft?.denom, + freeDrop: homeViewModel.nft!.isFreeDrop.toFreeDropEnum(), + ); }, ); } @@ -64,8 +65,7 @@ class HomeScreenState extends State { easelProvider.isVideoLoading = true; ScaffoldMessenger.of(context).hideCurrentSnackBar(); homeViewModel.previousPage(); - if (homeViewModel.currentPage.value == 0 || - homeViewModel.currentPage.value == 1) { + if (homeViewModel.currentPage.value == 0 || homeViewModel.currentPage.value == 1) { Navigator.of(context).pop(); } } @@ -77,13 +77,12 @@ class HomeScreenState extends State { onBackPressed(); return false; }, - child: Container( + child: ColoredBox( color: EaselAppTheme.kWhite, child: SafeArea( bottom: false, child: Scaffold( - body: ChangeNotifierProvider.value( - value: homeViewModel, child: const HomeScreenContent()), + body: ChangeNotifierProvider.value(value: homeViewModel, child: const HomeScreenContent()), ), ), ), @@ -108,12 +107,7 @@ class HomeScreenContent extends StatelessWidget { homeViewModel.currentStep.value = map[page]!; }, itemBuilder: (BuildContext context, int index) { - final map = { - 0: chooseFormatScreen, - 1: describeScreen, - 2: priceScreen, - 3: publishScreen - }; + final map = {0: chooseFormatScreen, 1: describeScreen, 2: priceScreen, 3: publishScreen}; return map[index]?.call() ?? const SizedBox(); }, diff --git a/easel/lib/screens/preview_nft/nft_video_player_screen.dart b/easel/lib/screens/preview_nft/nft_video_player_screen.dart index b56bd6da05..f29c1f8dc8 100644 --- a/easel/lib/screens/preview_nft/nft_video_player_screen.dart +++ b/easel/lib/screens/preview_nft/nft_video_player_screen.dart @@ -55,7 +55,7 @@ class NFTVideoPlayerScreen extends StatelessWidget { sigmaX: 5.0, sigmaY: 5.0, ), - child: Container( + child: ColoredBox( color: Colors.black.withOpacity(0.3), child: Padding( padding: EdgeInsets.only(bottom: 30.h), diff --git a/easel/lib/screens/preview_nft/preview_nft_full_screen.dart b/easel/lib/screens/preview_nft/preview_nft_full_screen.dart index 69a79fec71..2a43592997 100644 --- a/easel/lib/screens/preview_nft/preview_nft_full_screen.dart +++ b/easel/lib/screens/preview_nft/preview_nft_full_screen.dart @@ -31,7 +31,7 @@ class _PreviewNFTFullScreenState extends State { super.initState(); } - onBackPressed({required BuildContext context}) { + void onBackPressed({required BuildContext context}) { if (easelProvider.publishedNFTClicked.assetType == AssetType.Video.name && easelProvider.videoPlayerController.value.isInitialized) { if (easelProvider.videoPlayerController.value.isPlaying) { @@ -64,10 +64,9 @@ class _PreviewNFTFullScreenState extends State { assetType: easelProvider.publishedNFTClicked.assetType .toAssetTypeEnum()), Column( - mainAxisAlignment: MainAxisAlignment.start, children: [ ClipRect( - child: Container( + child: ColoredBox( color: Colors.black.withOpacity(0.3), child: Padding( padding: EdgeInsets.fromLTRB(20.w, 30.h, 0, 10.h), diff --git a/easel/lib/screens/preview_screen.dart b/easel/lib/screens/preview_screen.dart index a17b9a0d20..a70eb03148 100644 --- a/easel/lib/screens/preview_screen.dart +++ b/easel/lib/screens/preview_screen.dart @@ -29,7 +29,7 @@ class PreviewScreen extends StatefulWidget { } class _PreviewScreenState extends State { - var repository = GetIt.I.get(); + Repository repository = GetIt.I.get(); @override void initState() { super.initState(); @@ -56,7 +56,6 @@ class _PreviewScreenState extends State { Column(children: [ SizedBox(height: MediaQuery.of(context).viewPadding.top + 20.h), Align( - alignment: Alignment.center, child: Text(LocaleKeys.nft_preview_header.tr(), textAlign: TextAlign.center, style: Theme.of(context).textTheme.bodyText2!.copyWith(color: EaselAppTheme.kLightPurple, fontSize: 15.sp, fontWeight: FontWeight.w600)), ), @@ -106,21 +105,21 @@ class _PreviewScreenState extends State { Widget buildPreviewWidget(EaselProvider provider) { switch (provider.nftFormat.format) { case NFTTypes.image: - return ImageWidget(file: provider.file!); + return ImageWidget(file: provider.file); case NFTTypes.video: return VideoWidget( - file: provider.file!, + file: provider.file, previewFlag: false, isForFile: true, isDarkMode: false, ); case NFTTypes.audio: - return AudioWidget(file: provider.file!, previewFlag: true); + return AudioWidget(file: provider.file, previewFlag: true); case NFTTypes.threeD: - return Model3dViewer(path: provider.file!.path, isFile: true); + return Model3dViewer(path: provider.file?.path, isFile: true); case NFTTypes.pdf: return PdfViewer( - file: provider.file!, + file: provider.file, previewFlag: true, ); } diff --git a/easel/lib/screens/price_screen.dart b/easel/lib/screens/price_screen.dart index 4eda3a4f90..abfab021be 100644 --- a/easel/lib/screens/price_screen.dart +++ b/easel/lib/screens/price_screen.dart @@ -31,7 +31,7 @@ class PriceScreen extends StatefulWidget { class _PriceScreenState extends State { final _formKey = GlobalKey(); - var repository = GetIt.I.get(); + Repository repository = GetIt.I.get(); NFT? nft; final ValueNotifier _royaltiesFieldError = ValueNotifier(""); @@ -46,7 +46,7 @@ class _PriceScreenState extends State { @override void initState() { - nft = repository.getCacheDynamicType(key: nftKey); + nft = repository.getCacheDynamicType(key: nftKey) as NFT; repository.logUserJourney(screenName: AnalyticsScreenEvents.priceScreen); super.initState(); } @@ -333,7 +333,7 @@ class _PriceScreenState extends State { onPressed: () async { if (provider.isFreeDrop != FreeDrop.unselected) { FocusScope.of(context).unfocus(); - validateAndUpdatePrice(true); + validateAndUpdatePrice(moveNextPage: true); } }, cuttingHeight: 15.h, @@ -351,7 +351,7 @@ class _PriceScreenState extends State { return; } FocusScope.of(context).unfocus(); - validateAndUpdatePrice(false); + validateAndUpdatePrice(moveNextPage: false); }, child: Text( LocaleKeys.save_as_draft.tr(), @@ -371,7 +371,7 @@ class _PriceScreenState extends State { ); } - void validateAndUpdatePrice(bool moveNextPage) async { + Future validateAndUpdatePrice({required bool moveNextPage}) async { final navigator = Navigator.of(context); final HomeViewModel homeViewModel = context.read(); diff --git a/easel/lib/screens/publish_screen.dart b/easel/lib/screens/publish_screen.dart index 0a08c6d418..3cd129ef06 100644 --- a/easel/lib/screens/publish_screen.dart +++ b/easel/lib/screens/publish_screen.dart @@ -47,13 +47,13 @@ class PublishScreen extends StatefulWidget { } class _PublishScreenState extends State { - var repository = GetIt.I.get(); - var easelProvider = GetIt.I.get(); - var homeViewModel = GetIt.I.get(); + Repository repository = GetIt.I.get(); + EaselProvider easelProvider = GetIt.I.get(); + HomeViewModel homeViewModel = GetIt.I.get(); @override - initState() { - easelProvider.nft = repository.getCacheDynamicType(key: nftKey); + void initState() { + easelProvider.nft = repository.getCacheDynamicType(key: nftKey) as NFT; easelProvider.collapsed = false; easelProvider.setLog(screenName: AnalyticsScreenEvents.publishScreen); super.initState(); @@ -174,7 +174,7 @@ class _OwnerBottomDrawerState extends State { children: [ BuildPublishBottomSheet( collapseStatus: viewModel.collapsed, - onCollapsed: (context) => Container( + onCollapsed: (context) => DecoratedBox( decoration: const BoxDecoration(gradient: LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [EaselAppTheme.kTransparent, EaselAppTheme.kBlack])), child: Padding( padding: EdgeInsets.only(left: 16.w, right: 16.w, top: 8.h, bottom: 16.h), @@ -224,7 +224,7 @@ class _OwnerBottomDrawerState extends State { case ButtonState.paused: return InkWell( onTap: () { - viewModel.playAudio(false); + viewModel.playAudio(forFile: false); }, child: Icon( Icons.play_arrow_outlined, @@ -236,7 +236,7 @@ class _OwnerBottomDrawerState extends State { case ButtonState.playing: return InkWell( onTap: () { - viewModel.pauseAudio(false); + viewModel.pauseAudio(forFile: false); }, child: Icon( Icons.pause, @@ -253,7 +253,7 @@ class _OwnerBottomDrawerState extends State { valueListenable: viewModel.audioProgressNotifier, builder: (_, value, __) { return Padding( - padding: EdgeInsets.only(right: 10.w, bottom: 3.h, top: 0, left: 5.w), + padding: EdgeInsets.only(right: 10.w, bottom: 3.h, left: 5.w), child: ProgressBar( progressBarColor: EaselAppTheme.kWhite, thumbColor: EaselAppTheme.kWhite, @@ -266,7 +266,7 @@ class _OwnerBottomDrawerState extends State { thumbRadius: 10.h, timeLabelPadding: 3.h, onSeek: (position) { - viewModel.seekAudio(position, false); + viewModel.seekAudio(position, forFile: false); }, ), ); @@ -346,7 +346,7 @@ class _OwnerBottomDrawerState extends State { SizedBox(height: 5.h), buildRow( title: LocaleKeys.editions.tr(), - subtitle: widget.nft.quantity.toString(), + subtitle: widget.nft.quantity, ), SizedBox(height: 5.h), buildRow( @@ -372,7 +372,7 @@ class _OwnerBottomDrawerState extends State { if (viewModel.nft.assetType == kAudioText) { viewModel.disposeAudioController(); } - bool isRecipeCreated = await viewModel.verifyPylonsAndMint(nft: viewModel.nft); + final bool isRecipeCreated = await viewModel.verifyPylonsAndMint(nft: viewModel.nft); if (!isRecipeCreated) { return; } @@ -499,7 +499,7 @@ class _OwnerBottomDrawerState extends State { case ButtonState.paused: return InkWell( onTap: () { - viewModel.playAudio(false); + viewModel.playAudio(forFile: false); }, child: Icon( Icons.play_arrow_outlined, @@ -511,7 +511,7 @@ class _OwnerBottomDrawerState extends State { case ButtonState.playing: return InkWell( onTap: () { - viewModel.pauseAudio(false); + viewModel.pauseAudio(forFile: false); }, child: Icon( Icons.pause, @@ -541,7 +541,7 @@ class _OwnerBottomDrawerState extends State { thumbRadius: 6.h, timeLabelPadding: 2.h, onSeek: (position) { - viewModel.seekAudio(position, false); + viewModel.seekAudio(position, forFile: false); }, ), ); @@ -568,11 +568,11 @@ class _OwnerBottomDrawerState extends State { ); } - void onViewOnIPFSPressed({required EaselProvider provider}) async { + Future onViewOnIPFSPressed({required EaselProvider provider}) async { await provider.repository.launchMyUrl(url: provider.nft.url.changeDomain()); } - Widget buildRow({required String title, required String subtitle, final viewIPFS = false, final bool canCopy = false}) { + Widget buildRow({required String title, required String subtitle, bool viewIPFS = false, bool canCopy = false}) { final viewModel = context.watch(); return Row( @@ -586,9 +586,9 @@ class _OwnerBottomDrawerState extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ InkWell( - onTap: () { + onTap: () async { if (viewIPFS) { - return onViewOnIPFSPressed(provider: viewModel); + await onViewOnIPFSPressed(provider: viewModel); } }, child: Text( diff --git a/easel/lib/screens/splash_screen.dart b/easel/lib/screens/splash_screen.dart index ccc65e5745..151062b5b1 100644 --- a/easel/lib/screens/splash_screen.dart +++ b/easel/lib/screens/splash_screen.dart @@ -81,14 +81,14 @@ class _SplashScreenState extends State { ); } - void populateCoinsAndMoveForward() async { + Future populateCoinsAndMoveForward() async { context.read().populateCoinsIfPylonsNotExists(); navigatorKey.currentState!.pushReplacementNamed(RouteUtil.kRouteCreatorHub); } void onGetStarted() { - var onBoardingComplete = GetIt.I.get().getOnBoardingComplete(); + final onBoardingComplete = GetIt.I.get().getOnBoardingComplete(); if (!onBoardingComplete) { Navigator.of(context).pushNamed(RouteUtil.kRouteTutorial); return; diff --git a/easel/lib/screens/tutorial_screen.dart b/easel/lib/screens/tutorial_screen.dart index 51c6518cc8..ed1e5f44b6 100644 --- a/easel/lib/screens/tutorial_screen.dart +++ b/easel/lib/screens/tutorial_screen.dart @@ -62,7 +62,7 @@ class TutorialScreenState extends State { super.initState(); tutorialProvider.setLog(); - + myBottomDrawerController = BottomDrawerController(); slides = kTutorialItems .map((item) => Column( @@ -71,15 +71,26 @@ class TutorialScreenState extends State { Padding( padding: EdgeInsets.symmetric(horizontal: 0.22.sw), child: Image.asset( - item[kImageTutorial], + item[kImageTutorial] as String, height: 10.h, width: 40, fit: BoxFit.fill, )), SizedBox(height: 0.1.sh), - Text(item[kHeaderTutorial], style: TextStyle(fontSize: isTablet ? 16.sp : 18.sp, fontWeight: FontWeight.w800, color: EaselAppTheme.kDartGrey), textAlign: TextAlign.center), + Text( + item[kHeaderTutorial] as String, + style: TextStyle(fontSize: isTablet ? 16.sp : 18.sp, fontWeight: FontWeight.w800, color: EaselAppTheme.kDartGrey), + textAlign: TextAlign.center, + ), SizedBox(height: 15.h), - SizedBox(width: 0.63.sw, child: Text(item[kDescriptionTutorial], style: TextStyle(color: Colors.black, fontSize: 13.sp, fontWeight: FontWeight.w400), textAlign: TextAlign.center)), + SizedBox( + width: 0.63.sw, + child: Text( + item[kDescriptionTutorial] as String, + style: TextStyle(color: Colors.black, fontSize: 13.sp, fontWeight: FontWeight.w400), + textAlign: TextAlign.center, + ), + ), ], )) .toList(); @@ -105,15 +116,15 @@ class TutorialScreenState extends State { Padding( padding: EdgeInsets.symmetric(horizontal: 0.22.sw), child: Image.asset( - item[kImageTutorial], + item[kImageTutorial] as String, height: isTablet ? 140.w : 200.w, width: isTablet ? 140.w : 200.w, fit: BoxFit.fill, )), SizedBox(height: 0.15.sh), - Text(item[kHeaderTutorial], style: TextStyle(fontSize: isTablet ? 16.sp : 18.sp, fontWeight: FontWeight.w800, color: EaselAppTheme.kDartGrey), textAlign: TextAlign.center), + Text(item[kHeaderTutorial] as String, style: TextStyle(fontSize: isTablet ? 16.sp : 18.sp, fontWeight: FontWeight.w800, color: EaselAppTheme.kDartGrey), textAlign: TextAlign.center), SizedBox(height: 15.h), - SizedBox(width: 0.63.sw, child: Text(item[kDescriptionTutorial], style: TextStyle(color: Colors.black, fontSize: 13.sp, fontWeight: FontWeight.w400), textAlign: TextAlign.center)), + SizedBox(width: 0.63.sw, child: Text(item[kDescriptionTutorial] as String, style: TextStyle(color: Colors.black, fontSize: 13.sp, fontWeight: FontWeight.w400), textAlign: TextAlign.center)), ], )) .toList(); @@ -165,7 +176,6 @@ class TutorialScreenState extends State { height: 16.h, decoration: const BoxDecoration( color: EaselAppTheme.kLightRed, - shape: BoxShape.rectangle, )), SizedBox(width: 24.w), SizedBox( @@ -190,7 +200,6 @@ class TutorialScreenState extends State { height: 16.h, decoration: const BoxDecoration( color: EaselAppTheme.kYellow, - shape: BoxShape.rectangle, )), SizedBox(width: 24.w), SizedBox( @@ -215,7 +224,6 @@ class TutorialScreenState extends State { height: 16.h, decoration: const BoxDecoration( color: EaselAppTheme.kDarkGreen, - shape: BoxShape.rectangle, )), SizedBox(width: 24.w), SizedBox( @@ -234,7 +242,6 @@ class TutorialScreenState extends State { SizedBox(height: 20.h), ScreenResponsive( mobileScreen: (context) => Align( - alignment: Alignment.center, child: PylonsButton( onPressed: () async { await onDownloadNowPressed(context); @@ -276,7 +283,7 @@ class TutorialScreenState extends State { } } - void moveForwardToEaselMessage() async { + Future moveForwardToEaselMessage() async { tutorialProvider.forwarding(); await navigatorKey.currentState!.pushReplacementNamed(RouteUtil.kRouteWelcomeEasel); tutorialProvider.forwarding(); diff --git a/easel/lib/screens/welcome_easel.dart b/easel/lib/screens/welcome_easel.dart index 3c47e48355..ff5913dd99 100644 --- a/easel/lib/screens/welcome_easel.dart +++ b/easel/lib/screens/welcome_easel.dart @@ -92,7 +92,7 @@ class _WelcomeEaselState extends State { ); } - void populateCoinsAndMoveForward() async { + Future populateCoinsAndMoveForward() async { GetIt.I.get().saveOnBoardingComplete(); context.read().populateCoinsIfPylonsNotExists(); diff --git a/easel/lib/screens/welcome_screen/widgets/show_something_wrong_dialog.dart b/easel/lib/screens/welcome_screen/widgets/show_something_wrong_dialog.dart index 88de2f1850..5e7c08a835 100644 --- a/easel/lib/screens/welcome_screen/widgets/show_something_wrong_dialog.dart +++ b/easel/lib/screens/welcome_screen/widgets/show_something_wrong_dialog.dart @@ -95,7 +95,7 @@ class ShowSomethingWentWrongDialog { padding: EdgeInsets.symmetric(horizontal: 0.1.sw), child: ClipPath( clipper: DialogClipper(), - child: Container( + child: ColoredBox( color: EaselAppTheme.kLightRed, child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, diff --git a/easel/lib/screens/welcome_screen/widgets/show_wallet_install_dialog.dart b/easel/lib/screens/welcome_screen/widgets/show_wallet_install_dialog.dart index 49ed9a6f39..1469d5ff64 100644 --- a/easel/lib/screens/welcome_screen/widgets/show_wallet_install_dialog.dart +++ b/easel/lib/screens/welcome_screen/widgets/show_wallet_install_dialog.dart @@ -109,7 +109,7 @@ class ShowWalletInstallDialog { padding: EdgeInsets.symmetric(horizontal: 0.1.sw), child: ClipPath( clipper: DialogClipper(), - child: Container( + child: ColoredBox( color: EaselAppTheme.kLightRed, child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, diff --git a/easel/lib/services/datasources/cache_manager.dart b/easel/lib/services/datasources/cache_manager.dart index 2b2662c175..ff997b6cff 100644 --- a/easel/lib/services/datasources/cache_manager.dart +++ b/easel/lib/services/datasources/cache_manager.dart @@ -35,7 +35,7 @@ class CacheManagerImp extends CacheManager { @override String deleteString({required String key}) { if (cache.containsKey(key)) { - return cache.remove(key); + return cache.remove(key) as String; } return ''; } @@ -59,13 +59,13 @@ class CacheManagerImp extends CacheManager { @override String getString({required String key}) { if (cache.containsKey(key)) { - return cache[key]; + return cache[key] as String; } return ''; } @override - bool setDynamicType({required String key, required value}) { + bool setDynamicType({required String key, required dynamic value}) { cache[key] = value; return true; } diff --git a/easel/lib/services/datasources/local_datasource.dart b/easel/lib/services/datasources/local_datasource.dart index 3b5292ee90..7dc0ea1266 100644 --- a/easel/lib/services/datasources/local_datasource.dart +++ b/easel/lib/services/datasources/local_datasource.dart @@ -137,7 +137,7 @@ class LocalDataSourceImpl implements LocalDataSource { /// returns cookbookId @override Future autoGenerateCookbookId() async { - String cookbookId = "Easel_CookBook_auto_cookbook_${getFullDateTime()}"; + final String cookbookId = "Easel_CookBook_auto_cookbook_${getFullDateTime()}"; await sharedPreferences.setString(kCookbookId, cookbookId); @@ -148,7 +148,7 @@ class LocalDataSourceImpl implements LocalDataSource { /// returns easelId @override String autoGenerateEaselId() { - String cookbookId = "Easel_Recipe_auto_recipe_${getFullDateTime()}"; + final String cookbookId = "Easel_Recipe_auto_recipe_${getFullDateTime()}"; return cookbookId; } @@ -170,7 +170,7 @@ class LocalDataSourceImpl implements LocalDataSource { @override Future saveOnBoardingComplete() async { - return await sharedPreferences.setBool(onboardingComplete, true); + return sharedPreferences.setBool(onboardingComplete, true); } @override @@ -260,7 +260,7 @@ class LocalDataSourceImpl implements LocalDataSource { @override Future> getNfts() async { - return await database.nftDao.findAllNft(); + return database.nftDao.findAllNft(); } @override @@ -289,7 +289,7 @@ class LocalDataSourceImpl implements LocalDataSource { } @override - bool setCacheDynamicType({required String key, required value}) { + bool setCacheDynamicType({required String key, required dynamic value}) { return cacheManager.setDynamicType(key: key, value: value); } @@ -299,7 +299,7 @@ class LocalDataSourceImpl implements LocalDataSource { } @override - deleteCacheDynamic({required String key}) { + void deleteCacheDynamic({required String key}) { cacheManager.deleteCacheDynamic(key: key); } diff --git a/easel/lib/services/datasources/remote_datasource.dart b/easel/lib/services/datasources/remote_datasource.dart index 9569e6bd56..3e83508a7c 100644 --- a/easel/lib/services/datasources/remote_datasource.dart +++ b/easel/lib/services/datasources/remote_datasource.dart @@ -2,7 +2,6 @@ import 'dart:io'; import 'package:dio/dio.dart'; import 'package:easel_flutter/easel_provider.dart'; -import 'package:easel_flutter/models/api_response.dart'; import 'package:easel_flutter/models/storage_response_model.dart'; import 'package:easel_flutter/models/upload_progress.dart'; import 'package:easel_flutter/services/third_party_services/analytics_helper.dart'; @@ -15,13 +14,18 @@ abstract class RemoteDataSource { /// This method is used uploading provided file to the server using [httpClient] /// Input : [file] which needs to be uploaded , [onUploadProgressCallback] a callback method which needs to be call on each progress /// Output : [Future>] the ApiResponse which can contain [success] or [error] response - Future> uploadFile({required OnUploadProgressCallback uploadProgressCallback, required File file}); + Future uploadFile({required OnUploadProgressCallback uploadProgressCallback, required File file}); /// This method is used to getRecipesList based on CookbookID /// Input : [cookBookID] against which recipes needs to be fetched /// Output : [Future>] which will be a Future list of Recipes against the given [cookbookID] Future> getRecipesByCookbookID(String cookBookID); + + + /// This method is used to log user journey in the easel app. + /// Input: [screenName] the screen name in the easel. + /// Output: [bool] tells whether the user journey is recorded or not Future logUserJourney({required String screenName}); } @@ -32,7 +36,7 @@ class RemoteDataSourceImpl implements RemoteDataSource { RemoteDataSourceImpl({required this.httpClient, required this.analyticsHelper}); @override - Future> uploadFile({required OnUploadProgressCallback uploadProgressCallback, required File file}) async { + Future uploadFile({required OnUploadProgressCallback uploadProgressCallback, required File file}) async { final response = await httpClient.post( "/upload", data: Stream.fromIterable(file.readAsBytesSync().map((e) => [e])), @@ -40,7 +44,7 @@ class RemoteDataSourceImpl implements RemoteDataSource { 'Content-Length': file.lengthSync().toString(), }), onSendProgress: (uploaded, total) { - double uploadedPercentage = uploaded / total; + final double uploadedPercentage = uploaded / total; uploadProgressCallback( UploadProgress(totalSize: total, sendSize: uploaded, uploadedProgressData: uploadedPercentage), ); @@ -48,17 +52,16 @@ class RemoteDataSourceImpl implements RemoteDataSource { ); if (response.statusCode == HttpStatus.ok) { - final data = StorageResponseModel.fromJson(response.data); - return ApiResponse.success(data: data); + final data = StorageResponseModel.fromJson(response.data as Map); + return data; } - return ApiResponse.error( - errorMessage: response.data["error"]["message"] ?? LocaleKeys.update_failed.tr(), - ); + + throw response.data["error"]["message"] as String? ?? LocaleKeys.update_failed.tr(); } @override Future> getRecipesByCookbookID(String cookBookID) async { - var sdkResponse = await PylonsWallet.instance.getRecipes(cookBookID); + final sdkResponse = await PylonsWallet.instance.getRecipes(cookBookID); return sdkResponse.data!; } diff --git a/easel/lib/services/third_party_services/video_player_helper.dart b/easel/lib/services/third_party_services/video_player_helper.dart index 5c9bc91c51..292261c161 100644 --- a/easel/lib/services/third_party_services/video_player_helper.dart +++ b/easel/lib/services/third_party_services/video_player_helper.dart @@ -44,12 +44,12 @@ class VideoPlayerHelperImp implements VideoPlayerHelper { VideoPlayerHelperImp(this.videoPlayerController); @override - void initializeVideoPlayerWithFile({required File file}) async { + Future initializeVideoPlayerWithFile({required File file}) async { videoPlayerController = VideoPlayerController.file(file)..initialize().then((value) => {}); } @override - void initializeVideoPlayerWithUrl({required String videoUrl}) async { + Future initializeVideoPlayerWithUrl({required String videoUrl}) async { videoPlayerController = VideoPlayerController.network(videoUrl)..initialize().then((value) => {}); } diff --git a/easel/lib/utils/amount_formatter.dart b/easel/lib/utils/amount_formatter.dart index b51c40cb70..246092db6d 100644 --- a/easel/lib/utils/amount_formatter.dart +++ b/easel/lib/utils/amount_formatter.dart @@ -17,9 +17,9 @@ class AmountFormatter extends TextInputFormatter { if (newValue.selection.baseOffset > maxDigits) { return oldValue; } - double value = double.parse(newValue.text); + final double value = double.parse(newValue.text); final formatter = NumberFormat(isDecimal ? "#,##0.00" : "#,###", "en_US"); - String newText = formatter.format(isDecimal ? value / 100 : value); + final String newText = formatter.format(isDecimal ? value / 100 : value); return newValue.copyWith( text: newText, diff --git a/easel/lib/utils/extension_util.dart b/easel/lib/utils/extension_util.dart index 4f1940ddd8..ba4c561d02 100644 --- a/easel/lib/utils/extension_util.dart +++ b/easel/lib/utils/extension_util.dart @@ -173,7 +173,7 @@ extension FileSizeInGB on int { extension FileSizeString on int { String getFileSizeString({required int precision}) { - var i = (log(this) / log(1024)).floor(); + final i = (log(this) / log(1024)).floor(); return ((this / pow(1024, i)).toStringAsFixed(precision)) + suffixes[i]; } } diff --git a/easel/lib/utils/file_utils_helper.dart b/easel/lib/utils/file_utils_helper.dart index 3de4f6acf8..f70f951f74 100644 --- a/easel/lib/utils/file_utils_helper.dart +++ b/easel/lib/utils/file_utils_helper.dart @@ -82,7 +82,7 @@ class FileUtilsHelperImpl implements FileUtilsHelper { break; } - FilePickerResult? result = await filePicker.pickFiles(type: type, allowedExtensions: allowedExtensions); + final FilePickerResult? result = await filePicker.pickFiles(type: type, allowedExtensions: allowedExtensions); if (result == null) { return PickedFileModel( @@ -118,7 +118,7 @@ class FileUtilsHelperImpl implements FileUtilsHelper { @override String getFileSizeString({required int fileLength, required int precision}) { - var i = (log(fileLength) / log(1024)).floor(); + final i = (log(fileLength) / log(1024)).floor(); return ((fileLength / pow(1024, i)).toStringAsFixed(precision)) + suffixes[i]; } @@ -133,13 +133,13 @@ class FileUtilsHelperImpl implements FileUtilsHelper { if (canLaunch) { launchUrlString(url, mode: LaunchMode.externalApplication); } else { - throw (LocaleKeys.cannot_launch_url.tr()); + throw LocaleKeys.cannot_launch_url.tr(); } } Future cropImage({required String filePath}) async { try { - CroppedFile? croppedFile = await imageCropper.cropImage( + final CroppedFile? croppedFile = await imageCropper.cropImage( sourcePath: filePath, aspectRatioPresets: [CropAspectRatioPreset.square, CropAspectRatioPreset.ratio3x2, CropAspectRatioPreset.original, CropAspectRatioPreset.ratio4x3, CropAspectRatioPreset.ratio16x9], uiSettings: [ diff --git a/easel/lib/utils/read_more.dart b/easel/lib/utils/read_more.dart index 9557953ae5..4ac29f93a1 100644 --- a/easel/lib/utils/read_more.dart +++ b/easel/lib/utils/read_more.dart @@ -122,7 +122,7 @@ class ReadMoreTextState extends State { recognizer: TapGestureRecognizer()..onTap = _onTapLink, ); - Widget result = LayoutBuilder( + final Widget result = LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { assert(constraints.hasBoundedWidth); final double maxWidth = constraints.maxWidth; diff --git a/easel/lib/viewmodels/home_viewmodel.dart b/easel/lib/viewmodels/home_viewmodel.dart index f4804a480e..a703e29600 100644 --- a/easel/lib/viewmodels/home_viewmodel.dart +++ b/easel/lib/viewmodels/home_viewmodel.dart @@ -19,7 +19,7 @@ class HomeViewModel extends ChangeNotifier { NFT? nft; String? from; - final List pageTitles = [ + final List pageTitles = [ LocaleKeys.upload.tr(), LocaleKeys.nft_detail_text.tr(), LocaleKeys.nft_pricing.tr(), @@ -31,7 +31,7 @@ class HomeViewModel extends ChangeNotifier { repository.deleteCacheString(key: fromKey); if (from == kDraft) { - nft = repository.getCacheDynamicType(key: nftKey); + nft = repository.getCacheDynamicType(key: nftKey) as NFT; Future.delayed(const Duration(milliseconds: 1), () { setTextField.call(); @@ -43,40 +43,40 @@ class HomeViewModel extends ChangeNotifier { case UploadStep.assetUploaded: currentPage = ValueNotifier(1); currentStep = ValueNotifier(1); - pageController = PageController(keepPage: true, initialPage: 1); + pageController = PageController(initialPage: 1); return; case UploadStep.descriptionAdded: currentPage = ValueNotifier(2); currentStep = ValueNotifier(2); - pageController = PageController(keepPage: true, initialPage: 2); + pageController = PageController(initialPage: 2); break; case UploadStep.priceAdded: currentPage = ValueNotifier(3); currentStep = ValueNotifier(2); - pageController = PageController(keepPage: true, initialPage: 3); + pageController = PageController(initialPage: 3); break; case UploadStep.none: currentPage = ValueNotifier(0); currentStep = ValueNotifier(0); - pageController = PageController(keepPage: true, initialPage: 0); + pageController = PageController(); break; } } else { currentPage = ValueNotifier(0); currentStep = ValueNotifier(0); - pageController = PageController(keepPage: true, initialPage: 0); + pageController = PageController(); } } - void nextPage() async { + Future nextPage() async { await pageController.nextPage( duration: const Duration(milliseconds: kPageAnimationTimeInMillis), curve: Curves.easeIn); notifyListeners(); } - void previousPage() async { + Future previousPage() async { from = kDraft; await pageController.previousPage( duration: const Duration(milliseconds: kPageAnimationTimeInMillis), diff --git a/easel/lib/widgets/audio_widget.dart b/easel/lib/widgets/audio_widget.dart index 4efc462cb0..d1686a386a 100644 --- a/easel/lib/widgets/audio_widget.dart +++ b/easel/lib/widgets/audio_widget.dart @@ -33,11 +33,11 @@ class AudioWidgetState extends State with WidgetsBindingObserver { Repository get repository => GetIt.I.get(); @override - initState() { + void initState() { super.initState(); if (!widget.previewFlag) { - easelProvider.initializeAudioPlayer(publishedNFTUrl: widget.filePath); + easelProvider.initializeAudioPlayer(publishedNFTUrl: widget.filePath ?? ""); return; } else { easelProvider.initializeAudioPlayerForFile(file: widget.file!); @@ -76,6 +76,7 @@ class AudioWidgetState extends State with WidgetsBindingObserver { SizedBox( height: 0.4.sh, ), + // ignore: prefer_if_elements_to_conditional_expressions (shouldShowThumbnailButtonOrStepsOrNot()) ? SizedBox( height: 100.h, @@ -96,7 +97,7 @@ class AudioWidgetState extends State with WidgetsBindingObserver { case ButtonState.paused: return InkWell( onTap: () { - viewModel.playAudio(widget.file != null); + viewModel.playAudio(forFile: widget.file != null); }, child: Icon( Icons.play_arrow, @@ -108,7 +109,7 @@ class AudioWidgetState extends State with WidgetsBindingObserver { case ButtonState.playing: return InkWell( onTap: () { - viewModel.pauseAudio(widget.file != null); + viewModel.pauseAudio(forFile: widget.file != null); }, child: Icon( Icons.pause, @@ -138,7 +139,7 @@ class AudioWidgetState extends State with WidgetsBindingObserver { thumbRadius: 10.h, timeLabelPadding: 3.h, onSeek: (position) { - viewModel.seekAudio(position, widget.file != null); + viewModel.seekAudio(position, forFile: widget.file != null); }, ), ); @@ -152,7 +153,7 @@ class AudioWidgetState extends State with WidgetsBindingObserver { SizedBox( height: 40.0.h, ), - shouldShowThumbnailButtonOrStepsOrNot() ? _buildThumbnailButton() : const SizedBox(), + if (shouldShowThumbnailButtonOrStepsOrNot()) _buildThumbnailButton() else const SizedBox(), ], ), ), @@ -189,8 +190,8 @@ class AudioWidgetState extends State with WidgetsBindingObserver { ); } - void audioThumbnailPicker() async { - easelProvider.pauseAudio(true); + Future audioThumbnailPicker() async { + easelProvider.pauseAudio(forFile: true); final pickedFile = await repository.pickFile(NftFormat.supportedFormats[0]); final result = pickedFile.getOrElse(() => PickedFileModel(path: "", fileName: "", extension: "")); if (result.path.isEmpty) { diff --git a/easel/lib/widgets/clippers/bottom_sheet_clipper.dart b/easel/lib/widgets/clippers/bottom_sheet_clipper.dart index 10d1267b2d..af5ff24708 100644 --- a/easel/lib/widgets/clippers/bottom_sheet_clipper.dart +++ b/easel/lib/widgets/clippers/bottom_sheet_clipper.dart @@ -29,7 +29,7 @@ class BottomSheetClipper extends CustomClipper { @override Path getClip(Size size) { - Path path0 = Path(); + final Path path0 = Path(); path0.moveTo(0, size.height); path0.lineTo(0, size.height * 0.1241250); path0.lineTo(size.width * 0.0753750, 0); diff --git a/easel/lib/widgets/easel_hashtag_input_field.dart b/easel/lib/widgets/easel_hashtag_input_field.dart index 9d25809124..2f9023bc25 100644 --- a/easel/lib/widgets/easel_hashtag_input_field.dart +++ b/easel/lib/widgets/easel_hashtag_input_field.dart @@ -50,7 +50,6 @@ class _HashtagInputFieldState extends State { fit: BoxFit.fill, ), Row( - crossAxisAlignment: CrossAxisAlignment.center, children: [ Padding( padding: EdgeInsets.only(left: 10.0.w), @@ -60,14 +59,11 @@ class _HashtagInputFieldState extends State { child: SizedBox( height: isTablet ? 32.h : 40.h, child: Align( - alignment: Alignment.center, child: TextFormField( style: TextStyle(fontSize: isTablet ? 16.sp : 18.sp, fontWeight: FontWeight.w400, color: EaselAppTheme.kDarkText), controller: _inputController, minLines: 1, - maxLines: 1, keyboardType: TextInputType.text, - textCapitalization: TextCapitalization.none, decoration: InputDecoration( hintText: "hashtag_hint".tr(), hintStyle: TextStyle(fontSize: isTablet ? 16.sp : 15.sp, color: EaselAppTheme.kGrey), @@ -76,7 +72,7 @@ class _HashtagInputFieldState extends State { contentPadding: EdgeInsets.fromLTRB(10.w, 0.h, 10.w, 0.h), ), inputFormatters: [ - FilteringTextInputFormatter.allow(RegExp(r'[a-zA-Z0-9]')), + FilteringTextInputFormatter.allow(RegExp('[a-zA-Z0-9]')), ], ), ))), diff --git a/easel/lib/widgets/easel_price_input_field.dart b/easel/lib/widgets/easel_price_input_field.dart index d7b05169fc..0a7fd3799c 100644 --- a/easel/lib/widgets/easel_price_input_field.dart +++ b/easel/lib/widgets/easel_price_input_field.dart @@ -54,9 +54,7 @@ class EaselPriceInputField extends StatelessWidget { controller: controller, validator: validator, minLines: 1, - maxLines: 1, keyboardType: TextInputType.number, - textCapitalization: TextCapitalization.none, inputFormatters: inputFormatters, decoration: InputDecoration( hintText: LocaleKeys.price_hint.tr(), @@ -99,7 +97,6 @@ class _CurrencyDropDown extends StatelessWidget { padding: EdgeInsets.only(left: 5.w), height: isTablet ? 32.h : 40.h, child: Align( - alignment: Alignment.center, child: DropdownButton( onTap: () { FocusManager.instance.primaryFocus?.unfocus(); @@ -125,7 +122,6 @@ class _CurrencyDropDown extends StatelessWidget { return DropdownMenuItem( value: value.symbol, child: Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ value.getIconWidget(), SizedBox(width: isTablet ? 10.w : 10.w), diff --git a/easel/lib/widgets/easel_text_field.dart b/easel/lib/widgets/easel_text_field.dart index 3f2fe1ad40..14c36fe396 100644 --- a/easel/lib/widgets/easel_text_field.dart +++ b/easel/lib/widgets/easel_text_field.dart @@ -68,7 +68,6 @@ class EaselTextField extends StatelessWidget { return SizedBox( height: noOfLines == 1 ? 40.h : 120.h, child: Align( - alignment: Alignment.center, child: TextFormField( style: TextStyle( fontSize: noOfLines == 1 ? 18.sp : 15.sp, @@ -100,7 +99,6 @@ class EaselTextField extends StatelessWidget { return SizedBox( height: noOfLines == 1 ? 32.h : 110.h, child: Align( - alignment: Alignment.center, child: TextFormField( style: TextStyle( fontSize: noOfLines == 1 ? 16.sp : 14.sp, diff --git a/easel/lib/widgets/model_viewer.dart b/easel/lib/widgets/model_viewer.dart index 571fd8d311..19992a2773 100644 --- a/easel/lib/widgets/model_viewer.dart +++ b/easel/lib/widgets/model_viewer.dart @@ -30,7 +30,6 @@ class Model3dViewerState extends State { modelViewer = ModelViewer( src: widget.isFile ? 'file://${widget.path!}' : widget.path!, autoRotate: false, - cameraControls: true, backgroundColor: EaselAppTheme.kBlack, ); } diff --git a/easel/lib/widgets/pdf_viewer_full_screen.dart b/easel/lib/widgets/pdf_viewer_full_screen.dart index 4765704f2a..620cf796f6 100644 --- a/easel/lib/widgets/pdf_viewer_full_screen.dart +++ b/easel/lib/widgets/pdf_viewer_full_screen.dart @@ -15,6 +15,7 @@ class PdfViewerFullScreen extends StatefulWidget { class _PdfViewerFullScreenState extends State { @override Widget build(BuildContext context) { + // ignore: cast_nullable_to_non_nullable final doc = ModalRoute.of(context)!.settings.arguments as List; return SafeArea( child: Scaffold( diff --git a/easel/lib/widgets/pylons_button.dart b/easel/lib/widgets/pylons_button.dart index 610e3b4fb3..2ad91fd10f 100644 --- a/easel/lib/widgets/pylons_button.dart +++ b/easel/lib/widgets/pylons_button.dart @@ -65,8 +65,8 @@ class PylonsButton extends StatelessWidget { class PylonsButtonClipper extends CustomClipper { @override - getClip(Size size) { - Path path0 = Path(); + Path getClip(Size size) { + final Path path0 = Path(); path0.moveTo(0, 0); path0.lineTo(size.width * 0.8991000, 0); path0.lineTo(size.width, size.height * 0.3484000); diff --git a/easel/lib/widgets/rounded_purple_button_widget.dart b/easel/lib/widgets/rounded_purple_button_widget.dart index ca2407cf1c..2f584ccd76 100644 --- a/easel/lib/widgets/rounded_purple_button_widget.dart +++ b/easel/lib/widgets/rounded_purple_button_widget.dart @@ -20,7 +20,6 @@ class RoundedPurpleButtonWidget extends StatelessWidget { boxShadow: [ BoxShadow( color: EaselAppTheme.kBlue.withOpacity(0.6), - offset: const Offset(0, 0), blurRadius: 10.0) ], gradient: const LinearGradient( diff --git a/easel/lib/widgets/video_widget.dart b/easel/lib/widgets/video_widget.dart index ae48813140..102e8a1c7a 100644 --- a/easel/lib/widgets/video_widget.dart +++ b/easel/lib/widgets/video_widget.dart @@ -143,9 +143,7 @@ class VideoWidgetState extends State { child: SingleChildScrollView( child: Column( children: [ - shouldShowThumbnailButton() - ? VerticalSpace(80.h) - : const SizedBox(), + if (shouldShowThumbnailButton()) VerticalSpace(80.h) else const SizedBox(), if (!shouldShowThumbnailButton()) ...[ VideoBuilder( onVideoLoading: (BuildContext context) => Center( @@ -226,9 +224,7 @@ class VideoWidgetState extends State { SizedBox( height: 10.w, ), - shouldShowThumbnailButton() - ? _buildThumbnailButton() - : const SizedBox(), + if (shouldShowThumbnailButton()) _buildThumbnailButton() else const SizedBox(), ], ), ), diff --git a/easel/lib/widgets/video_widget_full_screen.dart b/easel/lib/widgets/video_widget_full_screen.dart index a4a1798a9d..bc86947970 100644 --- a/easel/lib/widgets/video_widget_full_screen.dart +++ b/easel/lib/widgets/video_widget_full_screen.dart @@ -26,7 +26,7 @@ class _VideoWidgetFullScreenState extends State { final repository = GetIt.I.get(); @override - initState() { + void initState() { super.initState(); } @@ -72,7 +72,7 @@ class _VideoWidgetFullScreenState extends State { sigmaX: 5.0, sigmaY: 5.0, ), - child: Container( + child: ColoredBox( color: Colors.black.withOpacity(0.3), child: Padding( padding: EdgeInsets.only(bottom: 30.h), diff --git a/easel/pubspec.yaml b/easel/pubspec.yaml index bbd315a150..183a6f6441 100644 --- a/easel/pubspec.yaml +++ b/easel/pubspec.yaml @@ -82,9 +82,9 @@ dependencies: dev_dependencies: build_runner: ^2.3.0 floor_generator: ^1.3.0 - flutter_lints: ^2.0.1 flutter_test: sdk: flutter + lint: ^1.5.3 mockito: ^5.3.2 diff --git a/easel/test/mock/mock_repository.dart b/easel/test/mock/mock_repository.dart index 276bb0b325..58041bd492 100644 --- a/easel/test/mock/mock_repository.dart +++ b/easel/test/mock/mock_repository.dart @@ -2,11 +2,11 @@ import 'dart:io'; import 'package:dartz/dartz.dart'; import 'package:easel_flutter/easel_provider.dart'; -import 'package:easel_flutter/models/api_response.dart'; import 'package:easel_flutter/models/nft.dart'; import 'package:easel_flutter/models/nft_format.dart'; import 'package:easel_flutter/models/picked_file_model.dart'; import 'package:easel_flutter/models/save_nft.dart'; +import 'package:easel_flutter/models/storage_response_model.dart'; import 'package:easel_flutter/repository/repository.dart'; import 'package:easel_flutter/utils/failure/failure.dart'; import 'package:pylons_sdk/pylons_sdk.dart'; @@ -25,7 +25,7 @@ class MockRepositoryImp implements Repository { } @override - deleteCacheDynamic({required String key}) { + void deleteCacheDynamic({required String key}) { throw UnimplementedError(); } @@ -50,7 +50,7 @@ class MockRepositoryImp implements Repository { } @override - getCacheDynamicType({required String key}) { + NFT getCacheDynamicType({required String key}) { return MOCK_NFT; } @@ -136,7 +136,7 @@ class MockRepositoryImp implements Repository { } @override - bool setCacheDynamicType({required String key, required value}) { + bool setCacheDynamicType({required String key, required dynamic value}) { return true; } @@ -162,7 +162,7 @@ class MockRepositoryImp implements Repository { } @override - Future> uploadFile({required File file, required OnUploadProgressCallback onUploadProgressCallback}) { + Future> uploadFile({required File file, required OnUploadProgressCallback onUploadProgressCallback}) { throw UnimplementedError(); } diff --git a/easel/test/mocks/mock_constants.dart b/easel/test/mocks/mock_constants.dart index b96fb4011e..1478475987 100644 --- a/easel/test/mocks/mock_constants.dart +++ b/easel/test/mocks/mock_constants.dart @@ -45,4 +45,4 @@ NFT MOCK_PRICED_NFT = NFT( ); -CollectionType MOCK_COLLECTION_TYPE = CollectionType.draft; \ No newline at end of file +CollectionType MOCK_COLLECTION_TYPE = CollectionType.draft; diff --git a/easel/test/models/denom_test.dart b/easel/test/models/denom_test.dart index d3c297f8ae..18f88245cb 100644 --- a/easel/test/models/denom_test.dart +++ b/easel/test/models/denom_test.dart @@ -4,7 +4,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { test('should have all the available denoms', () { - for (Denom denom in Denom.availableDenoms) { + for (final Denom denom in Denom.availableDenoms) { if (denom.name == "Pylon") { expect(denom.symbol, kPylonSymbol); } diff --git a/wallet/analysis_options.yaml b/wallet/analysis_options.yaml index 5922222a10..a8469a9d98 100644 --- a/wallet/analysis_options.yaml +++ b/wallet/analysis_options.yaml @@ -30,7 +30,7 @@ analyzer: always_declare_return_types: error override_on_non_overriding_member: error annotate_overrides: error -# avoid_relative_lib_imports: error + avoid_relative_lib_imports: error avoid_empty_else: error avoid_returning_null_for_future: error empty_statements: error @@ -55,8 +55,8 @@ analyzer: linter: rules: -# - annotate_overrides -# - await_only_futures + - annotate_overrides + - await_only_futures # - camel_case_types # - cancel_subscriptions # - close_sinks @@ -65,7 +65,7 @@ linter: # - empty_statements # - always_declare_return_types # - avoid_empty_else -## - avoid_relative_lib_imports + - avoid_relative_lib_imports # - avoid_returning_null_for_future # - always_put_control_body_on_new_line # - always_require_non_null_named_parameters diff --git a/wallet/pubspec.yaml b/wallet/pubspec.yaml index 91651a1d71..54a0402ca9 100644 --- a/wallet/pubspec.yaml +++ b/wallet/pubspec.yaml @@ -103,7 +103,6 @@ dev_dependencies: flutter_test: sdk: flutter lint: ^1.5.3 - lints: ^2.0.0 mockito: ^5.3.2