Dart extension methods
HTML-код
- Опубликовано: 30 июл 2024
- Dart is adding a new feature called Extension Methods. It's one of the features that you can live without, but it does make some things very convenient. Learn more now!
Overview → goo.gle/2PJunfp
A more indepth article → goo.gle/2sNgfsj
Some code samples → goo.gle/36VhZyr
Learn everything about Flutter at → flutter.dev
Subscribe! → goo.gle/FlutterYT
#dart #darttopic
I didn't use to program, but i used to watch Flutter and dart videos just because they're funny🤣. Now I know dart and I use Flutter every day. Thanks!
Haha. I made a video about Dart extensions a few weeks ago and also said “with great power comes great responsibility” 😀
Very well explained!
Your videos are great
Love your video tutorials!
Flutter :- We have a widget for that.
Dart :- We have a method for that.
Coming from Swift-land, I'm glad Dart has extension methods. They're one of my favorite language features.
Hey there, Isuru! Thanks so much for your feedback. It's great to see users so excited about new features!
Don't forget to check out this article for more on Dart Extension Methods! → goo.gle/2sNgfsj
I'm a C# program and Extension Method is one of my favorites features on this language. It's very exciting see this feature in Flutter too. Thank for this guys!
Thanks for the video!
2:10 was too damn funny
JSAN L. Hahah filip is the best!
If at some point in your career you had created atleast one StringUtil class, you'll definitely love extension methods :)
I've been in and out of top 20 programming languages & never had this much fun
thank you flutter team
This functionality should be useful. I hope that Dart doesn't go too much down the C# path, though, in the sense of adding tons of features that make the language less approachable. Often when a language is made more efficient for its experienced users, it becomes more intimidating and less readable for newcomers.
Thats pretty cool.
and the 'principle of least astonishment' you mentioned is one of the main reasons I love dart...everything seems to work more or less as i expect it to.
Awesome video, thanks for sharing 😊! This funny, authentic, well prepared and informative videos are part of the future success of flutter and dart. Keep it going 🙏
I remember using extensions in Swift and thought it was the coolest feature ever. So glad it's being used in Dart as well!
I'm trying to learn flutter, and must say it's the coolest framework, so fun! Thank you for your work dev team👌😉
Just what I was searching for! No need to fork repos anymore 😂
Right? That is exactly what brought me here. I have like 5-6 repos I forked in this current project with changes and was just thinking how much of a pain it will be down the road trying to maintain.
I really liked the 2:10 minute, when the “revelation” was showed out! 😁
That’s Awesome
Really happy to see Extension methods
VERY GOOD NEWS!. extensions were very useful to me when I was writing Swift, can't wait to use them in my new favorite language :)
This is sick, in Java I have been waiting for this forever
this remembers me about prototypes in javascript, very useful!!
Awesome tutorial, fun and informative, thanks!
Very well explained! Thanks
Fantastic!!! this is just what I needed!
fantastic features! 💯
I love the emoji at 2:10 ha
This is amazing, thank you guys :D
Woah, this is awesome! This will probably save a bit of work :)
Seems pretty powerful. Nice feature.
Brilliant. Very useful feature.
The Flutter videos should be a series on Netflix, they're so entertaining!
Can't wait for the movie.
i am not even a programmer, never in any school or university, but hooly ss, its so easy to coding because of dart language. iam even got score in stackoverflow answer bounty question about flutter, aroud 1k just answer people question, and its fun, and i am proud of it(because iam newbie). i do it for hobby, right know i get my first serious project since 2018(my first lang is java btw). :D. thanks flutter team
It's beautiful to be able to add a 'hasValue' or 'hasNonEmptyValue' method to strings. Saves a ton of null and empty checking.
Who doesn't wants to learn more features? Everybody loves it
Hey beautiful Flutter team, I hope that one day, Flutter's website will have an official 'Google Certified Flutter Developer' exam facility. It's really impressive to witness such a growth of a framework.
Gonna be fun ! Translation, serialisation, converter waouh :) !
Dart and flutter are amazing!
Very nice.
Still, a short section around 2'52'' caught my attention when it referred to
' verb(object) vs object.verb '
I've been unsuccessfully looking for information about it for a while as there is something there that keeps bothering me. Would anyone have any suggestion of material to check on this topic ?
Cheers
Hi i have a question here i have windows dll for to collect the meter reading from meter using optical probe flutter support windows dll ? please answer
Awesome. Next we want 'Trailing closures'
WOW!!! This will be awesome for generated code!!!
Awesome feature
You can also extend enum classes right? explaining that also would be nice.
Guys i have a question. If i intend to build an app thats private and not Open Sourced with a sublicense, can i do that with Flutter as its licensed under BSD-3 license ?
absolutely great, i love it. :-)
Wow, EXTENSION rocks!
Thanks :)
I'm going to ask a silly question.
I get the whole "with great power, comes great responsibility" bit, but what's to stop someone from adding that "scream" method (although, more insidious things could be done)?
It feels like this might just be something extra for codebase maintainers to look out for when merging pull requests, no?
You're right. If, for example, person A silently adds the scream() method to String in their popular package P, and other people import that file , then they'll have .scream() on every string. But! You can't "override" with extension methods - so people would also have to actively call .scream() for this to have effect. Extension methods aren't actually added to the class, so it wouldn't even have performance implications.
but what happens if the extensions method is already used in the parent class?
does the extension override??
anyone?
thanks!!
5:14 is the source_gen lib already implement with extension? I cant find the official documentation about it anywhere
As far as I can recall you need to include in your yaml file build_runner and do build run script in the console and it will generate that.
Can the extension methods be shown in a stylized portion of the source file that was extended, inside IDEs? Sometimes when I'm thinking about how to solve some issue I just browse around the source files, see what my options are, and go from there(because sometimes documentation is lacking, and I wasn't the original author of the code). If some of the methods are already created elsewhere (via extensions) I might end up re-writiting an already created method. If the extension methods could be superimposed into the original source file (while still being clear that these are extensions and not actually part of the original source) that would be super helpful.
For example: in a Pizza Delivery App, I might not think to look in the FAQ.dart class for the bestBy(Pizza p) method that tells me for how long a pizza is safe to eat. I would want to see the definition in the Pizza.dart file, and, ideally, be able to Ctrl+click(as I do in IntelliJ) on the method name to take me to the file with the actual code definition so I can modify it, if needed, or just review the implementation of that particular extension.
salamun aleykum. can the app run on ios android if i use flutter as front end and python as back end?
I understood the "Jujustu Kaisen" reference
very nice
Adding extension methods is great, but not adding extension lambda parameters so that Flutter DSLs can be created is a big missed opportunity. The syntax chosen isn't flexible enough that it can be used to add this feature later.
For those who don't know what a DSL is, it's a way to create structured strongly typed type hierarchies. They are VERY popular in Kotlin, Scala, Groovy, and a few other modern languages. The most obvious use case is getting rid of Flutters widget creation Constructor hell, and replacing it with a proper DSL. This would be so much better than what's currently there.
Okay, let's face it--dart is becoming AWESOME! It's now my favorite language.
Awesome!
COOL
Can I override a function using extension function?
Dart ROCKS!!!
I'm unable to understand this 5:20
How fromJson can be called?
1. Planet.fromJson(json)
2. Declaring Planet _planet ; then call method _planet.fromJson(json)
3. Planet(what if there's required parameters here).fromJson(json)
My current work around is to name the extension and just call the static method.
Example: PlanetExtension.fromJson(json)
Not currently possible to add static extension method
github.com/dart-lang/language/issues/723
dart is the future
Dart becoming better and better as flutter framework becomes popular......2020 is the time of both dart and flutter.
Is there any Dart tutorial from the official for beginners?
I think android studio version 3.5.3 have problem with flutter.
If it possible make a video tutorial how to fix it
They are quite similar to the class extensions in Swift, aren't they?
Pretty much
Looks like the folks at dart will take a lot of stuff from Swift and Kotlin.
Which is a good thing!
And Kotlin as well
@@nadeemshaikh7863 I wouldn't want the task of trying to track down the origin of every feature in any of these languages. :-)
I've been around Android, Firebase and Flutter channels for a while and 2:10 it the first joke attempt that i find actually funny
Nice, like Kotlin Extensions!
*cough* like Swift extensions :)
cough, cough... like Objective C extens... categories!
inb4 C# extensions (though the syntax isn't as clean ._.)
Can I access private members from extensions?
Awesome question
Well, are private.
Maybe with reflection.
That should be easy to check
It’s just some syntactic sugar. No super powers involved (although it can improve semantics quite a lot).
2:06 are you sure these aren’t called inception methods?
I like long time.
Facade is good too
Is the code anywhere I can find?
I don't understand the part "Source generation" 4:48
How to make extension Global?
Just like swift ! 😉
Nice, but AFAIK classes cannot be extended with static methods using this approach. (As shown in the video)
You are right and I am extremely disappointed!
I came to this video by a google search because I was wondering if I could use extension methods together with code generation. I was really happy when he mentioned exactly what I had in mind... And then to find out it is a lie. That yes, you can declare a static extension method, but no it isn't applied to the class being extended.
2:32 font name ?
Already use it last month
, I think it's a little bit late for the video
2:10 🤣👍
Just came from Kotlin and this is so much simpler
2:11 hahahahha here you have your like mr.
I wish vs code would be able to automatically import ext files..
The same thing as in Swift.
Scala has too:) kotlin has too:) how about make type variance syntax go with `+T` and `-T`
So, why do not use kotlin?
lol
Name font in editor ?
It's Input. My favorite.
gold
why not use Mixin !
Love that! Now that’s all said and done, migrate Flutter to Kotlin ❤️
I think this is a really awesome addition. I think I will use it to clean up my widget tree in flutter.
Quite often when you read the tree, you will encounter lot's of clutter like Center, SizedBox, Padding, etc. I think MeaningfulWidget(...).padding() is much more readable than Padding(
child: MeaningfulWidget(...)
),
Why is this in the Flutter channel instead of...you know...a channel for the Dart language?
Someone needs to update: en.wikipedia.org/wiki/Extension_method and add dart.
Hmm. This implementation of extension methods is better than kotlin's. 🧐I like it.
The first thing of dart, which is better than in Kotlin 😁
It is supper, but the flutter itself failing to support this kind of methods
ruclips.net/video/D3j0OSfT9ZI/видео.html BRAAAAAP
I feel bad for C#. It has all the best convenience like these for years now but because of its closeness, it hasn't really been embraced by the community the way it deserves to be.
closeness? .Net core has been open source for over 4 years, and is one of the most used enterprise languages to date. I don't think C# is having a problem of not being embraced :P
@@aaronhoush7184 ikr. Like the staggering number of nix based softwares written on C# out there. I can't even choose which one to consume