Have you thought about why Pubsec isn’t in dart? Why is it in another language? I was curious today, so I did a little bit of searching.
Before we discuss that, Let’s discuss Yaml first. Do you know Yaml stands for Yaml ain’t markup language! It is a programming language and is mostly used because it is human-readable and easy to understand.

In flutter, we mostly use it for packages and assets(images, fonts, videos, etc).
environment:
sdk: ">=2.15.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.4
tap_debouncer: ^2.0.1
If you want to know more about it, here’s a good article about Pubsec.Yaml: Pubsec.Yaml Definition and Syntax
Related: Login and Register Easily with Flutter using Firebase
Now Let’s discuss Why Pubsec isn’t in dart.
I found the answer in this Reddit post.
“Hi, I’m one of the co-designers of pub. There are two slightly different ways to ask your question:
Why aren’t pubspecs Dart programs?
We didn’t want pubspecs to contain arbitrary Dart code because we wanted pub and other tools to be able to parse and understand the contents of the file without needing an entire Dart interpreter for complexity reasons. For safety reasons, we didn’t want processing a pubspec to allow running arbitrary code which could read the user’s file system, talk to the network, etc. For performance, we wanted the language to not be Turing-complete so that processing the file would be reliably fast.
Why don’t pubspecs use Dart syntax?
As you suggest below, we could have said the file isn’t an entire Dart program, but does use the existing Dart map literal syntax. As JSON is to JavaScript, we could have said that the pubspec was “DSON”—a subset of Dart syntax containing only map literals, list literals, etc.
(We did consider JSON which Dart can parse already, but it doesn’t support comments. We felt users should be able to comment their pubspecs without having to use hacks like 'comment': 'some ignored key'
.)
This was actually my initial pitch, and I think it would have been a good choice. We talked to the VM team about adding support for parsing a subset of the language since they already had a parser for the full language. At the time (this was a long time ago with a very different team), they didn’t want to do it. That left us writing a custom parser from scratch. I don’t remember the exact reasoning, but we ultimately decided that if we had to write a parser, we should use a language that was already widely established. JSON was out since it didn’t allow comments. XML was too verbose and complex. At the time, YAML was quite popular, so it’s what we went with.
In practice, most pubspecs are pretty simple so it doesn’t matter much.”