Utility

DateTime extension

Convert DateTime object to formatted String. Usage

import 'core/utils/datetime_extension.dart'

final dateTime = DateTime.now();
final formattedDate = dateTime.dateFormat('dd-MM-yyyy');
print(formattedDate); // 30-09-2022

List of common Datetime pattern. For example if DateTime.now() = 30 Sep 2022 15:19:20

Pattern
Outputs

yyyy

2022

MM

09

dd

30

HH

15

mm

19

ss

20

MMM

Sep

EEE

Fri

dd-MM-yyyy

30-09-2022

dd MMM yyyy

30 Sep 2022

EEE, dd MMM yyyy

Fri, 30 Sep 2022

You can browse the full pattern list from herearrow-up-right

Int to IDR formatter

Usage :

Json Custom Parser

JsonSerializable is not able to convert data when the type is not match. Like example when we try to parse this data

and we have data model like this

It will crash on runtime because the json data of price is string, not int. So we will use custom parser that we implements from JsonConverter class and add that custom parser to Product class

Use this class as annotation in your models. Example :

Here is list of available custom parser :

- JsonStringToInt

Parse potential nullable string to int, without this it will crash whenever we try to parse data like this {"price":"10000"}. When failed to parse data then it will return 0

- JsonStringToIntNullable

Same as JsonStringToInt but it will return null instead of 0 when parse failed

- JsonStringToDouble

Parse potential nullable string to double. Return 0 if data is null

- JsonStringToDoubleNullable

Same as JsonStringToDoubleNullable but it will return null instead of 0 when parse failed

- JsonIntToBool

Parse 1 as true and 0 as false

Media Service

Use this class to pick image from camera or gallery. Example usage :

Bloc Transformer

This starter is already include bloc_concurrencyarrow-up-right library that consist of 4 default transformer :

  • concurrent : process event concurrently

  • sequential : process event sequentially

  • droppable : ignore any event added while an event is processing

  • restartable : process only latest event and cancel previous event handler

Bonus :

  • debounceSequential : delay process of any event. Usefull to delay user input like search feature

Example usage :

Let Callback

Execute callback when value is not null. Usefull checking null value. Example usage :

Password Strength

Find the password strength of given String.

  • PasswordStrength.weak : <8 character

  • PasswordStrength.medium : >= 8 character with number

  • PasswordStrength.strong : >= 8 character with number and uppercase letter

  • PasswordStrength.veryStrong : >= 8 character with number, uppercase, and special symbol

Example usage :

Self Sign Cert

Bypass network error when there is invalid https certificate. Use this for debugging purpose only because it can risk our user to MITM attack, for example when we need to debug or intercept http request with third party tools like burpsuite or postman. Example usage :

Email Validator

Check if email is valid. Example usage

Remove Html Tags

Remove all html tags. Example usage

Asset Icon to Google Maps Marker Converter

Use this extension to convert existing marker icon assets (ex: assets/images/marker.png) to Uint8List. Usefull to convert asset icon to marker bitmap.

Notification Service

Usage :

  1. Initialize service.

  1. Show notification

To replace default notification icon

  • android : app/src/main/res/mipmap*/ic_launcher.png

  • ios : coming soon

Last updated