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
215
votes
53 answers

Flutter App stuck at "Running Gradle task 'assembleDebug'... "

When I run the app it get stuck Launching lib\main.dart on Lenovo A319 in debug mode... Running Gradle task 'assembleDebug'... (This is taking an unexpectedly long time.) It never initialize Gradle nor the dependencies
learner
  • 2,191
  • 2
  • 6
  • 10
214
votes
40 answers

How to change status bar color in Flutter?

I am trying to change the status bar color to white. I found this pub on flutter. I tried to use the example code on my dart files.
Mohamed Hassan
  • 2,177
  • 2
  • 12
  • 8
179
votes
12 answers

Do not use BuildContexts across async gaps

I have noticed a new lint issue in my project. Long story short: I need to use BuildContext in my custom classes flutter lint tool is not happy when this being used with aysnc method. Example: MyCustomClass{ final buildContext context; …
169
votes
4 answers

how to use local flutter package in another flutter application?

How to use local flutter package in another flutter application? I created a package using following command: flutter create --template=package my_new_package and then in my application source code => main.dart import…
behzad besharati
  • 5,873
  • 3
  • 18
  • 22
114
votes
21 answers

Error: Member not found: 'FirebaseAppPlatform.verifyExtends'

I get this error: Member not found: 'FirebaseAppPlatform.verifyExtends'. FirebaseAppPlatform.verifyExtends(_delegate); flutter clean flutter pub get pod install
Rafael Pedrosa
  • 1,173
  • 2
  • 2
  • 3
113
votes
5 answers

Update flutter dependencies in /.pub-cache

I erased in my folder .pub-cache/hosted/pub.dartlang.org/this_plugin What is the command to update the dependencies inside pubsec.yaml? I believe it is flutter packages get The folder under .pub-cache is still not up to date. Note: there was a…
Raymond Chenon
  • 11,482
  • 15
  • 77
  • 110
113
votes
14 answers

How to get unique device id in flutter?

In Android we have, Settings.Secure.ANDROID_ID. I do not know the iOS equivalent. Is there a flutter plugin or a way to get a unique device id for both Android and IOS in flutter?
karan vs
  • 3,044
  • 4
  • 19
  • 26
85
votes
9 answers

PluginRegistry cannot be converted to FlutterEngine

As soon as I updated the flutter to version 1.12.13 I found this issue and can't fix it. I did as the firebase_messaging tutorial sent and got the following error: "error: incompatible types: PluginRegistry cannot be converted to FlutterEngine …
83
votes
1 answer

" Error: Member not found: 'packageRoot' " in Flutter

While trying to run any flutter project on Android Studio, I am getting this particular error : [+11147 ms] [+13655 ms] ../../flutter/.pub-cache/hosted/pub.dartlang.org/platform-3.0.2/lib/src/interface/local_platform.dart:46:19: Error: Member not…
ghosh_joy
  • 1,031
  • 1
  • 5
  • 10
76
votes
12 answers

Update Gradle in Flutter project

I have this project in Flutter, but I haven't been able to build an apk for a couple of weeks, because of the Gradle version. I've tried everything, but Flutter always returns the error below: I already install every update I found, even though, it…
Israeldev
  • 868
  • 1
  • 5
  • 7
67
votes
7 answers

Which channel do I use in Flutter SDK?

There was an announcement of Preview 1 at " Announcing Flutter Release Preview 1 – Flutter – Medium" Download the latest beta release of the Flutter SDK In the document. Get Started: Install on macOS - Flutter Latest beta release version is 0.5.1.…
granoeste
  • 1,531
  • 3
  • 12
  • 15
62
votes
5 answers

How to fix 'net::ERR_CLEARTEXT_NOT_PERMITTED' in flutter

I have implemented webView in flutter but it is not opening my php website which is on server what I'm doing wrong. I am new to flutter and tried webview to integrate my website webpage in my application but no luck. Widget build(BuildContext…
Akash Agarwal
  • 621
  • 1
  • 5
  • 4
62
votes
3 answers

How to schedule background tasks in Flutter?

I have been looking a lot for this but haven't found any packages or a way to schedule background tasks in Flutter. Like in Android there is WorkManager,AlarmManager. I know I can access those classes using MethodChannel, but I want something that…
Gurleen Sethi
  • 3,162
  • 6
  • 26
  • 48
60
votes
11 answers

Because every version of flutter_test from sdk depends on... flutter_test from sdk is forbidden, version solving failed

I'm having this issue when I've added http dependency in my flutter project. Can anyone please help me with it?
Shoaib Nomani
  • 601
  • 1
  • 5
  • 4
59
votes
18 answers

Flutter : Target file "lib/main.dart" not found

When I perform a flutter run I get an error Target file "lib/main.dart" not found. Why is this happening and how can I fix this ?
Keshav Aditya R P
  • 3,001
  • 5
  • 21
  • 28
1
2 3
99 100