DartUtil.dart 1.18 KB
Newer Older
林生雨's avatar
林生雨 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
/*
 * @author lsy
 * @date   2020/5/22
 **/
import 'package:flutter/material.dart';
import 'package:gm_flutter/commonModel/view/ActivePage.dart';

class DartUtil {
  //为了导包
}

extension WidgetExt on Widget {
  Widget margin(EdgeInsets edgeInsets, double width, double height) {
    return Container(
      width: width,
      height: height,
      margin: edgeInsets,
      child: this,
    );
  }

  Widget padding(EdgeInsets edgeInsets, double width, double height) {
    return Container(
      width: width,
      height: height,
      padding: edgeInsets,
      child: this,
    );
  }

  Widget gestureDetector(VoidCallback onTap) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: onTap,
      child: this,
    );
  }

  Widget minColumn(List<Widget> list) {
    return Column(
      mainAxisSize: MainAxisSize.min,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: list,
    );
  }

  Widget toActive() {
    return ActivePage(this);
  }
}

extension StringExt on String {
  bool isPhone() {
    return new RegExp(
            '^((13[0-9])|(15[^4])|(166)|(17[0-8])|(18[0-9])|(19[8-9])|(147,145))\\d{8}\$')
        .hasMatch(this);
  }
}