s_extensions 1.4.0
s_extensions: ^1.4.0 copied to clipboard
A dart package aiming to provide useful extensions and helper functions to ease and speed up development.
1.4.0 #
Added #
NumberExtensions #
areareturns the area of a circle with this number as radius.perimeterreturns the perimeter of a circle with this number as radius.spherereturns the surface area of a sphere with this number as radius.cubeVolumereturns the cube volume with this number as radius.toColorreturns the color value of this number.
1.3.0 #
Added #
StringExtensions #
isDigitreturnstrueif this string is digit only.isAlphareturnstrueif this string is alphabetic only.isAlphaNumericreturnstrueif this string is alphanumeric only.isJsonreturnstrueif this string is a valid JSON string.copyToClipboardcopies this string to the clipboard.toColorreturns the color value of this string.
ColorExtensions #
toHexreturns the hexadecimal string representation of this color.isDarkreturns true if this color is dark.isLightreturns true if this color is light.opacityreturns the color with the given opacity.brightnessreturns the color with the given brightness.oppositeColorreturns the opposite color of this color.
WidgetExtensions #
scaffoldreturns a new Scaffold widget with the given body.
Fixes #
StringExtensions #
isBlankwas going in loop when checking for blank string.
1.2.0 #
Added #
ListExtensions #
toSetreturns a set with all the unique elements in this list (removes duplicates).toCsvserializes this list to a CSV line(s).toStringListconverts each element to its toString().mostFrequentreturns the most frequent element(s) in this list.minimumreturns the minimum element in this list.maximumreturns the maximum element in this list.safeGetreturns the element at the given index or null if OOB.removeNullsremoves all null elements from this list.groupBygroups this list into a map of lists, where each key is the result of applying [key] to each element.containsAllreturns true if this list contains all the elements in [other].containsAnyreturns true if this list contains any of the elements in [other].differencereturns a new list with all the elements in this list that are not in [other].symmetricDifferencereturns a new list with all the elements in either this list or [other], but not both.wrapWithwraps each element with a widget builder.
1.1.0 #
Added #
BoolExtensions #
toIntreturns1if this boolean istrue, and0if this boolean isfalse.toOnOffreturns'on'if this boolean istrue, and'off'if this boolean isfalse.toYesNoreturns'yes'if this boolean istrue, and'no'if this boolean isfalse.toEnabledDisabledreturns'enabled'if this boolean istrue, and'disabled'if this boolean isfalse.whenTrueexecutes [action] if this boolean istrue.whenFalseexecutes [action] if this boolean isfalse.
BuildContextExtensions #
themegets the current ThemeData.textThemegets the current TextTheme.colorSchemegets the current ColorScheme.isRTLgets if the current directionality is right-to-left.isLTRgets if the current directionality is left-to-right.topPaddingreturns the top padding of the app bar.bottomPaddingreturns the bottom padding of the navigation bar.devicePixelRatiogets the device pixel ratio.isTabletgets if the device is tablet-sized (shortestSide ≥ 600).poppops the current route off the navigator stack.pushpushes a new page with MaterialPageRoute.pushNamedpushes a new page with MaterialPageRoute and the given name.brightnessgets the current brightness independent of the theme.isHighContrastgets if device accessibility high contrast is enabled.isScreenSmallgets if width < 360px (useful for responsive).widgetSizegets the size of the widget tied to this context.widgetPositiongets the global position of the widget.
1.0.1 #
Added #
MapExtensions #
mergeWithmerges two maps, applying a custom combine function when keys overlap.filterKeysreturns a new map containing only entries whose keys satisfy a predicate.filterValuesreturns a new map containing only entries whose values satisfy a predicate.excludeKeysreturns a new map containing entries whose keys are not in the [keys] list.excludeValuesreturns a new map containing entries whose values are not in the [values] list.pickKeysreturns a new map containing entries whose keys are in the [keys] list.pickValuesreturns a new map containing entries whose values are in the [values] list.mapKeystransforms all the keys in the map by applying a function, producing a new map.mapValuestransforms all the values in the map by applying a function, producing a new map.toQueryStringconverts the map into a URL query-string style representation (e.g. ?key1=value1&key2=value2).invertswaps keys and values (values must be unique).safeUpdateupdates the value of the key if it exists. Else, do nothing.ensureKeyensures that the map contains the [key]. If not, add it with the [value] to prevent null or overriding values.containsAllKeyschecks if it contains all required keys.containsAnyKeychecks if it contains any key from a list.
1.0.0 #
Fixes #
This is the first version of the package.
Version 1.0.0 includes a hotfix for the animations extensions for widgets.
This version includes all the extensions and utils from the previous versions.
0.0.9 #
Added #
DateTimeExtensions #
formatHrMin12formats the time in 12-hour format.formatHrMinSec12formats the time in 12-hour format with seconds.formatHrMin24formats the time in 24-hour format.formatHrMinSec24formats the time in 24-hour format with seconds.formatDaygets the full name of this day of this date.formatMonthgets the full name of this month of this date.
Changed #
DateTimeExtensions #
yyyyMMddchanged toformatYearMonthDayfor better readability.ddMMyyyychanged toformatDayMonthYearfor better readability.yyyyMMddHHmmsschanged toformatYearMonthDayHrMinSecfor better readability.yyyyMMddHHmmchanged toformatYearMonthDayHrMinfor better readability.
0.0.8 #
0.0.7 #
Added #
StringExtensions #
removeNumbersremoves all the numbers from theString.removeWhiteSpaceremoves all the white spaces from theString.
WidgetExtensions #
marginAllreturns a new widget with the given margin.marginSymmetricreturns a new widget with the given margin.marginOnlyreturns a new widget with the given margin.paddingAllreturns a new widget with the given padding.paddingSymmetricreturns a new widget with the given padding.paddingOnlyreturns a new widget with the given padding.expandedreturns a new expanded widget with the given flex.flexiblereturns a new flexible widget with the given flex.alignreturns a new aligned widget with the given alignment.centerreturns a new centered widget.directionalityreturns a new directed text widget with the given text direction.roundedreturns a new rounded widget with the given radius.roundedTopreturns a new rounded widget from top with the given radius.roundedBottomreturns a new rounded widget from bottom with the given radius.decorationreturns a new decorated widget with the given decoration.refreshablereturns a new refresh indicator widget.scrollablereturns a new scrollable widget with the given scroll physics.constrainedreturns a new constrained widget with the given width and height.widthreturns a new constrained widget with the given width.heightreturns a new constrained widget with the given height.gesturesreturns a new [GestureDetector] widget with the given gestures.
0.0.6 #
Added #
StringExtensions #
isPalindromereturnstrueif this string is a palindrome.truncatetruncates theStringwhen more thanlengthcharacters exist.
BuildContextExtensions #
isKeyboardVisiblereturnstrueif the keyboard is visible.keyboardHeightreturns the height of the keyboard.isLandscapereturnstrueif the device orientation is landscape.isPortraitreturnstrueif the device orientation is portrait.
0.0.5 #
0.0.4 #
Added #
DateTimeExtensions #
operator +ads this duration of time to this date and returns the result.operator -subtracts this duration of time from this date and returns the result.fromNowreturns the duration between this date and now.isPastreturnstrueif this date is in the past.isFuturereturnstrueif this date is in the future.isInPreviousMonthreturnstrueif this date is in the previous month.isInNextMonthreturnstrueif this date is in the next month.isInNextYearreturnstrueif this date is in the next year.isInPreviousYearreturnstrueif this date is in the previous year.isTodayreturnstrueif this date is today.isTomorrowreturnstrueif this date is tomorrow.isYesterdayreturnstrueif this date is yesterday.
0.0.3 #
Added #
StringExtensions #
reversereturns the reversed version of this string.wordsreturns a list of words in this string.parseJsonreturns a parsed json [map] of this string.isBlankreturnstrueif this string is a blank by any chance.
MapExtensions #
toJsonreturns a parsed json [string] of this map.
ListExtensions #
toJsonreturns a parsed json [string] of this list.operator +ads new [element] or [elements] to this list.[1, 2, 3] + 4; // [1, 2, 3, 4] [1, 2, 3] + [4, 5, 6]; // [1, 2, 3, 4, 5, 6]toStackreturns a stack widget with this list as children.toColumnreturns a column widget with this list as children.toRowreturns a row widget with this list as children.randomreturns a random element from this list.
NumberExtensions #
isBetweenreturnstrueif this number is between the provided [min] and [max] values.isDivisibleByreturnstrueif this number is divisible by the provided [divisor].isEvenreturnstrueif this number is a even number.
BoolExtensions #
togglereturnsfalseif this boolean istrue, andtrueif this boolean isfalse.
Changes #
StringExtensions #
firstLetterUpperCaseis deleted. Usecapitalizeinstead.toDatereturnsDateTime?to handle invalid formats.toDoublereturnsdouble?to handle invalid formats.toIntreturnsint?to handle invalid formats.
0.0.2 #
Added #
NumberExtensions: with format helperformat.DateTimeExtensions: with format helpersformat,yyyyMMdd,yyyyMMddHHmm,yyyyMMddHHmmss,HHmm.
0.0.0 #
Added #
NumExtensionswith numeric helpers:half,quarter,square,sqRoot.- Duration helpers:
misec,msec,sec,min,hr,day. screenWidthextension getter for responsive layouts via property access (e.g.,0.9.screenWidth).- Static initialization and context management with
FlutterSExtensionsto support property-based access without passingBuildContext. - Initialization verification (
isInitialized), explicit init (init), and hot-reload-safe updates (update).