Can we just say Flutter is awesome! The community around the great product is something that makes it particulary fantastic. Every day Flutter developers around the world discover the new smart ways to write a beautiful code faster, and luckily they share their findings with their fellow Flutter developers on Twitter.
Software developers at Codemagic have collected their top hacks/tips of the previous months that will help you master your Flutter skills.
Click to tweet
If you have some valuable tips/ hacks to share, please DM @codemagicio or just use hastag #Flutter Tip to be included to the next edition.
Happy building!
Twitter tip #1
Quick tip:
If you are writing same thing again and again like MediaQuery.of(context).size or Theme.of(context).textTheme
then make sure you make a snippet of it in whatever IDE you use. It can save a hell lot of time.#Flutter #VSCode #IntelliJ
— Pawan Kumar (@imthepk) January 28, 2020
Twitter tip #2
#Flutter tip: Run your tests with a random seed:
flutter test –test-randomize-ordering-seed random
A few things could happen:
– Everything works! Great job! 😎
– Something broke! Go fix it! 💪
– You have no tests? Go write some! 👩💻👨💻— Jorge Coca 🐶💙🦄 (@jcocaramos) February 11, 2020
Twitter tip #3
Random #Flutter tip:
You can use GlobalKeys inside StatelessWidget by combining GlobalObjectKey and BuildContext (and potentially tuples)
This avoids using global variables, which therefore makes the widget reusable. 🙂 pic.twitter.com/uWs9x8fuIS
— Remi Rousselet (@remi_rousselet) January 16, 2020
Twitter tip #4
Dart: List `sort` function is void. But there is a hack! 🤠 Use double dot to make it return array back. 👍 #dart #flutter #mobiledev #androiddev #iosdev #tark #dartdev #flutterdev pic.twitter.com/fRCZ4iF02k
— Airon Tark (@airon_tark) September 9, 2019
Twitter tip #5
#Flutter devs! This is why you should NEVER put logic (except for animations etc.) into your UI. Flutter is practically one big data binding 😂 https://t.co/MopsUBULDc
— Reso Coder (@resocoder) February 26, 2020
Twitter tip #6
While I don’t think hooks are the best solution for everything, I love them for Flutter forms
Without, forms are so painful to write because of all these long-lived objects.
But with hooks you can just forget about it and focus on what matters pic.twitter.com/q5NYg9plcV
— Remi Rousselet (@remi_rousselet) February 21, 2020
Twitter tip #7
Pro tip; when testing your newly built app, be sure to use credentials that are easy to remember for authentication.
how on earth will I remember “vzdncfhvcdynsdt@email.com and nfvdfmjsvdfkg” to login? 😰🙆😂#Flutter #DroidconKE— KendiJ💙 (@kendyjaky) February 26, 2020
Twitter tip #8
Flutter tip: add how to add a debug print function to your dart/flutter class..#Flutter #flutterdev pic.twitter.com/1nUjXTOT12
— sriram kota 💙💛🌻 (@sriramskota) February 26, 2020
Twitter tip #9
Discovered great new tip w/the Windows Application Packaging Project-Had a non-VS project (flutter for windows) that I want to package the output folder w/#MSIX. Trick is to add the binaries as “content” files and then set <EntryPointExe> in the wap project file. Worked great! pic.twitter.com/g3X45k1cv8
— AdamBr 🇺🇸🇺🇦 (@TheAdamBr) February 20, 2020
Twitter tip #10
Twitter tip #11
#flutter tip: JsonSerializable(anyMap: true)
— Rubens de Melo (@rubensdemelo) February 16, 2020
Twitter tip #12
#Flutter tip
I love to use the finder by widget type but it’s not that clear.
You have to get runtime Type of your widget. Could be an awesome pull request to simplify this. #flutterDev #dart #flutterTip pic.twitter.com/FNLOqniKGR— Gautier 💙 (@mcflyDev) February 13, 2020
Twitter tip #13
#flutterdev tip: Sometimes designers create custom icons, and you’d have to convert them to fonts + dart code. The best way to do this is via the open-source tool https://t.co/wlcTts7rMd, but sometimes the SVGs aren’t rendered correctly…THREAD! @flutteriodaily @Flutter_Africa
— who? (@txe_bert) January 1, 2020
Twitter tip #14
#flutter tip: when testing, you need to use ‘_test’ at END of filename. pic.twitter.com/CioTOeF9Po
— Rubens de Melo (@rubensdemelo) February 8, 2020
Twitter tip #15
I’d say avoid things like MobX/Redux/Bloc unless you’re sure you can’t go without them. Provider will get you 90% of the way there for most apps
— Nollie (@stargazing_dino) February 5, 2020
Twitter tip #16
#flutter tip: On iOS, setup your flutter/firebase project with Xcode. Don’t use vscode or android studio ( run pod install/update)
— Rubens de Melo (@rubensdemelo) January 31, 2020
Twitter tip #17
You can’t render @FlutterDev app on a transparent canvas, but you can get some alpha during layer composition phase with this CoreImageFilter which turns all black pixels into transparent#flutter #MacOS
(ugly hack, don’t use) pic.twitter.com/3ZELau1FlA
— Andrei Lesnitsky 💙 (@lesnitsky_dev) October 21, 2019
Flutter Web
Twitter tip #18
Flutter Web/Desktop Tip: You can use the following line of code to check “Whether or not a mouse is connected and has produced events”. This can be useful to adjust UI affordances to best suit the device.
RendererBinding.instance.mouseTracker.mouseIsConnected
— Hillel Coren (@hillelcoren) January 21, 2020
Hacks from #FlutterEurope
Conference and Meetups are great places to learn some new tricks. Flutter Europe was definitely a great start for the year to boost your Flutter skills.
Twitter tip #19
“When validation of form in #flutter fail, focus on the first field that failed.” SUPER USEFUL TIP from @rogoodhead at #FlutterEurope
— Paul Kastel (@paulkastel) January 24, 2020
Twitter tip #20
#tips Try MobX and RxVMS for less boilerplate. Redux in flutter can be tricky; add memoization and built value https://t.co/k2IRzTsVW4 From @hillelcoren at #FlutterEurope
— Simon B. (@sesammases) January 24, 2020
Twitter tip #21
Use can use
MediaQuery(
data: MediaQuery.of(context) .copyWith(textScaleFactor: 1),
child: //your child
),
To keep the text size constant regardless of the text size user has selected natively.🤓💙
You can change the textScaleFactor to tweak around.#flutter #fluttertips— Shekar Mudaliyar 💙 (@0_B1NARY) January 5, 2020
Twitter tip #22
If you want to have offline support for your app, then Hive is preferred over sqflite.
If you want common database for Web, desktop and mobile the go with hive.#flutter #fluttertips #hive @r_FlutterDev @FlutterEurope @dhuma1981 @ayushshekhar17— Vivek Yadav #PROCoach | ZestMoney (@viveky259259) January 5, 2020
Twitter tip #23
If you want to put space between two widgets use SizedBox();
eg. SizedBox(width:16) //for horizontal space
SizedBox(height:16) //for vertical space#flutter #fluttertips @FlutterDev @pblead26 @burhanrashid52 @ThomasBurkhartB @bugs_creator— Vivek Yadav #PROCoach | ZestMoney (@viveky259259) January 3, 2020
Twitter tip #24
If you want to try some dart/flutter code but your machine is not with you.
Then #dartpad is for you.
Go to https://t.co/wzl51G5ZlL and experience it.
#flutter #fluttertips @FlutterDev @FlutterEurope @ibhavikmakwana— Vivek Yadav #PROCoach | ZestMoney (@viveky259259) January 3, 2020
Twitter tip #25
“Logs are your friends. Read them carefully. They are your true source of information” Priit Lätt #fluttereurope
— Codemagic (@codemagicio) January 24, 2020
Source of good Flutter tips
Introducing “Tips”: Code samples and useful tips for day-to-day Flutter app development.
Here are the first two tips on my Flutter website:
– Top & bottom ListView separators: https://t.co/02ie2jhR1s
– Unused builder arguments: https://t.co/4HQuzkTIp6Happy coding!
— Andrea Bizzotto 💙 (@biz84) January 12, 2020
Happy building!
Discussion about this post