sachinganesh / screenshot Goto Github PK
View Code? Open in Web Editor NEWFlutter Screenshot Library
Home Page: https://pub.dev/packages/screenshot
License: MIT License
Flutter Screenshot Library
Home Page: https://pub.dev/packages/screenshot
License: MIT License
I have a list of items in
ListView(), not ListView.builder(). And in the ListView each child is wrapped with Screenshot widget.
When the ListView is built I store the Screenshot controller for each widget in a list.
When trying to capture only the first widget gets captured and then I get this exception
/flutter ( 2557): Caught error: NoSuchMethodError: The method 'findRenderObject' was called on null.
I/flutter ( 2557): Receiver: null
I/flutter ( 2557): Tried calling: findRenderObject()
I/flutter ( 2557): #0 ScreenshotController.capture.<anonymous closure>
package:screenshot/screenshot.dart:41
I/flutter ( 2557): #1 new Future.delayed.<anonymous closure> (dart:async/future.dart:326:39)
I/flutter ( 2557): #2 _rootRun (dart:async/zone.dart:1182:47)
I/flutter ( 2557): #3 _CustomZone.run (dart:async/zone.dart:1093:19)
I/flutter ( 2557): #4 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
I/flutter ( 2557): #5 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
I/flutter ( 2557): #6 _rootRun (dart:async/zone.dart:1190:13)
I/flutter ( 2557): #7 _CustomZone.run (dart:async/zone.dart:1093:19)
I/flutter ( 2557): #8 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1021:23)
I/flutter ( 2557): #9 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
I/flutter ( 2557): #10 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:397:19)
I/flutter ( 2557): #11 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:428:5)
I/flutter ( 2557): #12 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
Hello, guys!
Would it be possible to take a 'printscreen' of the entire application window? As if it were a printscreen (manual) where an 'extender' button appears?
Because in my application there is information down there and the 'printscreen' cannot remove it from the bottom of the window.
Can someone help me?
Thanks!
Steps to reproduce:
Like so:
@override
Widget build(BuildContext context) {
return RepaintBoundary(
key: ScreenShotable.previewContainer,
child: widget.child,
);
}
Usage:
final img = await screenshotController.captureAsUiImage(
Container(
height: 100,
width: 100,
color: Colors.brown,
child: GoogleMap(
initialCameraPosition: CameraPosition(
target: FlitLatLng(-20.1020344, 57.5621812999999).toLatLng(),
zoom: 13.0,
),
rotateGesturesEnabled: false,
tiltGesturesEnabled: false,
// markers: Set<Marker>.of(controller.markers.values),
),
),
delay: Duration(seconds: 6));
ScreenshotControllers.captureAsUiImage
RenderRepaintBoundary boundary =
this.view!.context.findRenderObject() as RenderRepaintBoundary;
ui.Image image = await boundary.toImage(pixelRatio: pxRatio); // crash here
Actual:
Error: Unexpected null value.
at Object.throw_ [as throw] (http://localhost:49196/dart_sdk.js:5037:11)
at Object.nullCheck (http://localhost:49196/dart_sdk.js:5362:30)
at _engine.PlatformViewLayer.new.preroll (http://localhost:49196/dart_sdk.js:135222:12)
at _engine.OffsetEngineLayer.new.prerollChildren (http://localhost:49196/dart_sdk.js:134614:15)
at _engine.OffsetEngineLayer.new.preroll (http://localhost:49196/dart_sdk.js:134881:35)
at _engine.OffsetEngineLayer.new.prerollChildren (http://localhost:49196/dart_sdk.js:134614:15)
at _engine.OffsetEngineLayer.new.preroll (http://localhost:49196/dart_sdk.js:134881:35)
at _engine.TransformEngineLayer.new.prerollChildren (http://localhost:49196/dart_sdk.js:134614:15)
at _engine.TransformEngineLayer.new.preroll (http://localhost:49196/dart_sdk.js:134881:35)
at _engine.RootLayer.new.prerollChildren (http://localhost:49196/dart_sdk.js:134614:15)
at _engine.RootLayer.new.preroll (http://localhost:49196/dart_sdk.js:134609:31)
at _engine.LayerTree.new.flatten (http://localhost:49196/dart_sdk.js:135508:22)
at _engine.LayerScene.new.toImage (http://localhost:49196/dart_sdk.js:135263:36)
at layer$.OffsetLayer.new.toImage (http://localhost:49196/packages/flutter/src/rendering/layer.dart.js:1327:30)
at toImage.next (<anonymous>)
at runBody (http://localhost:49196/dart_sdk.js:37393:34)
at Object._async [as async] (http://localhost:49196/dart_sdk.js:37424:7)
at layer$.OffsetLayer.new.toImage (http://localhost:49196/packages/flutter/src/rendering/layer.dart.js:1318:20)
at proxy_box.RenderRepaintBoundary.new.toImage (http://localhost:49196/packages/flutter/src/rendering/proxy_box.dart.js:3096:26)
at captureFromWidget (http://localhost:49196/packages/screenshot/screenshot.dart.js:242:44)
at captureFromWidget.next (<anonymous>)
at http://localhost:49196/dart_sdk.js:37374:33
at _RootZone.runUnary (http://localhost:49196/dart_sdk.js:37245:59)
at _FutureListener.thenAwait.handleValue (http://localhost:49196/dart_sdk.js:32501:29)
at handleValueCallback (http://localhost:49196/dart_sdk.js:33028:49)
at Function._propagateToListeners (http://localhost:49196/dart_sdk.js:33066:17)
at _Future.new.[_complete] (http://localhost:49196/dart_sdk.js:32906:25)
at http://localhost:49196/dart_sdk.js:32085:30
at internalCallback (http://localhost:49196/dart_sdk.js:24224:11)
Expected:
No crash. Even better if we get the screenshot of the map.
On Mobile, we get blank screen.
Further debugging:
I tried with my own code above and even with the https://pub.dev/packages/screenshot package. Same result
If you have any clue on what the error above means, I would appreciate, even a small comment. It will help me find a workaround
Hello,
I tried using this plugin with a widget with google maps in it. It captures the screen but without the maps part. It appears blank.
Appreciate if you can help.
Thanks
Hello,
I have 10 items in a list and if they can not visible in screen they are not showing in screenshot also. how can i capture screenshot for whole list of data.
Is it possible to take the screenshot of this entire widget?
Stack(
clipBehavior: Clip.none,
alignment: Alignment.center,
children: [
Container(
color: Colors.red,
width: 20,
height: 20,
),
Positioned(
top: -10,
child: Container(
color: Colors.green,
width: 20,
height: 20,
),
),
Positioned(
top: -20,
child: Container(
color: Colors.bue,
width: 20,
height: 20,
),
),
],
)
I'm only getting the first one and the half of the second one; probably because the other ones are being overflown
Excellent Package you got here! So I tried capturing invisible widget but I get this error which I can't fathom.
[ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: 'package:screenshot/screenshot.dart': Failed assertion: line 92 pos 12: 'logicalSize.aspectRatio == imageSize.aspectRatio': is not true.
E/flutter ( 6791): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39)
E/flutter ( 6791): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
E/flutter ( 6791): #2 ScreenshotController.captureFromWidget (package:screenshot/screenshot.dart:92:12)
E/flutter ( 6791): #3 _BeginState.build.<anonymous closure> (package:Phoenix/src/Begin/begin.dart:243:50)
E/flutter ( 6791): #4 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:989:21)
E/flutter ( 6791): #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter ( 6791): #6 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:607:11)
E/flutter ( 6791): #7 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:296:5)
E/flutter ( 6791): #8 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:230:7)
E/flutter ( 6791): #9 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:475:9)
E/flutter ( 6791): #10 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:93:12)
E/flutter ( 6791): #11 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:138:9)
E/flutter ( 6791): #12 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:397:8)
E/flutter ( 6791): #13 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:136:18)
E/flutter ( 6791): #14 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:122:7)
E/flutter ( 6791): #15 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:439:19)
E/flutter ( 6791): #16 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:419:22)
E/flutter ( 6791): #17 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:287:11)
E/flutter ( 6791): #18 GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:374:7)
E/flutter ( 6791): #19 GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:338:5)
E/flutter ( 6791): #20 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:296:7)
E/flutter ( 6791): #21 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:279:7)
E/flutter ( 6791): #22 _rootRunUnary (dart:async/zone.dart:1370:13)
E/flutter ( 6791): #23 _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter ( 6791): #24 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
E/flutter ( 6791): #25 _invoke1 (dart:ui/hooks.dart:182:10)
E/flutter ( 6791): #26 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:282:7)
E/flutter ( 6791): #27 _dispatchPointerDataPacket (dart:ui/hooks.dart:96:31)
I used the same code used in the example
IconButton(
icon: Icon(Ionicons.barcode_outline),
color: Colors.white,
iconSize: deviceWidth / 18,
onPressed: () {
ScreenshotController screenshotController = ScreenshotController();
screenshotController
.captureFromWidget(Container(
padding: const EdgeInsets.all(30.0),
decoration: BoxDecoration(
border: Border.all(color: Colors.blueAccent, width: 5.0),
color: Colors.redAccent,
),
child: Text("This is an invisible widget")))
.then((capturedImage) {
// Handle captured image
});
});
Would you please help me out here?
Edit: Turns out this only happens in debug mode and works fine in release. I don't know whether this is an intended behavior or not. If it is intended, then feel free to close this issue.
what's your license please?
I am using the previous version 0.2.0 of screenshot and it support capture as File. With the new 0.3.0, it is now Uint8List.
How do I convert Uint8List into File ?
screenshotController.capture().then((Uint8List image) {
//Capture Done
setState(() {
_imageFile = image;
print("the image file is "+_imageFile.toString());
});
}).catchError((onError) {
print(onError);
});
iam using this code its working fine in mobile(android+ios) but not working in web
throwing this error -- "Unsupported operation: toImage is not supported on the Web"
Ability to capture screenshots of individual widgets in a list
Hello, just implemented this package, when I call:
final captureImage = await screenshotController.captureAsUiImage(pixelRatio: 2);
final data = await captureImage.toByteData(format: ui.ImageByteFormat.png);
return CaptureResult(data?.buffer?.asUint8List(), captureImage.width, captureImage.height);
I got this error:
E/flutter (25668): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: 'package:flutter/src/rendering/proxy_box.dart': Failed assertion: line 2958 pos 12: '!debugNeedsPaint': is not true.
E/flutter (25668): #0 ScreenshotController.captureAsUiImage.<anonymous closure>
package:screenshot/screenshot.dart:78
E/flutter (25668): #1 new Future.delayed.<anonymous closure> (dart:async/future.dart:326:39)
E/flutter (25668): #2 _rootRun (dart:async/zone.dart:1182:47)
E/flutter (25668): #3 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (25668): #4 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter (25668): #5 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
E/flutter (25668): #6 _rootRun (dart:async/zone.dart:1190:13)
E/flutter (25668): #7 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (25668): #8 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1021:23)
E/flutter (25668): #9 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
E/flutter (25668): #10 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:397:19)
E/flutter (25668): #11 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:428:5)
E/flutter (25668): #12 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
E/flutter (25668):
Please help. Thank you.
Hello, is there a solution to save the screenshot as jpg ?
or maybe a way to convert the png in jpg not using image plugin...
thank you so much for your help !
I am trying to use this with flutter web but I think it might be not supported because I get an error:
Assertion failed: org-dartlang-sdk:///flutter_web_sdk/lib/_engine/engine/surface/scene_builder.dart:111:16
matrix4[0] == window.devicePixelRatio &&
matrix4[5] == window.devicePixelRatio
is not true
can you update that please
Hello @SachinGanesh thanks for the package. I'm trying to screenshot a part of the widget tree but I need to add some custom widgets to the screenshot, those widgets in the screenshot should not be shown on the screen. Is there a way to achieve this using this package?
This library uses a really old path_provider version. Can you update to the latest one ?
Hi,
Is it possible to make it able to take a screen shot of surface view on Android?
It only generate a blank screen as of now.
It is helping me only to capture the flutter application screen/widget even I am using any other application. But I want to track all activities on the machine while flutter application is running in background. for example when flutter app is running in background and chrome is active on screen, it should capture present visible screen of the machine.
Is there a way to implement watermarks for the screenshots you take? I have been trying to figure out how can that be possible. I tried using the visibility widget but to no avail sadly.
W/System.err(25434): java.io.FileNotFoundException: /storage/emulated/0/example/1572487834458.png (No such file or directory)
W/System.err(25434): at java.io.FileOutputStream.open0(Native Method)
W/System.err(25434): at java.io.FileOutputStream.open(FileOutputStream.java:308)
W/System.err(25434): at java.io.FileOutputStream.(FileOutputStream.java:238)
W/System.err(25434): at java.io.FileOutputStream.(FileOutputStream.java:180)
W/System.err(25434): at com.example.imagegallerysaver.ImageGallerySaverPlugin.saveImageToGallery(ImageGallerySaverPlugin.kt:61)
W/System.err(25434): at com.example.imagegallerysaver.ImageGallerySaverPlugin.onMethodCall(ImageGallerySaverPlugin.kt:33)
W/System.err(25434): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
W/System.err(25434): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
W/System.err(25434): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:656)
W/System.err(25434): at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err(25434): at android.os.MessageQueue.next(MessageQueue.java:332)
W/System.err(25434): at android.os.Looper.loop(Looper.java:168)
W/System.err(25434): at android.app.ActivityThread.main(ActivityThread.java:6867)
W/System.err(25434): at java.lang.reflect.Method.invoke(Native Method)
W/System.err(25434): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
W/System.err(25434): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:876)
platform: android
android version: 9.1
flutter doctor:
[✓] Flutter (Channel stable, v1.9.1+hotfix.5, on Mac OS X 10.14.5 18F132, locale en-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.0)
[✓] Android Studio (version 3.4)
[✓] VS Code (version 1.39.1)
[✓] Connected device (1 available)
I have to add an image to my MapBox map so I want to build a Widget, capture it as an image, and then send it into the map. The Widget is not going to be rendered on-screen at all in the context. Here's my code for creating the image and passing it to the MapBoxController:
Future<void> _addImageFromPOI(MapboxMapController controller, POI poi) async {
// Create an image from the POI icon information
// Needs to build a widget and then draw an image of it for use on the map
// Uint8List _imageFile;
ScreenshotController screenshotController = ScreenshotController();
POIWidget widget = POIWidget(poi: poi);
Screenshot(
controller: screenshotController,
child: widget,
);
await screenshotController.capture().then((Uint8List image) {
controller.addImage(poi.docId, image);
controller.addSymbol(
SymbolOptions(
geometry: LatLng(poi.latitude, poi.longitude),
iconImage: poi.docId,
),
);
}).catchError((onError) {
print(onError);
});
}
... and I am getting an error:
The method 'findRenderObject' was called on null.
- I suspect that this is because the Widget is not being rendered on the context. Is this correct?
this._screenshotOwner
.capture(delay: Duration(milliseconds: 10), pixelRatio: 3)
.then((File captureImage) async {
Map<PermissionGroup, PermissionStatus> permissionResult = await PermissionHandler().requestPermissions([PermissionGroup.storage]);
if (permissionResult[PermissionGroup.storage] != PermissionStatus.granted) throw "Permission Denied";
final result = await ImageGallerySaver.saveImage(captureImage.readAsBytesSync());
print(result);
});
This plugin not captured widget Google Map.
flutter doctor -v
[✓] Flutter (Channel beta, 1.24.0-10.2.pre, on Mac OS X 10.15.7 19H2 darwin-x64, locale en-EC)
• Flutter version 1.24.0-10.2.pre at /Users/yudisetiawan/fvm/versions/beta
• Framework revision 022b333a08 (4 weeks ago), 2020-11-18 11:35:09 -0800
• Engine revision 07c1eed46b
• Dart version 2.12.0 (build 2.12.0-29.10.beta)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/yudisetiawan/Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.0.1, Build version 12A7300
• CocoaPods version 1.10.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] IntelliJ IDEA Community Edition (version 2020.2.3)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
[✓] VS Code (version 1.50.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.16.0
[✓] Connected device (3 available)
• Redmi Note 4 (mobile) • faa168ce9804 • android-arm64 • Android 7.0 (API 24)
• Web Server (web) • web-server • web-javascript • Flutter Tools
• Chrome (web) • chrome • web-javascript • Google Chrome 87.0.4280.88
• No issues found!
Can I take desktop screenshot (not want to take widget screenshot), how?
For example, a ListView or a large artboard。
capture()
method does not work on Windows because the paths in windows use \
while your package is using /
which works for other platforms. I would suggest adding a check to see if the platform is windows or not and add the path separator accordingly
It would be useful for UX to have a screenshot animation, when the screenshot is taken - maybe something similar to this.
I am trying to take screenshot of web page (WebView) on my app. It is giving below error.
E/flutter (10118): [ERROR:flutter/flow/layers/platform_view_layer.cc(25)] Trying to embed a platform view but the PrerollContext does not support embedding
E/flutter (10118): [ERROR:flutter/flow/layers/platform_view_layer.cc(40)] Trying to embed a platform view but the PaintContext does not support embedding
screenshot: ^0.2.0
was working perfectly fine till I updated Flutter to 2.0 and Screenshot Package to screenshot: ^1.0.0-nullsafety.1
I started getting "NoSuchMethodError: The method 'toImage' was called on null." exception.
I'm calling screenshotController.capture()
method.
The exception is thrown inside captureAsUiImage()
method when it tries to call boundary.toImage(...);
This happens when I try to capture multiple widgets screenshot.
I've multiple CardView
inside a Column
which is wrapped with Screenshot
widget. When I try to all .capture()
for each ScreenshotController
only the first call to capture
works and for the rest it throws NoSuchMethodError
I've also tried increasing the delay, however, no success.
Is there any version related to null safety support? I couldn't find it. If not, is there any plan to do it?
It would be helpful to have the controller constructor as const to drop the warning when I am using it.
Note the following compilation warning; delay is not nullable so the ??
operation is redundant.
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/screenshot-1.1.0/lib/screenshot.dart:45:31: Warning: Operand of null-aware operation '??' has type 'Duration' which excludes null.
- 'Duration' is from 'dart:core'.
return new Future.delayed(delay ?? Duration(milliseconds: 20), () async {
The plugin works pretty well, but when I export the image it is saved as a full page screenshot with the widget that I am taking screenshot of in center and black area on top and bottom. Is it possible to create dimensions that we can use to take screenshot like providing a specific height and width. Or cropping it to the specified dimensions before saving in gallery.
Text styling in my screenshot goes bananas when I style with Theme.of(context).textTheme.*
but the screenshot will look okay if I hardcode text styles. This was reproducible in our iOS and Android emulators with Flutter v2.0.6
and screenshot: ^1.2
. Examples below, let us know if there's anything else that'll be useful to provide for debugging!
Hardcoded Text Style Example
What screenshot looks like when we are hardcoding text style (which is correct and matches what widget looks like in app):
// Widget code that gets captured
return Column(
children: [
Text(
'Title Header Font 24',
textAlign: TextAlign.center,
style: TextStyle( // <----- hardcoded to match our Theme.of(context).textTheme.headline6
fontFamily: 'Rubik',
fontSize: 24,
color: Colors.black,
height: 1,
),
),
Text(
'Tilte Font 40',
textAlign: TextAlign.center,
style: TextStyle( // <----- hardcoded to match our Theme.of(context).textTheme.headline1
fontFamily: 'Rubik',
fontSize: 40,
fontWeight: FontWeight.bold,
color: Colors.black,
height: 1,
),
),
],
);
Broken Styling Using Theme Example
When using Theme.of(context).textTheme
:
// Widget code that gets captured
return Column(
children: [
Text(
'Title Header Font 24',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.headline6,
),
Text(
'Tilte Font 40',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.headline1,
),
],
);
In case it's useful, this is how we're capturing:
final ScreenshotController controller = ScreenshotController();
final Uint8List imageBytes = await controller.captureFromWidget(widget);
final String tempPath = (await getTemporaryDirectory()).path;
final File file = File('$tempPath/$filename');
// Render a preview of cached image file in the app + combine with share extensions
font in pubspec.yaml
flutter:
fonts:
- family: Rubik
fonts:
- asset: assets/fonts/Rubik-Regular.ttf
- asset: assets/fonts/Rubik-Bold.ttf
weight: 700
i am taking screenshot in list view but it is not working and showing error like "Multiple widgets used the same GlobalKey."
Please document somewhere that the App directory cannot be read from another app, this is by design and I understand this fully. When the image is stored in the App directory(as suggested in your write-up) gMail app cannot attach the file. I would suggest to use the Temp directory for this instead of the App directory. Also with a mention about this intricate situation.
Mario
Hi
I am working with animations in my app
there are any way to convert the animations in video o gif ?
I have been trying to capture a widget which has images in it, and unfortunately, images are not captured in the screenshot
I have been trying to screen capture a picture of WebView and the result that I get is an empty picture. Do you have a solution to solve them? I had no error in the command line, it only sent me an empty picture. Thank you in advance.
Hi,
I am using this lib and the https://pub.dev/packages/video_player, but seems dont work correctly.
The generate image is always black, anyone knows how to fix this?
Thanks
Hi,
We are using PDFTron for viewing PDF in Flutter but when we use the screenshot, it is not showing. The rest of the screen can capture except for the pdftron documentview.
I'm having multiple tables which are introduced inside a SingleChildScrollView. I'm using the Screensot as the parent widget in the body of the Scaffold, but when i caputre the screenshot I'm just getting the image only which is visible to the user but not all the tables when scrolled down/up.
ScreenshotController screenshotController = ScreenshotController();
body: Screenshot(
controller: screenshotController,
child: TabBarView(
children: [
SingleChildScrollView(
child: Padding(
padding: EdgeInsets.only(bottom: 50.h.toDouble()),
child: Column(children: v0),
),
),
SingleChildScrollView(child: Column(children: v1)),
SingleChildScrollView(child: Column(children: v2)),
SingleChildScrollView(child: Column(children: v3)),
],
controller: _tabController,
),
),
And the onPress function while capturing the screenshot
CaptureScreenshot() async {
final uint8List = await screenshotController.capture();
String tempPath = (await getTemporaryDirectory()).path;
File file = File('$tempPath/image.png');
await file.writeAsBytes(uint8List!);
await Share.shareFiles([file.path]);
}
And as i've went through other answers in issues found that the ScreenShot widget should be placed inside a SingleChildScrollView but if i use the SingleChildScrollView as the parent widget for the ScreenShot widget I'm getting an error as
RenderBox was not laid out: RenderRepaintBoundary#4b20b relayoutBoundary=up1 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1930 pos 12: 'hasSize'
Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
I'm trying to capture a screenshot of a drawing. On the phone is works great.
On an iPad pro iOS 14.4 (didn't try others) it is very blurred. Trying different pixel ratio parameters doesn't seem to help.
Using the latest version of Screenshot.
I have tried this package in my integration tests but didnt have any success. Is it possible to do this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.