showAddressPicker static method

void showAddressPicker(
  1. BuildContext context, {
  2. PickerStyle? pickerStyle,
  3. String initProvince = '',
  4. String initCity = '',
  5. String? initTown,
  6. bool addAllItem = true,
  7. AddressCallback? onChanged,
  8. AddressCallback? onConfirm,
  9. dynamic onCancel(
    1. bool isCancel
    )?,
  10. bool overlapTabBar = false,
})

自定义 地区选择器 initProvince 初始化 省 initCity 初始化 市 initTown 初始化 区 onChanged 选择器发生变动 onConfirm 选择器提交 addAllItem 市、区是否添加 '全部' 选项 默认:true

Implementation

static void showAddressPicker(BuildContext context,
    {PickerStyle? pickerStyle,
    String initProvince: '',
    String initCity: '',
    String? initTown,
    bool addAllItem: true,
    AddressCallback? onChanged,
    AddressCallback? onConfirm,
    Function(bool isCancel)? onCancel,
    bool overlapTabBar = false}) {
  if (pickerStyle == null) {
    pickerStyle = DefaultPickerStyle();
  }
  if (pickerStyle.context == null) {
    pickerStyle.context = context;
  }

  Navigator.of(context, rootNavigator: overlapTabBar).push(AddressPickerRoute(
    pickerStyle: pickerStyle,
    initProvince: initProvince,
    initCity: initCity,
    initTown: initTown,
    onChanged: onChanged,
    onConfirm: onConfirm,
    onCancel: onCancel,
    addAllItem: addAllItem,
    theme: Theme.of(context),
    barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
  ));
}