Skip to content
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

Update packages with breaking changes #133

Merged
merged 3 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions example/lib/_demos_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ class _TakeScreenshotPromptState extends State<_TakeScreenshotPrompt> {
String? _selectedPath;

Future<void> _selectFilePath() async {
final filePath = await getSavePath(
final fileLocation = await getSaveLocation(
acceptedTypeGroups: [
XTypeGroup(
extensions: [_imageFormat.extension],
Expand All @@ -739,7 +739,7 @@ class _TakeScreenshotPromptState extends State<_TakeScreenshotPrompt> {

if (mounted) {
setState(() {
_selectedPath = filePath;
_selectedPath = fileLocation?.path;
});
}
}
Expand Down Expand Up @@ -827,9 +827,9 @@ class _GenerateGifPromptState extends State<_GenerateGifPrompt> {
int _fps = 30;

Future<void> _selectFilePath() async {
final filePath = await getSavePath(
final fileLocation = await getSaveLocation(
acceptedTypeGroups: [
XTypeGroup(
const XTypeGroup(
extensions: ['gif'],
mimeTypes: ['image/gif'],
),
Expand All @@ -840,7 +840,7 @@ class _GenerateGifPromptState extends State<_GenerateGifPrompt> {

if (mounted) {
setState(() {
_selectedPath = filePath;
_selectedPath = fileLocation?.path;
});
}
}
Expand Down Expand Up @@ -978,7 +978,7 @@ class _GenerateScreenshotFramesPromptState extends State<_GenerateScreenshotFram
int _frameCount = 10;

Future<void> _selectFilePath() async {
final filePath = await getSavePath(
final fileLocation = await getSaveLocation(
acceptedTypeGroups: [
XTypeGroup(
extensions: [_imageFormat.extension],
Expand All @@ -991,12 +991,12 @@ class _GenerateScreenshotFramesPromptState extends State<_GenerateScreenshotFram

if (mounted) {
setState(() {
_selectedDirectory = filePath != null ? File(filePath).parent : null;
_selectedDirectory = fileLocation != null ? File(fileLocation.path).parent : null;

if (filePath != null) {
final fileName = FileName.fromFilePath(filePath);
if (fileLocation != null) {
final fileName = FileName.fromFilePath(fileLocation.path);
_titleTemplate = fileName.name.endsWith('#') ? fileName.name : '${fileName.name}_###';
_templatePath = filePath;
_templatePath = fileLocation.path;
} else {
_titleTemplate = 'frame_###';
}
Expand Down
8 changes: 4 additions & 4 deletions example/lib/_processing_demo_sketch_display.dart
Original file line number Diff line number Diff line change
Expand Up @@ -364,26 +364,26 @@ class ProcessingDemoState extends State<ProcessingDemo> with SingleTickerProvide

// Retrieve the pixel data for the current sketch painting.
final frameBytes = await image.toByteData();
final rawImageData = frameBytes!.buffer.asUint8List();
final rawImageBuffer = frameBytes!.buffer;

// Convert the pixel data to the desired format.
late List<int> formattedImageData;
switch (imageFormat) {
case ImageFileFormat.png:
formattedImageData = imageFormats.encodePng(
imageFormats.Image.fromBytes(image.width, image.height, rawImageData),
imageFormats.Image.fromBytes(width: image.width, height: image.height, bytes: rawImageBuffer),
);
break;
case ImageFileFormat.jpeg:
formattedImageData = imageFormats.encodeJpg(
imageFormats.Image.fromBytes(image.width, image.height, rawImageData),
imageFormats.Image.fromBytes(width: image.width, height: image.height, bytes: rawImageBuffer),
);
break;
case ImageFileFormat.tiff:
throw UnimplementedError('Tiff images are not supported in save()');
case ImageFileFormat.targa:
formattedImageData = imageFormats.encodeTga(
imageFormats.Image.fromBytes(image.width, image.height, rawImageData),
imageFormats.Image.fromBytes(width: image.width, height: image.height, bytes: rawImageBuffer),
);
break;
}
Expand Down
12 changes: 6 additions & 6 deletions example/lib/demos/_hacking_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,30 @@ class _HackingDemoState extends State<HackingDemo> {
break;
}

final filePath = await getSavePath(
final fileLocation = await getSaveLocation(
acceptedTypeGroups: [
XTypeGroup(
extensions: [extension],
mimeTypes: [mimeType],
),
],
);
if (filePath == null) {
if (fileLocation == null) {
print('User cancelled the file selection');
return;
}

_fileToSaveImage = File(filePath);
_fileToSaveImage = File(fileLocation.path);
}

Future<void> _saveImageFrame() async {
final filePath = await getSavePath();
if (filePath == null) {
final fileLocation = await getSaveLocation();
if (fileLocation == null) {
print('User cancelled the file selection');
return;
}

_dirToSaveFrames = File(filePath).parent;
_dirToSaveFrames = File(fileLocation.path).parent;
_remainingFrames = 10;
}

Expand Down
4 changes: 2 additions & 2 deletions example/lib/io/gif.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GifGenerator {

await sketch.loadPixels();

final gifFrame = gif.Image.fromBytes(sketch.width, sketch.height, sketch.pixels!.buffer.asUint8List());
final gifFrame = gif.Image.fromBytes(width: sketch.width, height: sketch.height, bytes: sketch.pixels!.buffer);
final timeInHundredths = (_gifFrameRateFps.inMilliseconds / 10).round();
_gifEncoder.addFrame(gifFrame, duration: timeInHundredths);
_addedFrameCount += 1;
Expand Down Expand Up @@ -68,7 +68,7 @@ class GifGenerator {
}

final frameBytes = await frame.toByteData();
final gifFrame = gif.Image.fromBytes(frame.width, frame.height, frameBytes!.buffer.asUint8List());
final gifFrame = gif.Image.fromBytes(width: frame.width, height: frame.height, bytes: frameBytes!.buffer);
_frames.add(gifFrame);
// final timeInHundredths = (_gifFrameRateFps.inMilliseconds / 10).round();
// _gifEncoder.addFrame(gifFrame, duration: timeInHundredths);
Expand Down
Loading
Loading