In this section, we will add the functionality of FloatingActionButton to let the user choose an image from the gallery of the device. This will eventually be sent to the server so that we can receive a response.
The following steps describe how to launch the gallery and let the user choose an image:
- To allow the user to choose an image from the device's gallery, we will use the image_picker library. This launches the gallery and stores the image file selected by the user. We will start by adding a dependency in the pubspec.yaml file:
image_picker: 0.4.12+1
Also, we fetch the library by running flutter pub get on the Terminal.
- Next, we import the library inside the image_super_resolution.dart file:
import 'package:image_picker/image_picker.dart';
- Now, let's define the pickImage() ...