-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Craft better error message for OffsetLayer.toImage in the HTML renderer #49857
Comments
|
@domesticmouse would you be interested in fixing the error message in a PR that tells developers that this is not currently supported? |
I’m currently in I/O crunch, so I’m happy to look at this, but it’ll be a month or two before I have time. |
Is there any updates on this ? This feature would be much useful if it runs on web. I am getting
|
is there any solution to screenshot a widget on the web |
Also looking for a solution to take a screenshot of widgets on flutter web. |
1 similar comment
Also looking for a solution to take a screenshot of widgets on flutter web. |
I think this might help you this flutter example from @rxlabz allows you to save your canvas as a png image live on the web here and you can find the source code here |
@maheshmnj with the slight problem, unfortunately, that it isn't a |
@yjbanov Yegor, judging by the labels and commits, you might be the most active player in this area. :-) I have identified and collected four errors (some actually fork into two being different problems on DomCanvas and CanvasKit) that, although separate errors, all belong to the same group of picture manipulation, this one being one of them. All of them are such showstoppers for me that I started to delve into the engine, trying to fix myself. (All of them are reported here, by the way.) Just to recap:
Is there any way to have a few messages about these (eg. I think Ifound what's actually missing for the first to work but I don't know if it would be ever included or replaced with another functionality on the web), maybe out of band? Just to see if these (or anything that lies behind these errors) are being worked on actively and if there's anything to be had by us trying to work on them, too. |
@yjbanov I fixed the first problem, I'll move on with the second problem but it would be nice to be able to show you the fix. |
Verified and replicable on latest master and get below error message: error log
flutter doctor -v
|
https://github.com/flutter/photobooth |
Reproducible on the latest versions of flutter. code sampleimport 'dart:typed_data';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
GlobalKey globalKey = GlobalKey();
void _incrementCounter() async {
RenderRepaintBoundary boundary =
globalKey.currentContext!.findRenderObject() as RenderRepaintBoundary;
ui.Image image = await boundary.toImage(pixelRatio: 1);
ByteData? byteData =
await image.toByteData(format: ui.ImageByteFormat.png);
Uint8List? pngBytes = byteData?.buffer.asUint8List();
print('PNG Image size: ${pngBytes?.length}');
}
@override
Widget build(BuildContext context) {
return RepaintBoundary(
key: globalKey,
child: Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: const Center(
child: Text('Some text'),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
),
);
}
}
flutter doctor -v
|
I'm attempting to convert a Canvas widget's content to an image, using the following code. It works fine on iOS and macOS, but dies on the web.
VSCode console output:
JS Console stacktrace
The text was updated successfully, but these errors were encountered: