सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
universal_html सभी प्लेटफॉर्मों पर काम करने वाला एक एकीकृत 'dart:html' API प्रदान करता है, जिसमें मोबाइल, डेस्कटॉप और सर्वर-साइड वातावरणों में Flutter शामिल है। यह रनटाइम के आधार पर समांगी HTML और XML प्रोसेसिंग सुनिश्चित करता है, जिससे क्रॉस-प्लेटफॉर्म विकास सरल हो जाता है। यह पैकेज DOM मैनिपुलेशन, HTTP रिक्वेस्ट्स और संरचित सामग्री के पार्सिंग के लिए एक संगत इंटरफ़ेस प्रदान करके वेब और गैर-वेब संदर्भों के बीच के अंतर को पूरा करता है। वेब और बैकएंड सेवाओं के बीच साझा लॉजिक के लिए आदर्श है, जिससे कोड दोहराव कम होता है और विकास कार्यप्रवाह सुगम होता है।
उपयोग
प्लेटफॉर्म-स्वतंत्र वेब और सर्वर तर्क
साझा HTML/XML पार्सिंग
सर्वर-साइड रेंडरिंग उपकरण
Flutter ऐप में वेब कंपोनेंट पुनर्उपयोग
सार्वभौम डार्ट एप्लिकेशन बनाना
मुख्य विशेषताएँ
प्लेटफॉर्म-अनुकूल dart:html API
सभी प्लेटफॉर्म पर DOM निर्माण का समर्थन करता है
निर्मित एक्सएमएल/एचटीएमएल विश्लेषण
फ्लटर और सर्वर के साथ बिना किसी दिक्कत के काम करता है
हल्का और न्यूनतम निर्भरता
इनके लिए उपयुक्त
बहुप्लेटफॉर्म लक्षित विकासकर्ता
HTML प्रोसेसिंग की आवश्यकता वाली बैकएंड सेवाएं
वेब-जैसी सुविधाओं की आवश्यकता वाले Flutter एप्लिकेशन
वेब और सर्वर के बीच कोड साझाकरण
प्लेटफ़ॉर्म-विशिष्ट शर्तों से बचने वाले प्रोजेक्ट्स
विचार योग्य बातें
गैर-वेब प्लेटफॉर्म पर सीमित ब्राउज़र-विशिष्ट विशेषताएं
कुछ DOM इवेंट्स का समर्थन वेब के बाहर नहीं है
सर्वर-साइड निष्पादन पर कार्यक्षमता में भिन्नता हो सकती है
पूर्ण ब्राउज़र प्रतिकृति के लिए नहीं बनाया गया है
असिंक्रोनस संचालन का ध्यानपूर्वक निर्माण करने की आवश्यकता है
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
Introduction
A cross-platform replacement for dart:html (or package:web):
Eases cross-platform development
You can use this package in browsers, mobile, desktop, and server-side VM, and Node.JS.
Just replace dart:html / package:web imports with package:universal_html/universal_html.dart. Normal
dart:html will continue to be used when application run in browsers.
Extensive support for processing HTML and XML documents
The project is licensed under the Apache License 2.0. Some of the source code was adopted
from the original dart:html in Dart SDK,
which is documented in the relevant files.
EventSource requests from real browsers are typically authenticated using cookies.
If you want to add cookies or customize other HTTP headers, you need to use
EventSourceOutsideBrowser:
import'package:universal_html/universal_html.dart';
import'dart:io'showCookie;
Future<void> main() async {
final eventSource = EventSource('http://example.com/events');
// The following block will NOT be executed in browsers.// Because compiler can infer instances of EventSourceOutsideBrowser are never constructed,// it will not appear in Javascript either.if (eventSource isEventSourceOutsideBrowser) {
eventSource.onHttpClientRequest = (eventSource, request) {
request.headers.set('Authorization', 'example');
request.cookies.add(Cookie('name', 'value'));
};
eventSource.onHttpClientResponse = (eventSource, request, response) {
// ...
};
}
awaitfor (var message in eventSource.onMessage) {
print('Event:');
print(' type: ${message.type}');
print(' data: ${message.data}');
}
}