frdatapicker 1.0.1

frdatapicker #

A new Flutter plugin.

Getting Started #

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

dependencies:
    frdatapicker:
        git: https://github.com/frcc00/frdatapicker

class AddressPicker {
  ///省
  static var _sArr = [];
  ///市
  static var _cArr = [];
  ///区
  static var _qArr = [];

  static showAddressPicker(context) async{
    Completer completer = Completer();
    _show(completer,context);
    return completer.future;
  }

  static _show(Completer completer,context) async{
    if(_sArr.isEmpty){
      var data = await HttpPart1().getAllProvince();
      _sArr = data['data'];
    }
    if(_cArr.isEmpty){
      var data = await HttpPart1().getChildById(_sArr.first['id'].toString());
      _cArr = data['data'];
    }
    if(_qArr.isEmpty){
      var data = await HttpPart1().getChildById(_cArr.first['id'].toString());
      _qArr = data['data'];
    }

    showModalBottomSheet(context: context, builder: (c){
      return FrDataPicker(
        itemCount: 3,
        cancelBtnTitle: '取消',
        okBtnTitle: '确定',
        dataSourceCallback: (i){
          if(i==0){
            return _sArr.map<String>((v)=>v['name']).toList();
          }
          if(i==1){
            return _cArr.map<String>((v)=>v['name']).toList();
          }
          return _qArr.map<String>((v)=>v['name']).toList();
        },
        onSelectedItemChanged: (int index, int columnIndex, Function(List<int> columnIndexs) needReloadColumns)async{
          if(columnIndex == 0){
            var data = await HttpPart1().getChildById(_sArr[index]['id'].toString());
            _cArr = data['data'];
            _qArr = [];
            if(_cArr.isNotEmpty){
              var data1 = await HttpPart1().getChildById(_cArr.first['id'].toString());
              _qArr = data1['data'];
            }
            needReloadColumns([1,2]);
          }
          if(columnIndex == 1){
            var data1 = await HttpPart1().getChildById(_cArr[index]['id'].toString());
            _qArr = data1['data'];
            needReloadColumns([2]);
          }
        },
        onDone: (list){
          var si = list[0];
          var ci = list[1];
          var qi = list[2];
          var sData = {};
          var cData = {};
          var qData = {};
          try{
            sData = _sArr[si];
          }catch(_){}
          try{
            cData = _cArr[ci];
          }catch(_){}
          try{
            qData = _qArr[qi];
          }catch(_){}
          completer.complete(AddressPickerResult(
            provinceId: (sData['id']??'').toString(),
            provinceName: sData['name']??'',
            cityId: (cData['id']??"").toString(),
            cityName: cData['name']??"",
            areaId: (qData['id']??"").toString(),
            areaName: qData['name']??"",
          ));
        },
      );
    });
  }
}

class AddressPickerResult {
  /// provinceId
  String provinceId;

  /// cityId
  String cityId;

  /// areaId
  String areaId;

  /// provinceName
  String provinceName;

  /// cityName
  String cityName;

  /// areaName
  String areaName;

  AddressPickerResult(
      {this.provinceId,
        this.cityId,
        this.areaId,
        this.provinceName,
        this.cityName,
        this.areaName});

  /// string json
  @override
  String toString() {
    Map<String, dynamic> obj = {
      'provinceName': provinceName,
      'provinceId': provinceId,
      'cityName': cityName,
      'cityId': cityId,
      'areaName': areaName,
      'areaId': areaId
    };
    obj.removeWhere((key, value) => value == null);

    return json.encode(obj);
  }
}

0.0.1 #

  • TODO: Describe initial release.

0.0.3 #

  • issues fix

0.0.4 #

  • update homepage

1.0.0 #

  • issues fix

1.0.1 #

  • androidx

example/README.md

frdatapicker_example #

Demonstrates how to use the frdatapicker plugin.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  frdatapicker: ^1.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:frdatapicker/frdatapicker.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
7
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
54
Learn more about scoring.

We analyzed this package on Feb 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7

Health suggestions

Format lib/frdatapicker.dart.

Run flutter format to format lib/frdatapicker.dart.

Format lib/generated/i18n.dart.

Run flutter format to format lib/generated/i18n.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8