flutter_ahlib_util library

Classes

ActionController
A controller which is used to store and invoke action callbacks. This controller can be used to implement point-to-point communication across widgets. If you want to use publish/subscribe pattern, or said event bus, please use https://pub.dev/packages/event_bus.
DownloadOption
A data class for downloadFile, which is used to describe some downloading options.
Err<T extends Object, E extends Object>
A type that represent a err TaskResult.
ExtendedLogger
This Logger is extended from https://github.com/leisim/logger, which contains some new instance method, such as changePrinter and addOutputListener.
Ok<T extends Object, E extends Object>
A type that represent a ok TaskResult.
PreferredPrinter
This is an implementation of LogPrinter, which is preferred by AoiHosizora :)
TaskResult<T extends Object, E extends Object>
A type that represents either ok/success or err/failure result, and is referred from rust's std::Result enum.
Tuple1<T>
Represents a 1-tuple, which can be used to wrap simple type as referable type.
Tuple2<T1, T2>
Represents a 2-tuple, or pair.
Tuple3<T1, T2, T3>
Represents a 3-tuple, or triple.
Tuple4<T1, T2, T3, T4>
Represents a 4-tuple, or quadruple.
Tuple5<T1, T2, T3, T4, T5>
Represents a 5-tuple, or quintuple.
Tuple6<T1, T2, T3, T4, T5, T6>
Represents a 6-tuple, or sextuple.

Enums

DownloadBehavior
An enum type for DownloadOption, which is used to describe how to download.
DownloadConflictBehavior
An enum type for DownloadOption, which is used to describe how to handle when the given filepath has already existed.
DownloadErrorType
An enum type for DownloadException, which is used to describe the exception type when downloading.

Extensions

BoolExtension on bool
An extension for bool.
BuildContextExtension on BuildContext
An extension for BuildContext.
ColorExtension on Color
An extension for Color.
FutureExtension on Future<T?>
An extension for Future.
IterableExtension on Iterable<T>
An extension for Iterable.
ListExtension on List<T>
An extension for List.
ObjectExtension on T
An extension for any non-null values.
PageControllerExtension on PageController
An extension for PageController.
RenderObjectExtension on RenderObject
An extension for RenderObject.
ScrollControllerExtension on ScrollController
An extension for ScrollController.
ScrollMetricsExtension on ScrollMetrics
An extension for ScrollMetrics.
StateExtension on State<T>
An extension for State.
TaskResultFutureExtension on Future<TaskResult<T, E>>
An extension of Future<TaskResult> type, which has the same methods as TaskResult.
TextSpanExtension on TextSpan
An extension for TextSpan.

Constants

kAlertDialogDefaultButtonPadding → const EdgeInsets
Defined in src/material/dialog.dart, used by AlertDialog.
kAlertDialogDefaultContentPadding → const EdgeInsets
Defined in src/material/dialog.dart, used by AlertDialog.
kAlertDialogDefaultTitlePadding → const EdgeInsets
Defined in src/material/dialog.dart, used by AlertDialog.
kAppBarDefaultElevation → const double
Defined in src/material/app_bar.dart, used by AppBar.
kAppBarDefaultShadowColor → const Color
Defined in src/material/app_bar.dart, used by AppBar.
kAppBarLeadingWidth → const double
Defined in src/material/app_bar.dart, used by AppBar.
kBottomAppBarDefaultElevation → const double
Defined in src/material/bottom_app_bar.dart, used by BottomAppBar.
kBottomSheetEnterDuration → const Duration
Defined in src/material/bottom_sheet.dart, used by BottomSheet.
kBottomSheetExitDuration → const Duration
Defined in src/material/bottom_sheet.dart, used by BottomSheet.
kCardDefaultElevation → const double
Defined in src/material/card.dart, used by Card.
kCupertinoTransitionDuration → const Duration
Defined in src/cupertino/route.dart, used by CupertinoRouteTransitionMixin.
kDialogDefaultElevation → const double
Defined in src/material/dialog.dart, used by Dialog.
kDialogDefaultInsetPadding → const EdgeInsets
Defined in src/material/dialog.dart, used by Dialog.
kDividerDefaultHeight → const double
Defined in src/material/divider.dart, used by Divider.
kDrawerBaseSettleDuration → const Duration
Defined in src/material/drawer.dart, used by Drawer.
kDrawerEdgeDragWidth → const double
Defined in src/material/drawer.dart, used by Drawer.
kDrawerHeaderHeight → const double
Defined in src/material/drawer_header.dart, used by DrawerHeader.
kDrawerHeaderPadding → const EdgeInsets
Defined in src/material/drawer_header.dart, used by DrawerHeader.
kDrawerWidth → const double
Defined in src/material/drawer.dart, used by Drawer.
kDropdownMenuDuration → const Duration
Defined in src/material/dropdown.dart, used by DropdownButton.
kDropdownMenuItemHeight → const double
Defined in src/material/dropdown.dart, used by DropdownButton.
kExpansionPanelExpandDuration → const Duration
Defined in src/material/expansion_panel.dart, used by ExpansionPanel.
kExpansionPanelHeaderCollapsedHeight → const double
Defined in src/material/expansion_panel.dart, used by ExpansionPanel.
kInputDecorationTransitionDuration → const Duration
Defined in src/material/input_decoration.dart, used by InputDecoration.
kMaterialBannerTransitionDuration → const Duration
Defined in src/material/banner.dart, used by MaterialBanner.
kMaterialDialogTransitionDuration → const Duration
Defined in src/material/dialog.dart, used by Dialog.
kMaterialTransitionDuration → const Duration
Defined in src/material/page.dart, used by MaterialRouteTransitionMixin.
kPopupMenuDuration → const Duration
Defined in src/material/popup_menu.dart, used by PopupMenuButton.
kScrollbarFadeDuration → const Duration
Defined in src/material/srollbar.dart, used by Scrollbar.
kScrollbarTimeToFade → const Duration
Defined in src/material/srollbar.dart, used by Scrollbar.
kSimpleDialogDefaultContentPadding → const EdgeInsets
Defined in src/material/dialog.dart, used by SimpleDialog.
kSimpleDialogDefaultOptionPadding → const EdgeInsets
Defined in src/material/dialog.dart, used by SimpleDialog.
kSimpleDialogDefaultTitlePadding → const EdgeInsets
Defined in src/material/dialog.dart, used by SimpleDialog.
kSnackBarDisplayDuration → const Duration
Defined in src/material/snack_bar.dart, used by SnackBar.
kSnackBarTransitionDuration → const Duration
Defined in src/material/snack_bar.dart, used by SnackBar.
kSwitchHeight → const double
Defined in src/material/switch.dart, used by Switch.
kSwitchHeightCollapsed → const double
Defined in src/material/switch.dart, used by Switch.
kSwitchThumbRadius → const double
Defined in src/material/switch.dart, used by Switch.
kSwitchTrackHeight → const double
Defined in src/material/switch.dart, used by Switch.
kSwitchTrackWidth → const double
Defined in src/material/switch.dart, used by Switch.
kSwitchWidth → const double
Defined in src/material/switch.dart, used by Switch.
kTabDefaultIndicatorWeight → const double
Defined in src/material/tabs.dart, used by TabBar.
kTabHeight → const double
Defined in src/material/tabs.dart, used by TabBar.
kTextAndIconTabHeight → const double
Defined in src/material/tabs.dart, used by TabBar.
kTextSelectionHandleSize → const double
Defined in src/material/text_selection.dart, used by TextSelection.
kTextSelectionToolbarContentDistance → const double
Defined in src/material/text_selection.dart, used by TextSelection.
kTextSelectionToolbarContentDistanceBelow → const double
Defined in src/material/text_selection.dart, used by TextSelection.
kTextSelectionToolbarHeight → const double
Defined in src/material/text_selection_toolbar.dart, used by TextSelectionToolbar.
kTextSelectionToolbarScreenPadding → const double
Defined in src/material/text_selection_toolbar.dart, used by TextSelectionToolbar.
kTooltipDefaultShowDuration → const Duration
Defined in src/material/tooltip.dart, used by Tooltip.
kTooltipDefaultVerticalOffset → const double
Defined in src/material/tooltip.dart, used by Tooltip.
kTooltipFadeInDuration → const Duration
Defined in src/material/tooltip.dart, used by Tooltip.
kTooltipFadeOutDuration → const Duration
Defined in src/material/tooltip.dart, used by Tooltip.

