सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
device_frame पैकेज आम डिवाइस के लिए कस्टमाइज़ करने योग्य मॉकअप प्रदान करता है, जिससे डेवलपर्स अपने Flutter ऐप्स को वास्तविक डिवाइस के संदर्भ में प्रीव्यू कर सकते हैं। यह Android, iOS, Web, macOS, Windows और Linux जैसे विभिन्न प्लेटफॉर्म का समर्थन करता है। प्रस्तुतियों, दस्तावेज़ीकरण और डिज़ाइन समीक्षा के लिए आदर्श, यह ऐप्स या विकास कार्यप्रवाह में आसानी से एकीकरण की अनुमति देता है। पैकेज में समायोज्य स्क्रीन आकार और ओरिएंटेशन के साथ पूर्व-निर्धारित डिवाइस फ्रेम प्रदान करता है, बाहरी उपकरणों के बिना दृश्य संचार को बढ़ावा देता है।
उपयोग
दस्तावेज़ में एप्प की पूर्वावलोकन
डिज़ाइन प्रेजेंटेशन मॉकअप्स
डिवाइस संदर्भ के साथ UI परीक्षण
डेवलपर प्रदर्शन
विकास के दौरान दृश्य प्रतिक्रिया
मुख्य विशेषताएँ
पूर्वनिर्धारित उपकरण प्रारूप
क्रॉस-प्लेटफ़ॉर्म समर्थन
कस्टमाइज़ किए गए फ्रेम आयाम
Flutter के साथ आसान एकीकरण
बहुत स्क्रीन ओरिएंटेशन का समर्थन करता है
इनके लिए उपयुक्त
Flutter विकासकर्ता
UI/UX डिजाइनर
तकनीकी लेखक
उत्पाद प्रबंधक
प्रस्तुति निर्माता
विचार योग्य बातें
उत्पादन ऐप UI के लिए नहीं बनाया गया है
नए उपकरणों के लिए हस्ताक्षरित फ्रेम अपडेट की आवश्यकता होती है
स्थिर मॉकअप रेन्डरिंग तक सीमित
कोई इंटरैक्टिव डिवाइस व्यवहार नहीं
सबसे अच्छा उपयोग डेव या डेमो परिवेश में किया जाता है
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
Simulate any device — screen, safe areas, locale, accessibility — with full framework fidelity.
You build on one screen; your users arrive on hundreds. Device Preview switches your running app to another device — an old 320pt phone, a tablet in landscape, a notched display, a half-width desktop window — instantly, with no rebuild and no simulator.
Screen size, pixel ratio, safe areas, orientation, folds, the software keyboard, locales, brightness, text scale, accessibility settings and target platform all change with it, and your app reads them through the same MediaQuery it always used. So the problems that normally surface in front of a customer — a clipped headline, a button under the home indicator, an overflow at 200% text — surface in front of you instead.
Control it from Flutter DevTools, from Dart, or from your tests.
Quickstart
dependencies:device_preview:<latestversion>
voidmain() {
DevicePreview.enable();
runApp(constMyApp()); // runs as usual — now simulatable
}
That's the whole integration. Open DevTools, select the device_preview tab, and pick a device.
enable() is safe to call unconditionally: simulation is active in debug and profile builds and completely off in release, so nothing ships to your users. Pass a value to decide yourself — DevicePreview.enable(enabled: kDebugMode) for debug only, DevicePreview.enable(enabled: false) to turn it off.
Programmatic control:
import'package:device_preview/presets.dart';
final c = DevicePreview.controller;
await c.applyPreset(DevicePresets.iPhone16Pro);
await c.setOrientation(Orientation.landscape);
await c.update((s) => s.copyWith(textScaleFactor: 2.0, platformBrightness: Brightness.dark));
await c.reset();
DevicePreview.controller throws when simulation is off (every release build); use DevicePreview.maybeController?.… from code that ships.
See device_preview/README.md for the full package documentation, including widget-test support via DevicePreviewBindingMixin.
The device catalog: one JSON per device — metrics, screen outline and body artwork. Generated into both the extension catalog and the package's built-in DevicePresets; see its README to add a device.
Legacy device frame drawings package from the 2.x era. Nothing in the 3.0 release depends on it — 3.0 renders frames from the device_specs artwork, carried by the built-in presets and pushed over the DevTools protocol.
The website, including its interactive demo — docs/demo is the counter example built for the web, docs/device_catalog.json the catalog its HTML panel pushes to it. Rebuild both with tool/build_demo.sh.