用法
欢迎来到 Pickers,要使用此插件,请在您的 pubspec.yaml 文件中将 pickers 添加为 依赖项。或者,您可以通过将以下内容添加到 pubspec.yaml 文件来从 GitHub 安装它。
dependencies:
pickers:
git:
url: https://github.com/ashtav/pickers.git
ref: master
示例
GestureDetector(
onTap: () async {
DateTime? dateTime = await Pickers.datePicker(context);
},
)
GestureDetector(
onTap: () async {
DateTime? dateTime = await Pickers.timePicker(context);
String time = Mixins.dateFormat(dateTime, format: 'HH:mm') // 10:30
},
)
GestureDetector(
onTap: () async {
List<Media>? images = await Pickers.imagePicker(context, maxImages: 5);
},
),
iOS
将以下键添加到您的 Info.plist 文件中,该文件位于 <project root>/ios/Runner/Info.plist
<key>NSCameraUsageDescription</key>
<string>your usage description here</string>
<key>NSMicrophoneUsageDescription</key>
<string>your usage description here</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Example usage description</string>
Android
将以下权限添加到您的 AndroidManifest.xml 文件中,该文件位于 <project root>/android/app/src/main/AndroidManifest.xml
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
在您的 android/app/build.gradle 文件中将最低 Android sdk 版本更改为 21(或更高)。
minSdkVersion 21