Articles

Flutter Developers’ Preferred Dart Packages

Top Dart Packages

Dart is the programming language used by Flutter. Dart.dev has a large and active community that offers officially supported third-party tools to make Flutter development more productive.

Developers contribute to keeping shared packages in Flutter, allowing us to create apps without much push or bustle. It prevents developers from having to start from scratch. Classes can be used to request network (HTTP), custom navigation route handling in Fluro, API integration, and making use of a third-party platform, among other things.

Packages are used in the Dart ecosystem to handle common software such as libraries and tools. You must use the pub package manager to receive Dart packages. You can locate publicly available packages at the pub. dev website or you can load packages from your local file system or elsewhere, exactly like you would with Git repositories. The pub maintains version dependencies and allows you to receive package versions that operate with each other and with your SDK version regardless of where your packages come from.

Most Dart-savvy IDEs enable pub, which includes generating, downloading, updating, and publishing packages. Alternatively, you can use pub on the command line.

A Dart package could be as simple as a directory containing a pubspec file. The pubspec contains some package-specific metadata. A package may also include dependencies (specified in the pubspec), Dart libraries, apps, resources, tests, pictures, and examples.

To use a package, do the following:

  • Create a pubspec (a file named pubspec.yaml that lists package dependencies and includes other metadata, like a version number).
  • Use pub to obtain your package’s dependencies.
  • If your Dart code depends on a library within the package, import the library.

This article lists the most promising and popular packages to prove you with an idea of Flutter’s maturity as a platform

Dart Packages

HTTP

Since everything nowadays is web-based, the HTTP library is a must-have. This Dart package contains a collection of high-level functions and classes that make it easy to consume HTTP resources. The Dart team has worked hard to build and maintain it. It’s been around since 2012. Therefore it’s bound to be reliable!

The library offers top-level functions that make it easy to work with HTTP:

import 'package:http/http.dart' as http;# Posting data

var url = 'https://example.com/whatsit/create';

var data = {'name': 'Jack', 'age': 38};var response = await http.post(url, body: data);print('Response status: ${response.statusCode}');

print('Response body: ${response.body}');# A simple GET request

print(await http.read('https://example.com/foobar.txt'));

Firebase Storage

This package acts as a container for platform-specific persistent storage libraries. It is an important flutter plug-in that works with both the iOS and Android programming platforms. It supports transactional as well as batch processing. It is automatic version management in the early phases. It can assist you in inserting, querying, editing, and deleting queries. Database operations are carried out on the background thread. It is intended for simple and uncomplicated data, such as user preferences, and employs the following:

Flutter Slidable

The flutter slidable plugin is connected to your project along with a feature-rich slider widget. Sliders like this one are common in scrollable lists. The Gmail app is an excellent example of how sliding list items may significantly boost productivity.

This plugin is loaded with features and is ready to use, but it is also very customisable if necessary. Among the features cited are:

  • Accepts primary (left/top) as well as a secondary (right/bottom) widget lists as slide actions
  • It can be dismissed
  • It has four built-in action panes
  • It also comprises two built-in slide action widgets
  • It has a Built-in dismiss animation
  • It can easily create custom layouts and animations that are efficient when put to use.
  • It automatically closes when a slide action has been tapped (overridable)
  • It closes loses when the nearest Scrollable starts to scroll (overridable)
  • It can be considered to be a great option to disable the slide effect easily

Shared Preferences

This package wraps platform-specific persistent storage libraries. It’s indented for easy and simple data, like user preferences, and it uses:

  • NSUserDefaults on iOS and macOS
  • SharedPreferences on Android
  • LocalStorage on websites
  • A JSON file on the local filesystem for Linux

Data could also be persisted to disk asynchronously, and no guarantee writes will be persisted to disk after returning, so this plugin isn’t meant for storing critical data.

Sqflite

This package provides a wrapper for platform-specific persistent storage libraries. It is a crucial flutter plug-in that supports the iOS and Android development platforms. It allows both transaction and batch processing. During the initial stages, it is automatic version management. It can help you insert, query, edit, and delete questions. DB operations are performed in the background thread. It is designed for specific data, such as user preferences, and it employs the following:

  • NSUserDefaults on iOS and macOS
  • SharedPreferences on Android
  • LocalStorage on websites
  • A JSON file on the local filesystem for Linux

Data is also persisted to disc asynchronously, and no guarantee writes will be continued to disc after returning. Hence this plugin is not intended to store essential data.

