Тёмный

Check Internet Connection Like a SENIOR in Flutter - Globally 

Flutter Guys
Подписаться 35 тыс.
Просмотров 25 тыс.
50% 1

📄This tutorial gives you examples of how to check the internet connection globally in Flutter.
📁 Source Code
🔗 github.com/mah...
⚡ SUBSCRIBE HERE⚡
🔗 cutt.ly/2XkZz0X
🌐 Social Media
🔗 Linkedin: / mahdinazmi
/ taimoorghafar
🔗 GitHub: github.com/mah...
github.com/tai...
🔗 Twitter: / mahdinazmi
#flutter #fluttertutorial #flutterwidgets #fluttercourse #flutterinhindi

Наука

Опубликовано:

 

26 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 90   
@user-wb9xp6qq5y
@user-wb9xp6qq5y 11 месяцев назад
Straightforward video, thank you! for this, however, I am facing a problem, when my internet connection is off and I open the app, I don't see the snack bar? Could you please help me to show the snack bar, when the internet connection is already off?
@_ritesh305
@_ritesh305 9 месяцев назад
@override void onInit() { super.onInit(); _checkInitialConnectionStatus(); _connectivity.onConnectivityChanged.listen(_updateConnectionStatus); } void _checkInitialConnectionStatus() async { ConnectivityResult connectivityResult = await _connectivity.checkConnectivity(); _updateConnectionStatus(connectivityResult); } modify your NetworkController class like this and instead of calling the DependencyInjection.init(); inside the main function use it inside the initState of the child of the runApp();
@kaustubhbavane-oq3nb
@kaustubhbavane-oq3nb 2 месяца назад
The argument type 'void Function(ConnectivityResult)' can't be assigned to the parameter type 'void Function(List)?'
@munimlabib9669
@munimlabib9669 20 дней назад
got the same error...you found any solution bro?
@KnightlyJones
@KnightlyJones 23 дня назад
its really useful buddy
@youssefchaoulid1989
@youssefchaoulid1989 4 дня назад
Tnx nice tuto 🎉❤
@lukamandic9694
@lukamandic9694 4 месяца назад
This is great, but I have a question. Why it does not work when you try to start the app while not connected to the net? Can we make it work in that case too? Thanks
@flutterguys
@flutterguys 4 месяца назад
Yes you can , please make it so I will merge it
@adityaaggarwal0
@adityaaggarwal0 4 месяца назад
if someone is struggling to display snackbar, the part where you write the snackbar code to display "No Internet", also add the same ssnackbar in else condition ( change the text to "internet found ")inside the if block, this worked for me!
@MrAmrmnabil74
@MrAmrmnabil74 4 месяца назад
why this error "The argument type 'void Function(ConnectivityResult)' can't be assigned to the parameter type 'void Function(List)?'"
@adityaaggarwal0
@adityaaggarwal0 4 месяца назад
@@MrAmrmnabil74 i think one parameter is missing
@MrAmrmnabil74
@MrAmrmnabil74 4 месяца назад
@@adityaaggarwal0 does this code worked with you ?
@adityaaggarwal0
@adityaaggarwal0 4 месяца назад
@@MrAmrmnabil74 yes it works, but sometimes its buggy. Will find better solution later but works for now
@faithtutsacademy7
@faithtutsacademy7 Год назад
Simple and to the point. Thanks
@talhasezer4
@talhasezer4 Год назад
This feature is really cool and easy to understand thanks to you. You got a new subscriber my friend.
@flutterguys
@flutterguys Год назад
❤✌
@Ayan-od8hk
@Ayan-od8hk 3 месяца назад
The only problem is that it only shows, if device is connected to network, not whether there is active internet
@user-vg7lo9fq9y
@user-vg7lo9fq9y Год назад
This is really great, Kindly make video on Provider & RiverPod too!
@flutterguys
@flutterguys Год назад
Noted
@tanvirislam8748
@tanvirislam8748 Год назад
Exactly you hit the pick point thanks ❤
@flutterguys
@flutterguys Год назад
❤✌
@ManpreetSingh-hq3dw
@ManpreetSingh-hq3dw 4 месяца назад
When i pass _udateconnectivityresult in listen then its showing error iff anybody know plz let me know
@nbakh16
@nbakh16 15 дней назад
On the new version the listener takes List of ConnectivityResult. Hence, now the method should be like this- void _updateConnectionStatus(List connectivityResult) { if (connectivityResult.contains(ConnectivityResult.none)) { Get.rawSnackbar( messageText: Text('Connect to the internet'), isDismissible: false, duration: Duration(days: 1), ); } else { if (Get.isSnackbarOpen) { Get.closeCurrentSnackbar(); } } }
@specksdude
@specksdude Год назад
Bro you saved my whole day
@Hazara_boy
@Hazara_boy Год назад
Your videos are pure gold.
@flutterguys
@flutterguys Год назад
Thank you
@nipunshah1373
@nipunshah1373 Год назад
Can you create a video depicting flutter project with GetX + Clean Archi + DI, with standard guidelines ??
@flutterguys
@flutterguys Год назад
Yes, it is in our plan.
@mrHachem
@mrHachem Год назад
thank you a lot you saved me a week of work take my subscribtion
@flutterguys
@flutterguys Год назад
❤✌
@morrigan_ghost
@morrigan_ghost Год назад
great tutorial. Btw as i heard many of flutter devs don't like getx
@flutterguys
@flutterguys Год назад
Yes, if you build your app based on Getx, it is very wrong, but in some cases it is not a problem to use it.
@iigama_yt3016
@iigama_yt3016 Год назад
​@@flutterguyscan you tell us why ?
@huyhoangvu3428
@huyhoangvu3428 Год назад
@@iigama_yt3016 actually, getx it self has many bugs
@SMAppshub
@SMAppshub Год назад
It's Working .Thank You So much. But it is not working at the beginning ,i mean if user Connection turn off and user open the app, it's not working, it is only working in inside the app Connection turn off and turn on . how can we make it work in the beginning.
@flutterguys
@flutterguys Год назад
Usually, in applications, when the user is not connected to the Internet and opens the application, we check separately on the splash page and give a warning.
@kurdev101
@kurdev101 7 месяцев назад
Keep going, thanks a lot . ❤
@anassa6737
@anassa6737 5 месяцев назад
how you pass a paremeter on void and not out it where you call it its make on m code??
@HelaFARHATI
@HelaFARHATI 7 месяцев назад
hello , thanks a lot for this explanation , i just want to ask if I'm already using bloc for state management is it okay to implement this code , or is there anyway I can do it using bloc? thanks in advance
@flutterguys
@flutterguys 7 месяцев назад
Yes, you can
@thenightguy6816
@thenightguy6816 11 месяцев назад
Can we do this using get_it package if so how would you approach this using get_it and connectivity_plus.
@ABHISHEKSHARMA-uj7jf
@ABHISHEKSHARMA-uj7jf 24 дня назад
best best
@tanvirislam8748
@tanvirislam8748 Год назад
How can I do the same thing using bloc? Please explain
@flutterguys
@flutterguys Год назад
You can use global navigator key. And inside bloc constructor, start listening to connectivity stream. As connectivity change, show snack bar or toast and use context of global navigator key. Use google to find how to use global navigator key.
@tanvirislam8748
@tanvirislam8748 Год назад
@@flutterguys thanks 👍
@user-uk7lu3dq9w
@user-uk7lu3dq9w Год назад
This will show on top of bottom navigation bar as well. How do we handle this if screen has bottom navigation or not?
@flutterguys
@flutterguys Год назад
I think you can't handle it , But please check Snackbar properties.
@thuanphamvan6210
@thuanphamvan6210 10 месяцев назад
Hi, How can I refresh the current page after reconnecting to the network, please?
@wadialyaqut3569
@wadialyaqut3569 7 месяцев назад
thank you.
@nashwan8829
@nashwan8829 9 месяцев назад
I want to get internal and external ip adrees and nrtworktype using flutter please
@tif7305
@tif7305 6 месяцев назад
beautiful
@abishekab21
@abishekab21 Месяц назад
Giving an error in the lime that's supposed to listen
@muhammadhilmiizzulhaq4375
@muhammadhilmiizzulhaq4375 Год назад
This is great! but I encountered a situation where the device starts in an offline state, the snackbar doesn't appear, how do I set it up for the snackbar to appear?
@flutterguys
@flutterguys Год назад
I have to fix it but I don't have time unfortunately. If you can fix it, and make a merge request on GitHub and I will merge.
@muhammadhilmiizzulhaq4375
@muhammadhilmiizzulhaq4375 Год назад
@@flutterguys Hahaha, I mean, I'm a beginner and I'm confused to fix it.
@fadij.8760
@fadij.8760 6 месяцев назад
I don't know if you still need this but here is the solution anyways lol. the logic to show the snackbar when the device goes offline, but it likely won't trigger if the initial state is offline because the listener in _updateConnectionStatus starts listening after initialization. replace oninit() methode in the networkcontroller with this methode and that should do it: void onInit() { super.onInit(); _connectivity.checkConnectivity().then((result) { _updateConnectionStatus(result); }); _connectivity.onConnectivityChanged.listen(_updateConnectionStatus); }
@dave8518
@dave8518 5 месяцев назад
@@fadij.8760 thanks bro ❤
@user-rj7rn2xt9m
@user-rj7rn2xt9m Год назад
hey I'm waiting for your clean architecture project with firebase ? could you give us that MVVM complete project in this month?
@flutterguys
@flutterguys Год назад
Soon
@ylmazyagzdokumac1662
@ylmazyagzdokumac1662 Год назад
First of all, thank you for the video, I did exactly what you did. But when I turn the internet back on, first it works properly, the snackbar goes away, then the snackbar comes back even though there is internet, as if there is no internet. Do you have any suggestions?
@flutterguys
@flutterguys Год назад
Please check source code
@ylmazyagzdokumac1662
@ylmazyagzdokumac1662 Год назад
@@flutterguys I went through all your code and used it exactly. The situation I said is not resolved. Solved when using internet connection checker instead of Connectivity Plus.
@malikkahfi2292
@malikkahfi2292 Год назад
Thanks
@uditrajmr3
@uditrajmr3 10 месяцев назад
i use mobx, how do i do it?
@manishadharmik5240
@manishadharmik5240 10 месяцев назад
how to make this with bloc
@roponpov
@roponpov 9 месяцев назад
how to using this with provider ?
@jeetchheda3675
@jeetchheda3675 3 месяца назад
is it possible to show a widget popup instead of a Snackbar ?
@flutterguys
@flutterguys 3 месяца назад
Yes
@gauravkushwaha7207
@gauravkushwaha7207 2 месяца назад
How can I give some idea hints to implement that ??​@@flutterguys
@chrisillafernanda2065
@chrisillafernanda2065 7 месяцев назад
is it still working if i navigate to many page?? and is it still working for the notification if i change to new page not using snackbar ?? is it stilll real time?? thank you
@flutterguys
@flutterguys 7 месяцев назад
Yes
@Omesh7
@Omesh7 Год назад
I want the Same using flutter riverpod
@adnannaatsofficial3728
@adnannaatsofficial3728 Год назад
sir you have added files insidr main but i have main file at home to plash screen and then other screens respectively so how i can access this network controller to all the othr screns as well need urgent response thanks
@flutterguys
@flutterguys Год назад
You need use GetMaterialApp insted of MaterialApp
@adnannaatsofficial3728
@adnannaatsofficial3728 Год назад
@@flutterguys I have use the same code you do ditto copy but still when I use screen on main as you do then also snack bar not showing at all
@adnannaatsofficial3728
@adnannaatsofficial3728 Год назад
@@flutterguys done actually network injection file was inside controllers folder tahtswhy not showing
@faheemahmadofficial7701
@faheemahmadofficial7701 6 месяцев назад
is thia depenxcy injecTion?
@flutterguys
@flutterguys 6 месяцев назад
Yes
@SuddenlyAPotatoAppears
@SuddenlyAPotatoAppears 4 месяца назад
The video would be perfect if it stil worked correctly
@SelfTalk0
@SelfTalk0 Год назад
Thank You so much ! It's exactly what i was looking for ! But, looking at your videos, something cames to my mind. Can we do the with something else than Getx ? I'm a Junior developer learning flutter and getx, but on the internet , there is too much polymic about getX, so i don't really know if i made a good choice. Or should i move to something else ? 😅 Once again : Thank you so much for your sharing such a golden tips ! ❤‍🔥
@flutterguys
@flutterguys Год назад
Thank you for your support ❤ Yes you can use other state managements like Bloc or Riverpod ... getx is really useful, but on the condition that you only use it in certain situations, like in this video. And it is better to use bloc or riverpod to manage the state.
@kaustubhbavane-oq3nb
@kaustubhbavane-oq3nb 2 месяца назад
The argument type 'void Function(ConnectivityResult)' can't be assigned to the parameter type 'void Function(List)?'
@edvinrushitaj
@edvinrushitaj 2 месяца назад
You should modify it like this: void _updateConnectionStatus(List connectivityResult) { if (connectivityResult.contains(ConnectivityResult.none)) { Get.rawSnackbar( messageText: const Text('No internet connection')...... etc
Далее
Angular Tutorial For Beginners | 3 Hours Course
3:17:50
Flutter Tutorial For Beginners in 3 Hours
3:15:32
Просмотров 608 тыс.
Only I get to bully my sister 😤
00:27
Просмотров 21 млн
Cute kitty gadgets 💛
00:24
Просмотров 12 млн
Flutter Basics by a REAL Project
25:42
Просмотров 458 тыс.
Top 10 Widgets every Flutter Developer should know!
10:18
Why You Shouldn’t Build Your Next App in Rust
9:18
📱магазин техники в 2014 vs 2024
0:41