
yulkin
Programming Flutter: Image.toByteData() does not exist (page40)
your book suggests to use Image.toByteData() to convert image to bytes, however I get the following error: "the getter ‘toByteData’ isn’t defined for the type ‘Image’. "
I tried importing the dart:typed_data package, but seems that this method does not exist. Can you please explain how to access it? It would be very useful for my app.
Most Liked

carminezacc
I’m terribly sorry for being so late to answer, but I wasn’t 100% aware of how DevTalk worked and I wasn’t getting notified of new posts, but now it should never happen again.
Anyway, you’re confusing the dart:ui’s Image class with the Image widget, on page 253 there is a little section about using ui.Image with a link to the page of the official reference about it, which tells you how to get an ui.Image object, in that code you’re just getting an Image widget and trying to cast it to an ui.Image object, when instead you should follow the instructions in the book (and in the official reference).
What you’re actually trying to do seems to me to have nothing to do with the Image object, as you can get the bytes for the image by running readAsBytes on the io.File directly.
Hope this answers your question, feel free to reply back and, again, I’m really sorry for being very late.
Popular Prag Prog topics







Modern Front-End Development for Rails - application does not start after run bin/setup (page xviii)



Other popular topics










Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /haskell
- /java
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /scala
- /zig
- /html
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /sublime-text
- /react-native
- /arch-linux
- /revery
- /ubuntu
- /manjaro
- /spring
- /django
- /diversity
- /nodejs
- /lua
- /c
- /julia
- /slackware
- /neovim
- /vapor