In computing, a library is a collection of non-volatile resources or subprograms used in computer programs.
These may include configuration data, documentation, help data, pre-writing codes and subroutines, classes, values, or type specifications (Wikipedia).
Here is a list of some libraries that in my opinion, every developer should know about.
There are many useful flutter libraries available on Pub.dev to help developers on each step of development. Here are some of the top flutter libraries that in my opinion, every developer should know about. So let’s dig into the flutter libraries right away.
mvc_pattern
Writing a clean and maintainable flutter code is crucial for your projects. This library attempt to offer the MVC in an intrinsic fashion incorporating much of the Flutter framework itself.
View
class _MyHomePageState extends State<MyHomePage> {
final Controller _con = Controller.con;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
widget.title,
),
Text(
'${_con.counter}',
style: Theme.of(context).textTheme.display1,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(
_con.incrementCounter
);
},
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}
Controller
class Controller extends ControllerMVC {
/// Singleton Factory
factory Controller() {
if (_this == null) _this = Controller._();
return _this;
}
static Controller _this;
Controller._();
static Controller get con => _this;
int get counter => _counter;
int _counter = 0;
void incrementCounter() => _counter++;
}
Model
class Model {
static int get counter => _counter;
static int _counter = 0;
static int _incrementCounter() => ++_counter;
}
To view the documentation click here
hive
Hive is a lightweight and blazing fast key-value database written in pure Dart. It is a perfect fit if you need a lightweight datastore for your app. After adding the required dependencies and initializing Hive, you can use Hive in your project.
var box = Hive.box('myBox');
box.put('name', 'David');
var name = box.get('name');
print('Name: $name');
To view the documentation click here
url_launcher
This is a Flutter plugin for launching a URL in the mobile platform. Supports iOS, Android, web, Windows, macOS, and Linux.
Example
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
void main() {
runApp(Scaffold(
body: Center(
child: RaisedButton(
onPressed: _launchURL,
child: Text('Show Flutter homepage'),
),
),
));
}
_launchURL() async {
const url = 'https://flutter.dev';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
To view the documentation click here
flushbar
I personally love using this packages to display a success or error message to the users of my applications. This packages did it job well by providing an customisable interface to notify the users of your flutter applications.
class YourAwesomeApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'YourAwesomeApp',
home: Scaffold(
Container(
child: Center(
child: MaterialButton(
onPressed: (){
Flushbar(
title: "Hey Ninja",
message: "Lorem Ipsum is simply dummy text of the printing and typesetting industry",
duration: Duration(seconds: 3),
)..show(context);
},
),
),
),
),
);
}
}
To view the documentation click here
dio
Dio is a powerful Http client for Dart, which supports Interceptors, Global configuration, FormData, Request Cancellation, File downloading, Timeout etc.
import 'package:dio/dio.dart';
void getHttp() async {
try {
Response response = await Dio().get("http://www.google.com");
print(response);
} catch (e) {
print(e);
}
}
To view the documentation click here
onesignal_flutter
OneSignal is a free push notification service for mobile apps. This SDK makes it easy to integrate your Flutter iOS and/or Android apps with OneSignal.
This library is flutter package to integrate OneSignal into your application. To integrate OneSignal to your application, See the Setup Guide for setup instructions.
To view the documentation click here
pull_to_refresh
This is a package provided to the enhance flutter scroll component to drop-down refresh and pull up load. The package is support by android and ios.
Feature of this package includes
- pull up load and pull down refresh
- It’s almost fit for all Scroll witgets, like GridView,ListView…
- provide global setting of default indicator and property
- provide some most common indicators
- Support Android and iOS default ScrollPhysics, the overScroll distance can be controlled, custom spring animate, damping, speed.
- horizontal and vertical refresh, support reverse ScrollView also(four direction)
- provide more refreshStyle: Behind, Follow, UnFollow, Front, provide more loadmore style
- Support twoLevel refresh, implements just like TaoBao twoLevel, Wechat TwoLevel
- enable link indicator which placing other place, just like Wechat FriendCircle refresh effect
To view the documentation click here
path_provider
This is a Flutter plugin for finding commonly used locations on the filesystem. Supports iOS, Android, Linux and MacOS. Not all methods are supported on all platforms.
Directory tempDir = await getTemporaryDirectory();
String tempPath = tempDir.path;
Directory appDocDir = await getApplicationDocumentsDirectory();
String appDocPath = appDocDir.path;google_fonts
To view the documentation click here
cached_network_image
This is a flutter library to show images from the internet and keep them in the cache directory.
CachedNetworkImage(
imageUrl: "http://via.placeholder.com/350x150",
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => Icon(Icons.error),
),
To view the documentation click here
font_awesome_flutter
This is a flutter packages built on he Font Awesome Icon pack available.
Based on Font Awesome 5.15.1. Includes all free icons:
- Regular
- Solid
- Brands
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class MyWidget extends StatelessWidget {
Widget build(BuildContext context) {
return IconButton(
icon: FaIcon(FontAwesomeIcons.gamepad),
onPressed: () { print("Pressed"); }
);
}
}
To view the documentation click here
submit_button
This is a fully customisable flutter animated button for forms and login/registration pages. Written in Dart.
class _MyHomePageState extends State<MyHomePage> {
bool _loading = false;
void _submit() {
setState(() {
_loading = true;
});
Future.delayed(Duration(milliseconds: 5000), () {
setState(() {
_loading = false;
});
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
children: [
SubmitButton(
isLoading: _loading,
spinnerColor: Colors.green,
backgroundColor: Colors.red,
button: FlatButton(onPressed: _submit,
child: Text("Submit")
),
),
],
)),
);
}
}
To view the documentation click here
flutter_screenutil
This is a flutter plugin for adapting screen and font size. Let your UI display a reasonable layout on different screen sizes.
Container(
width: ScreenUtil().setWidth(50),
height:ScreenUtil().setHeight(200),
)
To view the documentation click here