Expert Insights into Flutter App Development (Part # 01)
Tags: flutter, codenewbie, devops, appsync
Published: 2023-10-20 08:24:44

Hey there, fellow developers! Flutter has been the talk of the town since 2023. With the increasing number of flutter app developers, we all are looking for a flutter cheat sheet that will make us code easier. Today, I want to share some Flutter cheat codes that have made my coding journey easier. 

## Why Flutter?
Flutter is an open-source UI software development toolkit created by Google that has revolutionized the way we build natively compiled applications for mobile, web, and desktop from a single codebase.
Before we dive into the cheat codes, let's briefly understand what Flutter is. Flutter allows developers to create applications using a single codebase. This means you can write code once and run it on multiple platforms, including Android, iOS, web, and even desktop. It's like a magic wand for developers, making cross-platform development smoother and more efficient.

## Insights on [Flutter App Development](https://www.technbrains.com/mobile-application/flutter-app-development/)
I have had the privilege of witnessing the incredible potential of Flutter in our software development
journey. These cheat codes have helped us unlock its full potential:

**FOR INPUTS AND CONTROLS IN FLUTTER**

- TextField - displays a keyboard input field
Code:
**TextField(
controller: TextEditingController, 
keyboardType: TextInputType.number, 
decoration: InputDecoration, onChanged: (newVal) => {},
)**

TextField is the most commonly used text input widget. A TextField comes with an underline decoration by default. You can customize it by providing an `InputDecoration` object as the `decoration` property of the TextField. With `InputDecoration`, you can add a label, icon, inline hint text, and error text to the TextField. If you want to remove the decoration entirely, including the underline and the space reserved for the label, just set the `decoration` to `null`.

- FlatButton - shows you a button that you can press 
Code:
**FlatButton (
child: Widget, // Usually Text or Container 
onPressed: () => {},
textColor: Colors.red,
)**

In Flutter, the FlatButton widget is a user interface element that displays a rectangular area with an ink splash when pressed. It's designed to provide a simple and interactive way for users to trigger actions within your application.
Protip: OutlineButton and RaisedButton accept similar parameters

- DropDownButton – Create your own dropdown
Code:
**DropDownButton<String> (
value: curValue, // selected option 
icon: Icon (Icons.arrow_drop_down), 
onChanged: (newVal) => {},
items: [
DropDownMenuItem(
value: "opt1", child: Text ("Option 1")
),**

Flutter provides a useful widget called DropDownButton, which follows the material design guidelines. It allows users to choose one option from a set of values. By default, the button displays the current selection, and an arrow icon indicates the availability of additional options. When the user clicks on the button, a list appears with all available options, and the user can select their desired value from the list.

**FOR RESPONSIVE DESGIN**

MediaQuery - Use it to determine what device size you're using; adjust your output accordingly. 
**final width = MediaQuery.of (context).width; 
if (width <= 600) {
// mobile
} else if (width <= 960) {
// tablet
} else {
// desktop
}**

Designing mobile applications that meet the needs of users with various device sizes and preferences can be challenging. However, MediaQuery provides a solution to this problem. With MediaQuery, you can access information about the current device size and user preferences, and design your layout accordingly. 

MediaQuery provides a higher-level view of the current app's screen size, and it can also give more detailed information about the device and its layout preferences. This means that if a user has a preference set for different font sizes or wants to limit animations, you can make sure your application meets their needs. 

In practice, MediaQuery is always available and can be accessed by calling MediaQuery.of in the build method.

**EXPERT INSIGHTS – FLUTTER PLUGINS**

Leading the team of experienced Flutter developers, I understand the significance of utilizing the right plugins to enhance the functionality and efficiency of your Flutter applications. 
Below, I'll provide insights into a selection of highly recommended plugins and why they are invaluable for your Flutter development journey:

- **flutter_svg:** Scalable Vector Graphics (SVG) are essential for creating responsive and high-quality graphics in your app. This plugin allows you to render SVG images seamlessly, ensuring crisp visuals on various screen sizes and resolutions.

- **provider:**State management is a cornerstone of Flutter development. Provider is a popular choice for managing state efficiently, offering a convenient way to share data across your app and ensure a responsive user interface.

- **wiredash:**
 User feedback is invaluable for app improvement. Wiredash simplifies feedback collection, enabling users to report issues, suggest features, or provide general comments, fostering a more user-centric development process.

- **sentry:**
 Error monitoring is critical for app stability. Sentry provides real-time error tracking, helping you identify and address issues promptly, ensuring a smooth user experience.

- **http:**
 Networking is a fundamental aspect of most apps. The HTTP plugin streamlines network requests, making it easier to communicate with web services and fetch data.

- **get:**
Navigation in Flutter can become complex as your app grows. The 'get' package simplifies navigation management, making it easy to navigate between screens and pass data.

- **animations:**
 A visually appealing app can captivate users. The animations package provides a wide array of animation options to add life to your app's user interface.

- **flutter_hooks:**
 Building and managing widgets efficiently is essential. Flutter Hooks optimizes widget management and makes your code more organized and readable.

- **google_fonts:** 
Typography plays a crucial role in design. Google Fonts offers a vast selection of free, open-source fonts to enhance the visual appeal of your app.

- **video_player:**
 Multimedia content is prevalent in modern apps. The video_player package facilitates the integration of video content, ensuring a seamless playback experience.

- **dio:**
 Advanced network operations often require more control. Dio is a high-level HTTP client that provides customization and flexibility for complex networking tasks.

- **url_launcher:**
 Linking to external resources is common. The url_launcher plugin simplifies the process of launching external links, making it easy to open websites, maps, or other apps.

- **image_picker:**
 Many apps require image uploading or selection. The image_picker plugin simplifies image handling, allowing users to select or capture images effortlessly.

- **shared_preferences and hive:**
 Persistent data storage is crucial for maintaining user settings and app preferences. These packages make it easy to store and retrieve data locally.

## Wrapping it Up
In this expert insight, we've explored essential Flutter plugins that are indispensable for developers. From efficient state management with 'provider' to captivating user interfaces with 'animations,' each plugin serves a specific purpose in enhancing Flutter app functionality. Now over to you, let me know:
Which of these plugins have you found most beneficial in your Flutter projects, and why?
Have you faced any challenges with state management in Flutter apps? How did you overcome them, especially concerning plugins like 'provider' and 'flutter_hooks'?