Can we just say Flutter is awesome! The community around the great product is something that makes it particularly 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.
If you have some valuable tips/ hacks to share, please DM @codemagicio or just use hashtag #Flutter Tip to be included to the next edition.
Happy building!
Twitter tip #1
Quick tip:
— Pawan Kumar (@imthepk) January 28, 2020
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
Twitter tip #2
#Flutter tip: Run your tests with a random seed:
— Jorge Coca ๐ถ๐๐ฆ (@jcocaramos) February 11, 2020
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! ๐ฉโ๐ป๐จโ๐ป
Twitter tip #3
Random #Flutter tip:
— Remi Rousselet (@remi_rousselet) January 16, 2020
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
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
— Remi Rousselet (@remi_rousselet) February 21, 2020
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
Twitter tip #7
Pro tip; when testing your newly built app, be sure to use credentials that are easy to remember for authentication.
— KendiJ๐ (@kendyjaky) February 26, 2020
how on earth will I remember "vzdncfhvcdynsdt@email.com and nfvdfmjsvdfkg" to login? ๐ฐ๐๐#Flutter #DroidconKE
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
#flutter tip: JsonSerializable(anyMap: true)
— Rubens de Melo (@rubensdemelo) February 16, 2020
Twitter tip #11
#Flutter tip
— Gautier ๐ (@mcflyDev) February 13, 2020
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
Twitter tip #12
#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
— oncle vader (@txe_bert) January 1, 2020
Twitter tip #13
#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 #14
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 #15
#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 #16
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
— Andrei Lesnitsky ๐ (@lesnitsky_dev) October 21, 2019
(ugly hack, don't use) pic.twitter.com/3ZELau1FlA
Flutter Web
Twitter tip #17
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.
— Hillel Coren (@hillelcoren) January 21, 2020
RendererBinding.instance.mouseTracker.mouseIsConnected
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 #18
"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 #19
#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 #20
Use can use
— Shekar Mudaliyar ๐ (@0_B1NARY) January 5, 2020
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
Twitter tip #21
If you want to have offline support for your app, then Hive is preferred over sqflite.
— Vivek Yadav #PROCoach (@viveky259259) January 5, 2020
If you want common database for Web, desktop and mobile the go with hive.#flutter #fluttertips #hive @r_FlutterDev @FlutterEurope @dhuma1981 @ayushshekhar17
Twitter tip #22
If you want to put space between two widgets use SizedBox();
— Vivek Yadav #PROCoach (@viveky259259) January 3, 2020
eg. SizedBox(width:16) //for horizontal space
SizedBox(height:16) //for vertical space#flutter #fluttertips @FlutterDev @pblead26 @burhanrashid52 @ThomasBurkhartB @bugs_creator
Twitter tip #23
If you want to try some dart/flutter code but your machine is not with you.
— Vivek Yadav #PROCoach (@viveky259259) January 3, 2020
Then #dartpad is for you.
Go to https://t.co/wzl51G5ZlL and experience it.
#flutter #fluttertips @FlutterDev @FlutterEurope @ibhavikmakwana
Twitter tip #24
"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.
— Andrea Bizzotto ๐ (@biz84) January 12, 2020
Here are the first two tips on my Flutter website:
- Top & bottom ListView separators: https://t.co/02ie2jhR1s
- Unused builder arguments: https://t.co/4HQuzkTIp6
Happy coding!
Happy building!