Fireship · @fireship

Flutter File Upload - Pick, Crop, and Save Images to the Cloud

Uploaded July 29, 2019 · Length 8:49

Flutter File Upload - Pick, Crop, and Save Images to the Cloud

Summary

Flutter tutorial on how to capture, crop, and upload images to the cloud using Firebase and Flutter plugins.

  • flutter file upload
  • firebase storage
  • image picker
  • image cropper
  • flutter plugins
  • cloud storage
  • flutter tutorial

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    today we'll learn how to do three

  2. 0:01

    distinct things in flutter first we'll

  3. 0:02

    capture an image from the device using

  4. 0:04

    the camera or photo gallery next we'll

  5. 0:06

    allow the user to crop rotate or scale

  6. 0:08

    the image file and lastly we'll upload

  7. 0:09

    the file to a cloud storage bucket and

  8. 0:11

    we'll even throw in a progress bar and a

  9. 0:13

    pause resume button just because it's so

  10. 0:15

    easy to do with flutter and firebase if

  11. 0:16

    you're new here like and subscribe and

  12. 0:18

    follow along with the full write-up on

  13. 0:19

    fire ship I own let's start by taking a

  14. 0:21

    closer look at what we'll build over the

  15. 0:23

    next few minutes you can see down here

  16. 0:24

    in the bottom bar we have two icon

  17. 0:25

    buttons tapping the camera will bring up

  18. 0:27

    the device camera and the image will

  19. 0:29

    bring up the image gallery when the user

  20. 0:30

    selects an image it will give us access

  21. 0:32

    to that file object in our dart code

  22. 0:34

    when the user taps the crop button it

  23. 0:35

    will bring up the image crop or widget

  24. 0:37

    allowing the user to manipulate the

  25. 0:38

    image and that magic is made possible by

  26. 0:40

    the awesome image crop rap legend and

  27. 0:42

    lastly when the user taps the upload to

  28. 0:44

    firebase button it will immediately

  29. 0:45

    start uploading the file to a firebase

  30. 0:47

    storage bucket the progress indicator

  31. 0:48

    will show the percentage of bytes

  32. 0:50

    transferred while the file is uploading

  33. 0:51

    and the user can also control the state

  34. 0:53

    of the upload by pausing or resuming

  35. 0:55

    them so that's a lot of functionality

  36. 0:56

    for a single YouTube video but I think

  37. 0:58

    you might be pleasantly surprised at how

  38. 0:59

    easy this stuff is to implement to get

  39. 1:01

    started you'll need to have a flutter

  40. 1:02

    app with firebase installed I'm not

  41. 1:04

    going to cover the firebase setup

  42. 1:05

    instructions in this video but you can

  43. 1:07

    follow the official instructions or take

  44. 1:08

    the full flutter course as a fire ship

  45. 1:10

    Pro member now if we go ahead and jump

  46. 1:12

    into the pub spec yamo file you can see

  47. 1:14

    we have firebase core and storage these

  48. 1:16

    are the only two firebase dependencies

  49. 1:17

    that you need if your only concern is

  50. 1:19

    uploading files to a cloud storage

  51. 1:21

    bucket but in our case we also want the

  52. 1:23

    user to interact with the native device

  53. 1:25

    camera and image gallery which we can do

  54. 1:27

    with image picker and then image cropper

  55. 1:29

    will allow the user to then manipulate

  56. 1:31

    the image after it's been selected and

  57. 1:32

    these plugins do have a small amount of

  58. 1:34

    platform specific configuration when it

  59. 1:36

    comes to image picker you'll need to go

  60. 1:38

    into your info.plist file for iOS and

  61. 1:40

    add the corresponding permissions for

  62. 1:42

    the photo library and camera and for

  63. 1:44

    image cropper there's no config for iOS

  64. 1:46

    but you do need to add an activity to

  65. 1:48

    your Android manifest file and you

  66. 1:50

    should always refer to the official

  67. 1:51

    documentation when installing a new

  68. 1:53

    plugin in flutter now moving over to our

  69. 1:55

    main dart file we'll go ahead and import

  70. 1:57

    these dependencies and the only other

  71. 1:59

    unusual thing is that we're importing