New post on /r/flutterdev subreddit:
<b>18+ Flutter tips & tricks</b>
If you want to produce (or reproduce) a production ready flutter app, we have 18+ tips and tricks for you. 👇<strong>1. Create Intro Screen in Just 10 Minutes</strong>If you need an awesome intro screen but don’t have an awesome idea, <a href="
https://pub.dev/packages/introduction_screen">Introduction Screen</a> will save you. You'll be amazed.<strong>2. Use Flutter Snippet</strong>If you need productivity, Flutter Code Snippet will make you a superstar. You can easily create commonly used Flutter classes and methods. For example, you can create StreamBuilder Widget or SingleChildScrollView Widget by typing the shortcut streamBldr and singleChildSV respectively. You can use the flutter snippet in <a href="
https://github.com/benznest/flutter-snippet">Android Studio</a> or <a href="
https://marketplace.visualstudio.com/items?itemName=Nash.awesome-flutter-snippets">VSCode</a>.<strong>3. Create Mind-blowing Icons Using Font Awesome</strong>You don’t have to be the designer to include mind-blowing icons in your app. Just use the <a href="
https://pub.dev/packages/font_awesome_flutter#-readme-tab-">font awesome for flutter</a> and you will create magic in minutes.<strong>4. Enjoy Dependency Magic Using</strong> <strong>
get.it</strong>A good practice is to put your app’s logic in classes separated from your Widgets and then inject it wherever needed. For example, one of my app, we need to access the Prefmanger class from multiple places to read and update the user state stored in the localstorage. We used <a href="
https://pub.dev/packages/get_it">get_it</a> so that this class can be injectable as a dependency.<code>GetIt locator = GetIt.instance;</code><code>void setupLocator() async {</code><code>var instance = await PrefManager.getInstance();</code><code>locator.registerSingleton<PrefManager>(instance,signalsReady: true);</code><code>FirebaseDatabase database = FirebaseDatabase.instance;</code><code>database.setPersistenceEnabled(true);</code><code>locator.registerSingleton<DatabaseReference>(database.reference());</code><code>}</code>//Now you can easily access our prefmanger class like below:<code>locator<PrefManager>().color = 12 ;</code>If you want to see the code block properly, please check out the <a href="
https://medium.com/programminghero/18-flutter-tips-tricks-to-give-birth-to-a-production-ready-app-95718e51b6be">full article on our Medium blog.</a><strong>5. Reuse Data Using the Singleton Pattern</strong>Singleton means the class has only one instance and also provides a global point of access to it. It is also an easy one to get wrong if you are not using it carefully. We need to access our ThemeColorclass (dark mode or light mode) again and again to set our theme color in widget . 👇<code>class ThemeColor{</code><code>// Singleton instance</code><code>static final ThemeColor _repo = new ThemeColor._();</code><code>// Singleton accessor</code><code>static ThemeColor get instance => _repo;</code><code>// A private constructor. Allows us to create instances of Repository</code><code>// only from within the Repository class itself.</code><code>ThemeColor._();</code><code>Color cardColor(){</code><code>return locator<PrefManager>().darkTheme? Color(0xff221F47):Colors.white;</code><code>}</code><code>Color containerColor(){</code><code>return locator<PrefManager>().darkTheme? Color(0xff161430):Colors.white;</code><code>}</code><code>}</code><code>ThemeColor.instance.cardColor()</code><strong>6. Avoid Widget Rebuild by Using</strong> <strong>const</strong> <strong>Constructor</strong>If you want to prevent unwanted widget rebuilds always use <strong>const</strong> constructor. In the code below, the instance of BoxDecoration will remain the same even if the setState is called.<code>Container(</code><code>width: 250,</code><code>height: 250,</code><code>decoration: const BoxDecoration(</code><code>borderRadius: BorderRadius.only(</code><code>bottomLeft:…