Chapter 8

  1. What is the purpose of adding the path and path_provider libraries into your app?
    The path package provides common operations for manipulating paths: joining, splitting, and normalizing. You can use path_provider to retrieve commonly used locations on the Android and iOS file systems, like the data folder.'

  2. In which files do you add the API key for Google Maps in your project for Android and/or iOS?
    For Android, you need to add the information into the android/app/src/main/AndroidManifest.xml application manifest. For iOS, you need to update the AppDelegate file at ios/Runner/AppDelegate.swift.

  3. When you pass the initialCameraPosition to a GoogleMap widget, which type of widget do you need to pass?
    When you pass the initialCameraPosition to a GoogleMap widget, you pass a CameraPosition, which in turn takes a LatLng object. An example is shown here:

CameraPosition( target: LatLng(41.9028, 12.4964),
zoom: 12,
);
  1. How can you get the current position of a device?
    You can use the Geolocator package: from a Geolocator instance, you can call the getCurrentPosition() method, that returns a Position object like shown in the following example: 

pos = await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.best);
  1. What is a Marker and when do you use it?
    A Marker identifies a location on a Map. You can use markers to show your user their current position, or any relevant position in the context of your app.

  2. When do you need to use a LatLng widget in a Marker?
    A Marker takes a LatLng in its position property, to identify its position on a map.

final marker = Marker(
position: LatLng(pos.latitude, pos.longitude)),
  1. Which is the method that returns a List of the available cameras on a device?
    The availableCameras() method of the camera package returns a List of the available cameras on a device.

  2. How can you show the camera preview to your users?
    The camera package contains a CameraController. Passing a CameraController, you can create an instance of a CameraPreview, that you can then show in your app. An example of using a CameraPreview is as follows:

cameraPreview = Center(child: CameraPreview(_controller));
  1. What's the purpose of a CameraController, and how do you create one?
    A CameraController, part of the camera package, establishes a connection to the device's camera, and you can use it to actually take the pictures. An example of creation is shown in the following code block:

_controller = CameraController(camera,
ResolutionPreset.medium,
);
  1. How do you take a picture in Flutter?
    In order to take a picture you need to retrieve a CameraController, and over that call the takePicture() method passing the path where you want to save the file like shown in the following example:

await _controller.takePicture(path);
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.30.178