Properties

globalLogger ExtendedLogger
The global ExtendedLogger for assistant, which defaults the default ExtendedLogger. You can replace this value to your own logger.
getter/setter pair

Functions

ansiEscapeCodeToPlainText(String s) String
Parses given text which contains ANSI escape code to plain text.
callAll(List<void Function()> functions) → void
Calls given all functions, this function can be used to avoid introducing braces and makes code more compact.
downloadFile({required String url, required String filepath, Map<String, String>? headers, BaseCacheManager? cacheManager, String? cacheKey, DownloadOption? option}) Future<File>
Downloads file from url with headers and saves to filepath. Here cacheManager defaults to DefaultCacheManager(), and cacheKey defaults to url, and option defines detailed downloading option, such as downloading behaviors.
filesize(int bytes, [int round = 2, bool mustRound = false]) String
Returns a formatted string value (such as "2 MB" and "2.34 KB") of given byte size.
filesizeWithoutSpace(int bytes, [int round = 2, bool mustRound = false]) String
Returns a formatted string value (such as "2MB" and "2.34KB") of given byte size.
getExtensionsFromMime(String mime) List<String>?
Gets extension list from given MIME type. Note that this function returns null if given MIME type has no correspond extension.
getMimeFromExtension(String extension) String?
Gets MIME type from given extension. Note that this function returns null if given extension has no correspond MIME type.
getPreferredExtensionFromMime(String mime) String?
Gets preferred extension from given MIME type. Here for example, "jpg" is preferred in "jpg" and "jpeg", "html" is preferred in "htm" and "html". Note that this function returns null if given MIME type has no correspond extension.
resultFromAsyncFunc<T extends Object, E extends Object>(FutureOr<T> func()) Future<TaskResult<T, E>>
Returns a result by executing given async function and catching current type of exception.
resultFromFunc<T extends Object, E extends Object>(T func()) TaskResult<T, E>
Returns a result by executing given function and catching current type of exception.

Typedefs

Action<T> = T Function()
An action function used in ActionController.
FilepathConflictHandler = Future<DownloadConflictBehavior> Function(String filepath)
The signature for handling filepath conflict, used by DownloadOption and downloadFile.
FilepathSuffixBuilder = String Function(int index)
The signature for building filepath suffix, used by DownloadOption and downloadFile.
LogEventCallback = void Function(LogEvent event)
The signature for callbacks when LogPrinter.log is called, used by ExtendedLogger.
OutputEventCallback = void Function(OutputEvent event)
The signature for callbacks when OutputEvent is generated, used by ExtendedLogger.
RedecideFilepathHandler = String Function(Map<String, String>? header, String? contentType)
The signature for redeciding filepath for saving, used by DownloadOption and downloadFile.

Exceptions / Errors

DownloadException
An exception type only used by downloadFile, with type as its type and message as its message.