common_utils 0.0.2 copy "common_utils: ^0.0.2" to clipboard
common_utils: ^0.0.2 copied to clipboard

outdated

Flutter common utils library. ScreenUtil, RegexUtil, ObjectUtil, WidgetUtil.

common_utils (Flutter common utils library) #

Pub

[common_utils] is a common tools library for Flutter. Contains ScreenUtil, RegexUtil, ObjectUtil, WidgetUtil.

Add dependency #

dependencies:
  common_utils: x.x.x  #latest version

APIs #

  • ScreenUtil

screenWidth
screenHeight
screenDensity
appBarHeight
statusBarHeight
  • WidgetUtil

asyncPrepare              : Widget rendering listener.
getWidgetBounds           : get Widget Bounds (width, height).
getWidgetLocalToGlobal    : Get the coordinates of the widget on the screen.
  • RegexUtil

isMobileSimple
isMobileExact
isTel
isIDCard
isIDCard15
isIDCard18
isEmail
isURL
isZh
isDate
isIP
  • ObjectUtil

isEmptyString             : String is empty.
isEmptyList               : List is empty.
isEmptyMap                : Map Map empty.
isEmpty                   : Object is empty.(String List Map).
isNotEmpty                : Object is not empty.(String List Map).
twoListIsEqual            : Two List Is Equal.

Example #


// Import package
import 'package:common_utils/common_utils.dart';

//First Page init. Notice!!!
ScreenUtil.getInstance().init(context);

ScreenUtil.screenWidth
ScreenUtil.screenHeight
ScreenUtil.statusBarHeight
ScreenUtil.screenDensity

List listA = ["A", "B", "C"];
List listB = ["A", "B", "C"];
print("Two List Is Equal: " + ObjectUtil.twoListIsEqual(listA, listB).toString());

// Global variable,Reference example
WidgetUtil widgetUtil = new WidgetUtil();

@override
Widget build(BuildContext context) {
  widgetUtil.asyncPrepare(context, false, (Rect rect) {
     double width = rect.width;
     double height = rect.height;
  });
    return ;
 }

//Widgets must be rendered completely. Otherwise return Offset.zero.
Rect rect = WidgetUtil.getWidgetBounds(context);
double width = rect.width;
double height = rect.height;

//Widgets must be rendered completely. Otherwise return Offset.zero.
Offset offset = WidgetUtil.getWidgetLocalToGlobal(context);
double dx = offset.dx  
double dx = offset.dy
159
likes
40
pub points
96%
popularity

Publisher

unverified uploader

Flutter common utils library. ScreenUtil, RegexUtil, ObjectUtil, WidgetUtil.

Repository (GitHub)
View/report issues

License

BSD-2-Clause (license)

Dependencies

flutter

More

Packages that depend on common_utils