0

Someone on stackoverflow posted about this issue before and there isn't an answer to this issue.

The issue:

Error on line 14, column 6 of pubspec.yaml: Expected ':'.
   ╷
14 │   dds: 2.7.10
   │      ^
   ╵

I tried everything that was suggested in this post: Error: Unable to 'pub upgrade' flutter tool

>>> flutter pub get
>>> flutter clean
>>> flutter run
>>> flutter pub cache repair
>>> flutter doctor
>>> flutter upgrade

All this didn't work, still jump to this error.

If anyone knows how to solve this issue, please answer or add a comment on this question, thanks.

here is my pubspec.yaml file:

name: mytable
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1

environment:
  sdk: '>=3.0.5 <4.0.0'

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
  cupertino_icons: ^1.0.2
  flutter:
    sdk: flutter
  flutter_screenutil: ^5.8.4
  flutter_svg: ^2.0.7
  flutter_custom_clippers: ^2.1.0
  intl: ^0.18.1
  

dev_dependencies:

  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # # rules and activating additional ones.
  flutter_lints: ^2.0.0
  flutter_test:
    sdk: flutter

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true
  # To add assets to your application, add an assets section, like this:
  assets: 
  - assets/images/
  
  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware
  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages
  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  fonts:
    - family: Almarai-Bold
      fonts:
        - asset: assets/fonts/Almarai/Almarai-Bold.ttf

    - family: Almarai-Regular
      fonts:
        - asset: assets/fonts/Almarai/Almarai-Regular.ttf
     
    - family: Poppins-Medium
      fonts:
        - asset: assets/fonts/Poppins/Poppins-Medium.ttf

    - family: Amiri
      fonts: 
        - asset: assets/fonts/Amiri/Amiri-Bold.ttf
       
   
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

screenshot of pubspec.yaml

3 Answers3

0

You can try replacing your pubspec.yaml file with a fresh new pubsepc.yaml file.

Then run,

flutter clean
flutter pub get 

Then add all the dependencies of your project 1 by 1.

Try this if it works.

0

I don't see that error line on your yaml file. Probably cause you created a new one?

In any case, make sure you use the carrot sign before version number.

Also, indentation kinda matters depending which section you are in inside the yaml file, as there are different categories.

