Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import intl library in Flutter?

I am new in Flutter. When I import the library: import 'package:intl/intl.dart'; , it says that the target of URI doesn't exist:package:intl/intl.dart; enter image description here

like image 677
TSR Avatar asked Aug 06 '18 10:08

TSR


People also ask

How do you use Intl in flutter?

Setting up Flutter Intl. Open Android Studio's preferences by pressing Command-, (comma) on macOS or Control-Alt-S on Linux or Windows. Select Plugins on the left-side panel (1) and Marketplace in the upper tab bar (2). Type intl in the search bar (3), then click Install for Localizely's Flutter Intl result (4).

What is Intl in Dart?

The Intl class provides a common entry point for internationalization related tasks. An Intl instance can be created for a particular locale and used to create a date format via anIntl. date() . Static methods on this class are also used in message formatting.


1 Answers

When you import any package, example:

import 'package:intl/intl.dart';

You need to also add the package inside the pubspec.yaml file under the dependencies field example:

dependencies:
  intl: ^0.15.7

Then from the terminal you can execute the following command:

flutter packages get

or

From Android Studio/IntelliJ:

Click Packages Get in the action ribbon at the top of pubspec.yaml

more info here:

https://flutter.io/using-packages/

like image 184
Peter Haddad Avatar answered Oct 01 '22 01:10

Peter Haddad