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
32
votes
6 answers

flutter_launcher_icons not working Unhandled exception: FormatException: Invalid number (at character 1)

I want to change my app icon in flutter using flutter_launcher_icons: ^0.9.2 It shows me errors while I'm running Command flutter pub run flutter_launcher_icons:main Image of the error I tried many times but no new results
Yassin Elshaiatany
  • 323
  • 1
  • 3
  • 7
32
votes
8 answers

flutter_localizations from sdk depends on intl 0.17.0 and fstore depends on intl ^0.16.1, flutter_localizations from sdk is forbidden

Because every version of flutter_localizations from SDK depends on intl 0.17.0 and fstore depends on intl ^0.16.1, flutter_localizations from SDK is forbidden. So, because fstore depends on flutter_localizations any from SDK, version solving…
32
votes
21 answers

Flutter packages get does not install new package

I'm trying to install a package (dynamic_theme) in flutter. When I run flutter packages get -v it does not even try to install the package. So far I've tried: Running flutter packages get Running flutter packages get Restarting my computer Updated…
Alve
  • 640
  • 2
  • 9
  • 19
31
votes
5 answers

How to add asset image in app bar as an action icon in Flutter application?

Problem I am trying to add a logout image icon in appbar of flutter screen. I have created a asset folder and created directories images/icons/ and placed icons in them. I have mentioned them in pubspec.yaml file. I tried to implement a asset…
user3831831
30
votes
16 answers

MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core) on Android

I am getting the above error when calling Firebase.initializeApp() in my flutter code. I have followed the documentation here: https://firebase.flutter.dev/docs Here is my pubspec.yaml dependencies: flutter: sdk: flutter firebase_core:…
28
votes
6 answers

Error: RenderBox was not laid out, Failed assertion: line 1940 pos 12: 'hasSize'

I can't fix this error RenderBox was not laid out: RenderPointerListener#2b92a relayoutBoundary=up9 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE 'package:flutter/src/rendering/box.dart': Failed assertion: line 1940 pos 12: 'hasSize'. The relevant…
27
votes
28 answers

Finished with error: Gradle task assembleDebug failed with exit code 1

Launching lib\main.dart on HTC One M9PLUS in debug mode... Initializing gradle... Resolving dependencies... Gradle task 'assembleDebug'... registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)…
asimsharf
  • 447
  • 1
  • 5
  • 14
26
votes
11 answers

Error: Field 'wLanguage' cannot be nullable or have type 'Null', it must be `int`, `double`, `Pointer`, or a subtype of `Struct` or `Union`

When running the flutter build appbundle command, I get the following error : ../../.pub-cache/hosted/pub.dev/package_info_plus_windows-2.1.0/lib/src/file_version_info.dart:13:17: Error: Field 'wLanguage' cannot be nullable or have type 'Null', it…
Gedeon Mutshipayi
  • 2,871
  • 3
  • 21
  • 42
26
votes
9 answers

Error: 'ModalBottomSheetRoute' is imported from both

Error: 'ModalBottomSheetRoute' is imported from both 'package:flutter/src/material/bottom_sheet.dart' and 'package:modal_bottom_sheet/src/bottom_sheet_route.dart'. import 'material.dart' hide ModalBottomSheetRoute;
Abdallah Mahmoud
  • 491
  • 1
  • 5
  • 8
25
votes
3 answers

How to change language of Show date picker in flutter

I would like to change the language from english to french in show date picker, Please find below the code i am using and one like which supposed to solve that but it makes the code not working for this part: new Step( …
25
votes
17 answers

flutter error Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'

I just cerate a empty application ,then when I run it on emulator ,error happend. this error only arise when I run on android emulator , but ios works fine. now I'm in the flutter beta channel. so If anyone has any ideas , please let me know. thanks…
sky
  • 341
  • 1
  • 5
  • 8
25
votes
6 answers

Not able to sync dependency in build.gradle in flutter

I want to use some native library. and I am using below dependnecy implementation 'com.google.android.gms:play-services-vision:10.+' in build.gradle in flutter project. How I will sync that dependency. Please help me!
Shruti Majajan
  • 359
  • 1
  • 4
  • 11
24
votes
8 answers

This is a most likely a transient condition and may be corrected by retrying with a backoff

I'm using firebase in my project and i got some issues mentioned below - [cloud_firestore/unavailable] The service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff. I'm using…
24
votes
2 answers

Can anyone tell the difference of "flutter_bloc" and "bloc" packages in Flutter

I am getting started with Bloc in Flutter. Can anyone tell what is really "flutter_bloc" and "bloc" packages I have these questions. are they same. when/how to use this. Thank you
24
votes
4 answers

How to use preCachePicture() in flutter_svg

I'm using flutter_svg package to render SVG images in my app, as flutter does not officially supports SVG yet.I'm having a delay of probably few seconds while trying to load SVG images in my app and while looking for the solution I found out that I…
Shubhamhackz
  • 7,333
  • 7
  • 50
  • 71