commons library

Classes

AddressCheckOptions
This class should be pretty self-explanatory. If AddressCheckOptions.port or AddressCheckOptions.timeout are not specified, they both default to DataConnectionChecker.DEFAULT_PORT and DataConnectionChecker.DEFAULT_TIMEOUT Also... yeah, I'm not great at naming things.
AddressCheckResult
Helper class that contains the address options and indicates whether opening a socket to it succeeded.
AndroidBuildVersion
Version values of the current Android operating system build derived from android.os.Build.VERSION.
AndroidDeviceInfo
Information derived from android.os.Build.
BaseAnimationBuilder
BaseClient
The abstract base class for an HTTP client.
BaseRequest
The base class for HTTP requests.
BaseResponse
The base class for HTTP responses.
Bidi
This provides utility methods for working with bidirectional text. All of the methods are static, and are organized into a class primarily to group them together for documentation and discoverability.
BidiFormatter
Bidi stands for Bi-directional text. According to Wikipedia: Bi-directional text is text containing text in both text directionalities, both right-to-left (RTL) and left-to-right (LTR). It generally involves text containing different types of alphabets, but may also refer to boustrophedon, which is changing text directionality in each row.
ByteStream
A stream of chunks of bytes representing a single piece of data.
Client
The interface for HTTP clients that take care of maintaining persistent connections across multiple requests to the same server.
CollectionScaleTransition
Adds a reversable and repetitive scale transition to each child.
CollectionSlideTransition
Adds a reversable and repetitive slide transition to each child.
ConnectionChecker
ConnectionChecker used for internet connection listener
Data
DataConnectionChecker
This is a singleton that can be accessed like a regular constructor i.e. DataConnectionChecker() always returns the same instance.
DateFormat
DateFormat is for formatting and parsing dates in a locale-sensitive manner.
DateFormats
DateTimeAPI
DeviceInfoPlugin
Provides device and operating system information.
EnglishLocale
FadingText
Adds fading effect on each character in the text provided to it.
GlowingProgressIndicator
Adds a glowing animation to its child widget.
HeartbeatProgressIndicator
Adds a heartbeat animation to its child widget.
Intl
The Intl class provides a common entry point for internationalization related tasks. An Intl instance can be created for a particular locale and used to create a date format via anIntl.date(). Static methods on this class are also used in message formatting.
IosDeviceInfo
Information derived from UIDevice.
IosUtsname
Information derived from utsname. See http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysutsname.h.html for details.
JumpingDotsProgressIndicator
Creates a list with numberOfDots text dots, with 3 dots as default default fontSize of 10.0, default color as black, dotSpacing (gap between each dot) as 0.0 and default time for one cycle of animation milliseconds as 250. One cycle of animation is one complete round of a dot animating up and back to its original position.
JumpingText
Adds jumping effect on each character in the text provided to it.
ListViewScreen<T>
Locale
MicroMoney
Used primarily for currency formatting, this number-like class stores millionths of a currency unit, typically as an Int64.
Miui10AnimBuilder
MultipartFile
A file to be uploaded as part of a MultipartRequest.
MultipartRequest
A multipart/form-data request.
NumberFormat
Provides the ability to format a number in a locale-specific way.
OffsetAnimationBuilder
OKToast
OpacityAnimationBuilder
Option
OptionsDialog
PackageInfo
Application metadata. Provides application bundle information on iOS and application package information on Android.
Patterns
Preferences
Prefs
Request
An HTTP request where the entire request body is known in advance.
Response
An HTTP response where the entire response body is known in advance.
ResponseCode
ScalingText
Adds jumping effect on each character in the text provided to it.
Share
Plugin for summoning a platform share sheet.
SharedPreferences
Wraps NSUserDefaults (on iOS) and SharedPreferences (on Android), providing a persistent store for simple data.
SimpleItem
StackTraceScreen
StreamedRequest
An HTTP request where the request body is sent asynchronously after the connection has been established and the headers have been sent.
StreamedResponse
An HTTP response where the response body is received asynchronously after the headers have been received.
TextDirection
Bidi stands for Bi-directional text. According to http://en.wikipedia.org/wiki/Bi-directional_text: Bi-directional text is text containing text in both text directionalities, both right-to-left (RTL) and left-to-right (LTR). It generally involves text containing different types of alphabets, but may also refer to boustrophedon, which is changing text directionality in each row.
TimeFormats
ToastFuture
use the dismiss to dismiss toast.
ToastPosition
Validator
WidgetViewScreen

