wmhpicker 0.0.8

  • Readme
  • Changelog
  • Example
  • Installing
  • 37

wmhpicker #

A new flutter plugin project.

Getting Started #

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

0.0.8 #

  • 使用时间选择器时,可以定位在当前日期
  • 选择日期后可以记录上一次选择日期

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:wmhpicker/wmhpicker.dart';
import 'package:flutter/cupertino.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      debugShowCheckedModeBanner: false,
      home: homeApp(),
    );
  }
}

class homeApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<homeApp> {
  bool showView = false;
  int selectYear = 0;
  int selectMonth = 0;
  int selectDay = 0;
  String _platformVersion = 'Unknown';
  List<Map> tempData = [
    {'subDatas' : ['明天','今天','后天']},
    {'subDatas' : ['不想','想','要']},
    {'subDatas' : ['去吃饭','去玩','去打游戏']},
  ];

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await Wmhpicker.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
//      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: GestureDetector(
          child: Container(
            width: 100,
            height: 100,
            color: Colors.red,
          ),
          onTap: () {
            print(this.selectYear.toString() + this.selectMonth.toString() + this.selectDay.toString());
            var now = new DateTime.now();

            showView = true;
            showDialog<Null>(
                context: context, //BuildContext对象
                barrierDismissible: false,
                builder: (BuildContext context) {
                  return WMHPickerView(showPicker: true, pickerData: this.tempData, callBack: (item) {
                    showView = false;
                    this.selectYear = int.parse(item[0].toString());
                    this.selectMonth = int.parse(item[1].toString());
                    this.selectDay = int.parse(item[2].toString());
                    print(this.selectYear.toString() + this.selectMonth.toString() + this.selectDay.toString());
                    setState(() {

                    });
                  }, cancelBtnColor: Colors.black,
                      confirmBtnColor: Colors.black,
                      pickerBackgroundColor: Colors.white,
                      pickerTextColor: Colors.black,
                      textSize: 20.0,pickerHeight: 300,
                  isDatePicker: true,
                  minYear: 2016,
                  maxYear: now.year,
                  selectDay: this.selectDay > 0 ? this.selectDay : now.day,
                  selectMonth: this.selectMonth > 0 ? this.selectMonth : now.month,
                  selectYear: this.selectYear > 0 ? this.selectYear : now.year);
                });
          },
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  wmhpicker: ^0.0.8

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:wmhpicker/wmhpicker.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
40
Overall:
Weighted score of the above. [more]
37
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Fix lib/wmhpicker.dart. (-1.99 points)

Analysis of lib/wmhpicker.dart reported 4 hints:

line 9 col 7: This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: WMHPickerView.pickerData, WMHPickerView.selectedArr, WMHPickerView.showPicker, WMHPickerView.cancelBtnColor, WMHPickerView.confirmBtnColor, WMHPickerView.pickerBackgroundColor, WMHPickerView.pickerTextColor, WMHPickerView.textSize, WMHPickerView.pickerHeight, WMHPickerView.isDatePicker, WMHPickerView.maxYear, WMHPickerView.minYear, WMHPickerView.selectYear, WMHPickerView.selectMonth, WMHPickerView.selectDay

line 68 col 7: This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: wmhPickerStateful.pickerData, wmhPickerStateful.selectedArr, wmhPickerStateful.showPicker, wmhPickerStateful.cancelBtnColor, wmhPickerStateful.confirmBtnColor, wmhPickerStateful.pickerBackgroundColor, wmhPickerStateful.pickerTextColor, wmhPickerStateful.textSize, wmhPickerStateful.pickerHeight, wmhPickerStateful.isDatePicker, wmhPickerStateful.maxYear, wmhPickerStateful.minYear, wmhPickerStateful.selectYear, wmhPickerStateful.selectMonth, wmhPickerStateful.selectDay

line 68 col 7: Name types using UpperCamelCase.

line 122 col 7: Name types using UpperCamelCase.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Running dartdoc failed with the following output: DetailedApiRequestError(status: 504, message: )

#0      _validateResponse (package:_discoveryapis_commons/src/clients.dart:852:9)
<asynchronous suspension>
#1      ApiRequester.request (package:_discoveryapis_commons/src/clients.dart:74:22)
<asynchronous suspension>
#2      ObjectsResourceApi.insert (package:googleapis/storage/v1.dart:3366:32)
#3      _MediaUploadStreamSink._startNormalUpload (package:gcloud/src/storage_impl.dart:599:10)
#4      new _MediaUploadStreamSink (package:gcloud/src/storage_impl.dart:514:9)
#5      _BucketImpl.write (package:gcloud/src/storage_impl.dart:179:16)
#6      uploadWithRetry.<anonymous closure> (package:pub_dev/shared/storage.dart:49:27)
<asynchronous suspension>
#7      retryAsync (package:pub_dev/shared/utils.dart:327:24)
<asynchronous suspension>
#8      uploadWithRetry (package:pub_dev/shared/storage.dart:47:9)
<asynchronous suspension>
#9      DartdocBackend.uploadDir.upload (package:pub_dev/dartdoc/backend.dart:137:13)
<asynchronous suspension>
#10     DartdocBackend.uploadDir.<anonymous closure> (package:pub_dev/dartdoc/backend.dart:149:64)
#11     Pool.withResource (package:pool/pool.dart:127:28)
<asynchronous suspension>
#12     DartdocBackend.uploadDir (package:pub_dev/dartdoc/backend.dart:149:39)
<asynchronous suspension>
#13     DartdocJobProcessor.process (package:pub_dev/dartdoc/dartdoc_runner.dart:249:30)
<asynchronous suspension>
#14     JobProcessor.run (package:pub_dev/job/job.dart:55:28)
<asynchronous suspension>
#15     JobMaintenance.run (package:pub_dev/job/job.dart:95:18)
#16     _workerMain.<anonymous closure> (package:pub_dev/service/entrypoint/dartdoc.dart:105:26)
#17     _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:73:64)
#18     StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:26)
#19     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#20     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:14)
#21     _rootRunUnary (dart:async/zone.dart:1134:38)
#22     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#23     _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
#24     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
#25     Future._propagateToListeners (dart:async/future_impl.dart:709:32)
#26     Future._completeWithValue (dart:async/future_impl.dart:524:5)
#27     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:32:15)
#28     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:290:13)
#29     DartdocJobProcessor.generateDocsForSdk (package:pub_dev/dartdoc/dartdoc_runner.dart)
#30     _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:73:64)
#31     StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:26)
#32     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#33     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:14)
#34     _rootRunUnary (dart:async/zone.dart:1134:38)
#35     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#36     _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
#37     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
#38     Future._propagateToListeners (dart:async/future_impl.dart:709:32)
#39     Future._completeWithValue (dart:async/future_impl.dart:524:5)
#40     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:32:15)
#41     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:290:13)
#42     VersionedJsonStorage.hasCurrentData (package:pub_dev/shared/storage.dart)
#43     _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:73:64)
#44     StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:26)
#45     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#46     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:14)
#47     _rootRunUnary (dart:async/zone.dart:1134:38)
#48     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#49     _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
#50     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
#51     Future._propagateToListeners (dart:async/future_impl.dart:709:32)
#52     Future._completeWithValue (dart:async/future_impl.dart:524:5)
#53     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:32:15)
#54     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:290:13)
#55     ApiRequester.request (package:_discoveryapis_commons/src/clients.dart)
#56     _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:73:64)
#57     StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:26)
#58     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#59     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:14)
#60     _rootRunUnary (dart:async/zone.dart:1134:38)
#61     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#62     _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
#63     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
#64     Future._propagateToListeners (dart:async/future_impl.dart:709:32)
#65     Future._complete (dart:async/future_impl.dart:514:7)
#66     Stream.join.<anonymous closure> (dart:async/stream.dart:844:18)
#67     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#68     StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#69     _rootRun (dart:async/zone.dart:1122:38)
#70     _CustomZone.run (dart:async/zone.dart:1023:19)
#71     _CustomZone.runGuarded (dart:async/zone.dart:925:7)
#72     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:391:13)
#73     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:401:15)
#74     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:285:7)
#75     _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:98:11)
#76     _EventSinkWrapper.close (dart:async/stream_transformers.dart:25:11)
#77     _StringAdapterSink.close (dart:convert/string_conversion.dart:251:11)
#78     _Utf8ConversionSink.close (dart:convert/string_conversion.dart:302:20)
#79     _ConverterStreamEventSink.close (dart:convert/chunked_conversion.dart:82:18)
#80     _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:143:24)
#81     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#82     StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#83     _rootRun (dart:async/zone.dart:1122:38)
#84     _CustomZone.run (dart:async/zone.dart:1023:19)
#85     _CustomZone.runGuarded (dart:async/zone.dart:925:7)
#86     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:391:13)
#87     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:401:15)
#88     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:285:7)
#89     _ForwardingStream._handleDone (dart:async/stream_pipe.dart:108:10)
#90     _ForwardingStreamSubscription._handleDone (dart:async/stream_pipe.dart:174:13)
#91     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#92     StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#93     _rootRun (dart:async/zone.dart:1122:38)
#94     _CustomZone.run (dart:async/zone.dart:1023:19)
#95     _CustomZone.runGuarded (dart:async/zone.dart:925:7)
#96     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:391:13)
#97     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:401:15)
#98     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:285:7)
#99     _ForwardingStream._handleDone (dart:async/stream_pipe.dart:108:10)
#100    _ForwardingStreamSubscription._handleDone (dart:async/stream_pipe.dart:174:13)
#101    StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#102    StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#103    _rootRun (dart:async/zone.dart:1122:38)
#104    _CustomZone.run (dart:async/zone.dart:1023:19)
#105    _CustomZone.runGuarded (dart:async/zone.dart:925:7)
#106    _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:391:13)
#107    _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:401:15)
#108    _BufferingStreamSubscription._close (dart:async/stream_impl.dart:285:7)
#109    _SyncStreamControllerDispatch._sendDone (dart:async/stream_controller.dart:774:19)
#110    _StreamController._closeUnchecked (dart:async/stream_controller.dart:631:7)
#111    _StreamController.close (dart:async/stream_controller.dart:624:5)
#112    _HttpParser._closeIncoming (dart:_http/http_parser.dart:1039:23)
#113    _HttpParser._doParse (dart:_http/http_parser.dart:777:15)
#114    _HttpParser._parse (dart:_http/http_parser.dart:320:7)
#115    _HttpParser._onData (dart:_http/http_parser.dart:812:5)
#116    StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:26)
#117    StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#118    StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:14)
#119    _rootRunUnary (dart:async/zone.dart:1134:38)
#120    _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#121    _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
#122    _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:338:11)
#123    _BufferingStreamSubscription._add (dart:async/stream_impl.dart:265:7)
#124    _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:766:19)
#125    _StreamController._add (dart:async/stream_controller.dart:642:7)
#126    _StreamController.add (dart:async/stream_controller.dart:588:5)
#127    _Socket._onData (dart:io-patch/socket_patch.dart:1831:41)
#128    StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:26)
#129    StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#130    StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:14)
#131    _rootRunUnary (dart:async/zone.dart:1134:38)
#132    _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#133    _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
#134    _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:338:11)
#135    _BufferingStreamSubscription._add (dart:async/stream_impl.dart:265:7)
#136    _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:766:19)
#137    _StreamController._add (dart:async/stream_controller.dart:642:7)
#138    _StreamController.add (dart:async/stream_controller.dart:588:5)
#139    _RawSecureSocket._sendReadEvent (dart:io/secure_socket.dart:1018:19)
#140    StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#141    StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#142    _rootRun (dart:async/zone.dart:1122:38)
#143    _CustomZone.run (dart:async/zone.dart:1023:19)
#144    _CustomZone.runGuarded (dart:async/zone.dart:925:7)
#145    _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965:23)
#146    StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#147    StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#148    _rootRun (dart:async/zone.dart:1126:13)
#149    _CustomZone.run (dart:async/zone.dart:1023:19)
#150    _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:949:23)
#151    Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:23:15)
#152    _Timer._runTimers (dart:isolate-patch/timer_impl.dart:384:19)
#153    _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:418:5)
#154    _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field https://code.9ji.com/minhang.wang/CHPickerView/src/master/WMHPicker was unreachable.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.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
Dev dependencies
flutter_test