DEV Community

Cover image for 7 must know Flutter packages for beginners
Rijin Reji Thomas
Rijin Reji Thomas

Posted on

7 must know Flutter packages for beginners

As Flutter is gaining traction, more and more developers are trying to learn and understand this new framework. Flutter is easy as compared to android, it saves a lot of development time and also helps in implementing complex designs easily. But wait, how do you implement native features such as accessing the device camera or using location services in flutter? Sounds complex doesn't it? Well thankfully, Flutter supports shared packages contributed by other developers which can be used in Dart and Flutter ecosystem. So, instead of writing a code for a functionality from scratch, you can use a package which does the same thing, saving your valuable time!

Packages are very much similar to libraries, saving a lot of your precious time. The following list contains 10 packages which every Flutter developer must know!

Let's do this

1. dio

Most of the time while developing an application, we need to send some http requests to get some data or sometimes post some data. Dio is a powerful Http client for Dart, which supports Interceptors, Global configuration, FormData, Request Cancellation, File downloading, Timeout etc.

And it's super simple to use!

Example:

import 'package:dio/dio.dart';
void getHttp() async {
  try {
    Response response = await Dio().get("http://www.google.com");
    print(response);
  } catch (e) {
    print(e);
  }
}
Enter fullscreen mode Exit fullscreen mode

To know more about this package: Click here

2. location

Want to access the location of the user? then, location is the package that solves this problem.

Example.

import 'package:location/location.dart';
final currentLoc = await Location().getLocation();
print(currentLoc.latitude);
print(currentLoc.longitude); 
Enter fullscreen mode Exit fullscreen mode

You can also use it for displaying maps in your application, but you'll have to have the Google Maps API key for this functionality to work.

Maps

To know more about this package: Click here

3. image_picker

Developing apps require various functionalities such as taking a new picture using a camera or uploading an existing image from the gallery. Image_picker is a plugin for iOS and Android for picking images from the image library, and taking new pictures with the camera.

Example:

import 'package:image_picker/image_picker.dart';
File _image;
  final picker = ImagePicker();

  Future getImage() async {
    final pickedFile = await picker.getImage(source: ImageSource.camera);

    setState(() {
      if (pickedFile != null) {
        _image = File(pickedFile.path);
      } else {
        print('No image selected.');
      }
    });
  }
Enter fullscreen mode Exit fullscreen mode

To know more about this package: Click here

4. sqflite

Flutter doesn't have a built-in abstraction for accessing the SQLite Database. So using sqflite package, you can access the SQLite database in both Android and iOS. The popularity of this package is 100%, so its is a well managed package.

Example:

var databasesPath = await getDatabasesPath();
String path = join(databasesPath, 'demo.db');

Database database = await openDatabase(path, version: 1,
    onCreate: (Database db, int version) async {
  // When creating the db, create the table
  await db.execute(
      'CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT, value INTEGER, num REAL)');
});

Enter fullscreen mode Exit fullscreen mode

To know more about this package: Click here

5. cached_network_image

Loading images from the internet can take some time and because of which the user experience might not be that pleasant. It's always a nice idea to show a placeholder when the image is loading. Cached_network_image helps with this problem. Not only does it helps to provide a placeholder, but also stores the image in the cache, so whenever the user opens the application again, the image will be loaded from the cache which takes literally microseconds.

Example:

CachedNetworkImage(
        imageUrl: "http://via.placeholder.com/350x150",
        placeholder: (context, url) => CircularProgressIndicator(),
        errorWidget: (context, url, error) => Icon(Icons.error),
     ),
Enter fullscreen mode Exit fullscreen mode

To know more about this package: Click here

6. path_provider

File handling is one major feature while developing an application. There may be instances where the application needs to download a data and store it in your device. Path_provider helps you to get commonly used locations on the filesystem. You can access directories like Temporary directory, Documents directory, Downloads directory, etc and store files in these directories.

Example:

Directory tempDir = await getTemporaryDirectory();
String tempPath = tempDir.path;

Directory appDocDir = await getApplicationDocumentsDirectory();
String appDocPath = appDocDir.path;
Enter fullscreen mode Exit fullscreen mode

To know more about this package: Click here

7. local_auth

This Flutter plugin provides means to perform local, on-device authentication of the user. This includes biometric authentication iOS and fingerprint APIs on android.

Fingerprint

To know more about this package: Click here

Developers after knowing these packages be like:

Strong

Conclusion:

If this post was helpful then don't forget to like it and you can also add some more packages I might've missed out in the comments section.

Connect with me:

LinkedIn

Top comments (7)

Collapse
 
quantuminformation profile image
Nikos

I'm just waiting for iOS to release push for PWA and I can skip all this native stuff

Collapse
 
real_rijin profile image
Rijin Reji Thomas

Yeah, but pwa is not that efficient as compared to native

Collapse
 
quantuminformation profile image
Nikos

yes, but its efficient on my wallet and fine for business sites/apps

Thread Thread
 
real_rijin profile image
Rijin Reji Thomas

Yeah, that's trueeeee

Collapse
 
pablonax profile image
Pablo Discobar

If you are interested in this, you can also look at my article about Flutter templates. I made it easier for you and compared the free and paid Flutter templates. I'm sure you'll find something useful there, too. - dev.to/pablonax/free-vs-paid-flutt...

Collapse
 
akashkaintura profile image
AKASH KAINTURA

Thanks alot for sharing this.

Collapse
 
real_rijin profile image
Rijin Reji Thomas

Your welcome! I'll be sharing a lot more articles on Flutter, I hope they'll be helpful too...