Questions tagged [flutter-dependencies]

For questions relating to the use of and issues with any use of flutter-specific dependencies in dart's pubspec.yaml

Dependencies are one of the core concepts of the pub package manager. A dependency is another package that your package needs in order to work. Dependencies are specified in your pubspec. You list only immediate dependencies — the software that your package uses directly. Pub handles transitive dependencies for you.

For each dependency, you specify the name of the package you depend on and the range of versions of that package that you allow. You can also specify the source, which tells pub how to locate the package, and any additional description that the source needs to find the package.

Here is an example of specifying a dependency:

dependencies:
  transmogrify: ^1.0.0

This YAML code creates a dependency on the transmogrify package using the default source (pub.dev) and allowing any version from 1.0.0 to 2.0.0 (but not including 2.0.0). See the version constraints section of this page for syntax details.

If you want to specify a source, the syntax looks a bit different:

dependencies:
  transmogrify:
    hosted:
      name: transmogrify
      url: http://some-package-server.com
    version: ^1.0.0

This YAML code creates a dependency on the transmogrify package using the hosted source. Everything under the source key (here, just a map with a url: key) is the description that gets passed to the source. Each source has its own description format, which is described in the dependency sources section of this page. The version constraint is optional but recommended.

Use this long form when you don’t use the default source or when you have a complex description that you need to specify. But in most cases, you’ll just use the simple packagename: version form.

Dependency sources

Pub can use the following sources to locate packages:

SDK
Hosted packages
Git packages
Path packages
6510 questions
23
votes
5 answers

Webview in flutter not working getting a platform error

Issue with webview in flutter getting an error [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception: PlatformException(error, Trying to create a platform view of unregistered type: plugins.flutter.io/webview, null) Trying…
viveksuggu
  • 737
  • 2
  • 7
  • 12
22
votes
12 answers

Android Studio Dart And Flutter Plugin is not installed

Here is the flutter doctor result: [√] Flutter (Channel stable, 1.22.1, on Microsoft Windows [Version 10.0.18362.30], locale en-US) [√] Android toolchain - develop for Android devices (Android SDK version 30.0.2) [!] Android Studio X Flutter…
22
votes
5 answers

What is the difference between `flutter packages get` and `flutter pub get`?

I just upgraded Android Studio and saw flutter packages get changed to flutter pub get in "Tools > Flutter". Does this have any change in the functionality? Or are they completely the same?
dmjy
  • 1,183
  • 3
  • 10
  • 26
21
votes
4 answers

The method 'IOSInitializationSettings' isn't defined using local notification plugin

flutter_local_notifications: ^11.0.0 I used this library but I can find IOSInitializationSettings please help me. I m trying to integrate push notifications into my flutter app.
21
votes
9 answers

Failed to evaluate expression 'handlePrimaryPointer':InternalError: No frame with index 45

Code that I have written for Admin Login: import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; class FirebaseServices { static Future adminSignIn(id) async { var res = await…
Ali ijaz
  • 321
  • 1
  • 2
  • 10
20
votes
8 answers

Using flutter webview as home and pressing back button closes Application

I'm trying to use a webview in flutter as my home page for my application. Everything loads just fine, however hitting the back button doesn't send me to the previous web page in the webview, it just exits the application. import…
20
votes
7 answers

How to send a message directly from my Flutter app to WhatsApp using UrlLauncher?

I am building an app that has to be able to take an order and send it to a specific WhatsApp number. What exactly am I supposed to do? I can open WhatsApp but I can't figure out how to send a message when opening it. title: new Text("WhatsApp"), …
Unison Coding
  • 309
  • 1
  • 2
  • 3
20
votes
3 answers

Storing API credentials in a flutter application

I am using googleapis services in my flutter app which requires some credentials in JSON format. What is the best way to store this credentials in my App? Can I keep a JSON file in my asset folder and read it in my main function? Or should I…
Unnikrishnan
  • 2,683
  • 5
  • 22
  • 39
19
votes
3 answers

Flutter - Overridden dependencies

After running "flutter pub get", I got this error: Warning: You are using these overridden dependencies: ! path 1.6.4
Khader Murtaja
  • 425
  • 1
  • 5
  • 15
19
votes
8 answers

How to convert Future to List in flutter?

I am using a plugin for flutter called search_widget. The data parameter of this widget takes a list. But as I use sqlite for fetching data, I have it in Future form. Is there any way I can convert Future to List? Or any other way to get…
Cipher
  • 391
  • 1
  • 4
  • 11
19
votes
3 answers

Flutter Camera Plugin taking dark image bug

I am getting dark images from flutter Camera Plugin. Camera Preview is showing correctly but after taking the picture it becomes too dark. I searched and what i found that it's about the FPS and exposure of the camera. How can I solve this…
shubham chhimpa
  • 263
  • 3
  • 10
19
votes
7 answers

[Firebase Messaging]: Background Message Handler method not called when the app in background?

I-am developing an app for pushing notifications using FCM, when the app in background or terminated and receiving new notification i need to save the data of this notification local in (SQLITE), without click on the notification or re-open the app…
Mahmoud AbdelAziz
  • 291
  • 1
  • 2
  • 8
18
votes
12 answers

Because app requires SDK version >=2.15.1 <3.0.0, version solving failed

Can anyone tell me why am I getting this error? The current Dart SDK version is 2.12.0. Because app requires SDK version >=2.15.1 <3.0.0, version solving failed. pub get failed (1; Because app requires SDK version >=2.15.1 <3.0.0, version solving…
Anurag Yadav
  • 199
  • 1
  • 1
  • 9
18
votes
5 answers

Error in compilation with Geolocator pluggin

I'm getting the current error when compiling a project with Geolocator pluggin: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\geolocator_android-2.0.0\android\src\main\java\com\baseflow\geolocator\location\LocationMapper.java:29: error: cannot…
18
votes
6 answers

flutter error: This widget has been unmounted, so the State no longer has a context (and should be considered defunct)

when I clicking on login button when my mobile number is wrong then open one error dialog box after that when I clicked okey on dialog box then i got this error. I got this message This widget has been unmounted, so the State no longer has a…
Deepak
  • 1,664
  • 3
  • 19
  • 52