Top 5 Flutter Packages that you must know

Flutter Knowledge Sharing #35

Widgets, Widgets, Widgets?

Location

bool _serviceEnabled;
PermissionStatus _permissionGranted;
LocationData _userLocation;

Future<void> _getUserLocation() async {
Location location = new Location();

// Check if location service is enable
_serviceEnabled = await location.serviceEnabled();
if (!_serviceEnabled) {
_serviceEnabled = await location.requestService();
if (!_serviceEnabled) {
return;
}
}

// Check if permission is granted
_permissionGranted = await location.hasPermission();
if (_permissionGranted == PermissionStatus.denied) {
_permissionGranted = await location.requestPermission();
if (_permissionGranted != PermissionStatus.granted) {
return;
}
}

final _locationData = await location.getLocation();
setState(() {
_userLocation = _locationData;
print('Your latitude: ${_userLocation.}');
});
}

Device_Info

// Add the dependencies
dependencies:
flutter:
sdk: flutter

device_info:
import 'package:device_info/device_info.dart';

DeviceInfoPlugin deviceInfo = new DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
print('Running on ${androidInfo.model}'); // e.g. "Moto G (4)"

IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
print('Running on ${iosInfo.utsname.machine}'); // e.g. "iPod7,1"

sqflite

url_launcher

Future<Null> _launchInBrowser(String url) async {
if (await canLaunch(url)) {
await launch(url, forceSafariVC: false, forceWebView: false);
} else {
throw 'Could not launch $url';
}
}

package:async

Conclusion

Mobile I Web I Data Science I AI — We write rich & meaningful content on development, technology, digital transformation & life lessons.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store