Comments (6)
It seems for some reason this._containerKey.currentContext
is null
in captureAsUiImage(...)
. Anyways I used RepaintBoundary
instead and got it working.
from screenshot.
@tehsunnliu Can I get the minimum code to reproduce this issue? Did you wrap your widget with Screenshot Widget?
from screenshot.
@ritheshSalyan Hi, Thank you for your response. First of all my apologies. I should have tested my code more before opening an issue. While I was writing a sample code to reproduce the error I mentioned. I found that I was calling setState()
before calling screenshotController.capture(...)
which called build()
function. And in build function, I've added _screenshotControllers.clear();
which clears all the ScreenshotController
in that list. Hence, throwing NoSuchMethodError
.
However, this same implementation works fine with RepaintBoundary. I'm not sure how this doesn't affect RepaintBoundary.
Anyways below is the code which throws NoSuchMethodError.
import 'package:flutter/material.dart';
import 'package:screenshot/screenshot.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
bool _isSaving = false;
List<ScreenshotController> _screenshotControllers = [];
List<Widget> _widgets = [
Card(
child: ListTile(
leading: Icon(
Icons.person,
),
title: Text('Testing Screenshot 1'),
),
),
Card(
child: ListTile(
leading: Icon(
Icons.person,
),
title: Text('Testing Screenshot 2'),
),
),
];
@override
Widget build(BuildContext context) {
_screenshotControllers.clear();
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: SingleChildScrollView(
child: Column(
children: _widgets.map((e) {
ScreenshotController controller = ScreenshotController();
_screenshotControllers.add(controller);
return Screenshot(
controller: controller,
child: e,
);
}).toList(),
),
),
floatingActionButton: _isSaving
? CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation(Colors.white),
)
: FloatingActionButton(
onPressed: _saveWidgets,
tooltip: 'Save',
child: Icon(Icons.save),
),
);
}
void _saveWidgets() async {
setState(() {
_isSaving = true;
});
try {
for (int i = _screenshotControllers.length - 1; i >= 0; --i) {
var data =
await _screenshotControllers[i].capture(pixelRatio: 3);
print('ScreenshotData: $data');
}
} catch (e) {
print('failed to capture: $e');
debugPrintStack();
}
setState(() {
_isSaving = false;
});
}
}
from screenshot.
@tehsunnliu The code you have shared is working perfectly fine, It didn't throw any error,
Here Is the video Proof for working.
https://user-images.githubusercontent.com/44966372/118475356-c913eb00-b729-11eb-9a55-f7d6207652f5.mp4
Can I know your flutter version?
You can close this issue if it is working.
from screenshot.
Oh, I don't know why it's happening with me with the same code I haven't changed anything. Have you tried on debug mode?
I'll share the Flutter version as soon as I get access to my pc.
Thank you.
from screenshot.
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.6, on Linux, locale en_IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Chrome - develop for the web
[✓] Android Studio
[✓] Connected device (1 available)
• No issues found!
from screenshot.
Related Issues (20)
- arguments don't match. const ViewConfiguration({ No named parameter with the name 'size'. HOT 1
- Can't print Text to screenshot image (using command line to export image) 💦 HOT 1
- No named parameter with the name 'size' :: vs. 2.3.0 issue with Flutter (Channel master, 3.21.0-9.0.pre.29, on macOS) HOT 12
- Flutter web use HTML renderer along with screenshot controller?
- Sometimes screenshot return back null captured image HOT 1
- The argument type 'Null Function(Uint8List)' can't be assigned to the parameter type 'FutureOr<dynamic> Function(Uint8List?)'. HOT 2
- How can I remove the corner radius in an image? HOT 2
- Long widget didn't work HOT 4
- Cannot capture Overlays HOT 1
- Capturing Screenshot doesn't work in HookWidget HOT 1
- Unable to capture width screenshot in Sony Xperia IV device
- No MediaQuery widget ancestor found. HOT 2
- Screenshot fails when trying to take a screenshot - Flutter Web when website is viewed from a mobile (ios) device. HOT 2
- Not build with new flutter 3.22.0 HOT 3
- Error (Xcode): ../../../.pub-cache/hosted/pub.dev/screenshot-2.4.0/lib/screenshot.dart:165:9: Error: No named parameter with the name 'logicalConstraints'. HOT 2
- Error: No named parameter with the name 'logicalConstraints'. HOT 7
- i have update 2.3.0 to 2.4.0 and getting this error . HOT 10
- Crashes on Linux / Flutter 3.22 HOT 1
- upgrade the package to support latest flutter version v3.22.1 HOT 2
- Error: No named parameter with the name 'size' HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from screenshot.