Extensions

DateTimeExtension
datetime extension functions
DateTimeTimeExtension
DoubleExtension
double extension functions
DurationTimeExtension
IntExtension
int extension functions
Stateful, Stateless widgets extension function of push, pop, replaceWith
NumTimeExtension
StringExtensions
String extension functions
TextEditingControllerExtension
TextEditingController extension functions

Constants

am → const String
Outputs if hour is AM or PM
'am'
d → const String
Outputs day compactly
'd'
D → const String
Outputs week day as long name
'D'
dd → const String
Outputs day as two digits
'dd'
DD → const String
Outputs week day as long name
'DD'
escape → const String
Escape delimiters to be used as normal string.
'\\'
h → const String
Outputs hour (0 - 11) compactly
'h'
H → const String
Outputs hour (0 to 23) compactly
'H'
hh → const String
Outputs hour (0 - 11) as two digits
'hh'
HH → const String
Outputs hour (0 to 23) as two digits
'HH'
m → const String
Outputs month compactly
'm'
M → const String
Outputs month as short name
'M'
mm → const String
Outputs month as two digits
'mm'
MM → const String
Outputs month as long name
'MM'
n → const String
Outputs minute compactly
'n'
nn → const String
Outputs minute as two digits
'nn'
s → const String
Outputs second compactly
's'
S → const String
Outputs millisecond compactly
'S'
ss → const String
Outputs second as two digits
'ss'
SSS → const String
Outputs millisecond as three digits
'SSS'
u → const String
Outputs millisecond compactly
'u'
uuu → const String
Outputs microsecond as three digits
'uuu'
w → const String
Outputs week in month
'w'
W → const String
Outputs week in year compactly
'W'
WW → const String
Outputs week in year as two digits
'WW'
yy → const String
Outputs year as two digits
'yy'
yyyy → const String
Outputs year as four digits
'yyyy'
z → const String
Outputs timezone as time offset
'z'
Z → const String
'Z'

Functions

