सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
स्क्रीनशॉट पैकेज किसी भी फ्लटर विंडगेट को कई प्लेटफॉर्मों पर रनटाइम में छवि के रूप में कैप्चर करने की अनुमति देता है। यह डेवलपर्स को एप्लिकेशन निष्पादन के दौरान विंडगेट्स के स्क्रीनशॉट लेने की अनुमति देता है, जो डिबगिंग, टेस्टिंग या दृश्य सामग्री साझा करने के लिए उपयोगी है। पैकेज एंड्रॉइड, आईओएस, वेब, मैकओएस, विंडोज और लिनक्स को सपोर्ट करता है, जिससे यह बहुत लचीला हो जाता है। यह फ्लटर के रेंडरिंग पाइपलाइन के साथ बिना किसी दिक्कत के एकीकृत होता है और विंडगेट ट्री से छवि बनाने के लिए एक सरल API प्रदान करता है। डायनामिक छवि उत्पादन या दृश्य प्रतिक्रिया की आवश्यकता वाले ऐप्स के लिए आदर्श है।
उपयोग
UI समस्याओं का निदान करें
साझा करने योग्य छवियाँ बनाना
स्वचालित परीक्षण
दृश्य दस्तावेज़
एप ट्यूटोरियल्स
पूर्वावलोकन विशेषताएं
मुख्य विशेषताएँ
रनटाइम विजेट स्क्रीनशॉट कैप्चर
क्रॉस-प्लेटफ़ॉर्म समर्थन
सरल API एकीकरण
उच्च गुणवत्ता वाली छवि आउटपुट
सभी प्रमुख प्लेटफॉर्म का समर्थन करता है
कोई बाहरी निर्भरता नहीं
इनके लिए उपयुक्त
गतिशील स्क्रीनशॉट की आवश्यकता वाले डेवलपर्स
परीक्षण और गुणवत्ता आश्वासन टीमें
दृश्य साझाकरण विशेषताओं वाले ऐप्स
शैक्षिक या पाठ्यक्रम एप्लिकेशन
UI प्रोटोटाइपिंग टूल्स
जटिल लेआउट का डीबगिंग
विचार योग्य बातें
बड़े विजेट्स पर प्रदर्शन प्रभाव
उच्च-रिज़ॉल्यूशन छवियों के लिए मेमोरी उपयोग
मोबाइल प्लेटफॉर्म पर उचित अनुमति की आवश्यकता होती है
वास्तविक समय वीडियो कैप्चर के लिए उपयुक्त नहीं
स्थिर विजेट स्नैपशॉट तक सीमित
प्लेटफॉर्म-विशिष्ट कॉन्फ़िगरेशन की आवश्यकता हो सकती है
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
A simple package to capture widgets as Images. Now you can also capture the widgets that are not rendered on the screen!
You can capture a long Invisible widgets by using captureFromLongWidget function.
var randomItemCount = Random().nextInt(100);
////// Step 1: Create Long widget using Column.///var myLongWidget = Builder(builder: (context) {
returnContainer(
padding: constEdgeInsets.all(30.0),
decoration: BoxDecoration(
border:
Border.all(color: Colors.blueAccent, width: 5.0),
color: Colors.redAccent,
),
////// Note: Do not use Scrolling widget, instead place your children in Column. /// /// Do not use widgets like 'Expanded','Flexible',or 'Spacer'///
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
for (int i = 0; i < randomItemCount; i++)
Text("Tile Index $i"),
],
));
});
////// Step 2: /// Use `captureFromLongWidget` function for taking screenshot.///
screenshotController
.captureFromLongWidget(
InheritedTheme.captureAll(
context,
Material(
child: myLongWidget,
),
),
delay: Duration(milliseconds: 100),
context: context,
////// Additionally you can define constraint for your image.////// constraints: BoxConstraints(/// maxHeight: 1000,/// maxWidth: 1000,/// )
)
.then((capturedImage) {
// Handle captured image
});
Saving images to Specific Location
For this you can use captureAndSave method by passing directory location. By default, the captured image will be saved to Application Directory. Custom paths can be set using path parameter. Refer path_provider
Note
Method captureAndSave is not supported for web.
final directory = (await getApplicationDocumentsDirectory ()).path; //from path_provide packageString fileName = DateTime.now().microsecondsSinceEpoch;
path = '$directory';
screenshotController.captureAndSave(
path //set path where screenshot will be saved
fileName:fileName
);
Saving images to Gallery
If you want to save captured image to Gallery, Please use https://github.com/hui-z/image_gallery_saver
Example app uses the same to save screenshots to gallery.
Sharing Captured Images
await _screenshotController.capture(delay: constDuration(milliseconds: 10)).then((Uint8List image) async {
if (image != null) {
final directory = awaitgetApplicationDocumentsDirectory();
final imagePath = awaitFile('${directory.path}/image.png').create();
await imagePath.writeAsBytes(image);
/// Share PluginawaitShare.shareFiles([imagePath.path]);
}
});
Note:
Captured image may look pixelated. You can overcome this issue by setting value for pixelRatio
The pixelRatio describes the scale between the logical pixels and the size of the output image. It is independent of the window.devicePixelRatio for the device, so specifying 1.0 (the default) will give you a 1:1 mapping between logical pixels and the output pixels in the image.