패키지, 저장소 및 앱 카테고리 검색

GitHub 저장소xiaomsh/FlutterCityPicker

FlutterCityPicker

:fire::fire::fire::+1: 도시 선택, 주소 선택, 실시간 요청 데이터, 다수의 사용자 정의 설정, 징동 스타일

FlutterCityPicker 프로젝트 이미지
스타
35
포크
15
최근 푸시(UTC)
2025. 11. 13.
프로젝트 상태
활성

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

地址选择器

由于地址选择的数据来源会更新,为了统一,在后台配置一份城市数据,前端获取,否则各个平台都配置一份数据,维护会很麻烦,而且有可能每个平台城市的数据结构都不一样。 本库就是由此而来,数据从后台实时获取,只要解析成固定的数据结构就可以

新版本 2.2.0 支持读取本地文件,但是不建议,因为会增加包体积,而且还要维护,因为有人提的多,所以在此给个 demo

Demo

web 预览

效果示例

导入方式
dependencies:
    flutter_city_picker: ^2.2.0
使用方法
  1. 简单使用
    CityPicker.show(context: context, cityPickerListener: this);
  1. 多配置的使用
    CityPicker.show(
          context: context,
          // 动画控制器
          animController: _animationController,
          // 背景透明度
          opacity: 0.5,
          // 点击外部是否消失
          dismissible: true,
          // 高度
          height: 400,
          // 标题高度
          titleHeight: 50,
          // 顶部圆角
          corner: 20,
          // 背景颜色
          backgroundColor: Colors.white
          // 距离左边的间距
          paddingLeft: 15,
          // 标题组件
          titleWidget: Container(
            padding: EdgeInsets.only(left: 15),
            child: Text(
              '请选择地址',
              style: TextStyle(
                color: Colors.black54,
                fontSize: 18,
                fontWeight: FontWeight.bold,
              ),
            ),
          ),
          // 选择文字
          selectText: "请选择",
          // 关闭图标组件
          closeWidget: Icon(Icons.close),
          // tab 高度
          tabHeight: 40,
          // 是否显示指示器
          showTabIndicator: _showTabIndicator,
          // tab 间隔
          tabPadding: 15,
          // tab 指示器颜色
          tabIndicatorColor: Theme.of(context).primaryColor,
          // tab 指示器高度
          tabIndicatorHeight: 2,
          // tab 字体大小
          labelTextSize: 15,
          // tab 选中的字体颜色
          selectedLabelColor: Theme.of(context).primaryColor,
          // tab 未选中的字体颜色
          unselectedLabelColor: Colors.black54,
          // 列表 item 头部高度
          itemHeadHeight: 30,
          // 列表 item 头部背景颜色
          itemHeadBackgroundColor: Colors.white,
          // 列表 item 头部分割线颜色
          itemHeadLineColor: Colors.black,
          // 列表 item 头部分割线高度
          itemHeadLineHeight: 0.1,
          // 列表 item 头部文字样式
          itemHeadTextStyle: TextStyle(fontSize: 15, color: Colors.black),
          // 列表 item 高度
          itemHeight: 40,
          // 索引组件宽度
          indexBarWidth: 28,
          // 索引组件 item 高度
          indexBarItemHeight: 20,
          // 索引组件背景颜色
          indexBarBackgroundColor: Colors.black12,
          // 索引组件文字样式
          indexBarTextStyle: TextStyle(fontSize: 14, color: Colors.black54),
          // 列表选中的图标组件
          itemSelectedIconWidget:
              Icon(Icons.done, color: Theme.of(context).primaryColor, size: 16),
          // 列表选中的文字样式
          itemSelectedTextStyle: TextStyle(
              fontSize: 14,
              fontWeight: FontWeight.bold,
              color: Theme.of(context).primaryColor),
          // 列表未选中的文字样式
          itemUnSelectedTextStyle: TextStyle(fontSize: 14, color: Colors.black54),
          // 初始默认地址
          initialAddress: _selectedAddress,
          cityPickerListener: this,
        );
  1. 监听事件
    <你的组件> implements CityPickerListener

    @override
    Future<List<T>> onDataLoad(int index, T data) async {
      return 返回城市数据;
    }

    @override
    void onFinish(List<T> data) {
      // 最终回调,返回省市区的代码和名称
    }
待优化

无

欢迎提 PR 或者 ISSUE

ms GitHub avatar
GitHub 작성자

ms ↗

like android like coding,welcome to contact me --- 79556355@qq.com

China shenzhen
언어DartObjective-CHTMLKotlin

분류

사용 중인 의존성

의존성 목록 2 개

프로젝트에 맞는 저장소를 선택하려면?

사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.

  1. 이름, 작성자 또는 설명으로 검색하고 기술 주제로 범위를 좁힙니다.
  2. 스타, 포크, 최근 푸시를 함께 비교하세요. 스타는 관심의 지표이며 품질을 보장하지 않습니다.
  3. 사용하기 전에 GitHub에서 README, 라이선스, Issues를 확인하세요.

출처 및 관리

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