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

पैकेज विवरणv2.1.6

platform_detect

चल रहे ब्राउज़र और ओएस का पता लगाने के लिए हल्का लाइब्रेरी

Web
30-दिन डाउनलोड
1 लाख
लाइक
38
Pub अंक
125

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

flutter pub add platform_detect

पैकेज अवलोकन

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

platform_detect एक हल्का Flutter Web पुस्तकालय है जो रनटाइम पर वर्तमान ऑपरेटिंग सिस्टम और ब्राउज़र वातावरण की पहचान करने के लिए डिज़ाइन किया गया है। यह OS (उदाहरण के लिए Windows, macOS, Linux) और ब्राउज़र (उदाहरण के लिए Chrome, Safari, Firefox) जैसे प्लेटफॉर्म विवरण की सरल, विश्वसनीय पहचान प्रदान करता है, जिससे डेवलपर उपयोगकर्ता के वातावरण के आधार पर व्यवहार या UI को अनुकूलित कर सकते हैं। यह पैकेज वेब एप्लिकेशन के लिए अनुकूलित है और Flutter के वेब प्लेटफॉर्म के साथ बिना किसी दिक्कत के एकीकृत होता है। यह क्लाइंट-साइड जावास्क्रिप्ट डिटेक्शन पर निर्भर है और कोई बाहरी निर्भरता नहीं है।

उपयोग

  • विभिन्न ब्राउज़र के लिए UI लेआउट का अनुकूलन
  • ऑपरेटिंग सिस्टम के आधार पर फीचर्स को शर्त के आधार पर सक्षम करना
  • प्लेटफॉर्म-विशिष्ट समस्याओं का निराकरण
  • ब्राउज़र के अनुसार प्रदर्शन अनुकूलित करें
  • ब्राउज़र सुविधा असंगतियों का प्रबंधन

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

  • हल्का और तेज़
  • कोई बाहरी निर्भरता नहीं
  • मुख्य ब्राउज़र और ओएस का समर्थन करता है
  • सरल एपीआई, स्पष्ट परिणाम
  • Flutter Web के लिए विशेष रूप से बनाया गया

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

  • वेब के लिए मात्र Flutter ऐप्स
  • क्रॉस-ब्राउज़र सुमेलता तर्क
  • पर्यावरण-संवेदनशील यूआई रेंडरिंग
  • विकासक उपकरण और निदान

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

  • केवल वेब प्लेटफॉर्म के लिए सीमित
  • ब्राउज़र/उपयोगकर्ता एजेंट स्ट्रिंग पर निर्भर करता है
  • नए ब्राउज़र संस्करण के लिए अपडेट की आवश्यकता हो सकती है
  • मोबाइल या डेस्कटॉप ऐप्स के लिए उपयुक्त नहीं

मूल README

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

codecov documentation

platform_detect

A library for detecting browser and platform type and version.

Usage

A simple usage example:

import 'package:platform_detect/platform_detect.dart';

main() {
  if (browser.isChrome) {
	print('thank you for being a friend');
  }

  if (operatingSystem.isMac) {
	print('');
  }
}

Decorating the <html> element with CSS classes

This library can also be used to place CSS classes on the <html> element based on the operating system, browser, or a specific supported feature.

Add the decorator.dart import as shown in the example below, and call decorateRootNodeWithPlatformClasses within main in your application.

import 'package:platform_detect/platform_detect.dart';
import 'package:platform_detect/decorator.dart';

main() {
  decorateRootNodeWithPlatformClasses();
}

The <html> node of your application will now look like something like this:

<html lang="en" class="ua-chrome ua-chrome45 ua-lt-chrome46 ua-lt-chrome47 os-mac no-touch no-mstouch">
  <!-- ... -->
</html>
Feature detection

By default, the only browser feature that the library detects for you is touch / mstouch.

You can extend this functionality to bake in a Modernizr-esque implementation by creating your own Feature instances, and passing a list of them as the features argument to decorateRootNodeWithPlatformClasses:

import 'package:platform_detect/platform_detect.dart';
import 'package:platform_detect/decorator.dart';

// For instance, if you need to detect whether a browser supports H5 canvas stuff...
var canvasFeature = new Feature('canvas', new CanvasElement().context2D != null);

main() {
  // Decorate HTML element
  decorateRootNodeWithPlatformClasses(features: [canvasFeature]);

  // Or use the `isSupported` field somewhere else in your app...
  if (canvasFeature.isSupported) {
    // Do something
  } else {
    // Fall back / warn / etc...
  }
}

The <html> node of your application will now look like something like this for browsers that support canvas:

<html lang="en" class="canvas ...">
  <!-- ... -->
</html>

and something like this for browsers that don't support canvas:

<html lang="en" class="no-canvas ...">
  <!-- ... -->
</html>

श्रेणियाँ

निर्भरताएँ

निर्भरता सूची 2 आइटम

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

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

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