パッケージ、リポジトリ、アプリカテゴリを検索

duration_picker のカバー
パッケージ詳細v2.0.0

duration_picker

分と時を両方選択できるタイムピッカーのウィジェット。flutter_duration_picker からフォークされました。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
1万
いいね数
126
Pub ポイント
160

パッケージをインストール

flutter pub add duration_picker

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

flutter_duration_picker から派生した、時間と分で期間を選択するための Flutter ウィジェットです。ユーザーが時間間隔を選択するための洗練された直感的なインターフェースを提供し、タイマー、タスクの所要時間、予約の長さなどの設定に最適です。このピッカーは、モバイル、ウェブ、デスクトップを含むすべての主要プラットフォームをサポートしています。シンプルさと一貫性を重視して設計されており、複雑なセットアップなしに、期間入力が必要なアプリにスムーズに統合できます。

用途

  • タイマーの期間を設定する
  • タスク長さの好みを設定する
  • 予約のスケジュール長さ
  • ワークアウトセッションの時間を入力する
  • 再生時間のカスタマイズ
  • 遅延インターバルの定義

主な機能

  • 時と分を選択する
  • クロスプラットフォーム互換性
  • シンプルな統合
  • クリーンなUIデザイン
  • 更新を維持したフォーク
  • すべての Flutter プラットフォームをサポートしています

適している対象

  • 時間間隔の選択が必要なアプリ
  • 生産性またはフィットネスアプリケーション
  • カレンダーやスケジューリングツール
  • タイマーまたはリマインダー機能
  • 軽量な期間ピッカーを探している開発者

注意事項

  • 時と分のみに制限
  • 秒のサポートなし
  • 期間値の手動処理が必要です
  • 非常に長い期間には適していません
  • フォークされたリポジトリの安定性に依存しています
  • 組み込みの検証なし

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Duration Picker for flutter

Fork from flutter_duration_picker. https://github.com/cdharris/flutter_duration_picker

A little widget for picking durations. Heavily inspired from the Material Design time picker widget.

How to setup localization

In order to support other languages, developers need to configure localization settings like the settings for the time picker. Example for english and korean:

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Duration Picker Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      localizationsDelegates: [
        DurationPickerLocalizations.delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      supportedLocales: [Locale('en'), Locale('ko')],
      home: const MyHomePage(title: 'Duration Picker Demo'),
    );
  }
}

How to add more languages

  1. Add a localizations class in localizataions dir.
class DurationPickerLocalizationsKo extends DurationPickerLocalizations {
  @override
  String get baseUnitHour => '시간';

  @override
  String get baseUnitMillisecond => '밀리초';

  ...
}

The class should extend DurationPickerLocalizations. This makes it easy to write everything you should write.

  1. Add the language code to the supportedLocales array in _DurationPickerLocalizationDelegate.
class _DurationPickerLocalizationDelegate
    extends LocalizationsDelegate<DurationPickerLocalizations> {
  const _DurationPickerLocalizationDelegate();

  static const supportedLocales = ['en', 'ko'];

  ...

}
  1. Return a DurationPickerLocalizations implementation as locale at load method in _DurationPickerLocalizationDelegate.
@override
  Future<DurationPickerLocalizations> load(Locale locale) async {
    switch (locale.languageCode) {
      case 'ko':
        return DurationPickerLocalizationsKo();
      default:
        return DurationPickerLocalizationsEn();
    }
  }

Example Usage:

dependencies:
  duration_picker: "^1.0.0"
import 'package:flutter/material.dart';
import 'package:duration_picker/duration_picker.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Duration Picker Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Duration Picker Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  Duration _duration = Duration(hours: 0, minutes: 0);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Expanded(
                child: DurationPicker(
              duration: _duration,
              onChange: (val) {
                setState(() => _duration = val);
              },
            ))
          ],
        ),
      ),
      floatingActionButton: Builder(
          builder: (BuildContext context) => FloatingActionButton(
                onPressed: () async {
                  var resultingDuration = await showDurationPicker(
                    context: context,
                    initialTime: Duration(minutes: 30),
                  );
                  ScaffoldMessenger.of(context).showSnackBar(SnackBar(
                      content: Text('Chose duration: $resultingDuration')));
                },
                tooltip: 'Popup Duration Picker',
                child: Icon(Icons.add),
              )),
    );
  }
}

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト