v1.2.0
cancelation_token
इस पैकेज में रद्द करने के टोकन के लिए इंटरफ़ेस और विभिन्न कार्यान्वयन (रद्द करने योग्य, समय सीमा, संयुक्त...) प्रदान करता है।
2लाइक 32.3 हज़ार30-दिन डाउनलोड160Pub अंक
AndroidiOSLinuxmacOSWebWindows
रद्द करने के लिए टोकन इंटरफ़ेस + कुछ वास्तविकीकरण
यह अंग्रेज़ी मूल स्नैपशॉट है। नवीनतम सामग्री GitHub पर देखें।
This package provides an interface for cancelation tokens as well as various implementations:
CancelableToken which can be canceled programmatically;CompositeToken which is canceled when any or all tokens are canceled;TimeoutToken which is canceled after a timeout period.Cancel a long-running execution after a timeout.
import 'package:cancelation_token/cancelation_token.dart';
void main() async {
final timeout = Duration(seconds: 5);
final errorOnTimeout = CanceledException.withStackTrace('Too long!');
final token = TimeoutToken(timeout, errorOnTimeout);
token.ensureStarted();
try {
await longProcess(token);
} on CanceledException catch (ex, st) {
print(ex.message);
print(ex.stackTrace);
print(st);
}
}
Future<void> longProcess(CancelationToken token) async {
// very long indeed!
while (true) {
token.throwIfCanceled();
await Future.delayed(const Duration(milliseconds: 100));
}
}
उपयोग के अनुसार छाँटें, गतिविधि की तुलना करें और अपनाने से पहले मूल प्रोजेक्ट की आवश्यकताएँ जाँचें।
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