core_utils 1.0.5 copy "core_utils: ^1.0.5" to clipboard
core_utils: ^1.0.5 copied to clipboard

A package that contains common utilities needed in Flutter projects.

analytics

A package containing helpful utility functions and widgets for Flutter projects. #

-> Submit an issue here. -> Create a pull request here. -> Contact me via email here.

  • Responsive widget that rebuilds for mobile, tablet, and desktop views.
    • ResponsiveView(mobile: YOUR_WIDGET, tablet: YOUR_WIDGET, desktop: YOUR_WIDGET)
  • Shorthands for MediaQuery.of(context).size.HEIGHT/WIDTH * SOME_FRACTION
    • heightFrac(context, SOME_FRACTION)
    • widthFrac(context, SOME_FRACTION)
  • Number formatting.
    • largeNumberFormatter(int number) -> Example: 1812212 to "1.8m"
    • numberPostfix(int number) -> Example: 4 to "th", or 3 to "rd"
  • And much more, just scroll down for the list of functions/widgets!

Example Gif 📸 #

Functions: Numbers 📜 #

Checks if the integer passed is plural. #

bool isPlural(int number);

Example: 13 -> true

Converts large numbers into smaller representations with letters. #

String largeNumberFormatter(
int  number, {
String  billionLetter  =  "b",
String  millionLetter  =  "m",
String  thousandLetter  =  "k",
});

Example: 1,812,398 -> "1.8m"

Adds a postfix to numbers. #

String numberPostfix(int number);

Example: 4 -> "4th"

Functions: Sizing 📜 #

Height fraction of screen, up to a set point. #

double heightBreakpointFrac(Buildcontext context, double fraction, double lockPoint);

Example: If you set fraction as 1/4, then this will return 1/4 * screen height up to the point that you set as lockPoint.

Width fraction of screen, up to a set point. #

double widthBreakpointFrac(Buildcontext context, double fraction, double lockPoint);

Example: If you set fraction as 1/4, then this will return 1/4 * screen width up to the point that you set as lockPoint.

Height fraction of screen. #

double  heightFrac(BuildContext  context, double  fraction);

Example: If you set fraction as 1/5, then it will return 1/5 * screen height.

Width fraction of screen. #

double  widthFrac(BuildContext  context, double  fraction);

Example: If you set fraction as 1/5, then it will return 1/5 * screen width.

Height excluding top or bottom safe area. #

double  heightWithoutSafeArea(BuildContext  context,{bool  withoutTopSafeArea  =  true, bool  withoutBottomSafeArea  =  true});

Example: Will return the height of the screen excluding either the top or bottom safe area heights.

Number until limit. #

double  numberUntilLimit(double number, double limit);

Example: If number is the screen width and limit is 200, then this will return the screen width until limit is reached, then it will just return 200.

Functions: Types 📜 #

Checks if value is null. #

bool  isNull(dynamic value);

Example: If null is passed, this will return true. Otherwise, it would return false.

Checks if value is not null. #

bool  notNull(dynamic value);

Example: If "14" is passed, this will return true.

Functions: Validators 📜 #

Passed String is empty checker. #

bool emptyValidator(String value);

Example: If " " is passed, then it will return false.

Passed list of Strings is empty checker. #

bool  multipleEmptyValidator(List<String> values);

Example: If ["test1", "test2", " "] is passed, then it will return false;

Widgets: Sizing 📜 #

Mobile, Tablet, and Desktop view builder. #

ResponsiveView(
	 mobile: Scaffold(...),
	 tablet: Scaffold(...),
	 desktop: Scaffold(...),
);

Example: Builds out 3 different views based on screen width breakpoints. Breakpoint values can be customized.

SizedBox same height as bottom safe area. #

SimulatedBottomSafeArea(
	 heightMultiplier: 2,
);

Example: Returns a SizedBox with the height of the bottom safe area * heightMultiplier. Useful for lists where you desire them to be scrolled without being wrapped with a SafeArea, but don't want the last list item to be obscured by it. Usually, placed at the end of a long list of widgets.

Additional Info 📣 #

  • The package is always open to improvements, suggestions, and additions!

  • I'll deal with PRs and issues as soon as I can!

8
likes
140
pub points
37%
popularity

Publisher

verified publishermatthewtrent.me

A package that contains common utilities needed in Flutter projects.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on core_utils