acceptJsonTypeJson() → dynamic
acceptJsonTypeJsonWithAuth(String authKey) → dynamic
acceptJsonTypeXForm() → dynamic
acceptJsonTypeXFormWithAuth(String authKey) → dynamic
acceptJsonWithAuth(String authKey) → dynamic
canLaunch(String urlString) Future<bool>
Checks whether the specified URL can be handled by some app installed on the device.
checkInternet({dynamic lookupAddress = "google.com"}) Future<bool>
Instant check internet connection by providing the lookup address default is google.com
closeWebView() Future<void>
Closes the current WebView, if one was previously opened via a call to launch.
confirmationDialog(BuildContext context, String message, {dynamic showNeutralButton = true, String positiveText, Function positiveAction, String negativeText, Function negativeAction, String neutralText = "Cancel", Function neutralAction, dynamic title = "Confirmation?", dynamic closeOnBackPress = false, dynamic icon = AlertDialogIcon.HELP_ICON, dynamic confirm = true, dynamic textAlign = TextAlign.center, dynamic confirmationText = "Check this box for confirmation!"}) → dynamic
Confirmation Dialog
dayInYear(DateTime date) int
delay(Duration duration, Function fun) → dynamic
future delay
delete(dynamic url, {Map<String, String> headers}) Future<Response>
Sends an HTTP DELETE request with the given headers to the given URL, which can be a Uri or a String.
dialog(BuildContext context, Color color, String title, String message, bool showNeutralButton, bool closeOnBackPress, {String neutralText, Function neutralAction, String positiveText, Function positiveAction, String negativeText, Function negativeAction, AlertDialogIcon icon, dynamic confirm = false, dynamic textAlign = TextAlign.center, Widget customIcon, String confirmationText}) → dynamic
Generic dialog function
dismissAllToast({bool showAnim = false}) → void
use the method to dismiss all toast.
encodingUTF8() → dynamic
errorDialog(BuildContext context, String message, {dynamic showNeutralButton = true, String positiveText, Function positiveAction, String negativeText, Function negativeAction, String neutralText = "Okay", Function neutralAction, dynamic title = "Error", dynamic closeOnBackPress = false, dynamic icon = AlertDialogIcon.ERROR_ICON, dynamic textAlign = TextAlign.center}) → dynamic
Error Dialog
errorToast(String message) → dynamic
formatDate(DateTime date, List<String> formats, {Locale locale = const EnglishLocale()}) String
get(dynamic url, {Map<String, String> headers}) Future<Response>
Sends an HTTP GET request with the given headers to the given URL, which can be a Uri or a String.
getDeviceInfo() Future<String>
device info function
getPackageInfo() Future<String>
package info function
getRequest(String url, Map header, {Map<String, String> body, dynamic log = true}) Future<Response>
Sends an HTTP HEAD request with the given headers to the given URL, which can be a Uri or a String.
highlightSubTitleTextWidget(BuildContext context, String string, String word, {TextStyle stringStyle, TextStyle wordStyle}) Widget
highlight sub title text
highlightTitleTextWidget(BuildContext context, String string, String word, {TextStyle stringStyle, bool boldTitle = true, TextStyle wordStyle}) Widget
highlight title textfun
infoDialog(BuildContext context, String message, {dynamic showNeutralButton = true, String positiveText, Function positiveAction, String negativeText, Function negativeAction, String neutralText = "Okay", Function neutralAction, dynamic title = "Info", dynamic closeOnBackPress = false, dynamic icon = AlertDialogIcon.INFO_ICON, dynamic textAlign = TextAlign.center}) → dynamic
Info Dialog
infoToast(String message) → dynamic
launch(String urlString, {bool forceSafariVC, bool forceWebView, bool enableJavaScript, bool enableDomStorage, bool universalLinksOnly, Map<String, String> headers, Brightness statusBarBrightness, String webOnlyWindowName}) Future<bool>
Parses the specified URL string and delegates handling of it to the underlying platform.
loadingScreen(BuildContext context, {dynamic message = "Loading", dynamic closeOnBackPres = false, Duration duration, dynamic loadingType = LoadingType.SCALING}) Widget
multiSelectDialog<T extends Data>(BuildContext context, String title, Set<T> dataList, Set<T> selectedItems, Function onSubmit, {dynamic autoClose = true, dynamic searchable = true}) → dynamic
mustPop<T extends Object>(BuildContext context, [T result]) → dynamic
optionsDialog(BuildContext context, String title, List<Option> options, {dynamic autoClose = true}) → dynamic
ordinalDayFromMarchFirst(int month, int day) int
Return the day of the year counting March 1st as 1, after which the number of days per month is constant, so it's easier to calculate. Formula from http://en.wikipedia.org/wiki/Ordinal_date
patch(dynamic url, {Map<String, String> headers, dynamic body, Encoding encoding}) Future<Response>
Sends an HTTP PATCH request with the given headers and body to the given URL, which can be a Uri or a String.
pop<T extends Object>(BuildContext context, [T result]) → dynamic
Navigator pop function
post(dynamic url, {Map<String, String> headers, dynamic body, Encoding encoding}) Future<Response>
Sends an HTTP POST request with the given headers and body to the given URL, which can be a Uri or a String.
postJsonRequest(String url, Map header, Map body, {dynamic log = true}) Future<Response>
postRequest(String url, Map header, {Map body, dynamic log = true}) Future<Response>
push<T extends Object>(BuildContext context, Widget route) Future<T>
Navigator push function
put(dynamic url, {Map<String, String> headers, dynamic body, Encoding encoding}) Future<Response>
Sends an HTTP PUT request with the given headers and body to the given URL, which can be a Uri or a String.
radioListDialog<T extends Data>(BuildContext context, String title, Set<T> dataSet, dynamic onSubmit(T), {Data selectedItem, dynamic autoClose = true}) → dynamic
read(dynamic url, {Map<String, String> headers}) Future<String>
Sends an HTTP GET request with the given headers to the given URL, which can be a Uri or a String, and returns a Future that completes to the body of the response as a String.
readBytes(dynamic url, {Map<String, String> headers}) Future<Uint8List>
Sends an HTTP GET request with the given headers to the given URL, which can be a Uri or a String, and returns a Future that completes to the body of the response as a list of bytes.
replaceWith<T extends Object>(BuildContext context, Widget route) Future<T>
Navigator push replacement function
request(BuildContext context, State<StatefulWidget> state, RequestMethod requestMethod, String url, Map headers, {Map prams, bool dialog = false, bool log = true, bool showErrorDialogs = true}) Future<Response>
selectAllOnFocus(TextEditingController controller, FocusNode node) → dynamic
select all text on focus
showToast(String msg, {BuildContext context, Duration duration, ToastPosition position, TextStyle textStyle, EdgeInsetsGeometry textPadding, Color backgroundColor, double radius, VoidCallback onDismiss, TextDirection textDirection, bool dismissOtherToast, TextAlign textAlign, OKToastAnimationBuilder animationBuilder, Duration animationDuration, Curve animationCurve}) ToastFuture
show toast with msg,
showToastWidget(Widget widget, {BuildContext context, Duration duration, ToastPosition position, VoidCallback onDismiss, bool dismissOtherToast, TextDirection textDirection, bool handleTouch, OKToastAnimationBuilder animationBuilder, Duration animationDuration, Curve animationCurve}) ToastFuture
show widget with oktoast
singleInputDialog(BuildContext context, {String title = "Input", String label = "Input Field", String value = "", String positiveText = "Submit", dynamic positiveAction(String), String negativeText = "Clear", Function negativeAction, String neutralText = "Close", Function neutralAction, TextInputType keyboardType = TextInputType.text, bool autoClose = true, bool obscure = false, int minLines, int maxLines, String validator(String)}) → dynamic
Single Input Dialog function
singleSelectDialog<T extends Data>(BuildContext context, String title, Set<T> dataList, dynamic onItemSelected(T), {dynamic autoClose = true, dynamic searchable = true}) → dynamic
successDialog(BuildContext context, String message, {dynamic showNeutralButton = true, String positiveText, Function positiveAction, String negativeText, Function negativeAction, String neutralText = "Okay", Function neutralAction, dynamic title = "Success", dynamic closeOnBackPress = true, dynamic icon = AlertDialogIcon.SUCCESS_ICON, dynamic textAlign = TextAlign.center}) → dynamic
Success dialog
successToast(String message) → dynamic
toast(String message, {dynamic position = ToastPosition.bottom, Color backgroundColor, dynamic textColor = Colors.black, dynamic fontSize = 16.0, Duration duration}) → dynamic
toBeginningOfSentenceCase(String input, [String locale]) String
Convert a string to beginning of sentence case, in a way appropriate to the locale.
tryCatch(BuildContext context, State<StatefulWidget> state, Function action) → dynamic
try catch with error dialog function
waitDialog(BuildContext context, {dynamic message = "Please wait...", Duration duration}) → dynamic
Waiting Dialog
warningDialog(BuildContext context, String message, {dynamic showNeutralButton = true, String positiveText, Function positiveAction, String negativeText, Function negativeAction, String neutralText = "Okay", Function neutralAction, dynamic title = "Warning", dynamic closeOnBackPress = false, dynamic icon = AlertDialogIcon.WARNING_ICON, dynamic textAlign = TextAlign.center}) → dynamic
Warning Dialog
warningToast(String message) → dynamic

Enums

AlertDialogIcon
DataConnectionStatus
Represents the status of the data connection. Returned by DataConnectionChecker.connectionStatus
LoadingType
RequestMethod

Typedefs

OKToastAnimationBuilder = Widget Function(BuildContext context, Widget child, AnimationController controller, double percent)

Exceptions / Errors

ClientException
An exception caused by an error in a pkg/http client.