Try this (there's a space after the colon fyi):

dds: ^2.7.10

Cornel
  • 180
  • 2
  • 4
  • 13
  • Thanks Cornel for taking the time to solve my issue, where should I put ( dds: ^2.7.10 )? – Ibrahim Gamal Aug 20 '23 at 11:42
  • That goes under dependencies section. In this case, add it after the following library line and make sure it's intended like the rest. intl: ^0.18.1 – Cornel Aug 20 '23 at 11:51
  • After that, go to your file where you want to use the dds library and add the import line on top. Visit pub.dev in your browser, type dds in the search, and then click on Installing link for details. By the way there is a newer version available for this library. – Cornel Aug 20 '23 at 11:54
  • Hi Cornel, I tried what you told me, but nothing changed. Also I don't know why I have a problem with this package, I don't use it. Is It necessary? I appreciate all your efforts Cornel, I have been looking for the solution for almost 2 days, also I deleted my project folders by mistake trying too fix this issue, I recovered some of it, I actually don't know what to do now? – Ibrahim Gamal Aug 20 '23 at 12:01
  • You shouldn't need this package by default. Perhaps there is an import reference to it in one of your dart files somewhere or you've got a piece of code that uses code from this library. – Cornel Aug 20 '23 at 12:03
  • I searched the files but didn't find anything related to dds package, what should I do now? I know your time is valuable Cornel so thanks again for trying to solve my issue. – Ibrahim Gamal Aug 20 '23 at 12:11
  • Are you still getting an error? What does the error say? Try closing your ide or Android Studio or whatever you're using and reopen and try again. – Cornel Aug 20 '23 at 12:18
  • Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (8 tries left) Error on line 14, column 6 of pubspec.yaml: Expected ':'. ╷ 14 │ dds: 2.7.10 │ ^ ╵ – Ibrahim Gamal Aug 20 '23 at 12:18
  • Can you post a screenshot of your yaml file and the error? It's saying that you have dds package added to your yaml file but I can see that you don't have the carrot symbol before the number as I explained earlier. – Cornel Aug 20 '23 at 12:20
  • The vs code didn't want to Initialize Flutter. This message appeared: Failed to initialize Flutter: Process exited with code 1. – Ibrahim Gamal Aug 20 '23 at 12:21
  • I don't use VSCode, prefer Android Studio but you gotta know that if folder structure changes it's more difficult in VSCode. It might be best to just create a new folder for your project and move your dart files and stuff over there and then open the project folder with VSCode. VSCode may also need to be configured properly for Dart and Flutter to work, so I can't help too much there. – Cornel Aug 20 '23 at 12:24
  • Hi Cornel, I uploaded a screenshot. – Ibrahim Gamal Aug 20 '23 at 12:29
  • No worries Cornel, I appreciate your help. Thanks. – Ibrahim Gamal Aug 20 '23 at 12:29
  • The yaml file looks fine. Is your VSCode properly configured for Flutter/Dart? Perhaps if you look up a tutorial online it will help. – Cornel Aug 20 '23 at 12:30
  • Thanks Cornel, I think the problem is with Configuration with Flutter and Dart because VSCode didn't want to initialize Flutter, I will look for online tutorials thanks for your help. – Ibrahim Gamal Aug 20 '23 at 12:35
  • I'm not sure if you're just starting out with dart/flutter or you're experienced with it, but yeah first VSCode needs to be setup for Flutter and Dart. And then if you're doing mobile development you probably also want an emulated device setup for debugging. All this is explained in a YouTube video if you search for "how to setup flutter and dart for VSCode". – Cornel Aug 20 '23 at 12:40
  • Yeah I did all of that a couple of months ago, but the problem is, I remember pressing on the commit button in source control and I downloaded random files from github and all these errors started to show up, that's what happened. – Ibrahim Gamal Aug 20 '23 at 12:54
  • Hi Cornel, I figured up something that can help to identify this problem, I opened another project I worked on before and it showed me the same error, the problem isn't in my project or in my IDE either, because I used another IDE rather than VSCode and it showed me the same error, I think the problem is on my machine, Is there a way that I can reset the git or something on my machine, also you don't have to answer if you have important things, you helped a lot previously, and that's more than enough, thanks. – Ibrahim Gamal Aug 21 '23 at 05:34
  • I don't think Git is an issue. Are you using github to store your repository on the cloud? I think the best way to do is this. Remove flutter and dart completely. Then install the latest flutter which comes with dart and reconfigure your VSCode. After that create a new project with a simple one dart file and make sure it's able to compile. Follow a tutorial for this. – Cornel Aug 21 '23 at 06:47
  • Thanks Cornel I will try this, I will tell you what happened Inshallah. – Ibrahim Gamal Aug 21 '23 at 06:54
  • I don't think Git is an issue. Are you using github to store your repository on the cloud? I think the best way to do is this. Remove flutter and dart completely. Then install the latest flutter which comes with dart and reconfigure your VSCode. You have to set your environment variable and have flutter stored in a known folder on your machine. I used chocolatey for this. After, you can run pub upgrade, flutter doctor, and all those commands. Next, configure VSCode environment to work with flutter. After that create a new project with a simple one dart file and make sure it's able to compile. – Cornel Aug 21 '23 at 06:54
0

Add it to your dependency section in your yaml file after the line: intl: ^0.18.1 Be sure it's indented just like the intl line above it.

After that add the import in your dart file on top where you wish to use this library. Also, visit pub.dev, type dds, and search for it and check the Installing section for more info.

Cornel
  • 180
  • 2
  • 4
  • 13