s_extensions 1.10.0
s_extensions: ^1.10.0 copied to clipboard
A dart package aiming to provide useful extensions and helper functions to ease and speed up development.
1.10.0 #
Added #
NumberExtensions #
fixed000returns a string representation of this number with 3 decimal places.isOddreturnstrueif this number is a odd number.weekreturns the duration of weeks in this number.monthreturns the duration of months in this number.yearreturns the duration of years in this number.isNegativereturnstrueif this number is a negative number.isPositivereturnstrueif this number is a positive number.isZeroreturnstrueif this number is a zero number.isDoublereturnstrueif this number is a double number.isIntreturnstrueif this number is an integer number.
1.9.0 #
Added #
BuildContextExtensions #
appInforeturns the app info.packageInforeturns the package info.popAndPushNamedpop the current route off the navigator stack and push a new route.pushNamedAndRemoveUntilpush a named route and remove until a route is found.popAndPushNamedpop the current route off the navigator stack and push a new route.
1.8.0 #
Added #
BoolExtensions #
folddo some logic according to the state of this bool.lazyFolddo some async logic according to the state of this bool.
BuildContextExtensions #
pushReplacementpush and replace the current route with a new widget.pushReplacementNamedpush and replace the current route with a new named route.
NumberExtensions #
wget the dynamic width based on screen size provided, used in responsive UI.hget the dynamic height based on screen size provided, used in responive UI.
ObjectExtensions #
isNullreturns true if the object is null.isNotNullreturn true if the object is not null.
StringExtensions #
isNotBlankreturns true if the string is not empty in any chance.
WidgetExtensions #
safeAreawrap current widget with SafeArea.
Changes and Migrations #
BuildContextExtensions #
pushNamedArgsremoved as thepushNameddo the same work now.
StringExtensions #
matchesis now acceptsr'String'directly without the need forRegExp(r'String').
🔧 Static Context Manager #
From 1.8.0 on.. there is no need for calling FlutterSExtensions.update(context) in MaterialApp.builder``FlutterSExtensions. but it's still can be called in tests.
You can now wrap your app with SExtensionsScreenUtil for better dynamic scaling and responsive UI usage:
SExtensionsScreenUtil(
screenSize: const Size(390.0, 844.0), // screen size from design (e.g., Figma, ...)
app: MaterialApp(
home: const MyHomePage(),
),
);
1.7.0 #
Added #
BuildContextExtensions #
deviceInforeturns the device info.androidInforeturns the android device info.iosInforeturns the ios device info.macOsInforeturns the macos device info.windowsInforeturns the windows device info.linuxInforeturns the linux device info.webBrowserInforeturns the web browser info.
1.6.0 #
Added #
WidgetExtensions #
paddingreturns a new widget with the given padding for all attributes.marginreturns a new widget with the given margin for all attributes.positionedreturns a new widget with the given position.positionedDirectionalreturns a new widget with the given position.roundedRightreturns a new widget with the given radius for the right side.roundedLeftreturns a new widget with the given radius for the left side.cardwrap current widget with card.heromake a hero widget with the given tag.tooltipreturns a new widget with the given tooltip.intrinsicHeightreturns a new widget with the given height.intrinsicWidthreturns a new widget with the given width.onTapreturns a new widget with the given tap callback.onDoubleTapreturns a new widget with the given double tap callback.onLongPressreturns a new widget with the given long press callback.onTouchreturns a new widget with the given touch callback.inkreturns a new widget with the given ink splash radius.
1.5.0 #
Added #
BuildContextExtensions #
argumentsreturns the arguments passed to the current route.canPopreturns true if the navigator can pop.isAnimationsDisabledreturns true if system's animations are disabled by the user.longestSidereturns the longest screen dimension.shortestSidereturns the shortest screen dimension.pushNamedArgspushes a new page with MaterialPageRoute and the given arguments.
StringExtensions #
isUUIDreturnstrueif this string is a valid UUID v4 format.containsAnyreturnstrueif this string contains any of the given [values].containsAllreturnstrueif this string contains all the given [values].matchreturnstrueif this string matches the given [pattern].
Changed #
isScreenSmallchanged toisSmallScreento match the new naming convention.
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).
