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
15
votes
8 answers

Error: The non-abstract class 'InternalSelectableMathState'

I just updated flutter version from 2.5.3 to 2.8. I have the following error that i dont know how resolve it. There is no error on any plugin installed, It seems that the error comes from the inner classes themselves and I don't know in which part…
Maikzen
  • 1,504
  • 2
  • 6
  • 18
15
votes
1 answer

Using Flutter Downloader plugin, after download app closes

I use flutter_downloader package. After complete download some files, my app closes automatically and disconnects from the android studio. Anyone help me to find solutions. final status = await Permission.storage.request(); if…
15
votes
3 answers

What is meant by 'Sort pub dependencies'?

I am trying to migrate a project into null safety mode,after migrating and clearing all the errors, I am getting this problem named 'Sort pub dependencies.dart(sort_pub_dependencies)'. I searched Google but couldn't find any solution. Any help would…
15
votes
6 answers

Flutter version management. error : -bash: fvm: command not found

I am trying to install the flutter version manager to switch the flutter version among the different flutter projects. I use the command to install the fvm - pub global activate fvm but when I run the command on the terminal - fvm help There is an…
MANISH PATHAK
  • 2,602
  • 4
  • 27
  • 31
15
votes
7 answers

When I try to build the APK Following shows in the debug console. Build: Build Failed with an exception

When I try to build the APK Following shows in the debug console. Build: Build Failed with an exception . Error in console…
Ahmed Ashraf
  • 281
  • 1
  • 2
  • 12
15
votes
6 answers

How to fix this error Task 'assembleAarRelease' not found in root project 'flutter_plugin_android_lifecycle'.?

When i tried to run the app I'm getting this error Task 'assembleAarRelease' not found in root project 'flutter_plugin_android_lifecycle'. how to rectify this?
Akshay gopan
  • 161
  • 1
  • 2
  • 4
15
votes
1 answer

Install native iOS pod in flutter

I am facing an error while making a flutter plugin on the iOS side while using pods. The pods are installed successfully then also I am able to import them in the file. The pod in my case which I am trying to use is Freshchat iOS SDK Steps I have…
nimi0112
  • 2,065
  • 1
  • 18
  • 32
15
votes
13 answers

Flutter: 'package get' has not been run; 'Pub get' has not been run

I dowloaded a Flutter sample code for Catalog from git, which showing me a warning, 'package get' has not been run 'Pub get' has not been run What does it mean? How to solve it? Should I ignore this warnings or Update dependencies as suggested…
Krunal
  • 77,632
  • 48
  • 245
  • 261
14
votes
5 answers

Flutter Stripe throws StripeException when Presenting Payment Sheet

I am trying to implement a Stripe payment system in my flutter app using the stripe_payment package. In my code, I call Stripe.instance.initPaymentSheet(...), however when I try to call Stripe.instance.presentPaymentSheet(...) just a few lines…
14
votes
9 answers

how to change size of svg image in flutter?

I used flutter_svg: ^0.18.0 to use svg images inside my project. But I cannot able to find a proper way to change the size of it. Here's my code body: SafeArea( child: Center( child: SvgPicture.asset('assets/images/morelights.svg'), …
Phanindra
  • 1,110
  • 2
  • 11
  • 24
14
votes
1 answer

How do you share code between 2 Flutter projects?

With Flutter now supporting web and mobile app development, what's the best practice to avoid rewriting code all the time? Say you have a few classes / functions living in your mobile app project that'd you'd like to reuse for your web project, is…
Kevan
  • 363
  • 2
  • 11
14
votes
2 answers

How to make Flutter Workmanager plugin and Location plugin work together

1. Problem description My goal is to build a Flutter app that gets periodic location updates using this workmanager plugin and using this location plugin. But I can't get the Location plugin to be loaded properly when my Workmanager callback fires.…
Tom O
  • 2,495
  • 2
  • 19
  • 23
14
votes
8 answers

How to get current country code in flutter

I have already tried to get current country code via this. Give me best solution for same. I want to show country flag on the Splash page, So I need to know about user country and This is required for me. Please help me guys
Akshay Jaiswal
  • 163
  • 1
  • 2
  • 8
14
votes
4 answers

How to resolve package conflict in Flutter?

I am trying to use an external package for generating a PDF document. I have used this library but when I import the below packages, I get en error The name 'StatelessWidget' is defined in the libraries 'package:flutter/src/widgets/framework.dart'…
Ashish Tiwari
  • 2,168
  • 4
  • 30
  • 54
14
votes
3 answers

Video player for web, mobile and desktop applications in Flutter?

There is this Flutter plugin for playing videos on iOS & Android (Video Plugin) However, I also want to embed a video player into my web and desktop applications. So I dont understand how Flutter is going this way of supporting plugins for different…
GreenTigerEye
  • 5,917
  • 9
  • 22
  • 33