Flutter Tutorial - Flutter Keys & Global Key

  Рет қаралды 33,364

HeyFlutter․com

HeyFlutter․com

Күн бұрын

Пікірлер: 61
@HeyFlutter
@HeyFlutter 2 жыл бұрын
This might help you :) 👉 12 Week Flutter Training from Newbie to Expert: heyflutter.com Source Code: github.com/JohannesMilke/key_global_example UniqueKey Tutorial: kzbin.info/www/bejne/jZnRc5Jrrs-sjbM ValueKey Tutorial: kzbin.info/www/bejne/Y3fCZqx-osSNqdE Null Safety Tutorial: kzbin.info/www/bejne/h5C6naKDg7CCobc Migrate App To Null Safety Tutorial: kzbin.info/www/bejne/fX3RgqOefc5keLs Native Splash Screen Tutorial: kzbin.info/www/bejne/bn6oaXawpshghcU Create Flutter Project For App Stores Tutorial: kzbin.info/www/bejne/apeUcoJjm5Kdj7M QR Code Scanner App Tutorial: kzbin.info/www/bejne/kGSViKaLnrSYndU Barcode Scanner App Tutorial: kzbin.info/www/bejne/e6vdqWObfqdnja8 Onboarding UI Screen Tutorial: kzbin.info/www/bejne/eYLPcmWmYpKie8k Date Picker & Time Picker Tutorial: kzbin.info/www/bejne/l5DJeKavrN5_b5I Face ID - Local Auth Tutorial: kzbin.info/www/bejne/jXrOlZablrSIpNU Fingerprint - Local Auth Tutorial: kzbin.info/www/bejne/p4XYh6iofNuXmK8 App Internationalization Tutorial: kzbin.info/www/bejne/kKiXfKKlp7urnck
@nerdbenana
@nerdbenana 2 жыл бұрын
This is way better than the official video. Thanks for the explanation!
@yasmeenabushaar2019
@yasmeenabushaar2019 2 жыл бұрын
You're the best ........ thanks a lot Milke for this tutorial
@HeyFlutter
@HeyFlutter 2 жыл бұрын
You’re most welcome, Yasmeen Abu shaar! 🙂
@gersonchadijunior7499
@gersonchadijunior7499 Жыл бұрын
Man you saved my life ! Thank you ! You have a new follower
@HeyFlutter
@HeyFlutter Жыл бұрын
Glad I could be of help, Thank you gerson chadi! 😊
@cavidanbagiri7837
@cavidanbagiri7837 2 жыл бұрын
Prosda Perfecto Teacher. You Are Krasavcik
@Sankkku
@Sankkku 2 жыл бұрын
Best teacher!!
@heisenberg5873
@heisenberg5873 3 жыл бұрын
Best video about key
@flavio.a
@flavio.a 2 жыл бұрын
Thank you for this tutorial. It helped me a lot!
@JobinJacobKavalam
@JobinJacobKavalam 3 жыл бұрын
Thank you. I found out how a parent widget can call methods in it's child's state.
@danielekpenyong5930
@danielekpenyong5930 2 жыл бұрын
love your videos man keep it up
@HeyFlutter
@HeyFlutter 2 жыл бұрын
Thank you, Daniel Ekpenyong! 🙂
@arnaudduquenoy2061
@arnaudduquenoy2061 3 жыл бұрын
So clear when you explain :) You should have been my math teacher when i was young :))
@arnaudduquenoy2061
@arnaudduquenoy2061 3 жыл бұрын
I returned today on the Global Key series. These kind of specialized tutos are very usefull compared to so many basic Dart tutos that you can find on the internet. A lot of people are trying to find advanced tutos on Dart but the majority of them are so Basic compared to these kind of tuto
@HeyFlutter
@HeyFlutter 2 жыл бұрын
Awesome, thanks a lot, Arnaud! 🙂 Yeah, I try my best so that people don't say the same about Flutter in the future 😉
@abdulrehman-ws9wl
@abdulrehman-ws9wl 3 жыл бұрын
Great Explanation...Thank you
@abdulrehman-ws9wl
@abdulrehman-ws9wl 3 жыл бұрын
@@HeyFlutter Have you create video on other type of keys in flutter like : unique key, Value key etc.?
@mohammadal-sadiqh.3871
@mohammadal-sadiqh.3871 3 жыл бұрын
Great explanation... Thank you
@yousour5112
@yousour5112 3 жыл бұрын
clear and perfect , thank you :)
@TrikNgonlen
@TrikNgonlen 3 жыл бұрын
that's great, @Johannes Milke ...
@farhanahmad-bv1mx
@farhanahmad-bv1mx 2 жыл бұрын
Awesome👏👍
@CodeWhizbang
@CodeWhizbang 3 жыл бұрын
Thanks.
@NurulIslam-dw8yp
@NurulIslam-dw8yp 3 жыл бұрын
Thanks
@meetamin7343
@meetamin7343 2 жыл бұрын
Thanks🙏🙏
@zerocel
@zerocel 3 жыл бұрын
thank you !!! finally useful!!!
@kingbheem640
@kingbheem640 3 жыл бұрын
Can you pls explain how to create multiple enddrawer in a single same page with different content
@usmanshoaib2099
@usmanshoaib2099 2 жыл бұрын
I am receiving GlobalKey current state null ?? I have tried for variable and function both but getting null value.
@enafor99
@enafor99 3 жыл бұрын
thank you so much awesom tutorial:)
@piattidjoka8946
@piattidjoka8946 3 жыл бұрын
Thanks you sir
@meetrajpopat2348
@meetrajpopat2348 3 жыл бұрын
one question brother my local app notification(not the firebase but native) is not working when app is terminated what to do(i already watched your old videos)? can you please make video on that? and also make video on native ad which uses the latest package from google ad, old one is deprecated and i lost where the part to write native code inside manifest file there is some errors regarding package and also note that i also used fluuter_native_ads package but due to new firebase firestore package i got error while building i will be very thankful if you help me out, btw love your content
@fluffycatstream6196
@fluffycatstream6196 2 жыл бұрын
Hi, How to access GlobalKey to another flutter page / file? another people asked this 6 months ago and you give a very outdated way. please tell me properly I really need this thank you.
@fluffycatstream6196
@fluffycatstream6196 2 жыл бұрын
@@HeyFlutter this does not work sir, this is a different topic
@kasandrop
@kasandrop 3 жыл бұрын
thanks for it I prefer to read the subtitles though.
@spinoff2011
@spinoff2011 3 жыл бұрын
And what happen with the explanation of the plain keys (not the global)? :s
@eNONO-ot4zh
@eNONO-ot4zh 3 жыл бұрын
in my projet i have this error: Looking up a deactivated widget's ancestor is unsafe. I try to folloz your course but i have a error like: "'dynamic' doesn't conform to the bound 'State' of the type parameter 'T'. Try using a type that is or is a subclass of 'State'." and "The name '_SalerListViewAnnounceWidgetState' isn't a type so it can't be used as a type argument. Try correcting the name to an existing type, or defining a type named '_SalerListViewAnnounceWidgetState'."
@HeyFlutter
@HeyFlutter 2 жыл бұрын
Thank you, e.NONO! 🙂 Make sure wherever you are using navigator.pop() must have atleast one screen availabe on stack
@congtoannguyen1940
@congtoannguyen1940 2 жыл бұрын
How do I dispose a TextFormField correctly with this global Form and can I (or should I ) dispose the Global Form Key too if so then how
@HeyFlutter
@HeyFlutter 2 жыл бұрын
Thank You Cong Toan Nguyen! Follow this link: stackoverflow.com/questions/68095494/why-did-if-statement-dispose-textformfield-in-flutter I hope you will get your answer 🙂
@piyushbhatnagar4735
@piyushbhatnagar4735 Жыл бұрын
Which key we have to use with Stateless Widget
@HeyFlutter
@HeyFlutter Жыл бұрын
Thank You @piyushbhatnagar4735! Follow this link: stackoverflow.com/questions/50080860/what-are-keys-in-the-stateless-widgets-class I hope you will get your answer 🙂
@vaibhavdangayachvd
@vaibhavdangayachvd 3 жыл бұрын
Why not use provider?
@theghost6606
@theghost6606 3 жыл бұрын
I dont understand why we use keys. In this example we used the key to access the methods and variables. But this is also possible with Classname.variable isnt it ?
@theghost6606
@theghost6606 3 жыл бұрын
@@HeyFlutter Thank you. Now i understand. Great Video!
@HeyFlutter
@HeyFlutter 2 жыл бұрын
Thanks, The Ghost! 🙂 The first example was only a very simple demonstration to showcase how Global Keys work, however, you are right this should not be used in your apps because you could also pass the counter variable directly down from the parent to the child widget without using GlobalKeys. The second example at 4:17 is a real example that makes more sense to use since the widget is from the Flutter SDK and we have no direct control over it however with the help of Global Keys we can access this external widget - its state and also its logic. Global Keys should be mainly used to access logic & state of EXTERNAL Source Codes such as packages & the Flutter SDK, as demonstrated at 4:17. If you write your own widgets prefer to use StatelessWidgets & write your logic with a State Management, then you don't need to care about Global Keys anymore. Check also my tutorials out about State Management here: 1. Riverpod Basics Providers Tutorial: kzbin.info/www/bejne/bnmWk6qurdGUars 2. Riverpod Basics Notifiers Tutorial: kzbin.info/www/bejne/rHWQemR3h66ApM0 3. Riverpod Basics Modifiers Tutorial: kzbin.info/www/bejne/bZmVc6WqgJ11psk 4. Riverpod & Calculator UI Tutorial: kzbin.info/www/bejne/bJrWiGVsmZ6Hn6c 5. Provider Tutorial: kzbin.info/www/bejne/mZ3XdKOOjptjic0 6. Provider & Firebase Tutorial: kzbin.info/www/bejne/e4eVdayogLSkqLs
@njomaboujaib4995
@njomaboujaib4995 3 жыл бұрын
Great and clear content as always
@njomaboujaib4995
@njomaboujaib4995 3 жыл бұрын
@@HeyFlutter it worked :D thanks for the explanation and quick answer :) you are the best
@HeyFlutter
@HeyFlutter 2 жыл бұрын
Thanks, Njm! 🙂 Sure good question, first of all you need to check if you can access the state of your GlobalKey by checking if keyCounter.currentState != null. Only if the currentState exists then you could access the state & logic of your StatefulWidget with the help of your GlobalKey. Check out the example below where we display the counter within the AppBar Title: import 'package:flutter/material.dart'; class BasicKeyPage extends StatefulWidget { @override _BasicKeyPageState createState() => _BasicKeyPageState(); } class _BasicKeyPageState extends State { final keyCounter = GlobalKey(); @override Widget build(BuildContext context) { final counter = keyCounter.currentState == null ? '0' : keyCounter.currentState!.counter; return Scaffold( appBar: AppBar( title: Text('My Counter: $counter'), centerTitle: true, ), body: Center( child: CounterWidget(key: keyCounter), ), floatingActionButton: FloatingActionButton( child: Icon(Icons.add), onPressed: () => setState(() => keyCounter.currentState!.increment()), ), ); } } class CounterWidget extends StatefulWidget { const CounterWidget({Key? key}) : super(key: key); @override _CounterWidgetState createState() => _CounterWidgetState(); } class _CounterWidgetState extends State { int counter = 0; void increment() => setState(() => counter += 5); @override Widget build(BuildContext context) => Text( 'Counter: $counter', style: TextStyle(fontSize: 32), ); }
@immunemart484
@immunemart484 3 жыл бұрын
How to make the height of the cursor same with the height of text in UITextField?
@immunemart484
@immunemart484 3 жыл бұрын
@@HeyFlutter i know but i have many doubts, so i comment on ur latest video so that u give me attantion.
@HeyFlutter
@HeyFlutter 2 жыл бұрын
Thanks, Mart! 🙂 This seems to be unrelated to the concept of Global Keys. Learn more about TextFields here: kzbin.info/www/bejne/eWbLe3yBeLmlrM0
@robertmrobo8954
@robertmrobo8954 3 жыл бұрын
Hi Milke, How do I access the global key defined in a different dart file?
@fabioburkard
@fabioburkard 3 жыл бұрын
@@HeyFlutter Excellent tutorial, Johannes! If you know any (recent) solution using GlobalKey, pls share... I don't know why, but some old codes don't work anymore, using GlobalKey's inside different files.
@HeyFlutter
@HeyFlutter 2 жыл бұрын
Thank you, Robert Mrobo! You could learn more about this problem here : stackoverflow.com/a/29182641
@Wick__op
@Wick__op 2 жыл бұрын
Nice
@HeyFlutter
@HeyFlutter 2 жыл бұрын
Thank you, blacky arinova! 🙂
@Tech1st
@Tech1st 3 жыл бұрын
Why r u using keys?
@HeyFlutter
@HeyFlutter 2 жыл бұрын
Thanks, Tech1st! 🙂 In this video, we were focused on Global Keys. With a Global Key, you can access the state of Stateful Widgets. Therefore a Global Key can be useful to access the state & logic of other widgets as demonstrated at 7:32 Especially the Flutter SDK uses this technique to implement some logic within their Stateful Widgets which you can then access over a GlobalKey. All in all, it is mainly used to access the logic of StatefulWidgets that were created for you within the Flutter SDK or within other Flutter packages.
@shubhamjaitapkar3359
@shubhamjaitapkar3359 2 жыл бұрын
if you make the class in different you won't be able to access the key!!
Flutter Tutorial - Flutter Keys & Value Key
8:52
HeyFlutter․com
Рет қаралды 16 М.
10x Your Speed With Flutter
8:04
Flutter Mapp
Рет қаралды 61 М.
Wait for it 😂
00:32
ILYA BORZOV
Рет қаралды 6 МЛН
Я сделала самое маленькое в мире мороженое!
00:43
小丑家的感情危机!#小丑#天使#家庭
00:15
家庭搞笑日记
Рет қаралды 37 МЛН
This mother's baby is too unreliable.
00:13
FUNNY XIAOTING 666
Рет қаралды 43 МЛН
Top 10 Flutter Widgets (for Responsive Layouts)
13:17
HeyFlutter․com
Рет қаралды 73 М.
Inspired by MKBHD | Built with Flutter - Panels App
24:24
35 Flutter Tips That Will Change Your Life
10:53
Flutter Mapp
Рет қаралды 307 М.
Keys in Flutter | Decoding Flutter
11:10
eTechViral
Рет қаралды 2,8 М.
Best 30 Flutter Widgets, Packages & Tips
5:11
Flutter Mapp
Рет қаралды 122 М.
Expense Tracker App • Flutter & BLoC Tutorial for Beginners
35:16
HeyFlutter․com
Рет қаралды 9 М.
Wait for it 😂
00:32
ILYA BORZOV
Рет қаралды 6 МЛН