पैकेज, रिपॉज़िटरी और ऐप श्रेणियाँ खोजें

पैकेज विवरणv1.6.0

datetime_loop

एक फ्लटर पैकेज जो सिस्टम के डेटाइम को सुनने और निर्दिष्ट समय इकाई के आधार पर पुनर्निर्माण करने के लिए एक विजेट प्रदान करता है।

AndroidiOSWebmacOSWindowsLinux
30-दिन डाउनलोड
274
लाइक
11
Pub अंक
160

पैकेज इंस्टॉल करें

flutter pub add datetime_loop

पैकेज अवलोकन

सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।

datetime_loop पैकेज एक फ्लटर उपयोगिता है जो सिस्टम के वर्तमान दिनांक और समय को निगरानी करने के लिए एक विजेट प्रदान करता है, जो कॉन्फ़िगरेबल समय अंतराल (सेकंड, मिनट, या घंटे) के आधार पर रीबिल्ड को ट्रिगर करता है। इससे घड़ी, डाउनकाउंट या लाइव डेटा प्रदर्शन जैसे डायनामिक समय-आधारित सामग्री के लिए यूआई में वास्तविक समय के अपडेट को सरल बनाया जाता है। विजेट सिस्टम समय परिवर्तनों को बिना अनावश्यक ओवरहेड के दक्षता से सुनता है, जिससे प्लेटफॉर्म के आसान प्रदर्शन की गारंटी मिलती है। समय विकास से जुड़े अवधि अपडेट की आवश्यकता वाले एप्लिकेशन के लिए उपयुक्त।

उपयोग

  • रियल-टाइम क्लॉक डिस्प्ले
  • डाउनटाइम टाइमर
  • लाइव डेटा अपडेट्स
  • समय-आधारित UI अद्यतन
  • डायनामिक कंटेंट स्केड्यूलिंग

मुख्य विशेषताएँ

  • निर्दिष्ट समय अंतरालों पर पुनर्निर्माण करता है
  • कुशल प्रणाली समय सुनना
  • क्रॉस-प्लेटफ़ॉर्म समर्थन
  • कॉन्फ़िगरेबल समय इकाइयाँ
  • न्यूनतम प्रदर्शन प्रभाव

इनके लिए उपयुक्त

  • समय-निर्भर यूआई वाले ऐप्स
  • हल्के समय सुनने वाले विकासकर्ता की आवश्यकता होती है
  • अक्सर UI अपडेट की आवश्यकता वाले प्रोजेक्ट
  • घड़ी या टाइमर अनुप्रयोग
  • रियल-टाइम डैशबोर्ड्स

विचार योग्य बातें

  • यदि अंतराल बहुत छोटा है, तो अत्यधिक पुनर्निर्माण का कारण बन सकता है
  • जटिल विजेट्स में राज्य के सावधानीपूर्वक निपटान की आवश्यकता होती है
  • लंबे समय तक चलने वाले बैकग्राउंड कार्यों के लिए आदर्श नहीं
  • अपरिवर्तनीय या हल्के उपयोगी घटकों के साथ सबसे अच्छा उपयोग करें
  • UI-स्तर समय मॉनिटरिंग तक सीमित

मूल README

संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।

Clock Example

Buy Me A Coffee
Pub BSD 3-Clause License Pub
Pub likes Download Pub points

A Flutter package that provides a widget to listen to the system's datetime and trigger a rebuild based on the specified time unit

Support the project by giving the repo a ⭐ and showing some ❤️!

Usage

Import the package in your Dart code:

import 'package:datetime_loop/datetime_loop.dart';
Using DateTimeLoopBuilder

Use the DateTimeLoopBuilder widget to rebuild UI elements based on system time updates. You can provide a timeUnit for simple setups or a custom DateTimeLoopController for advanced control (e.g., pause/resume):

DateTimeLoopBuilder(
  timeUnit: TimeUnit.seconds,
  builder: (context, dateTime, child) {
    return Column(
      children: [
        Container(
          width: 200,
          height: 200,
          color: Color((math.Random().nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0),
        ),
        Text('$dateTime'),
      ],
    );
  }
)
Using DateTimeLoopController

The DateTimeLoopController provides a stream of datetime updates and supports advanced features like pausing and resuming updates, useful for optimizing resource usage (e.g., when the app is backgrounded):

final controller = DateTimeLoopController(timeUnit: TimeUnit.minutes);
controller.dateTimeStream.listen((dateTime) {
  print('Current time: $dateTime');
});

// Pause updates to save resources
controller.pause();

// Resume updates with an immediate trigger
controller.resume(triggerImmediate: true);

// Use the controller with DateTimeLoopBuilder
DateTimeLoopBuilder(
  controller: controller,
  builder: (context, dateTime, child) {
  return Text('Time: ${dateTime.toString().split('.').first}');
  },
);

// Dispose of the controller when done
controller.dispose();
Testing with getNow

Both DateTimeLoopBuilder and DateTimeLoopController support a getNow parameter that allows you to mock the system time. This is particularly useful for testing and simulating different time scenarios:

// Example: Testing with a mocked time
DateTime customTime = DateTime(2025, 10, 31, 12, 0, 0);

DateTimeLoopBuilder(
  timeUnit: TimeUnit.seconds,
  getNow: () => customTime,
  builder: (context, dateTime, child) {
    return Text('Mocked time: $dateTime');
  },
)

// Example: Using getNow with DateTimeLoopController
final controller = DateTimeLoopController(
  timeUnit: TimeUnit.minutes,
  getNow: () => customTime,
);

This feature enables:

  • Unit Testing: Write deterministic tests by controlling the datetime value
  • Time Simulation: Simulate different time scenarios without waiting for real time to pass
  • Debugging: Test edge cases and time-dependent behavior

You can check more examples of using this widget here

Issues and Feedback

Please file any issues or feedback here.

श्रेणियाँ

सोर्स रिपॉज़िटरी

इस पैकेज का उपयोग करने वाले प्रोजेक्ट

अभी कोई डेटा उपलब्ध नहीं है।