Url Launcher

This Flutter package is used to launch URLs in mobile apps, as the name implies. It supports both Android and iOS platforms, and it comes in handy when you want the OS to handle the URL for you. The URL Launcher program supports a variety of URL schemes such as HTTP, mailto, SMS, and so on. This plugin assists you in launching a URL. URLs will take one of the following forms:

  • HTTP: http://example.org and https://example.org
  • E-mail: mailto:<e-mail address>
  • Phone numbers: tel:<phone number>
  • SMS text message: sms:<phone number>

Basic usage is incredibly straightforward:

const url = 'https://flutter.dev';if (await canLaunch(url)) {

await launch(url);

} else {

throw 'Could not launch $url';

}

Video Player

Many formats are supported, but it is entirely dependent on the platform you are using. For example, the supporting libraries differ between iOS and Android. Furthermore, the supported formats on the web are dependent on the browser you’re using.

It should be noted that, despite the name video player, this plugin may also play audio. Because the plugin is relatively mature and has achieved API stability, it’s not wrong to utilize it for audio over some of the alternatives.

This plugin can play video from both a local file (assets) and a remote server (e.g., a website).

Audio Players

A flutter plug-in is accustomed to playing different audio files simultaneously in Android and iOS. Start by installing dependencies as follows;

Dependencies:

audioplayers: ^0.13.0

An audioPlayer instance can play a sing audio file at a time by calling the constructor to form.

AudioPlayer audioPlayer = AudioPlayer ();

It is used for low latency API, which can serve a better experience for gaming sounds, use the following code:

AudioPlayer audioPlayer = AudioPlayer (mode: playermode.LOW_LATENCY);

Crypto

According to the Dart team, this is frequently a collection of cryptographic hashing routines implemented in pure Dart. This signifies that no other libraries are required to create this task.

The hashing algorithms listed below are supported:

 

  • SHA-1
  • SHA-224
  • SHA-256
  • SHA-384
  • SHA-512
  • MD5
  • HMAC (i.e. HMAC-MD5, HMAC-SHA1, HMAC-SHA256)

Since this is not a GUI tool but simply a crypto library, it works on all supported platforms.

Carousel Slider

A carousel slider can be seen in many apps and websites. The carousel slider plugin creates a stunning and customizable carousel that is cross-platform compatible.

Because the carousel supports widgets as content, you can slide anything.

You may see live demonstrations of the plugin on this website, which uses the Flutter web to demonstrate it.

Here’s an example of how a carousel could be used in your app:

 

CarouselSlider(

options: CarouselOptions(height: 400.0),

items: [1,2,3,4,5].map((i) {

return Builder(

builder: (BuildContext context) {

return Container(

width: MediaQuery.of(context).size.width,

margin: EdgeInsets.symmetric(horizontal: 5.0),

decoration: BoxDecoration(

color: Colors.amber

),

child: Text('text $i', style: TextStyle(fontSize: 16.0),)

);

},

);

}).toList(),

)

The carousel has several configurable options, like:

  • the height and aspect ratio
  • enabling infinite scrolling
  • reversing the carousel
  • enabling autoplay with a configurable interval, animation duration
  • defining the scroll direction (vertical, horizontal)

Path Provider

Paths are both complex and straightforward since they differ from platform to platform. And, to avoid introducing bugs or security risks into your code, always utilize the path library when working with paths. The path provider package allows developers to rapidly and efficiently obtain frequently used locations on Android and iOS file systems (such as temp and app data directories). When using the SQLite library, you can receive the database path by using this package. It supports internal and external storage and makes it simple to access directories such as documents, privates, etc. To link a manual and a file using the current file separator.

import 'package:path/path.dart' as p;

p.join('directory', 'file.txt');

Location Plugin

One of the essential characteristics of phones is their mobility, which is linked with the ability to track position correctly. This has already provided us with a plethora of practical applications. The Flutter location plugin makes it easier to get the current location. When the location changes, it sends a callback. It provides callbacks and API endpoints for correctly requesting access to a user’s location. It is a flutter plugin that handles real-time location on iOS and Android quite well. It also has options for optimizing performance and battery life.

Conclusion

Flutter packages allow us to create applications rapidly and save us many hours of work when developing a product. Flutter also allows developers to publish and participate to the development of flutters packages.

The lengthy list of flutter packages was graded based on package health, overall score, and ease of maintenance.


.

You may also like...