*)registrar {
+ FlutterMethodChannel* channel = [FlutterMethodChannel
+ methodChannelWithName:@"common_utils"
+ binaryMessenger:[registrar messenger]];
+ CommonUtilsPlugin* instance = [[CommonUtilsPlugin alloc] init];
+ [registrar addMethodCallDelegate:instance channel:channel];
+}
+
+- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
+ if ([@"getPlatformVersion" isEqualToString:call.method]) {
+ result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
+ } else {
+ result(FlutterMethodNotImplemented);
+ }
+}
+
+@end
diff --git a/ios/common_utils.podspec b/ios/common_utils.podspec
new file mode 100644
index 0000000..3e9f7b8
--- /dev/null
+++ b/ios/common_utils.podspec
@@ -0,0 +1,21 @@
+#
+# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
+#
+Pod::Spec.new do |s|
+ s.name = 'common_utils'
+ s.version = '0.0.1'
+ s.summary = 'A new Flutter plugin.'
+ s.description = <<-DESC
+A new Flutter plugin.
+ DESC
+ s.homepage = 'http://example.com'
+ s.license = { :file => '../LICENSE' }
+ s.author = { 'Your Company' => 'email@example.com' }
+ s.source = { :path => '.' }
+ s.source_files = 'Classes/**/*'
+ s.public_header_files = 'Classes/**/*.h'
+ s.dependency 'Flutter'
+
+ s.ios.deployment_target = '8.0'
+end
+
diff --git a/lib/common_utils.dart b/lib/common_utils.dart
new file mode 100644
index 0000000..8015413
--- /dev/null
+++ b/lib/common_utils.dart
@@ -0,0 +1,6 @@
+library common_utils;
+
+export 'src/object_util.dart';
+export 'src/regex_util.dart';
+export 'src/screen_util.dart';
+export 'src/widget_util.dart';
\ No newline at end of file
diff --git a/lib/src/object_util.dart b/lib/src/object_util.dart
new file mode 100644
index 0000000..14d11b6
--- /dev/null
+++ b/lib/src/object_util.dart
@@ -0,0 +1,56 @@
+/**
+ * @Author: thl
+ * @GitHub: https://github.com/Sky24n
+ * @Description: Object Util.
+ * @Date: 2018/9/8
+ */
+
+///
+class ObjectUtil {
+ /// Returns true if the string is null or 0-length.
+ static bool isEmptyString(String str) {
+ return str == null || str.isEmpty;
+ }
+
+ /// Returns true if the list is null or 0-length.
+ static bool isEmptyList(List list) {
+ return list == null || list.isEmpty;
+ }
+
+ /// Returns true if there is no key/value pair in the map.
+ static bool isEmptyMap(Map map) {
+ return map == null || map.isEmpty;
+ }
+
+ /// Returns true String or List or Map is empty.
+ static bool isEmpty(Object object) {
+ if (object == null) return true;
+ if (object is String && object.isEmpty) {
+ return true;
+ } else if (object is List && object.isEmpty) {
+ return true;
+ } else if (object is Map && object.isEmpty) {
+ return true;
+ }
+ return false;
+ }
+
+ /// Returns true String or List or Map is not empty.
+ static bool isNotEmpty(Object object) {
+ return !isEmpty(object);
+ }
+
+ /// Returns true Two List Is Equal.
+ static bool twoListIsEqual(List listA, List listB) {
+ if (listA == listB) return true;
+ if (listA == null || listB == null) return false;
+ int length = listA.length;
+ if (length != listB.length) return false;
+ for (int i = 0; i < length; i++) {
+ if (!listA.contains(listB[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
diff --git a/lib/src/regex_util.dart b/lib/src/regex_util.dart
new file mode 100644
index 0000000..8417706
--- /dev/null
+++ b/lib/src/regex_util.dart
@@ -0,0 +1,116 @@
+/**
+ * @Author: thl
+ * @GitHub: https://github.com/Sky24n
+ * @Description: Regex Util.
+ * @Date: 2018/9/8
+ */
+
+///
+class RegexUtil {
+ /// Regex of simple mobile.
+ static final String regexMobileSimple = "^[1]\\d{10}\$";
+
+ /// Regex of exact mobile.
+ /// china mobile: 134(0-8), 135, 136, 137, 138, 139, 147, 150, 151, 152, 157, 158, 159, 178, 182, 183, 184, 187, 188, 198
+ /// china unicom: 130, 131, 132, 145, 155, 156, 166, 171, 175, 176, 185, 186
+ /// china telecom: 133, 153, 173, 177, 180, 181, 189, 199
+ /// global star: 1349
+ /// virtual operator: 170
+ static final String regexMobileExact =
+ "^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(16[6])|(17[0,1,3,5-8])|(18[0-9])|(19[8,9]))\\d{8}\$";
+
+ /// Regex of telephone number.
+ static final String regexTel = "^0\\d{2,3}[- ]?\\d{7,8}";
+
+ /// Regex of id card number which length is 15.
+ static final String regexIdCard15 =
+ "^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}\$";
+
+ /// Regex of id card number which length is 18.
+ static final String regexIdCard18 =
+ "^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9Xx])\$";
+
+ /// Regex of email.
+ static final String regexEmail =
+ "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$";
+
+ /// Regex of url.
+ static final String regexUrl = "[a-zA-z]+://[^\\s]*";
+
+ /// Regex of Chinese character.
+ static final String regexZh = "[\\u4e00-\\u9fa5]";
+
+ /// Regex of date which pattern is "yyyy-MM-dd".
+ static final String regexDate =
+ "^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)\$";
+
+ /// Regex of ip address.
+ static final String regexIp =
+ "((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)";
+
+ ///Return whether input matches regex of simple mobile.
+ static bool isMobileSimple(String input) {
+ return matches(regexMobileSimple, input);
+ }
+
+ ///Return whether input matches regex of exact mobile.
+ static bool isMobileExact(String input) {
+ return matches(regexMobileExact, input);
+ }
+
+ /// Return whether input matches regex of telephone number.
+ static bool isTel(String input) {
+ return matches(regexTel, input);
+ }
+
+ /// Return whether input matches regex of id card number.
+ static bool isIDCard(String input) {
+ if (input != null && input.length == 15) {
+ return isIDCard15(input);
+ }
+ if (input != null && input.length == 18) {
+ return isIDCard18(input);
+ }
+ return false;
+ }
+
+ /// Return whether input matches regex of id card number which length is 15.
+ static bool isIDCard15(String input) {
+ return matches(regexIdCard15, input);
+ }
+
+ /// Return whether input matches regex of id card number which length is 18.
+ static bool isIDCard18(String input) {
+ return matches(regexIdCard18, input);
+ }
+
+ /// Return whether input matches regex of email.
+ static bool isEmail(String input) {
+ return matches(regexEmail, input);
+ }
+
+ /// Return whether input matches regex of url.
+ static bool isURL(String input) {
+ return matches(regexUrl, input);
+ }
+
+ /// Return whether input matches regex of Chinese character.
+ static bool isZh(String input) {
+ return '〇' == input || matches(regexZh, input);
+ }
+
+ /// Return whether input matches regex of date which pattern is "yyyy-MM-dd".
+ static bool isDate(String input) {
+ return matches(regexDate, input);
+ }
+
+ /// Return whether input matches regex of ip address.
+ static bool isIP(String input) {
+ return matches(regexIp, input);
+ }
+
+ static bool matches(String regex, String input) {
+ if (input == null || input.isEmpty) return false;
+ return new RegExp(regex).hasMatch(input);
+ }
+}
diff --git a/lib/src/screen_util.dart b/lib/src/screen_util.dart
new file mode 100644
index 0000000..c2b601f
--- /dev/null
+++ b/lib/src/screen_util.dart
@@ -0,0 +1,51 @@
+import 'package:flutter/material.dart';
+
+/**
+ * @Author: thl
+ * @GitHub: https://github.com/Sky24n
+ * @Description: Screen Util.
+ * @Date: 2018/9/8
+ */
+
+///
+class ScreenUtil {
+ static double _screenWidth;
+ static double _screenHeight;
+ static double _screenDensity;
+ static double _statusBarHeight;
+ static double _appBarHeight;
+ static MediaQueryData _mediaQueryData;
+
+ static ScreenUtil singleton = new ScreenUtil();
+
+ static ScreenUtil getInstance() {
+ return singleton;
+ }
+
+ void init(BuildContext context) {
+ MediaQueryData mediaQuery = MediaQuery.of(context);
+ _mediaQueryData = mediaQuery;
+ _screenWidth = mediaQuery.size.width;
+ _screenHeight = mediaQuery.size.height;
+ _screenDensity = mediaQuery.devicePixelRatio;
+ _statusBarHeight = mediaQuery.padding.top;
+ _appBarHeight = kToolbarHeight;
+ }
+
+ ///screen width
+ static double get screenWidth => _screenWidth;
+
+ ///screen height
+ static double get screenHeight => _screenHeight;
+
+ ///appBar height
+ static double get appBarHeight => _appBarHeight;
+
+ ///screen density
+ static double get screenDensity => _screenDensity;
+
+ ///status bar Height
+ static double get statusBarHeight => _statusBarHeight;
+
+ static MediaQueryData get mediaQueryData => _mediaQueryData;
+}
diff --git a/lib/src/widget_util.dart b/lib/src/widget_util.dart
new file mode 100644
index 0000000..4f0833e
--- /dev/null
+++ b/lib/src/widget_util.dart
@@ -0,0 +1,54 @@
+import 'package:flutter/widgets.dart';
+
+/**
+ * @Author: thl
+ * @GitHub: https://github.com/Sky24n
+ * @Description: Widget Util.
+ * @Date: 2018/9/10
+ */
+
+///
+class WidgetUtil {
+ bool _hasMeasured = false;
+ double _width;
+ double _height;
+
+ /// Widget rendering listener.
+ /// Widget渲染监听
+ /// context: Widget context
+ /// isOnce: true,Continuous monitoring false,Listen only once.
+ /// onCallBack: Widget Rect CallBack
+ void asyncPrepare(
+ BuildContext context, bool isOnce, ValueChanged onCallBack) {
+ if (_hasMeasured) return;
+ WidgetsBinding.instance.addPostFrameCallback((Duration timeStamp) {
+ RenderBox box = context.findRenderObject();
+ if (box != null && box.semanticBounds != null) {
+ if (isOnce) _hasMeasured = true;
+ double width = box.semanticBounds.width;
+ double height = box.semanticBounds.height;
+ if (_width != width || _height != height) {
+ _width = width;
+ _height = height;
+ if (onCallBack != null) onCallBack(box.semanticBounds);
+ }
+ }
+ });
+ }
+
+ ///get Widget Bounds (width, height, left, top, right, bottom and so on).Widgets must be rendered completely.
+ ///获取widget Rect
+ static Rect getWidgetBounds(BuildContext context) {
+ RenderBox box = context.findRenderObject();
+ return (box != null && box.semanticBounds != null)
+ ? box.semanticBounds
+ : Rect.zero;
+ }
+
+ ///Get the coordinates of the widget on the screen.Widgets must be rendered completely.
+ ///获取widget在屏幕上的坐标,widget必须渲染完成
+ static Offset getWidgetLocalToGlobal(BuildContext context) {
+ RenderBox box = context.findRenderObject();
+ return box == null ? Offset.zero : box.localToGlobal(Offset.zero);
+ }
+}
diff --git a/pubspec.yaml b/pubspec.yaml
new file mode 100644
index 0000000..9b839d6
--- /dev/null
+++ b/pubspec.yaml
@@ -0,0 +1,52 @@
+name: common_utils
+description: Flutter common utils library. ScreenUtil, RegexUtil, ObjectUtil, WidgetUtil.
+version: 0.0.2
+author: thl <863764940@qq.com>
+homepage: https://github.com/Sky24n/common_utils
+
+environment:
+ sdk: ">=1.19.0 <3.0.0"
+
+dependencies:
+ flutter:
+ sdk: flutter
+
+# For information on the generic Dart part of this file, see the
+# following page: https://www.dartlang.org/tools/pub/pubspec
+
+# The following section is specific to Flutter.
+flutter:
+ plugin:
+ androidPackage: com.thl.commonutils
+ pluginClass: CommonUtilsPlugin
+
+ # To add assets to your plugin package, add an assets section, like this:
+ # assets:
+ # - images/a_dot_burr.jpeg
+ # - images/a_dot_ham.jpeg
+ #
+ # For details regarding assets in packages, see
+ # https://flutter.io/assets-and-images/#from-packages
+ #
+ # An image asset can refer to one or more resolution-specific "variants", see
+ # https://flutter.io/assets-and-images/#resolution-aware.
+
+ # To add custom fonts to your plugin package, add a fonts section here,
+ # in this "flutter" section. Each entry in this list should have a
+ # "family" key with the font family name, and a "fonts" key with a
+ # list giving the asset and other descriptors for the font. For
+ # example:
+ # fonts:
+ # - family: Schyler
+ # fonts:
+ # - asset: fonts/Schyler-Regular.ttf
+ # - asset: fonts/Schyler-Italic.ttf
+ # style: italic
+ # - family: Trajan Pro
+ # fonts:
+ # - asset: fonts/TrajanPro.ttf
+ # - asset: fonts/TrajanPro_Bold.ttf
+ # weight: 700
+ #
+ # For details regarding fonts in packages, see
+ # https://flutter.io/custom-fonts/#from-packages
diff --git a/uploadMaster b/uploadMaster
new file mode 100644
index 0000000..6f74d20
--- /dev/null
+++ b/uploadMaster
@@ -0,0 +1 @@
+git push origin master