
[
  {
    "content": "What is an API? An API, or Application Programming Interface, is a set of rules for building and interacting with software applications. It defines the methods and data formats for requesting and exchanging information between different software programs, enabling them to communicate and share functionalities efficiently.\nWhat is REST API? A REST API, or Representational State Transfer API, is a type of API that adheres to the REST architectural style. It uses HTTP requests to access and use data, with the operations including GET, POST, PUT, and DELETE.\nPrinciples of REST Client-server architecture: Separation of client and server functionalities to improve portability and scalability of the application. Stateless: Each request from the client to the server must contain all the information the server needs to understand and complete the request. Cacheable: Responses must define themselves as cacheable or not to prevent clients from reusing stale or inappropriate data. Uniform interface: Simplifies and decouples the architecture, which enables each part to evolve independently. Layered system: The client cannot tell whether it is connected directly to the end server or to an intermediary. Code on demand (optional): Servers can temporarily extend or customize the functionality of a client by transferring executable code. How Do REST APIs Work? When a client requires data or functionality, it sends a request to the server using a URL. The server processes the request, and then sends back a response. This response includes a status line indicating success or failure and the requested resource in the format specified by the request.\nComponents of a RESTful API Request Resource identifier (URL): Uniquely identifies the resource being requested. HTTP Method: Defines the operation to be performed (GET, POST, PUT, DELETE, etc.). Headers: Provide metadata for the HTTP request, including content type, authentication, etc. Body (optional): Contains data sent with the request (for POST, PUT methods). Benefits of RESTful APIs Scalability: Efficient client-server interactions and stateless operations facilitate scalability. Flexibility and Independence: The separation of client and server, along with the stateless nature of requests, allows various parts of an application to evolve independently. Widespread Use: Given its efficiency, simplicity, and support across programming languages, REST APIs are widely used for web services, including social media platforms, mobile applications, and IoT devices. HTTP Status Codes Here are some common HTTP status codes and their meanings:\n200 OK: The request was successful. 201 Created: The request has been fulfilled and resulted in a new resource being created. 400 Bad Request: The server cannot process the request due to a client error. 401 Unauthorized: The request has not been applied because it lacks valid authentication credentials. 404 Not Found: The server cannot find the requested resource. 500 Internal Server Error: The server encountered an unexpected condition that prevented it from fulfilling the request. ",
    "description": "A beginner-friendly guide to understanding APIs, RESTful APIs, and their importance in modern web development.",
    "tags": null,
    "title": "API and REST API",
    "uri": "/working-with-api/introduction-to-api-and-rest-api/"
  },
  {
    "content": "Introduction to Assets In the simplest terms, assets are files that are pack together with your Flutter application. These files can include a variety of types:\nType Description Images Common formats like JPEG, PNG, GIF, and more. Fonts Custom fonts to give your app a unique typography. Audio Sound effects and music files. Videos Small video files used in the app. Data JSON, XML, or other formatted data files. Info Note: In upcoming sections, you will learn how to use images, fonts, and other files in flutter.\nWhy Are Assets Important? Assets are an important part of any application because of the following reasons:\nEnhanced User Experience: Visually rich elements like custom images and fonts help in making your app stand out. Offline Availability: Since assets are bundled with the app, they’re available even when the user is offline. Performance: Bundled assets can be quicker to load compared to fetching resources over a network. Best Practices for Managing Assets Here are some best practices for managing assets in your app:\nOptimize Asset Size: Large assets can increase the size of your app. Optimize images and other files to balance quality and size. Organize Wisely: Maintain a clear structure in your assets folder. Group similar types of assets together. Use Descriptive Names: Name your assets descriptively to make them easier to identify and manage. Best Way to Organize Assets The best way to organize assets is to group them by type. For example, you can create separate folders for images, fonts, audio, and other files. This will make it easier to manage your assets as your app grows.\nassets/ fonts/ Roboto-Regular.ttf Roboto-Bold.ttf images/ logo.png banner.png audio/ sound.mp3 data/ data.json ",
    "description": "In this section, you will learn what is assets and how to use different types of assets in flutter. You will learn how to use images, fonts, and other files in flutter.",
    "tags": null,
    "title": "Assets in Flutter",
    "uri": "/working-with-assets/assets-in-flutter/"
  },
  {
    "content": "Flutter Buttons Buttons are an essential part of any application. They allow you to interact with the app and perform various actions. In this section, you will learn about different types of buttons available in Flutter, along with examples for each.\nButton Types in Flutter You can get different types of buttons in Flutter, such as:\nButton Description Material Button Mostly used button with material design. Elevated Button Shadowed button for important actions. Text Button Flat button for less important actions. Outlined Button Border button for secondary actions. Icon Button Button with an icon. Floating Action Button Circular main action button. Dropdown Button Button to select from a list of options. Popup Menu Button Button that shows more options. Info Note: You will learn about each button type with real world examples in upcoming sections.\nButton Useful Properties Here are some common properties that you can use with buttons in Flutter:\nProperty Description onPressed Things to do when the button is pressed. child Widget to display inside the button. Example 1: Simple MaterialButton In Flutter If you want to create a simple button with text, use the MaterialButton widget. It is a versatile button that can display text, icons, and more.\nMaterialButton( onPressed: () { // action to perform when button is pressed }, color: Colors.blue, child: const Text('Press Me', style: TextStyle(color: Colors.white)), ) Run Online Popular Buttons in Flutter In upcoming sections, you will learn about different types of buttons available in Flutter, along with examples for each. Click on the links below to get started with flutter buttons:\nMaterial Button in Flutter Elevated Button in Flutter Text Button in Flutter Outlined Button in Flutter Icon Button in Flutter Floating Action Button in Flutter Dropdown Button in Flutter Popup Menu Button in Flutter ",
    "description": "Learn how to display different types of buttons in flutter. You will learn how to display TextButton, ElevatedButton, OutlinedButton, IconButton and FloatingActionButton in flutter.",
    "tags": null,
    "title": "Buttons In Flutter",
    "uri": "/buttons-in-flutter/buttons-in-flutter/"
  },
  {
    "content": "Notification in Flutter A important part of app development, regardless of the platform, is the user’s ability to receive notifications. This article dives deep into the world of notifications in Flutter.\nInfo Note: Grasping the fundamentals of notifications can significantly amplify user engagement and satisfaction with your Flutter applications.\nWhy Notifications Is Important? Through rapidly alerting users to changes, messages, or events improving user experience, holding attention and promoting interaction, notifications play a crucial role in app engagement. In the end, they keep users informed and connected with relevant information. Notification are useful because of the following reasons:\nUser Engagement: Timely notifications can keep the user engaged by providing updates, reminders, or news, making them revisit the application more frequently.\nReal-time Updates: Notifications are crucial for apps that require real-time updates, such as news or chat apps.\nImproved User Experience: They can provide seamless experiences by informing users about completed tasks, new features, or essential actions needed.\nDifferent Notification Options in Flutter Flutter offers various packages and plugins that facilitate notification management, from local notifications to push notifications:\nLocal Notifications: Using plugins like flutter_local_notifications, developers can schedule and display notifications locally without the need for an external server. You can learn more about local notifications in Flutter here.\nFirebase Cloud Messaging (FCM): A cloud solution for messages on iOS, Android, and web applications. The firebase_messaging plugin in Flutter allows integrating push notifications in your applications.\nOneSignal: A popular third-party service for push notifications. Flutter developers can utilize the onesignal_flutter package to integrate OneSignal into their apps.\nLocal Vs Push Notifications While both serve the primary purpose of notifying users, they are distinct:\nLocal Notifications: These alerts are internal to the app and are not dependent on an internet connection. For things like daily reminders or alarms, they are ideal.\nPush Notifications: These need an internet connection and are transmitted to the user’s smartphone through the app. They originate from an external server and are perfect for marketing messages, news alerts, and real-time updates.\n",
    "description": "Learn how to display notification in flutter. You will learn how to display notification in flutter for android, ios, mac and linux.",
    "tags": null,
    "title": "Display Notification in Flutter",
    "uri": "/notification/display-notification-in-flutter/"
  },
  {
    "content": "Introduction Drawer is a sidebar that appears from the side of the screen, usually filled with menu options or navigation links, allowing you to navigate between different parts of the application.\nCreate Drawer in Flutter To create a drawer in flutter, you need to use Scaffold widget. Scaffold widget provides a drawer property to add a drawer in your app. Here is an example of drawer in flutter:\nScaffold( drawer: Drawer( ), appBar: AppBar( title: Text('Click Drawer Icon'), ), ) Run Online Drawer From Right By default, the drawer appears from the left side of the screen. If you want to make it appear from the right side, you can use endDrawer property of Scaffold widget. Here is an example of drawer from right:\nScaffold( endDrawer: Drawer( ), appBar: AppBar( title: Text('Click End Drawer Icon =\u003e\u003e\u003e\u003e'), ), ) Run Online Example 1: Simple Drawer In this example below, you will learn to create drawer with options Home, About, and Settings with icons.\nDrawer( child: ListView( children: const [ DrawerHeader( child: Text('Drawer Header'), ), ListTile( leading: Icon(Icons.home), title: Text('Home'), ), ListTile( leading: Icon(Icons.info), title: Text('About'), ), ListTile( leading: Icon(Icons.settings), title: Text('Settings'), ), ], ), ) Run Online Example 2: Ecoommerce App Drawer In this example below, you will learn how to create a beautiful drawer for an ecommerce app with options Home, Categories, Orders, Wishlist and Settings.\nDrawer( child: ListView( padding: EdgeInsets.zero, children: \u003cWidget\u003e[ DrawerHeader( child: Text('Menu'), decoration: BoxDecoration( color: Colors.blue, ), ), ListTile(title: Text('Home'), onTap: () {}), ListTile(title: Text('Categories'), onTap: () {}), ListTile(title: Text('Orders'), onTap: () {}), ListTile(title: Text('Wishlist'), onTap: () {}), ListTile(title: Text('Settings'), onTap: () {}), ], ), ) Run Online Example 3: Account Management in Social Media Apps In this example below, you will learn how to create a beautiful drawer for a social media app with options Profile, Friends, Messages and Settings.\nDrawer( child: ListView( padding: EdgeInsets.zero, children: \u003cWidget\u003e[ UserAccountsDrawerHeader( accountName: Text('User Name'), accountEmail: Text('user@example.com'), currentAccountPicture: CircleAvatar( backgroundColor: Colors.orange, child: Text('U'), ), ), ListTile(title: Text('Profile'), onTap: () {}), ListTile(title: Text('Friends'), onTap: () {}), ListTile(title: Text('Messages'), onTap: () {}), ListTile(title: Text('Settings'), onTap: () {}), ], ), ) Run Online Example 4: Beautiful Drawer Header In this example below, you will build a beautiful drawer header with background image and user profile image.\nDrawer( child: ListView( children: \u003cWidget\u003e[ DrawerHeader( decoration: BoxDecoration( image: DecorationImage( image: NetworkImage('https://flutter-tutorial.net/images/sample_background_image.jpg'), fit: BoxFit.cover, ), ), child: Column( mainAxisAlignment: MainAxisAlignment.end, children: \u003cWidget\u003e[ CircleAvatar( radius: 40, backgroundImage: NetworkImage('https://avatars.githubusercontent.com/u/33576285?v=4'), ), SizedBox(height: 10), Text('John Doe', style: TextStyle(color: Colors.white)), SizedBox(height: 10), ], ), ), ListTile( leading: Icon(Icons.home), title: Text('Home'), onTap: () { // Handle the tap if needed }, ), ListTile( leading: Icon(Icons.info), title: Text('About'), onTap: () { // Handle the tap if needed }, ), ], ), ) Run Online Challenge Create a beautiful drawer for accountinng app with options Dashboard, Invoices, Payments, Expenses and Settings.\n",
    "description": "Learn how to use drawer in flutter with the help of real world examples.",
    "tags": null,
    "title": "Drawer in Flutter",
    "uri": "/useful-widgets/drawer-in-flutter/"
  },
  {
    "content": "Forms in Flutter Form widget is used to group multiple form fields, such as textbox, checkboxes, and buttons, to create a easy data entry experience.\nWhy Forms are Useful? Form are important for building interactive and user-friendly applications. They are useful for the following reasons:\nData Collection: It is used to collect the user input data such as name, email, phone number, etc. Validation: It is used to validate the user input data such as email, phone number, etc. Submission: It is used to submit the user input data to the server. Example 1: Basic Form in Flutter In this example below, you will learn to create a form with First Name and Last Name fields.\nForm( child: Column( children: [ // Form fields go here TextFormField( decoration: InputDecoration( labelText: 'First Name', hintText: 'Enter your first name', ), ), TextFormField( decoration: InputDecoration( labelText: 'Last Name', hintText: 'Enter your last name', ), ), ], ), ) Run Online Example 2: Form with Validation in Flutter In this example below, you will learn to create a form with First Name and Last Name fields with validation. You will learn more about validation in the next section.\nfinal _formKey = GlobalKey\u003cFormState\u003e(); Form( key: _formKey, child: Column( children: [ // Form fields go here TextFormField( decoration: const InputDecoration( labelText: 'First Name', hintText: 'Enter your first name', ), validator: (value) { if (value == \"\") { return 'Please enter your first name'; } return null; }, ), TextFormField( decoration: const InputDecoration( labelText: 'Last Name', hintText: 'Enter your last name', ), validator: (value) { if (value == \"\") { return 'Please enter your last name'; } return null; }, ), const SizedBox(height: 10), ElevatedButton( onPressed: () { if (_formKey.currentState!.validate()) { // Perform submission logic } }, child: const Text('Submit'), ), ], ), ), Run Online Info Note: GlobalKey is a unique identifier for widgets. It is used to access the state of a widget from outside the widget.\n",
    "description": "Learn how to create form in flutter practically with the help of examples",
    "tags": null,
    "title": "Form in Flutter",
    "uri": "/forms-in-flutter/form-in-flutter/"
  },
  {
    "content": "Flutter Introduction \u0026 Basics This section will help you to setup environment for flutter development and learn the basics of flutter. Here you will learn the following topics:\nIntroduction to Flutter, How to install Flutter, Useful Flutter Commands, Basic Flutter Program, Widgets in Flutter, Text in Flutter, Container in Flutter, Row in Flutter, Column in Flutter, Row and Column in Flutter, Stack in Flutter, and Create Counter App. Practice Questions Complete this section \u0026 practice this question to improve and test your flutter skill.\n",
    "description": "Learn the basics of the flutter. You will learn flutter introduction, installation, basic program, variables, data types, comments, operators, input, and string.",
    "tags": null,
    "title": "Introduction and Basics",
    "uri": "/introduction-and-basics/"
  },
  {
    "content": "\nWhat is Flutter? Flutter is a free tool developed by Google for creating mobile, web, and desktop apps with single code. It uses Dart programming language to create apps. Flutter quickly gained popularity because of easy and fast development process.\nWhy You Should Learn Flutter? Flutter offers a many advantages for developers and businesses like:\nSingle Codebase: You can use the same code to make apps for android, iOS, web, and desktop. Beautiful UI: Flutter has special things called widgets, that help you to create beautiful user interfaces. Fast Development: Flutter has a hot reload feature that allows you to see changes in your app in real time. This makes the development process faster. Efficient Testing: With Flutter, you can easily test your app on different devices and platforms at the same time. Ready Made Packages: You can get thousands of ready made packages to enhance your app’s functionality. Some Popular Apps Built With Flutter Here are some popular apps made with Flutter:\nGoogle Earth, Youtube Create, Google Pay, Alibaba, BMW, Ebay, Google Ads, etc. Info Note: As of May 2023, there are more than 1 millions apps built with flutter. This shows the popularity of flutter in such a short time.\nFlutter History Here is a timeline of Flutter’s history:\n📅Date 🎉Event 2015 Google started Flutter as an open-source project. May 12, 2017 First alpha release of Flutter. Dec 4, 2018 Flutter 1.0 (first stable version) launches. Mar 3, 2021 Flutter 2.0 releases with web \u0026 desktop support. May 5, 2022 Flutter 3.0 releases with advanced features. Feb 15, 2024 Flutter 3.19 releases with more advanced features. Key Points Flutter allows you to build, test, and publish mobile, web, desktop apps from a single codebase. It uses Dart programming language, which helps you to build apps fast for many platforms. It has lots of widgets to build beautiful user interfaces. There are many ready made packages available for Flutter. It is backed by Google and trusted by well-known brands worldwide. ",
    "description": "learn about flutter, a free tool by Google for building apps across mobile, web, and desktop using a singular codebase. Dive into its benefits, history, and notable apps created with it.",
    "tags": null,
    "title": "Introduction to Flutter",
    "uri": "/introduction-and-basics/introduction-to-flutter/"
  },
  {
    "content": "Introduction State means the data or the properties of an app that can change over time. State management is the process of managing and updating the state in your app.\nInfo Note: Proper state management helps you build scalable and maintainable Flutter apps.\nWhy State Management? You should use state management in your Flutter apps to:\nKeep UI and business logic separate. Keep your app’s UI in sync with its data. Update the UI in response to user interactions or other events. Manage app-wide state and data. State Management Approaches in Flutter Flutter offers multiple ways to manage state, including:\nLocal State Management: Using StatefulWidget to manage state within a widget. Global State Management: Managing app-wide state using solutions like Provider, Riverpod, Bloc, and more. Popular State Management Packages Here are some popular state management packages for Flutter:\nProvider: A simple and effective way to manage app-wide state. Riverpod: A provider package that offers a more powerful and flexible way to manage state. Bloc: A predictable state management library that helps you manage app state and UI separately. GetX: A lightweight and fast state management solution for Flutter. Conclusion This is all about State Management in Flutter. In the next section, you will learn Provider, and build quiz app using it.\n",
    "description": "Learn the fundamentals of state management in Flutter. This section introduces the concept of state management, explains why it's crucial for Flutter apps, and outlines the basic approaches to managing state.",
    "tags": null,
    "title": "Introduction to State Management",
    "uri": "/state-management/introduction-to-state-management-in-flutter/"
  },
  {
    "content": "Navigation in Flutter Navigation is process of moving between different screens (also known as routes or pages) within an app. It’s like going from the Home screen of a app to the Contact screen.\nHow to Navigate in Flutter? There are different ways to navigate between screens in Flutter. They are:\nUsing the Navigator Using Named Routes Using Router Using Navigator Here’s a simple way to navigate to a new screen using Navigator. You will learn more about navigator in the next section.\nNavigator.of(context).push( MaterialPageRoute(builder: (context) =\u003e SecondScreen()), ); Run Online Using Named Routes Named routes are routes that are named using a string. Here’s how to use named routes to navigate to a new screen.\n// First, ensure you have defined the named route in your MaterialApp widget. MaterialApp( routes: { '/': (context) =\u003e FirstScreen(), '/second': (context) =\u003e SecondScreen(), }, ); // Then, use Navigator.pushNamed to navigate to the second screen. Navigator.pushNamed(context, '/second'); Run Online Using Router For simple apps, you can use Navigator to move between screens. If your app needs advance navigation, you can use a Router package like (go_router).\nConclusion In conclusion, if you are making simple apps, use Navigator to move between screens. If you are making complex apps, consider using a Router package like go_router.\n",
    "description": "Learn how to navigate between screens in Flutter applications with practical examples",
    "tags": null,
    "title": "Navigation in Flutter",
    "uri": "/navigation-in-flutter/navigation-in-flutter/"
  },
  {
    "content": "Profile App Using Flutter This guide will walk you through creating a Profile App using Flutter. The app will display user information in a clean and simple layout.\n1. Setup and Project Creation Ensure you have Flutter installed on your system. Create a new Flutter project with this command:\nflutter create profile_app 2. Designing the User Interface Replace the lib/main.dart file with the following code to set up the user interface:\nimport 'package:flutter/material.dart'; void main() { runApp(const ProfileApp()); } class ProfileApp extends StatelessWidget { const ProfileApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: Colors.blue, visualDensity: VisualDensity.adaptivePlatformDensity, ), home: Scaffold( appBar: AppBar( title: const Text('Profile'), ), body: const ProfilePage(), ), ); } } class ProfilePage extends StatelessWidget { const ProfilePage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return SingleChildScrollView( padding: const EdgeInsets.all(20.0), child: Column( children: \u003cWidget\u003e[ const CircleAvatar( radius: 80, backgroundImage: NetworkImage( 'https://avatars.githubusercontent.com/u/33576285?v=4'), ), const SizedBox(height: 20), Text('Bishworaj Poudel', style: Theme.of(context) .textTheme .bodyLarge ?.copyWith(fontWeight: FontWeight.bold)), const SizedBox(height: 10), Text( 'I love teaching students and helping them to achieve their dreams.', textAlign: TextAlign.center, style: Theme.of(context).textTheme.bodyLarge), const SizedBox(height: 20), Card( elevation: 4.0, child: Column( children: \u003cWidget\u003e[ const ListTile( leading: Icon(Icons.cake), title: Text('Birth Date'), subtitle: Text('1997-05-14'), ), ListTile( leading: const Icon(Icons.web), title: const Text('Website'), subtitle: const Text('brp.com.np'), onTap: () {}), const ListTile( leading: Icon(Icons.email), title: Text('Email'), subtitle: Text('bishworajpoudelofficial@gmail.com'), ), const ListTile( leading: Icon(Icons.location_on), title: Text('Address'), subtitle: Text('Pokhara, Nepal'), ), ], ), ), const SizedBox(height: 20), Wrap( spacing: 10, children: \u003cWidget\u003e[ IconButton( icon: const Icon(Icons.facebook), onPressed: () {}, color: Colors.blue, tooltip: 'Facebook', ), IconButton( icon: const Icon(Icons.link), onPressed: () {}, color: Colors.blue, tooltip: 'LinkedIn', ), IconButton( icon: const Icon(Icons.code), onPressed: () {}, color: Colors.black, tooltip: 'GitHub', ), ], ), ], ), ); } } Run Online Run the App To run the app, execute flutter run in your terminal. Alternatively, in Visual Studio Code, you can start debugging by pressing F5.\nThis guide gives you a basic structure for a Profile App. You can customize and enhance this app by adding more user information, styling, and interactivity.\nChallenge Create your profile app with your information and customize the UI to your liking. You can add more details, such as education, work experience, and hobbies.\n",
    "description": "Learn to create simple profile app using flutter practically step by step.",
    "tags": null,
    "title": "Profile App",
    "uri": "/create-full-apps/my-profile-app/"
  },
  {
    "content": "How To Show Banner Ad In Flutter In this section, you will learn how to show banner ad in flutter. You will learn how to integrate admob banner ad in flutter with these steps:\nStep 1: Create Flutter Project First of all, create a flutter project with the name my_admob_app. To create a flutter project, open the command prompt and type the following command.\nflutter create my_admob_app Step 2: Add Admob Package Now, open your project in android studio and add the admob package in your project. To add the admob package, open the pubspec.yaml file and add the following code in it.\nflutter pub add google_mobile_ads Step 3: Add Admob App Id Now, open the android folder and add the admob app id in the AndroidManifest.xml file. To get the admob app id, go to the admob website and create an account. After creating an account, create an app will appear and you have to click it, after that get the app id from there then add the app id in the AndroidManifest.xml file.\nAdd Internet Permission Open the AndroidManifest.xml file and add the following code inside the tag.\n\u003cuses-permission android:name=\"android.permission.INTERNET\"/\u003e \u003cuses-permission android:name=\"com.google.android.gms.permission.AD_ID\"/\u003e Open AndroidManifest.xml File And Add Code Now, open the AndroidManifest.xml file and add the following code inside the tag. You can find the value of the app id in the admob website.\n\u003c!-- For Admob. change the value to your own Admob App ID --\u003e \u003cmeta-data android:name=\"com.google.android.gms.ads.APPLICATION_ID\" android:value=\"ca-app-pub-3940256099942544~3347511713\"/\u003e Change Minimum SDK Version After adding google_mobile_ads, you need to make sure that your app is using Android SDK version 19 or higher. Open my_admob_app\\android\\app\\build.gradle and inside defaultConfig, change the minimum SDK version to 19. Also set multiDexEnabled to true.\ndefaultConfig { minSdkVersion 19 multiDexEnabled true } Create Banner Ad Widget Now, create a banner ad widget. To create a banner ad widget, lets create a file ad.dart inside the lib folder and add the following code in it.\nimport 'package:flutter/material.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; // Class to manage ads class AdManager { // Replace with your own Ad Unit ID static const String bannerAdUnitId = 'ca-app-pub-3940256099942544/6300978111'; // Banner ad instance BannerAd? myBanner; // Initialize banner ad void initialize() { myBanner = createBannerAd(); } // Create a BannerAd BannerAd createBannerAd() { return BannerAd( adUnitId: bannerAdUnitId, size: AdSize.banner, request: const AdRequest(), listener: BannerAdListener( // Event handlers for the ad lifecycle onAdLoaded: (Ad ad) =\u003e debugPrint('Ad loaded.'), onAdFailedToLoad: (Ad ad, LoadAdError error) =\u003e debugPrint('Ad failed to load: $error'), onAdOpened: (Ad ad) =\u003e debugPrint('Ad opened.'), onAdClosed: (Ad ad) =\u003e debugPrint('Ad closed.'), onAdImpression: (Ad ad) =\u003e debugPrint('Ad impression.'), ), ); } } Add Banner Ad Widget Finally, add the banner ad widget in your flutter application. To add the banner ad widget, open the main.dart file and add the following code in it.\nimport 'package:flutter/material.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; import 'ad.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); MobileAds.instance.initialize(); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Admob', theme: ThemeData( primarySwatch: Colors.blue, ), home: const MyHomePage(), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({Key? key}) : super(key: key); @override _MyHomePageState createState() =\u003e _MyHomePageState(); } class _MyHomePageState extends State\u003cMyHomePage\u003e { // Instance of AdManager final AdManager adManager = AdManager(); // Banner ad instance late BannerAd myBanner; @override void initState() { super.initState(); // Initialize AdManager and load the banner ad adManager.initialize(); myBanner = adManager.myBanner!; myBanner.load(); } @override void dispose() { super.dispose(); // Dispose of the banner ad when it's no longer needed myBanner.dispose(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text(\"Admob Example\"), centerTitle: true, ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: \u003cWidget\u003e[ // Display the banner ad SizedBox( height: 50, child: AdWidget(ad: myBanner), ), ], ), ), ); } } Run Flutter App Finally, run your flutter app using the following command.\nflutter run Conclusion In this tutorial, you learned how to integrate admob banner ad in flutter with these step by step tutorials. You have also learned how to show banner ad in flutter. If you like this tutorial, please share it with others.\n",
    "description": "Learn how to integrate admob banner ad in flutter with this step by step tutorial.",
    "tags": null,
    "title": "Show Banner Ad In Flutter",
    "uri": "/admob-integration/show-banner-ad-in-flutter/"
  },
  {
    "content": "Update All Packages in Flutter We shall discover how to update every package in Flutter by looking at this example. To update all of the flutter packages, we will use the flutter pub upgrade command.\nSee Available Upgrades If you want to see the available upgrades, you can use the flutter pub outdated command. It will show you the available upgrades for your flutter project.\nflutter pub outdated Update All Packages To update all packages in flutter, you can use the flutter pub upgrade command. It will update all packages in your flutter project.\nflutter pub upgrade Update a Specific Package If you want to update a specific package, you can use the flutter pub upgrade command with the package name. It will update the specific package in your flutter project.\nflutter pub upgrade \u003cpackage_name\u003e Example: Update Specific Package Let’s suppose you want to update the firebase_auth package. To update the firebase_auth package, you can use the following command.\nflutter pub upgrade firebase_auth Update a Specific Package to a Specific Version If you want to update a specific package to a specific version, you can use the flutter pub upgrade command with the package name and version. It will update the specific package to a specific version in your flutter project.\nflutter pub upgrade \u003cpackage_name\u003e \u003cversion\u003e Example: Update Specific Package to a Specific Version Let’s suppose you want to update the firebase_auth package to version 1.0.0. To update the firebase_auth package to version 1.0.0, you can use the following command.\nflutter pub upgrade firebase_auth 1.0.0 ",
    "description": "Learn how to update all packages in flutter with single command. You will learn how to update all packages in flutter, how to update a specific package in flutter, and how to update a specific package to a specific version in flutter.",
    "tags": null,
    "title": "Update All Packages in Flutter",
    "uri": "/how-to/update-all-packages-in-flutter/"
  },
  {
    "content": "Internet Permission in Flutter In this example, you will learn how to add internet permission in flutter. And then you will learn how to add internet permission in flutter for android and ios.\nAdd Internet Permission in Android To add internet permission in android, you need to add the following line in the android/app/src/main/AndroidManifest.xml file.\n\u003cuses-permission android:name=\"android.permission.INTERNET\"/\u003e File Should Look Like This:\n\u003cmanifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\u003e \u003cuses-permission android:name=\"android.permission.INTERNET\"/\u003e \u003capplication android:label=\"Learn Computer Basic\" android:icon=\"@mipmap/ic_launcher\"\u003e Add Internet Permission in iOS To add internet permission in iOS, you need to add the following line in the ios/Runner/Info.plist file.\n\u003ckey\u003eNSAppTransportSecurity\u003c/key\u003e \u003cdict\u003e \u003ckey\u003eNSAllowsArbitraryLoads\u003c/key\u003e \u003ctrue/\u003e \u003c/dict\u003e ",
    "description": "Learn how to add internet permission in flutter. You will learn how to add internet permission in flutter for android and ios.",
    "tags": null,
    "title": "Add Internet Permission in Flutter",
    "uri": "/how-to/add-internet-permission-in-flutter/"
  },
  {
    "content": "Convert Website to Flutter App This part will teach you how to turn a website into a Flutter application. You can convert any website to flutter app using the webview_flutter package. This package is used to convert any website to flutter app.\nStep 1: Create a Flutter Project We will convert google.com website to flutter app. So, create a flutter project using the below command.\nflutter create website_to_flutter_app Step 2: Add Package Add webview_flutter package to your pubspec.yaml file.\ndependencies: flutter: sdk: flutter webview_flutter: ^4.4.1 Step 3: Add Code Add the below code to your main.dart file.\nimport 'package:flutter/material.dart'; import 'package:webview_flutter/webview_flutter.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { // Controller final WebViewController controller = WebViewController() ..loadRequest(Uri.parse('https://www.google.com')); @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Google Website'), ), body: WebViewWidget(controller: controller)), ); } } Step 4: Run App Run your app using the below command.\nflutter run Convert HTML to Flutter App You can also convert website content to dart variable and then use it in your flutter app. For example, you can convert the below html code to dart variable and then use it in your flutter app.\nimport 'package:flutter/material.dart'; import 'package:webview_flutter/webview_flutter.dart'; String htmlContent = ''' \u003c!DOCTYPE html\u003e \u003chtml\u003e \u003cbody\u003e \u003ch1\u003eMy First Heading\u003c/h1\u003e \u003cp\u003eMy first paragraph.\u003c/p\u003e \u003c/body\u003e \u003c/html\u003e '''; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { // Controller final WebViewController controller = WebViewController() ..loadHtmlString(htmlContent); @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Google Website'), ), body: WebViewWidget(controller: controller)), ); } } Permissions You need to add internet permission in your AndroidManifest.xml file. For iOS, you don’t need to add any permission.\n\u003cuses-permission android:name=\"android.permission.INTERNET\"/\u003e Conclusion Congratulations, you have successfully converted website to flutter app.\n",
    "description": "Learn how to convert website to flutter app. After reading this, you can easily convert any website to flutter app.",
    "tags": null,
    "title": "Convert Website to Flutter App",
    "uri": "/how-to/convert-website-to-flutter-app/"
  },
  {
    "content": "Display Local Notification in Flutter The flutter_local_notifications package can be used with Flutter to show local notifications. You may use this package to schedule and show notifications in your Flutter App.\nStep 1: Create Flutter Project Let’s create a flutter project called local_notification by flutter create command. Follow the below steps to create a flutter project.\nflutter create local_notification Step 2: Add flutter_local_notifications Package To add the flutter_local_notifications package to your Flutter project, open the pubspec.yaml file and add the following code:\ndependencies: flutter_local_notifications: ^15.1.1 Step 3: Create File Without increasing the complexity of the app, let’s create 3 files. main.dart : In this file we will do the initiation home_screen.dart : This file will be used as UI to implement and show notifications in the app notification_service.dart : This will maintain the core logic of the notification.\nHere is code for main.dart file:\nimport 'package:flutter/material.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:local_noti/home_screen.dart'; import 'package:local_noti/service/notification_service.dart'; FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); void main() async { WidgetsFlutterBinding.ensureInitialized(); await NotificationService.init(); runApp(const MainApp()); } class MainApp extends StatelessWidget { const MainApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( home: HomeScreen(), ); } } Here is code for home_screen.dart file:\nimport 'package:flutter/material.dart'; import 'notification_service.dart'; class HomeScreen extends StatelessWidget { const HomeScreen({super.key}); @override Widget build(BuildContext context) { return Scaffold( body: Center( child: InkWell( onTap: () =\u003e NotificationService.showNotification( title: \"This is the title of the notification\", body: \"This is the body of the notification\", ), child: const Text('Send Notification')), ), ); } } Here is code for notification_service.dart file:\n/// Importing this for showing log import 'dart:developer'; /// Dependency import for local notifications import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'main.dart'; /// Remember the global varibales I have created in main.dart /// this import allows us to use that varibale /// Notificaition Service class handles everything regarding notifications class NotificationService { /// the method is static, for making it easier to use. You can follow the object /// instance method as well static Future\u003cvoid\u003e init() async { /// This is where start the initialization // ****** Andriod Initialization ****** /// @mipmap/ic_launcher' is the icon for the notification, which is deafult in flutter /// if you want to use your custom icon make sure to provide the path to that icon. AndroidInitializationSettings androidInitializationSettings = const AndroidInitializationSettings('@mipmap/ic_launcher'); // ****** IOS Initialization ****** DarwinInitializationSettings darwinInitializationSettings = const DarwinInitializationSettings( // this will ask permissions to display alert and others are clean with the name requestAlertPermission: true, requestBadgePermission: true, defaultPresentSound: true); // ****** Combining Initializations ****** InitializationSettings initializationSettings = InitializationSettings( iOS: darwinInitializationSettings, android: androidInitializationSettings); /// now using the global instance of FlutterLocalNotificationsPlugin() /// Let's Initialize the notification bool? init = await flutterLocalNotificationsPlugin .initialize(initializationSettings); log('Noti $init'); } /* Notifications have few things : id, title, body and payload, in this method the id is optional, however you're recommended to provide id for different notifications. */ static showNotification({ int? id = 0, required String title, required String body, var payload, }) async { /* In notifications, there are few things that we keep in mind.The sound, how important the notification is and what is the priority of the notification, playload ( this basically means what data does your notifications hold ) of the notification. We need channel id and channel name in the notification, here \"flutter-tut\" is channel id and \"flutter tutorial\" is channel name. You can give whatever name you wish to give. */ // ****** Andriod Configuration ****** AndroidNotificationDetails androidNotificationDetails = const AndroidNotificationDetails( 'flutter-tut', 'flutter tutorial', playSound: true, // Higher the Priority and Importance, // will result in high visibility of notification priority: Priority.max, importance: Importance.max, ); // ****** iOS Configuration : with the necessary requirements ****** DarwinNotificationDetails darwinNotificationDetails = const DarwinNotificationDetails( presentAlert: true, presentSound: true, presentBanner: true, presentBadge: true, ); /// let's combine both details. NotificationDetails noti = NotificationDetails( iOS: darwinNotificationDetails, android: androidNotificationDetails); /* This line will show the notification, after all the configuration is done Passing the payload is totally option. However if your want to navigate to a particular screen on click of the notification of perform certain action. Payload become crutial. */ await flutterLocalNotificationsPlugin.show(0, title, body, noti, payload: payload); } } Step 4: Run the App Now, run the app and click on the Send Notification button to display the local notification.\n",
    "description": "Learn how to display local notification in flutter with the help of examples",
    "tags": null,
    "title": "Display Local Notification in Flutter",
    "uri": "/notification/display-local-notification-in-flutter/"
  },
  {
    "content": "Flutter Installation There are multiple ways to install a flutter on your system. You can install Flutter on Windows, Mac, and Linux or run it from the browser. In this tutorial, you will learn easiest way to install a flutter on your system. If you got stuck somewhere, you can watch the video below to be more clear.\nRequirements Flutter SDK, VS code or other editors like Intellij [We will use VS Code here]. Git [For Version Control]. Anrdoid Studio. Flutter Windows Installation Follow the below instructions to install a flutter on the windows operating system.\nSteps: Download Flutter sdk from here. Extract or copy Flutter sdk to your C drive. Setup path C:\\flutter\\bin to your environment variable. Watch the video below to be more clear. Open the command prompt and type flutter –version to check it. flutter --version Install VS Code from here and add Dart and Flutter Extension. Install Android Studio from here and add Android sdk. Install Git from here for version control and to keep track of your code changes. Open the command prompt and type flutter doctor to check and diagnose the setup of your flutter development environment. flutter doctor Flutter Windows Installation Video Watch this video to easily install a flutter on your windows operating system. Flutter Mac Installation Follow the below instructions to install Flutter on the Mac operating system.\nInfo Note: You must install Xcode before installing Flutter.\nSteps: Download Flutter sdk from here. Extract the file in the desired location. Install VS Code from here and add Dart and Flutter Extension. Install Android Studio from here and add Android sdk. Open terminal and type: nano ~/.zshrc Paste below content into the file and replace path_to_flutter_directory with the real location of your Flutter SDK.\nexport PATH=\"$PATH:`path_to_flutter_directory`/flutter/bin\" Info Note: Press CTRL + O to save the changes, then press Enter. After that, press CTRL + X to exit nano.\nFlutter Mac Installation [Video] Watch this video to easily install a flutter on your Mac operating system. Flutter Linux Installation To install a flutter on Linux, open your terminal and copy/paste the below commands. If you have any problem, you can watch the video below.\nSteps: Install VS Code and add Dart and Flutter Extension. Type the following commands in terminal: sudo apt install snapd sudo apt update sudo apt install -y curl git unzip xz-utils zip libglu1-mesa sudo snap install flutter --classic sudo snap install android-studio --classic Open android studio and install latest command line tools and latest SDK tools. Flutter Linux Installation Video Watch this video to easily install a flutter on your Ubuntu operating system. Check Flutter Installation Open your command prompt and type flutter doctor. If you see everything is fine, then you are good to go.\nSome Useful Commands Command Description flutter --help Show all available commands. flutter create Create a flutter project. flutter run Run the flutter project. Run Flutter On Web You can run the basic flutter program on your browser without installing any software. Dartpad is a web tool to write and run your flutter code.\nRun Flutter on Web Install Flutter Official Link Here is official flutter link to install flutter on your devices:\nInstall Flutter Official Link Can You Run Flutter From Mobile? Yes, you can use DartPad to run simple flutter programs from your phone without installing any software. For bigger projects, using DartPad is not recommended.\n",
    "description": "Learn how to install flutter. After reading this, you can install a flutter on your operating system. Install flutter for windows, linux \u0026 mac.",
    "tags": null,
    "title": "Install Flutter",
    "uri": "/introduction-and-basics/flutter-install/"
  },
  {
    "content": "Simple Interest Calculator App Using Flutter This guide will help you create a Simple Interest Calculator using Flutter. You’ll learn to build a user interface for inputting values, calculate simple interest, and display the result.\n1. Setup and Project Creation Ensure Flutter is installed on your system. Begin by creating a new Flutter project:\nflutter create simple_interest_calculator 2. Designing the User Interface Navigate to lib/main.dart and replace its content with the following code to design the interface:\nimport 'package:flutter/material.dart'; void main() =\u003e runApp(SimpleInterestApp()); class SimpleInterestApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Simple Interest Calculator', home: InterestCalculatorScreen(), ); } } class InterestCalculatorScreen extends StatefulWidget { @override _InterestCalculatorScreenState createState() =\u003e _InterestCalculatorScreenState(); } class _InterestCalculatorScreenState extends State\u003cInterestCalculatorScreen\u003e { final TextEditingController principalController = TextEditingController(); final TextEditingController rateController = TextEditingController(); final TextEditingController timeController = TextEditingController(); String result = ''; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Simple Interest Calculator')), body: Container( padding: EdgeInsets.all(20), child: Column( children: [ _buildTextField(principalController, 'Principal'), _buildTextField(rateController, 'Rate of Interest'), _buildTextField(timeController, 'Time in Years'), SizedBox(height: 20), MaterialButton( child: Text('Calculate'), onPressed: _calculateInterest, ), SizedBox(height: 20), Text(result, style: TextStyle(fontSize: 20)), ], ), ), ); } Widget _buildTextField(TextEditingController controller, String label) { return TextField( controller: controller, decoration: InputDecoration(labelText: label), keyboardType: TextInputType.number, ); } void _calculateInterest() { double principal = double.tryParse(principalController.text) ?? 0.0; double rate = double.tryParse(rateController.text) ?? 0.0; double time = double.tryParse(timeController.text) ?? 0.0; double interest = principal * rate * time / 100; setState(() { result = 'Simple Interest: \\$${interest.toStringAsFixed(2)}'; }); } } Run Online Explanation SimpleInterestApp: The root widget that sets up the MaterialApp. InterestCalculatorScreen: A StatefulWidget that contains the UI for the calculator. TextEditingController: Controllers for handling text input. _calculateInterest: Function to calculate the simple interest. User Interface Components Text fields for entering the principal amount, rate of interest, and time. A button to trigger the calculation. A text widget to display the result. Run the App To run the application in Visual Studio Code, press F5 or navigate to Run \u003e Start Debugging. Alternatively, use the following command in your terminal:\nflutter run Challenge Create a new screen to display the result in a more visually appealing manner. You can use a Card widget to display the result.\n",
    "description": "Learn to create simple interest calculator app using flutter practically step by step",
    "tags": null,
    "title": "Interest Calculator App",
    "uri": "/create-full-apps/simple-interest-calculator-app/"
  },
  {
    "content": "What is JSON? JSON (JavaScript Object Notation) is a lightweight data-interchange format. Mostly it is used to transfer data between computers.\nCharacteristics of JSON Lightweight: JSON is designed to be easy to use and quick to interpret, making it ideal for data interchange. Self-describing: JSON structures are clear and understandable, making it easy to read and write. Language Independent: Although derived from JavaScript, JSON is language-independent, with many programming languages providing support for parsing and generating JSON data. Info Note: JSON files have a .json extension.\nUse Cases of JSON App and Web Development: JSON is extensively used in app and web development for transferring data between a server and a client. APIs and Web Services: Many web services and APIs exchange data using JSON format due to its straightforward and efficient structure. JSON Data Types JSON supports various data types, including:\nString: A sequence of characters wrapped in quotes. Number: Numeric data (integer or floating point). Boolean: Represents a truth value (true or false). Null: Represents a null value. Array: An ordered list of values, enclosed in square brackets []. Object: A collection of key-value pairs, enclosed in curly braces {}. JSON Syntax Rules Data is in name/value pairs. Curly braces {} hold objects, while square brackets [] hold arrays. Data is separated by commas, and each name in an object is followed by a colon : which precedes the value. Example of JSON Data:\n{ \"name\": \"John Doe\", \"age\": 30, \"isEmployed\": true, \"address\": { \"street\": \"123 Main St\", \"city\": \"Anytown\" }, \"phoneNumbers\": [\"123-456-7890\", \"456-789-0123\"] } JSON vs. XML JSON and XML are both used for data interchange, but JSON is generally preferred due to its simpler syntax, faster parsing, and lighter data format.\nParsing JSON with Dart To parse JSON in Dart, you can use the jsonDecode function from the dart:convert package.\nExample of Parsing JSON in Dart:\nimport 'dart:convert'; void main() { String jsonString = ''' { \"name\": \"John Doe\", \"age\": 30, \"isEmployed\": true } '''; var decodedJson = jsonDecode(jsonString); print('Name: ${decodedJson['name']}'); print('Age: ${decodedJson['age']}'); print('Is Employed: ${decodedJson['isEmployed']}'); } Run Online Info Note: Dart’s jsonDecode function returns a Map\u003cString, dynamic\u003e, allowing for easy access to JSON properties.\n",
    "description": "An essential guide to understanding JSON, its syntax, data types, and practical applications in data interchange.",
    "tags": null,
    "title": "Introduction to JSON",
    "uri": "/working-with-api/introduction-to-json/"
  },
  {
    "content": "Flutter List and Grid This section will help you to learn about ListView and GridView in Flutter with the help of real-world examples. Here you will learn the following topics:\nListView in Flutter, GridView in Flutter, ListView.builder in Flutter, and GridView.builder in Flutter. Practice Questions Complete this section \u0026 practice this question to improve and test your flutter skill.\n",
    "description": "Learn about list and grid in flutter. You will learn list view, list view builder, grid view, grid view builder, and other useful widgets.",
    "tags": null,
    "title": "List and Grid",
    "uri": "/list-and-grid/"
  },
  {
    "content": "ListView In Flutter ListView is a type of widget in Flutter used to display a list of items in a scrollable column or row. It’s similar to how you scroll through your contacts on a phone or through posts on a social media app. ListView is flexible and can be used for simple lists as well as more complex ones with different types of items.\nExample 1: To Do List App In this example below, you will learn how to create a simple to-do list app using ListView. Here’s how you can make a list with titles and subtitles for each task.\nListView( children: [ ListTile( title: Text('Go to Gym'), subtitle: Text('Go to Gym at 6:00 AM'), ), ListTile( title: Text('Go to College'), subtitle: Text('Go to College at 8:00 AM'), ), ListTile( title: Text('Go to Office'), subtitle: Text('Go to Office at 11:00 AM'), ), // Add more ListTiles as needed ], ) Run Online Info Note: ListTiles are a convenient way to create lists of items. They provide a leading icon, a title, and a subtitle. You can also add trailing icons if needed.\nExample 2: Contact List App In this example below, you will learn how to create a simple contact list using ListView with icons, names, numbers, and a call icon.\nListView( children: [ ListTile( leading: Icon(Icons.person), title: Text('John Doe'), subtitle: Text('555-555-5555'), trailing: Icon(Icons.call), ), ListTile( leading: Icon(Icons.person), title: Text('Jane Doe'), subtitle: Text('555-555-5555'), trailing: Icon(Icons.call), ), ListTile( leading: Icon(Icons.person), title: Text('John Smith'), subtitle: Text('555-555-5555'), trailing: Icon(Icons.call), ), ], ) Run Online Example 3: Image Gallery App In this example below, you will learn how to create a photo gallery app using ListView. You can change the scroll direction to horizontal to create a horizontal photo gallery.\nListView( // try changing to `scrollDirection: Axis.horizontal` to see horizontal list scrollDirection: Axis.horizontal, children: [ Image.network('https://picsum.photos/250?image=9'), Image.network('https://picsum.photos/250?image=10'), Image.network('https://picsum.photos/250?image=11'), Image.network('https://picsum.photos/250?image=12'), Image.network('https://picsum.photos/250?image=13'), Image.network('https://picsum.photos/250?image=14'), Image.network('https://picsum.photos/250?image=15'), ], ) Run Online Example 4: Reverse List In this example below, you will learn how to reverse a list using ListView. You can use the reverse property to reverse the order of the list.\nListView( reverse: true, children: [ ListTile( title: Text('Go to Gym'), subtitle: Text('Go to Gym at 6:00 AM'), ), ListTile( title: Text('Go to College'), subtitle: Text('Go to College at 8:00 AM'), ), ListTile( title: Text('Go to Office'), subtitle: Text('Go to Office at 11:00 AM'), ), // Add more ListTiles as needed ], ) Run Online Challenge Create a restaurant app that displays a list of dishes. Each dish should have a name, description, and price.\n",
    "description": "Learn about the ListView widget in Flutter. Understand what a ListView is, how to use it, and create dynamic and efficient list-based interfaces with practical examples.",
    "tags": null,
    "title": "List View in Flutter",
    "uri": "/list-and-grid/list-view-in-flutter/"
  },
  {
    "content": "Introduction MaterialButton is one of the most commonly used buttons in Flutter. It is a versatile button that can display text, icons, and more. This guide will help you understand the MaterialButton with the help of real-world examples.\nExample 1: Simple MaterialButton In this example below, you will learn to create a simple button with text using the MaterialButton widget.\nMaterialButton( onPressed: () {}, color: Colors.blue, child: const Text('Press Me'), ) Run Online Example 2: MaterialButton With Icon In this example below, you will learn to create a button with an icon using the MaterialButton widget.\nMaterialButton( onPressed: () { // Action to perform on button press }, color: Colors.green, textColor: Colors.white, child: const Row( mainAxisSize: MainAxisSize.min, // Align text and icon closely together children: \u003cWidget\u003e[ Icon(Icons.add), SizedBox(width: 8), // Space between icon and text Text('Add Item'), ], ), ) Run Online Example 3: Rounded Corners MaterialButton In this example below, you will learn to create a button with rounded corners using the MaterialButton widget.\nMaterialButton( onPressed: () {}, color: Colors.blue, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(18.0), ), child: const Text('Press Me'), ) Run Online Example 4: MaterialButton with Shadow and Elevation In this example below, you will learn to create a button with shadow and elevation using the MaterialButton widget.\nMaterialButton( onPressed: () {}, color: Colors.blue, elevation: 5, child: const Text('Press Me'), ) Run Online Example 5: Disabled MaterialButton In this example below, you will learn to create a disabled button using the MaterialButton widget.\nMaterialButton( onPressed: null, color: Color.fromARGB(255, 205, 208, 211), child: Text('Disabled Button'), ) Run Online Example 6: Gradient Background In MaterialButton In this example below, you will learn to create a button with a gradient background using the MaterialButton widget.\nMaterialButton( onPressed: () {}, child: Ink( decoration: BoxDecoration( gradient: const LinearGradient( colors: [Colors.blue, Colors.red] ), borderRadius: BorderRadius.circular(10.0), ), child: Container( constraints: const BoxConstraints(minWidth: 88.0, minHeight: 36.0), alignment: Alignment.center, child: const Text( 'Gradient Button', style: TextStyle(color: Colors.white, fontSize: 20), ), ), ), ) Run Online Info Note: Ink widget is used for decorating a part of your UI with a background image, color, or custom drawings\nChallenge Create a simple MaterialButton with text “Click Me” with a red color and white text color. When the button is pressed, display a snackbar with the message “Button Pressed”.\n",
    "description": "This tutorial covers the basics of using the MaterialButton widget in Flutter, including examples of simple buttons, buttons with icons, buttons with rounded corners, buttons with shadow and elevation, and disabled buttons. Learn how to create customizable Material Buttons with various styles and animations.",
    "tags": null,
    "title": "Material Button in Flutter",
    "uri": "/buttons-in-flutter/material-button-in-flutter/"
  },
  {
    "content": "Moving to Another Screen in Flutter Flutter provides several ways to navigate between screens, but the most common method is using Navigator. Here is sample code to move to another screen:\nNavigator.of(context).push( MaterialPageRoute(builder: (context) =\u003e SecondScreen()), ); Example 1: Move To Second Screen Flutter provides the Navigator class to manage routes. Here’s a simple way to navigate to a new screen:\nStep 1: Define a Screen First, define a new screen as a StatelessWidget or StatefulWidget:\nclass SecondScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(\"Second Screen\"), ), body: Center( child: Text(\"Welcome to the second screen!\"), ), ); } } Step 2: Moving to the New Screen Use the Navigator.push method to move to the new screen:\nNavigator.of(context).push( MaterialPageRoute(builder: (context) =\u003e SecondScreen()), ); Navigating Back To return to the previous screen, use the Navigator.pop method:\nNavigator.pop(context); Run Online Challenge Create two screens, HomeScreen and AboutScreen. When you click a button on the home screen, navigate to the about screen.\n",
    "description": "A easy guide on how to navigate between screens in a Flutter application.",
    "tags": null,
    "title": "Move to Another Screen",
    "uri": "/navigation-in-flutter/move-to-other-screen-in-flutter/"
  },
  {
    "content": "Move Using Named Routes in Flutter Named routes provide a clear and easy way to manage navigation between screens. Instead of navigating directly to a widget, you use a string identifier (the route’s name) to tell Flutter which screen to show.\nNavigator.pushNamed(context, '/routeName') Example 1: Move To Another Screen Using Named Routes In this example below, there is HomeScreen and ProfileScreen. When you click a button on the home screen, it navigates to the profile screen. First, let’s create a MaterialApp with named routes.\nStep 1: Define Named Routes Define the named routes in the MaterialApp widget:\nMaterialApp( initialRoute: '/', routes: { '/': (context) =\u003e HomeScreen(), '/profile': (context) =\u003e ProfileScreen(), }, ); Home Screen (HomeScreen) This is the main screen of the application.\nclass HomeScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(\"Home Screen\"), ), body: Center( child: ElevatedButton( child: Text('Go to Profile Page'), onPressed: () { // Navigation Code Here }, ), ), ); } } Profile Screen (ProfileScreen) A page displaying profile information.\nclass ProfileScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(\"Profile Page\"), ), body: Center( child: Text(\"Welcome to the Profile Page!\"), ), ); } } Navigate To The New Screen When the button is pressed, HomeScreen should navigate to ProfileScreen. Use the Navigator.pushNamed method to move to the new screen:\nNavigator.pushNamed(context, '/profile'); Run Online ",
    "description": "Comprehensive guide on using named routes for navigation in Flutter. Includes practical examples and detailed explanations.",
    "tags": null,
    "title": "Move Using Named Routes",
    "uri": "/navigation-in-flutter/navigation-using_named_route/"
  },
  {
    "content": "Provider in Flutter The Provider package is a recommended way to manage state in Flutter applications. It simplifies data flow in your app and makes it more manageable and scalable. Provider allows for efficient and scalable state management, making it easier to share state across different parts of your Flutter application.\nWhy Use Provider? Simplicity: Provider simplifies state management in Flutter, making it more readable and maintainable. Scalability: It supports scalable architecture, making it suitable for small to large applications. Performance: Provider is optimized for performance, ensuring minimal rebuilds. Example 1: Counter App Using Provider In this example below, you will learn to create a simple counter app using Provider.\nStep 1: Setup Provider First, add the Provider package to your pubspec.yaml file.\ndependencies: flutter: sdk: 'flutter' provider: '^5.0.0' or\nflutter pub add provider Step 2: Create a Counter Model Define a model class for your counter logic.\nimport 'package:flutter/foundation.dart'; class Counter extends ChangeNotifier { int _count = 0; int get count =\u003e _count; void increment() { _count++; notifyListeners(); } } Step 3: Use Provider in Your App Wrap your app or widget with a ChangeNotifierProvider to provide the counter model.\nimport 'package:flutter/material.dart'; import 'package:provider/provider.dart'; void main() =\u003e runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return ChangeNotifierProvider( create: (context) =\u003e Counter(), child: MaterialApp( home: CounterPage(), ), ); } } class CounterPage extends StatelessWidget { const CounterPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { final counter = Provider.of\u003cCounter\u003e(context); return Scaffold( appBar: AppBar( title: const Text('Provider Counter App'), ), body: Center( child: Text('Counter: ${counter.count}'), ), floatingActionButton: FloatingActionButton( onPressed: counter.increment, tooltip: 'Increment', child: const Icon(Icons.add), ), ); } } Run Online Challenge Add a decrement button to the counter app and implement the logic to decrement the counter value.\nExample 2: Todo App Using Provider In this example, you will learn to create a simple todo app using Provider.\nStep 1: Create a Todo Model Define a model class for your todo logic.\nimport 'package:flutter/foundation.dart'; class Todo extends ChangeNotifier { List\u003cString\u003e _todos = []; List\u003cString\u003e get todos =\u003e _todos; void add(String todo) { _todos.add(todo); notifyListeners(); } void remove(String todo) { _todos.remove(todo); notifyListeners(); } } Step 2: Use Provider in Your App Wrap your app or widget with a ChangeNotifierProvider to provide the todo model.\nimport 'package:flutter/material.dart'; import 'package:provider/provider.dart'; void main() =\u003e runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return ChangeNotifierProvider( create: (context) =\u003e Todo(), child: MaterialApp( home: TodoPage(), ), ); } } class TodoPage extends StatelessWidget { const TodoPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { final todo = Provider.of\u003cTodo\u003e(context); TextEditingController todoController = TextEditingController(); return Scaffold( appBar: AppBar( title: const Text('Provider Todo App'), ), body: Column( children: [ TextField( decoration: const InputDecoration( labelText: 'Type todo and hit enter', contentPadding: EdgeInsets.all(10), ), controller: todoController, onSubmitted: (value) { todo.add(value); todoController.clear(); }, ), Expanded( child: ListView.builder( itemCount: todo.todos.length, itemBuilder: (context, index) { return ListTile( title: Text(todo.todos[index]), trailing: IconButton( icon: const Icon(Icons.delete), onPressed: () { todo.remove(todo.todos[index]); }, ), ); }, ), ), ], ), ); } } Run Online Challenge Add edit functionality to the todo app. When a user taps on a todo item, it should be editable.\n",
    "description": "Learn how to use the Provider package for state management in your Flutter applications. This section provides an introduction to the Provider package, including two basic examples to demonstrate its usage.",
    "tags": null,
    "title": "Provider in Flutter",
    "uri": "/state-management/provider-in-flutter/"
  },
  {
    "content": "How To Show Interstitial Ad In Flutter? In this section, you will learn how to show interstitial ad in flutter. You will learn how to integrate admob interstitial ad in flutter with step by step tutorial.\nStep 1: Create Flutter Project First of all, create a flutter project. Let’s create a flutter project with the name my_admob_app. To create a flutter project, open the command prompt and type the following command.\nflutter create my_admob_app Step 2: Add Admob Package Now, open your project in android studio and add the admob package in your project. To add the admob package, open the pubspec.yaml file and add the following code in it.\nflutter pub add google_mobile_ads Step 3: Add Admob App Id Now, open the android folder and add the admob app id in the AndroidManifest.xml file. To get the admob app id, go to the admob website and create an account. After creating an account, create an app will appear and you have to click it, after that get the app id from there. Now, add the app id in the AndroidManifest.xml file.\nAdd Internet Permission Open the AndroidManifest.xml file and add the following code inside the tag.\n\u003cuses-permission android:name=\"android.permission.INTERNET\"/\u003e \u003cuses-permission android:name=\"com.google.android.gms.permission.AD_ID\"/\u003e Open AndroidManifest.xml File And Add Code Now, open the AndroidManifest.xml file and add the following code inside the tag. You can find the value of the app id in the admob website.\n\u003c!-- For Admob. change the value to your own Admob App ID --\u003e \u003cmeta-data android:name=\"com.google.android.gms.ads.APPLICATION_ID\" android:value=\"ca-app-pub-3940256099942544~3347511713\"/\u003e Change Minimum SDK Version After adding google_mobile_ads, you need to make sure that your app is using Android SDK version 19 or higher. Open my_admob_app\\android\\app\\build.gradle and inside defaultConfig, change the minimum SDK version to 19. Also set multiDexEnabled to true.\ndefaultConfig { minSdkVersion 19 multiDexEnabled true } Create Interstitial Ad Widget Now, create a interstitial ad widget. To create a interstitial ad widget, create a new file named ad.dart and add the following code in it.\nimport 'package:google_mobile_ads/google_mobile_ads.dart'; // Class to manage ads class AdManager { // Replace with your own Interstitial Ad Unit ID static const String interstitialAdUnitId = 'ca-app-pub-3940256099942544/1033173712'; // Interstitial ad instance InterstitialAd? myInterstitialAd; // Flag to keep track of whether interstitial ad is ready bool isInterstitialAdReady = false; // Initialize interstitial ad void initialize() { createInterstitialAd(); } // Create an InterstitialAd void createInterstitialAd() { InterstitialAd.load( adUnitId: interstitialAdUnitId, request: AdRequest(), adLoadCallback: InterstitialAdLoadCallback( onAdLoaded: (InterstitialAd ad) { // Keep a reference to the ad so you can show it later myInterstitialAd = ad; isInterstitialAdReady = true; ad.fullScreenContentCallback = FullScreenContentCallback( // Reload the ad when it's dismissed onAdDismissedFullScreenContent: (InterstitialAd ad) { createInterstitialAd(); }, ); }, onAdFailedToLoad: (LoadAdError error) { print('InterstitialAd failed to load: $error'); }, ), ); } // Show the interstitial ad if it's ready void showInterstitialAd() { if (myInterstitialAd == null) { print('Warning: attempt to show interstitial before loaded.'); return; } myInterstitialAd!.show(); myInterstitialAd = null; isInterstitialAdReady = false; } } Add Interstitial Ad Widget In Main.dart File Finally, add the interstitial ad widget in the main.dart file. To add the interstitial ad widget, open the main.dart file and add the following code in it.\nimport 'package:flutter/material.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; import 'ad.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); MobileAds.instance.initialize(); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Admob', theme: ThemeData( primarySwatch: Colors.blue, ), home: const MyHomePage(), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({Key? key}) : super(key: key); @override _MyHomePageState createState() =\u003e _MyHomePageState(); } class _MyHomePageState extends State\u003cMyHomePage\u003e { // Instance of AdManager final AdManager adManager = AdManager(); @override void initState() { super.initState(); // Initialize AdManager and load the interstitial ad adManager.initialize(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text(\"Admob Example\"), centerTitle: true, ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: \u003cWidget\u003e[ // Button to show the interstitial ad ElevatedButton( onPressed: () { if (adManager.isInterstitialAdReady) { adManager.showInterstitialAd(); } }, child: const Text('Show Interstitial Ad'), ), ], ), ), ); } } Run Flutter App Finally, run your flutter app using the following command.\nflutter run Conclusion In this tutorial, you learned how to show interstitial ad in flutter and how to integrate admob interstitial ad in flutter with this tutorial. Additionally, you now know how to make a flutter interstitial ad widget. Now, you can show interstitial ad in your flutter app.\n",
    "description": "Learn how to integrate admob interstitial ad in flutter. You will learn how to show interstitial ad in flutter with step by step tutorial.",
    "tags": null,
    "title": "Show Interstitial Ad In Flutter",
    "uri": "/admob-integration/show-interstitial-ad-in-flutter/"
  },
  {
    "content": "Introduction Snackbar is a lightweight message bar displayed at the bottom of the screen. It is used to show short notifications like saved or deleted and lets users perform actions such as undo or retry.\nExample 1: Simple Snackbar In this example below, you will create a simple Snackbar that displays a message This is a Snackbar! when a button is pressed.\nScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text('This is a Snackbar!'), ), ); Run Online Example 2: Snackbar with Action In this example below, you will create a Snackbar with an action that allows the user to undo an operation.\nScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text('Message deleted'), action: SnackBarAction( label: 'UNDO', onPressed: () { // Perform some action }, ), ), ); Run Online Example 3: Customized Snackbar In this example below, you will create a Snackbar with a custom background color.\nScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text('This is a custom Snackbar!'), backgroundColor: Colors.blue, ), ); Run Online Example 4: Snackbar with Duration In this example below, you will create a Snackbar that disappears after 3 seconds.\nScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text('This message will disappear after 3 seconds'), duration: Duration(seconds: 3), ), ); Run Online Challenge Create a Snackbar that displays a message Account created successfully when a user press Register button. The Snackbar should have a green background and disappear after 5 seconds.\nMaterialButton( onPressed: () { // your code here }, child: Text('Register'), ) Try Online ",
    "description": "Learn how to implement and customize Snackbar in Flutter with practical examples.",
    "tags": null,
    "title": "Snackbar in Flutter",
    "uri": "/useful-widgets/snackbar-in-flutter/"
  },
  {
    "content": "Introduction TextFormField is a widget that allows you to enter text into an app. It makes easy to collect text input, validate and save that input.\nExample 1: Basic TextFormField In this example, you will learn to create a basic form field for text input.\nTextFormField( decoration: InputDecoration( labelText: 'Enter your name', ), ) Run Online Example 2: TextFormField with Validation In this example below, you will learn to implement validation to ensure the input is not empty.\nTextFormField( decoration: InputDecoration( labelText: 'Enter your email', ), validator: (value) { if (value == null || value.isEmpty) { return 'Please enter your email'; } return null; }, ) Run Online Example 3: Password Field In this example below, you will learn to create a password field that hides the input.\nTextFormField( decoration: InputDecoration( labelText: 'Password', ), obscureText: true, ) Run Online Example 4: Styled TextFormField In this example below, you will learn to customize the appearance of your TextFormField.\nTextFormField( decoration: InputDecoration( border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), ), labelText: 'Enter your address', ), ) Run Online Example 5: TextFormField with Prefix and Suffix Icons In this example below, you will learn to create a TextFormField with prefix and suffix icons.\nTextFormField( decoration: InputDecoration( labelText: 'Phone Number', prefixIcon: Icon(Icons.phone), suffixIcon: Icon(Icons.check_circle), ), ) Run Online Example 6: TextFormField with Max Length In this example below, you will learn to create a TextFormField with a maximum length of 10 characters.\nTextFormField( decoration: InputDecoration( labelText: 'Enter your address', ), maxLength: 10, ) Run Online Example 7: TextFormField with Number Keyboard In this example below, you will learn to create a TextFormField that opens the number keyboard on focus.\nTextFormField( decoration: InputDecoration( labelText: 'Enter your age', ), keyboardType: TextInputType.number, ) Run Online Example 8: TextFormField with Input Formatter In this example below, you will learn to create a TextFormField with an input formatter that formats the input as a phone number. To achieve this, you will need to add the following import statement to your file:\nimport 'package:flutter/services.dart'; TextFormField( decoration: InputDecoration( labelText: 'Phone Number', ), inputFormatters: [ FilteringTextInputFormatter.digitsOnly, LengthLimitingTextInputFormatter(10), ], ) Run Online Input Formatters are used to format the input as it is being entered. In above example, we use FilteringTextInputFormatter to allow only digits and LengthLimitingTextInputFormatter to limit the input to 10 characters.\nChallenge Create a TextFormField for user feedback that includes validation to ensure the input is at least 15 characters long. Style the field with a rounded border and include a prefix icon that represents communication.\n",
    "description": "This guide explores the TextFormField widget in Flutter, offering examples of basic usage, validation, password fields, styled form fields, and fields with prefix and suffix icons. Learn how to utilize TextFormField to create engaging and user-friendly forms in your Flutter applications.",
    "tags": null,
    "title": "TextFormField in Flutter",
    "uri": "/forms-in-flutter/text-form-field-in-flutter/"
  },
  {
    "content": "Add Images in Flutter Images are a most common type of asset in mobile applications. Here you will learn how to include images in your flutter application. You can use images in your application in following ways:\nLocal Images Network Images Cached Images Info Note: You can use diffrent image format like: PNG, JPG, JPEG, GIF, webP, SVG, etc.\nLocal Images Local images are images that are stored locally in your app. They don’t need the internet to work and load faster. Click here to learn it practically.\nNetwork Images Network images are images that are fetched and displayed from the internet in real-time. Click here to learn it practically.\nCached Images Cached images are images that are stored locally after the first download. Click here to learn it practically.\n",
    "description": "In this section, you will learn how to add image in flutter with practical example. You will learn how to use local and network images in flutter.",
    "tags": null,
    "title": "Use Images in Flutter",
    "uri": "/working-with-assets/use-images-in-flutter/"
  },
  {
    "content": "Useful Flutter Commands Here you will find a list of useful Flutter commands that will make your app development process easier and faster.\n1. Setting Up Before diving into development, it’s essential to ensure that Flutter is set up correctly on your machine:\nflutter doctor This command checks your environment and displays a report of the status of your Flutter installation. It will also notify you of any dependencies you still need to install.\n2. Creating a New Project To start a new Flutter project you need to run flutter create command. This command will create a new Flutter project in the specified directory.\nflutter create my_app This command sets up a new Flutter project called my_app. If you want to include your organization’s domain name in the project, you can do it like this:\nflutter create --org com.yourdomain appname 3. Running the App After creating a project, navigate to the project directory and use this command to run the Flutter app in the default device (emulator/simulator).\nflutter run 4. Checking Installed Devices To check the list of all connected devices, use the following command:\nflutter devices 5. Building Apk For Android To build an APK file for Android, use:\nflutter build apk 6. Building IPA For iOS To build an IPA file for iOS, use:\nflutter build ios 7. Get All Packages To get all the packages in your project, use:\nflutter pub get 8. To Create Android App Bundle To create an app bundle for Android to publish app, use:\nflutter build appbundle Conclusion These are some of the basic commands to get you started with Flutter development. As you go advance, you will find more commands that Flutter provides to aid in the development process. Happy learning!\n",
    "description": "Learn useful flutter commands that will help you perform task quickly and easily.",
    "tags": null,
    "title": "Useful Flutter Commands",
    "uri": "/introduction-and-basics/useful-flutter-commands/"
  },
  {
    "content": "Basic Flutter Program In this section, you will learn how to create and run simple flutter program.\nSteps To Create Flutter Project Let’s create a flutter project called first_app. Follow the below steps to create a flutter project.\nOpen command prompt/terminal. Type flutter create first_app and press enter. Type cd first_app and press enter. Type code . to open project with visual studio code. Example 1: Hello World Program This is a simple Flutter application that displays Hello World on screen. First, open the main.dart file from the lib folder and replace the code with the below code.\nimport 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('My First App'), ), body: const Center( child: Text('Hello World!'), ), ), ), ); } Run Online Basic Flutter Program Explained The import ‘package:flutter/material.dart’; means we’re using the Material design package from Flutter. The void main() {…} function is where every Flutter application starts. The runApp(…); function is how we initialize and launch the app’s UI. The MaterialApp widget is our foundation for creating Material Design apps in Flutter. The Scaffold widget provides a basic visual structure, like a canvas, to design our app upon. The AppBar widget is like the top bar of an app, where we can place a title or action buttons. The Text widget is simply for displaying text on the screen. The Center widget centers the child widget. Run Flutter Project To run flutter project, go to run menu and click on Start Debugging or Run Without Debugging. You can also run the project with this command.\nflutter run Challenge Create a flutter project called second_app. Display your name on screen. ",
    "description": "Learn flutter basic program. You will learn how to create a basic flutter program, how to run flutter program, and how to create a full flutter project.",
    "tags": null,
    "title": "Basic Flutter Program",
    "uri": "/introduction-and-basics/basic-flutter-program/"
  },
  {
    "content": "Introduction Bottom Navigation Bar is a material widget at the bottom of the screen that displays multiple tabs for easy navigation between different views or functionalities in an app.\nBasic Bottom Navigation Bar To use a Bottom Navigation Bar in Flutter, you can wrap it inside a Scaffold widget. Here’s a basic example:\nScaffold( bottomNavigationBar: BottomNavigationBar( items: const \u003cBottomNavigationBarItem\u003e[ BottomNavigationBarItem( icon: Icon(Icons.home), label: 'Home', ), BottomNavigationBarItem( icon: Icon(Icons.business), label: 'Business', ), BottomNavigationBarItem( icon: Icon(Icons.school), label: 'School', ), ], ), ); Run Online Handling Navigation Typically, you want to change the body of the Scaffold based on the tab selected. This requires managing the state of the selected index. You can see complete demo in Example 1 soon.\nint _selectedIndex = 0; void _onItemTapped(int index) { setState(() { _selectedIndex = index; }); } ... BottomNavigationBar( items: \u003cBottomNavigationBarItem\u003e[...], currentIndex: _selectedIndex, onTap: _onItemTapped, ), Example 1: Ecommerce App Bottom Navigation Bar In this example below, you will create a Bottom Navigation Bar with 4 tabs: Home, Categories, Cart, and Profile. Each tab will have a corresponding screen.\nclass MyHomePage extends StatefulWidget { const MyHomePage({Key? key}) : super(key: key); @override State\u003cMyHomePage\u003e createState() =\u003e _MyHomePageState(); } class _MyHomePageState extends State\u003cMyHomePage\u003e { int _selectedIndex = 0; final List\u003cWidget\u003e _widgetOptions = const [ Text('Home'), Text('Categories'), Text('Cart'), Text('Profile'), ]; void _onItemTapped(int index) { setState(() { _selectedIndex = index; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Ecommerce App', style: TextStyle(color: Colors.white)), backgroundColor: Colors.indigo, // AppBar color ), body: Center( child: _widgetOptions.elementAt(_selectedIndex), ), bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.fixed, backgroundColor: Colors.indigo, // BottomNavigationBar background color selectedItemColor: Colors.amber, // Selected item color unselectedItemColor: Colors.white, // Unselected item color items: const [ BottomNavigationBarItem( icon: Icon(Icons.home), label: 'Home', ), BottomNavigationBarItem( icon: Icon(Icons.category), label: 'Categories', ), BottomNavigationBarItem( icon: Icon(Icons.shopping_cart), label: 'Cart', ), BottomNavigationBarItem( icon: Icon(Icons.person), label: 'Profile', ), ], currentIndex: _selectedIndex, onTap: _onItemTapped, ), ); } } Run Online Challenge Create a Bottom Navigation Bar with at least 4 items, each representing different functionalities of a gym app (e.g., Home, Workouts, Profile, Settings). Implement corresponding Text widgets for each tab.\n",
    "description": "Learn how to implement and use the Bottom Navigation Bar in Flutter with real-world examples.",
    "tags": null,
    "title": "Bottom Nav Bar in Flutter",
    "uri": "/useful-widgets/bottom-navigation-bar-in-flutter/"
  },
  {
    "content": "Introduction Checkbox is a widget that allows users to select between two states: checked or unchecked. This is typically used in forms and settings to enable or disable options.\nExample 1: Basic Checkbox In this example, you will learn to create a simple checkbox using the Checkbox widget.\nCheckbox( value: isChecked, onChanged: (bool? value) { setState(() { isChecked = value!; }); }, ), Run Online Example 2: Checkbox with Custom Colors In this example, you will learn to create a checkbox with custom colors using the Checkbox widget.\nCheckbox( value: isChecked, checkColor: Colors.white, // color of tick Mark activeColor: Colors.green, // background color onChanged: (bool? value) { setState(() { isChecked = value!; }); }, ) Run Online Example 3: Checkbox List In this example, you will learn to create a group of checkboxes using the CheckboxListTile widget.\nvar options = \u003cString\u003e['Option 1', 'Option 2', 'Option 3', 'Option 4']; var selectedOptions = \u003cString\u003e[]; ListView( children: options.map((String option) { return CheckboxListTile( title: Text(option), value: selectedOptions.contains(option), onChanged: (bool? value) { setState(() { if (value == true) { selectedOptions.add(option); } else { selectedOptions.remove(option); } }); }, ); }).toList(), ) Run Online Example 4: Accept Terms \u0026 Conditions Checkbox In this example, you will learn to create a checkbox for accepting terms and conditions using the CheckboxListTile widget.\nForm( child: Column( children: [ CheckboxListTile( title: Text(\"Accept Terms \u0026 Conditions\"), value: isAccepted, onChanged: (bool? value) { setState(() { isAccepted = value!; }); }, ), // Other form elements ], ), ) Run Online Example 5: Interest Selection Checkbox In this example, you will learn to find the selected interests from a list of interests using the CheckboxListTile widget.\nList\u003cString\u003e interests = [ 'Reading', 'Music', 'Travel', 'Sports', 'Cooking', ]; List\u003cString\u003e selectedInterests = []; Column( children: interests.map((String interest) { return CheckboxListTile( title: Text(interest), value: selectedInterests.contains(interest), onChanged: (bool? value) { setState(() { if (value == true) { selectedInterests.add(interest); } else { selectedInterests.remove(interest); } }); }, ); }).toList(), ) Run Online Challenge Create a checkbox group for selecting multiple programming languages from a list of languages.\n// available programming languages List\u003cString\u003e languages = [ 'Dart', 'Python', 'Java', 'JavaScript', 'C++', 'C#', 'Ruby', 'Go', 'Swift', 'Kotlin', ]; ",
    "description": "Learn checkbox widget in Flutter through practical examples. Learn how to implement checkboxes for accepting terms, toggling settings, custom styled checkboxes, integrating with forms, and managing state with a group of checkboxes. Enhance your Flutter applications with interactive and user-friendly checkbox elements.",
    "tags": null,
    "title": "Checkbox in Flutter",
    "uri": "/forms-in-flutter/checkbox-in-flutter/"
  },
  {
    "content": "Introduction ElevatedButton is one of the most commonly used button widgets in Flutter. It is a material design button that is elevated from the surface, making it prominent and visually appealing. Here you will learn how to use elevated buttons with real-world examples.\nExample 1: Simple ElevatedButton In this example below, you will learn to create a simple button with text using the ElevatedButton widget.\nElevatedButton( onPressed: () {}, child: Text('Press Me'), ) Run Online Example 2: ElevatedButton With Icon In this example below, you will learn to create a button with an icon using the ElevatedButton widget.\nElevatedButton.icon( onPressed: () {}, icon: Icon(Icons.add), label: Text('Add Item'), ) Run Online Example 3: Custom Color and TextStyle In this example below, you will learn to create a button with custom color and text style using the ElevatedButton widget.\nElevatedButton( onPressed: () {}, style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.green), textStyle: MaterialStateProperty.all( TextStyle(fontSize: 20), ), ), child: Text('Custom Style'), ) Run Online Example 4: Rounded Corners ElevatedButton In this example below, you will learn to create a button with rounded corners using the ElevatedButton widget.\nElevatedButton( onPressed: () {}, style: ButtonStyle( shape: MaterialStateProperty.all\u003cRoundedRectangleBorder\u003e( RoundedRectangleBorder( borderRadius: BorderRadius.circular(18.0), ), ), ), child: Text('Rounded Corners'), ) Run Online Example 5: Adjusting Shadow and Elevation In this example below, you will learn to create a button with shadow and elevation using the ElevatedButton widget.\nElevatedButton( onPressed: () {}, style: ButtonStyle( elevation: MaterialStateProperty.all(10), ), child: Text('Shadow and Elevation'), ) Run Online Example 6: Disabled ElevatedButton In this example below, you will learn to create a disabled button using the ElevatedButton widget.\nElevatedButton( onPressed: null, child: Text('Disabled Button'), ) Run Online Challenge Construct an ElevatedButton that changes its text from “Click Me” to “Clicked” upon being pressed. Additionally, the button should display a snackbar with the message “Button Pressed” when clicked.\n",
    "description": "Learn how to create an elevated button in flutter with the help of real world examples.",
    "tags": null,
    "title": "Elevated Button in Flutter",
    "uri": "/buttons-in-flutter/elevated-button-in-flutter/"
  },
  {
    "content": "Introduction Fetching data from a REST API is a fundamental task in modern app development. It allows your app to interact with external data sources, providing dynamic content to users. This guide covers how to fetch data from a REST API in Flutter, including setup, making network requests, and handling responses.\nSetup First, add the http package to your pubspec.yaml file to make HTTP requests:\ndependencies: flutter: sdk: flutter http: ^1.2.1 Example 1: Posts Listing App In this example below, you will learn how to fetch data from a REST API and display it in your Flutter app.\nimport 'package:flutter/material.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: PostList(), ); } } class PostList extends StatefulWidget { @override _PostListState createState() =\u003e _PostListState(); } class _PostListState extends State\u003cPostList\u003e { List\u003cdynamic\u003e _postData = []; Future\u003cvoid\u003e fetchData() async { final response = await http.get(Uri.parse('https://jsonplaceholder.typicode.com/posts')); if (response.statusCode == 200) { // If the server returns a 200 OK response, parse the JSON. setState(() { _postData = jsonDecode(response.body); }); } else { // If the server did not return a 200 OK response, // throw an exception. throw Exception('Failed to load data'); } } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Fetch Data Example'), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ ElevatedButton( onPressed: fetchData, child: const Text('Fetch Data'), ), const SizedBox(height: 20), Expanded( child: ListView.builder( itemCount: _postData.length, itemBuilder: (context, index) { return ListTile( title: Text(_postData[index]['title']), ); }, ), ), ], ), ), ); } } Run Online Challenges Create a motivational quotes app that fetches quotes from a REST API and displays them in a list. Here is URL to fetch quotes from:\nhttps://jsonguide.technologychannel.org/quotes.json ",
    "description": "A beginner's guide to fetching data from a REST API in Flutter. Learn how to use the http package to make network requests, handle responses, and integrate data into your Flutter application. Understand common challenges and best practices for working with APIs in Flutter.",
    "tags": null,
    "title": "Fetch Data from REST API",
    "uri": "/working-with-api/fetch-data-from-rest-api-in-flutter/"
  },
  {
    "content": "GridView In Flutter In Flutter, GridView is a versatile widget that allows the creation of grid layouts. It’s an essential widget when you need to display items in a two-dimensional list. GridView is ideal for situations where you want to present data in a visually appealing and organized manner, such as in photo galleries, product listings, or dashboard menus.\nExample 1: Photo Gallery App In this example, you will build a simple photo gallery app using GridView, demonstrating how to display a collection of images in a grid format.\nGridView.count( crossAxisCount: 3, children:[ Image.network('https://picsum.photos/200?image=25'), Image.network('https://picsum.photos/200?image=26'), Image.network('https://picsum.photos/200?image=27'), Image.network('https://picsum.photos/200?image=28'), Image.network('https://picsum.photos/200?image=29'), Image.network('https://picsum.photos/200?image=30'), // Add more images as needed ], ) Run Online Example 2: Ecommerce Product Listing Page In this example below, you will learn how to create an ecommerce product listing page using GridView, displaying products in a grid with their images and details.\nGridView.count( crossAxisCount: 2, children:[ Card( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children:[ Image.network('https://picsum.photos/200?image=25', height: 150, width: 150), const Text('Product 1'), const Text('Price: \\$100'), ], ), ), Card( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children:[ Image.network('https://picsum.photos/200?image=25', height: 150, width: 150), const Text('Product 2'), const Text('Price: \\$150'), ], ), ), // Add more product cards as needed ], ) Run Online Example 3: Simple Home Dashboard App With Menu Categories In this example below, you will learn how to create a simple home dashboard app with menu categories using GridView.\nGridView.count( crossAxisCount: 2, children: [ MaterialButton( onPressed: () {/* Handle click */}, child: const Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon(Icons.category), Text('Category 1'), ], ), ), MaterialButton( onPressed: () {/* Handle click */}, child: const Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon(Icons.category), Text('Category 2'), ], ), ), // Add more categories as needed ], ) Run Online Challenge Create a simple photo gallery app using GridView. Display images in a grid format with 3 columns and 5 rows.\n",
    "description": "Explore the GridView widget in Flutter. Learn how to create grid-based layouts like photo galleries, product listings, and dashboard menus with practical examples.",
    "tags": null,
    "title": "GridView in Flutter",
    "uri": "/list-and-grid/grid-view-in-flutter/"
  },
  {
    "content": "Introduction ListView.builder is a highly efficient way to create lists that display a large number of items. It creates items as they’re scrolled onto the screen, which is ideal for lists with a large number of items.\nInfo Note: Before learning ListView.builder, make sure you understand the basics of ListView.\nExample 1: Basic ListView.builder In this example below, you will learn how to create a simple list of items using ListView.builder.\nListView.builder( itemCount: 20, itemBuilder: (BuildContext context, int index) { return ListTile( title: Text('Item $index'), ); }, ) Run Online Example 2: To-Do List App In this example below, you will learn how to create a simple to-do list app using ListView.builder.\nimport 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { final List\u003cString\u003e tasks = [ 'Go to Gym', 'Go to College', 'Go to Office', // Add more tasks ]; @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar(title: const Text('To-Do List')), body: ListView.builder( itemCount: tasks.length, itemBuilder: (BuildContext context, int index) { return ListTile( title: Text(tasks[index]), ); }, ), ), ); } } Run Online Example 3: To-Do List App Using Using a Data Model In this example below, you will learn how to create a to-do list app using Data Model and ListView.builder.\nStep 1: Define the Data Model First, we define a simple data model for a task.\nclass Task { final String title; final String subtitle; Task({ required this.title, required this.subtitle, }); } Info Note: Data Model is a simple class that defines the structure of your data. This allows for a more structured and detailed representation of your data.\nStep 2: Create Sample Data Next, we create a list of sample tasks.\nList\u003cTask\u003e tasks = [ Task( title: 'Go to Gym', subtitle: 'Go to Gym at 6:00 AM', ), Task( title: 'Go to College', subtitle: 'Go to College at 8:00 AM', ), Task( title: 'Go to Office', subtitle: 'Go to Office at 11:00 AM', ), // Add more sample tasks ]; Step 3: Use ListView.builder Now, we use ListView.builder to build the list.\nListView.builder( itemCount: tasks.length, itemBuilder: (BuildContext context, int index) { return ListTile( title: Text(tasks[index].title), subtitle: Text(tasks[index].subtitle), ); }, ) Run Online Example 4: Social Media Feed App In this example below, you will learn how to create a social media feed app using ListView.builder. Click on run online button to see the output.\nStep 1: Define the Data Model First, we define a simple data model for a post.\nclass Post { final String username; final String userImageUrl; final String timestamp; final String contentText; final String contentImageUrl; Post({ required this.username, required this.userImageUrl, required this.timestamp, required this.contentText, required this.contentImageUrl, }); } Step 2: Create Sample Data Next, we create a list of sample posts.\nList\u003cPost\u003e posts = [ Post( username: 'John Doe', userImageUrl: 'https://picsum.photos/250?image=237', timestamp: '2h', contentText: 'Enjoying the beautiful sunset at the beach!', contentImageUrl: 'https://picsum.photos/250?image=51', ), Post( username: 'Mark Doe', userImageUrl: 'https://picsum.photos/250?image=238', timestamp: '1d', contentText: 'Just got back from a fun vacation in the mountains.', contentImageUrl: 'https://picsum.photos/250?image=52', ), // Add more sample posts ]; Step 3: Build the ListView Now, we use ListView.builder to build the list.\nListView.builder( itemCount: posts.length, itemBuilder: (BuildContext context, int index) { return Card( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ ListTile( leading: CircleAvatar(backgroundImage: NetworkImage(posts[index].userImageUrl)), title: Text(posts[index].username), subtitle: Text(posts[index].timestamp), ), Padding( padding: const EdgeInsets.all(8.0), child: Text(posts[index].contentText), ), Image.network(posts[index].contentImageUrl), ], ), ); }, ) Run Online Challenge Create app using ListView.builder to display a scrollable list containing the names of your 10 friends, with each name as a separate item.\n",
    "description": "Learn about the ListView.builder constructor in Flutter. Understand what it is, how to use it, and create dynamic and efficient list-based interfaces with practical examples.",
    "tags": null,
    "title": "ListView.builder in Flutter",
    "uri": "/list-and-grid/list-view-builder-in-flutter/"
  },
  {
    "content": "Creating a Quiz App Using Provider in Flutter Building a quiz app in Flutter with Provider involves managing the quiz state, including questions, answers, and user scores. This tutorial will guide you through creating a simple quiz app using Provider for state management.\nStep 1: Setup Provider First, ensure the Provider package is included in your pubspec.yaml file:\ndependencies: flutter: sdk: flutter provider: ^5.0.0 Step 2: Define the Quiz Model Create a model to represent your quiz. It should include questions, options, and the logic to check answers and track scores.\nclass Quiz with ChangeNotifier { final List\u003cMap\u003cString, dynamic\u003e\u003e _questions = [ { 'questionText': 'What is Flutter?', 'answers': [ {'text': 'A programming language', 'score': 0}, {'text': 'A web framework', 'score': 0}, {'text': 'A mobile UI framework', 'score': 1}, {'text': 'A game', 'score': 0}, ], }, { 'questionText': 'What language is Flutter written in?', 'answers': [ {'text': 'Dart', 'score': 1}, {'text': 'Java', 'score': 0}, {'text': 'Kotlin', 'score': 0}, {'text': 'Swift', 'score': 0}, ], }, // Add more questions here ]; int _questionIndex = 0; int _totalScore = 0; void answerQuestion(int score) { _totalScore += score; _questionIndex++; notifyListeners(); } int get questionIndex =\u003e _questionIndex; int get totalScore =\u003e _totalScore; List\u003cMap\u003cString, dynamic\u003e\u003e get questions =\u003e _questions; bool get isQuizFinished =\u003e _questionIndex \u003e= _questions.length; void resetQuiz() { _questionIndex = 0; _totalScore = 0; notifyListeners(); } } Step 3: Setup Provider in Main Wrap your app with ChangeNotifierProvider to provide the quiz model.\nimport 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'quiz.dart'; void main() =\u003e runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return ChangeNotifierProvider( create: (ctx) =\u003e Quiz(), child: MaterialApp( home: QuizPage(), ), ); } } Step 4: Build the Quiz UI Create a widget to display the quiz question and options. Use Provider.of to access and display quiz data, and to handle answer selection.\nclass QuizPage extends StatelessWidget { @override Widget build(BuildContext context) { var quiz = Provider.of\u003cQuiz\u003e(context); return Scaffold( appBar: AppBar(title: Text('Quiz App')), body: quiz.isQuizFinished ? Center( child: Text('Your score: ${quiz.totalScore}'), ) : Column( children: \u003cWidget\u003e[ Text(quiz.questions[quiz.questionIndex]['questionText']), ...(quiz.questions[quiz.questionIndex]['answers'] as List\u003cMap\u003cString, dynamic\u003e\u003e) .map((answer) =\u003e ElevatedButton( onPressed: () =\u003e quiz.answerQuestion(answer['score']), child: Text(answer['text']), )) .toList(), ], ), floatingActionButton: FloatingActionButton( onPressed: quiz.resetQuiz, child: Icon(Icons.refresh), ), ); } } Run Online ",
    "description": "Step-by-step guide to building a quiz app using the Provider package for state management in Flutter. This tutorial covers setting up Provider, creating quiz logic, and implementing a simple quiz UI.",
    "tags": null,
    "title": "Quiz App Using Provider",
    "uri": "/state-management/quiz-app-with-provider-in-flutter/"
  },
  {
    "content": "Todo App Using Flutter This guide will walk you through the steps to create a simple Todo application using Flutter. You will learn how to create a basic UI, manage state, and implement basic functionalities. 1. Setup and Project Creation First, make sure you have Flutter installed. Then, create a new Flutter project:\nflutter create todo_app 2. Designing the User Interface Now, it’s time to design the user interface. Go to the lib/main.dart file and replace the code with the following:\nimport 'package:flutter/material.dart'; void main() { runApp(TodoApp()); } class TodoApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Simple Todo App', home: TodoListScreen(), ); } } class TodoListScreen extends StatefulWidget { @override _TodoListScreenState createState() =\u003e _TodoListScreenState(); } class _TodoListScreenState extends State\u003cTodoListScreen\u003e { List\u003cString\u003e tasks = []; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Todo List')), body: ListView.builder( itemCount: tasks.length, itemBuilder: (context, index) =\u003e ListTile(title: Text(tasks[index])), ), floatingActionButton: FloatingActionButton( onPressed: () =\u003e _addTask(), child: Icon(Icons.add), ), ); } void _addTask() { // Prompt user to enter a task TextEditingController controller = TextEditingController(); showDialog( context: context, builder: (context) =\u003e AlertDialog( title: Text('New Task'), content: TextField(controller: controller), actions: [ MaterialButton( child: Text('Add'), onPressed: () { setState(() { tasks.add(controller.text); controller.clear(); }); Navigator.of(context).pop(); }, ), ], ), ); } } Run Online Explanation TodoApp: The root widget that sets up the MaterialApp. TodoListScreen: A StatefulWidget that manages the list of tasks. tasks: A list of strings to hold tasks. ListView.builder: Dynamically creates a list of tasks. FloatingActionButton: A button to add new tasks. _addTask: Function to show a dialog for adding a new task. Run the App To run the app in vs code, press F5 or go to Run \u003e Start Debugging. You can also run the app using the following command:\nflutter run Challenge Create a delete functionality for the tasks. When a user taps on a task, it should be removed from the list.\n",
    "description": "Learn to create simple todo app using flutter practically step by step.",
    "tags": null,
    "title": "Todo App",
    "uri": "/create-full-apps/todo-app/"
  },
  {
    "content": "Local Images Local images are pictures stored in your app. They don’t need the internet to work and load faster. These are ideal for images that don’t change, like logos and icons.\nHow to Use Local Images Step 1: Create an Assets Folder To use local image, first download it from here, then create an ‘assets’ folder in your project and add the downloaded image to this folder.\nStep 2: Add Images to the pubspec.yaml File Now, you need to add images to the pubspec.yaml file. Go to your pubspec.yaml file and add the following code in it:\nflutter: assets: - assets/learn_flutter.jpg Save your pubspec.yaml file.\nStep 3: Use the Images To display an image in Flutter, you need to use the Image widget. You can use the Image widget in two ways:\nImage.asset( 'assets/learn_flutter.jpg', width: 150, height: 150, ) Image( image: AssetImage('assets/learn_flutter.jpg'), width: 150, height: 150, ) Example 1: Profile App In this example, we will create a profile app and add a local image to it.\nimport 'package:flutter/material.dart'; void main() { runApp(const ProfileApp()); } class ProfileApp extends StatelessWidget { const ProfileApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const MaterialApp( title: 'Profile App', home: ProfileScreen(), ); } } class ProfileScreen extends StatelessWidget { const ProfileScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Profile App'), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const CircleAvatar( backgroundImage: AssetImage('assets/learn_flutter.jpg'), radius: 50, ), const SizedBox(height: 10), const Text( 'Flutter Tutorial', style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, ), ), const SizedBox(height: 10), const Text( 'https://flutter-tutorial.net', style: TextStyle( fontSize: 16, color: Colors.blue, ), ), ], ), ), ); } } ",
    "description": "In this section, you will learn how to add local image in flutter with practical example.",
    "tags": null,
    "title": "Use Local Images in Flutter",
    "uri": "/working-with-assets/use-local-images-in-flutter/"
  },
  {
    "content": "Working With Assets In Flutter This section will help you to learn how to use assets such as images, fonts, JSON file, icons and other files in your flutter application. Here you will learn the following topics:\nAssets in Flutter, Add Images in Flutter, Add Local Images in Flutter, Add Network Images in Flutter, Add Cached Images in Flutter, Add Local Fonts in Flutter, Add Google Fonts in Flutter, Add Local JSON in Flutter, Add Online JSON in Flutter, and Create Quotes App in Flutter. Practice Questions Complete this section \u0026 practice this question to improve and test your flutter skill.\n",
    "description": "Learn how to use images, fonts, and other files in flutter. You will learn how to use custom fonts, local and network images, and other files in flutter.",
    "tags": null,
    "title": "Working with Assets",
    "uri": "/working-with-assets/"
  },
  {
    "content": "Introduction Alert Dialog is simple pop-up message that grab the user’s attention for important information or decisions. They pop up over the app’s content, showing titles, messages, and action buttons for quick user responses.\nWhy Use Alert Dialogs? User Attention: Captures the user’s focus effectively. Immediate Action: Facilitates quick decision-making or acknowledgment from the user. Feedback Collection: Can be used to gather input or feedback from the user. Creating an Alert Dialog Creating an alert dialog in Flutter is straightforward. You typically wrap the dialog presentation in a function that can be called on a specific event, such as pressing a button.\nvoid showMyAlertDialog(BuildContext context) { showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: Text('Alert Dialog Title'), content: Text('This is an alert dialog. Are you sure you want to proceed?'), actions: \u003cWidget\u003e[ TextButton( child: Text('Cancel'), onPressed: () { Navigator.of(context).pop(); }, ), TextButton( child: Text('OK'), onPressed: () { // Handle the action and close the dialog Navigator.of(context).pop(); }, ), ], ); }, ); } To use the showMyAlertDialog function, you can call it from a button’s onPressed event or any other event that triggers the dialog.\nElevatedButton( onPressed: () =\u003e showMyAlertDialog(context), child: Text('Show Alert Dialog'), ) Run Online Example 1: Show Alert Dialog To Exit From App In this example, you will create an alert dialog that asks the user for confirmation before exiting the app.\nshowMyAlertDialog(BuildContext context) { showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: Text('Exit App'), content: Text('Are you sure you want to exit?'), actions: \u003cWidget\u003e[ TextButton( child: Text('Cancel'), onPressed: () { Navigator.of(context).pop(); }, ), TextButton( child: Text('OK'), onPressed: () { // Handle the action and close the dialog Navigator.of(context).pop(); }, ), ], ); }, ); } Run Online Example 2: Readymade Alert Dialog This is ready-made alert dialog function that you can use in your app. This function takes the context, title, and content as parameters and displays the alert dialog.\nshowMyAlertDialog(BuildContext context, String title, String content) { showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: Text(title), content: Text(content), actions: \u003cWidget\u003e[ TextButton( child: Text('Cancel'), onPressed: () { Navigator.of(context).pop(); }, ), TextButton( child: Text('OK'), onPressed: () { // Handle the action and close the dialog Navigator.of(context).pop(); }, ), ], ); }, ); } Run Online Challenge Try creating an alert dialog displaying a message Account created successfully when a user presses the Register button.\nMaterialButton( onPressed: () { // your code here }, child: Text('Register'), ) Try Online ",
    "description": "A beginner's guide to implementing alert dialogs in Flutter applications, complete with examples.",
    "tags": null,
    "title": "Alert Dialog in Flutter",
    "uri": "/useful-widgets/alert-dialog-in-flutter/"
  },
  {
    "content": "Online PDF Book Reader App Using Flutter In this guide, you’ll learn how to create an online PDF book reader app using Flutter. This app will allow users to view PDF books from a URL.\n1. Setup and Project Creation To start, ensure Flutter is installed on your system. Create a new Flutter project with the following command:\nflutter create pdf_reader_app 2. Adding Dependencies Open your pubspec.yaml file and add the following dependency to include the PDF rendering package:\ndependencies: flutter: sdk: flutter flutter_pdfview: ^1.0.4+2 3. Designing the User Interface Replace the code in lib/main.dart with the following to set up the user interface:\nimport 'package:flutter/material.dart'; import 'package:flutter_pdfview/flutter_pdfview.dart'; void main() =\u003e runApp(PDFReaderApp()); class PDFReaderApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'PDF Reader App', theme: ThemeData( primarySwatch: Colors.blue, ), home: PDFViewPage(), ); } } class PDFViewPage extends StatefulWidget { @override _PDFViewPageState createState() =\u003e _PDFViewPageState(); } class _PDFViewPageState extends State\u003cPDFViewPage\u003e { final String pdfUrl = 'http://www.africau.edu/images/default/sample.pdf'; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Online PDF Book Reader'), ), body: PDFView( filePath: pdfUrl, enableSwipe: true, swipeHorizontal: true, autoSpacing: false, pageFling: true, ), ); } } Explanation PDFReaderApp: The root widget initializing the MaterialApp. PDFViewPage: A StatefulWidget that displays the PDF reader. PDFView: A widget from flutter_pdfview used to render the PDF. User Interface Components A PDFView widget is used to display the PDF file. The app bar to provide a title for the app. Run the App To run the app, use the flutter run command. You can also run the app in Visual Studio Code by pressing F5.\n",
    "description": "Learn to create book reader app in flutter. You will learn to create a book reader app that will allow users to read PDF books from a URL.",
    "tags": null,
    "title": "Book Reader App",
    "uri": "/create-full-apps/book-reader-app/"
  },
  {
    "content": "Display Push Notification in Flutter In this section, you will learn how to display push notification in flutter using firebase_messaging package. This package allows you to display push notification in flutter for android, ios, web, and desktop.\nStep 1: Create Flutter Project Let’s create a flutter project called push_notification by flutter create command. Follow the below steps to create a flutter project.\nflutter create push_notification Info Note: Open the project in your favorite editor and make sure you are in the root directory of the project in terminal.\nStep 2: Create Firebase Project Go to Firebase Console and create a new project. If you already have a project, then you can use that project.\nStep 3: Add Firebase to Flutter App Click on Flutter icon to add firebase to flutter app. You also need to install firebase cli to add firebase to flutter app. You can install firebase cli using the following command. Also follow the instructions from firebase.\nInfo Note: If you don’t have npm installed, then you can install it from here.\nnpm install -g firebase-tools Command to add firebase to flutter app.\nfirebase login firebase init dart pub global activate flutterfire_cli flutterfire configure --project=\u003cprojectId\u003e Step 4: Add Packages Now it’s time to add firebase_core and firebase_messaging package in your pubspec.yaml file. You can add these packages in your pubspec.yaml file as shown below.\ndependencies: flutter: sdk: flutter firebase_core: ^2.16.0 firebase_messaging: ^14.6.8 Step 5: Create File In the lib folder, create a new file called firebase_api.dart and add the following code.\nimport 'package:firebase_messaging/firebase_messaging.dart'; class FirebaseApi{ final _firebaseMessaging = FirebaseMessaging.instance; Future\u003cvoid\u003e initNotification() async { await _firebaseMessaging.requestPermission( alert: true, badge: true, criticalAlert: true, sound: true, ); final token = await _firebaseMessaging.getToken(); print('Token: $token'); } void subscribeToTopic(String topic) async { await _firebaseMessaging.subscribeToTopic(topic); } } Change Main File In the main.dart file, add the following code.\nimport 'package:flutter/material.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'firebase_api.dart'; import 'firebase_options.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform, ); await FirebaseApi().initNotification(); FirebaseApi().subscribeToTopic('all'); FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler); runApp(MyApp()); } Future\u003cvoid\u003e _firebaseMessagingBackgroundHandler(RemoteMessage message) async { print('Handling a background message ${message.messageId}'); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: NotificationHandler(), ); } } class NotificationHandler extends StatefulWidget { @override _NotificationHandlerState createState() =\u003e _NotificationHandlerState(); } class _NotificationHandlerState extends State\u003cNotificationHandler\u003e { final FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance; @override void initState() { super.initState(); _firebaseMessaging.getToken().then((String? token) { assert(token != null); print(\"Push Messaging token: $token\"); }); FirebaseMessaging.onMessage.listen((RemoteMessage message) { print('Got a message whilst in the foreground!'); print('Message data: ${message.data}'); if (message.notification != null) { print('Message also contained a notification: ${message.notification}'); showDialog( context: context, builder: (context) =\u003e AlertDialog( content: ListTile( title: Text(message.notification!.title!), subtitle: Text(message.notification!.body!), ), actions: \u003cWidget\u003e[ MaterialButton( child: Text('Ok'), onPressed: () =\u003e Navigator.of(context).pop(), ), ], ), ); } }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Notification Handler'), ), body: Center( child: Text('Waiting for message...'), ), ); } } Step 6: Run Flutter Project Run your flutter project using the following command.\nflutter run Step 7: Send Notification Open your firebase console and go to Cloud Messaging. Click on New Notification and send a notification. You will see the notification on your device.\n",
    "description": "Learn how to display push notification in flutter. You will learn how to display push notification in flutter for android, ios, mac and linux.",
    "tags": null,
    "title": "Display Push Notification in Flutter",
    "uri": "/notification/display-push-notification-in-flutter/"
  },
  {
    "content": "Introduction Floating Action Button (FAB) is a circular icon button that floats above the user interface. In this section, you will learn how to use the FAB widget in Flutter to create a variety of floating action buttons with different styles and functionalities. It is commonly used to trigger primary actions in an application, such as adding a new item, composing a new message, or initiating a new task.\nExample 1: Simple FAB In this example below, you will learn to create a basic FAB with a default icon.\n// put FAB inside Scaffold. floatingActionButton: FloatingActionButton( onPressed: () {}, child: Icon(Icons.add), ) Run Online Example 2: Custom Color FAB In this example, you will learn to create a FAB with a custom background color.\nFloatingActionButton( onPressed: () {}, backgroundColor: Colors.green, child: Icon(Icons.phone), ) Run Online Example 3: Mini FAB In this example below, you will learn to implement a smaller version of the FAB suitable for limited spaces.\nFloatingActionButton( mini: true, onPressed: () {}, child: Icon(Icons.star), ) Run Online Example 4: Extended FAB In this example below, you will learn to create an extended FAB with a label and icon.\nFloatingActionButton.extended( onPressed: () {}, icon: Icon(Icons.add), label: Text('Add Item'), ) Run Online Challenge Create floating action button which change its background color from green to red when pressed.\n",
    "description": "Dive into the Floating Action Button (FAB) widget in Flutter, featuring examples of default FABs, FABs with icons, custom color FABs, mini FABs, extended FABs, and FABs with custom animations. Master the art of implementing effective and visually appealing floating action buttons in your Flutter applications.",
    "tags": null,
    "title": "Floating Action Button in Flutter",
    "uri": "/buttons-in-flutter/floating-action-button-in-flutter/"
  },
  {
    "content": "Introduction GridView.builder is an efficient way to create grid layouts that display a large number of items. It dynamically creates grid items as they become visible on the screen, making it ideal for grid layouts with numerous items.\nInfo Note: Before learning GridView.builder, make sure you understand the basics of GridView.\nExample 1: Basic GridView.builder In this example below, you will learn how to create a basic grid layout using GridView.builder.\nGridView.builder( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2), // Number of columns itemCount: 20, itemBuilder: (BuildContext context, int index) { return GridTile( child: Center( child: Text('Item $index'), ), ); }, ) Run Online Example 2: Photo Gallery App In this example below, you will learn how to create a simple photo gallery app using GridView.builder.\nimport 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { final List\u003cString\u003e imageUrls = [ 'https://picsum.photos/250?image=237', 'https://picsum.photos/250?image=238', 'https://picsum.photos/250?image=239', 'https://picsum.photos/250?image=240', 'https://picsum.photos/250?image=241', 'https://picsum.photos/250?image=242', 'https://picsum.photos/250?image=243', 'https://picsum.photos/250?image=244', // Add more image URLs ]; @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar(title: const Text('Photo Gallery')), body: GridView.builder( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 3), // Number of columns itemCount: imageUrls.length, itemBuilder: (BuildContext context, int index) { return Image.network(imageUrls[index]); }, ), ), ); } } Run Online Example 3: Create Tic-Tac-Toe Board In this example below, you will learn how to create a Tic-Tac-Toe board using GridView.builder.\nGridView.builder( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 3), // Number of columns itemCount: 9, itemBuilder: (BuildContext context, int index) { return Container( decoration: BoxDecoration( border: Border.all(color: Colors.black), ), child: Center( child: index % 2 == 0 ? const Text('X') : const Text('O'), ), ); }, ) Run Online Example 4: Product Catalog App Using Data Model In this example below, you will learn how to create a product catalog app using a Data Model and GridView.builder.\nStep 1: Define the Data Model First, we define a simple data model for a product.\nclass Product { final String title; final String subtitle; final String imageUrl; Product({ required this.title, required this.subtitle, required this.imageUrl, }); } Step 2: Create a List of Products Create a list of sample products.\nList\u003cProduct\u003e products = [ Product( title: 'Product 1', subtitle: 'Subtitle 1', imageUrl: 'https://picsum.photos/250?image=237', ), Product( title: 'Product 2', subtitle: 'Subtitle 2', imageUrl: 'https://picsum.photos/250?image=238', ), Product( title: 'Product 3', subtitle: 'Subtitle 3', imageUrl: 'https://picsum.photos/250?image=239', ), // Add more sample products ]; Step 3: Build the GridView Use GridView.builder to create the product grid.\nGridView.builder( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2), // Number of columns itemCount: products.length, itemBuilder: (BuildContext context, int index) { return Card( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Image.network(products[index].imageUrl), Text(products[index].title), Text(products[index].subtitle), ], ), ); }, ) Run Online Challenge Create chess board using GridView.builder. Make sure to use the following colors for the tiles:\n- White: #F0D9B5 - Black: #B58863 ",
    "description": "Learn about the GridView.builder constructor in Flutter. Explore its usage in creating dynamic grid-based interfaces with efficient rendering and practical examples.",
    "tags": null,
    "title": "GridView.builder in Flutter",
    "uri": "/list-and-grid/grid-view-builder-in-flutter/"
  },
  {
    "content": "Introduction Local storage is like the memory of your app. Think about it:\n📝 You have a to-do app. ❌ Every time you close the app, your tasks are gone. 🎩 Local storage is solution to this problem. Why Do We Need Local Storage? Wondering why local storage is a big deal? Here’s why:\nPersistence: Keep data even after the app is closed. Offline Access: Users can access their data without internet. Performance: Data on the device means faster access. User Experience: Apps that remember preferences = Happy users! 3. Flutter’s Local Storage Options There are different ways to store data locally in Flutter. Here are the most popular ones:\nOption Description SharedPreferences Great for small data like settings. Like a tiny storage box. Flutter Secure Storage For storing sensitive data like passwords. Encrypted \u0026 secure. Hive A blend of simplicity \u0026 performance. Think of it as Flutter’s magic. SQLite A lightweight database. Ideal when data needs structure. When you’re starting out, it’s best to start with SharedPreferences. It’s simple and easy to use. In upcoming sections, you will learn about each of these options in detail.\n",
    "description": "Learn how to store data locally in flutter with different storage options",
    "tags": null,
    "title": "Local Storage In Flutter",
    "uri": "/local-storage/introduction-to-local-storage-in-flutter/"
  },
  {
    "content": "Introduction In previous section, you learned how to move between screens. In this section, you will learn how to send data between screens. This is useful when you want to pass data from one screen to another, such as a user’s name, email, or any other information.\nExample 1: Greet User In this example, you will learn to greet the user by passing their name to the new screen. First, create a simple app with two screens: HomeScreen and GreetScreen.\nStep 1: Define Home Screen This is the main screen of the application. It has a text field to enter the user’s name and a button to navigate to the greet screen.\nclass HomeScreen extends StatelessWidget { final TextEditingController _controller = TextEditingController(); HomeScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Greet App')), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children:[ TextField( controller: _controller, decoration: InputDecoration(hintText: 'Enter your name'), ), ElevatedButton( child: Text('Greet'), onPressed: () { Navigator.of(context).push(MaterialPageRoute( builder: (context) =\u003e GreetScreen(name: _controller.text), )); }, ), ], ), ), ); } } Step 2: Define Greet Screen This screen displays a greeting message to the user. It receives the user’s name as a parameter.\nclass GreetScreen extends StatelessWidget { final String name; const GreetScreen({Key? key, required this.name}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text(\"Greet Screen\")), body: Center(child: Text('Hello, $name!')), ); } } Run Online Example 2: Pass Product Object Details In this example, you will learn to pass product object details to the new screen. First, create a simple app with two screens: HomeScreen and ProductScreen.\nStep 1: Create a Product Model First you need to create a simple data model for the product.\nclass Product { final String name; final double price; Product({required this.name, required this.price}); } Step 2: Sample Data Create a list of products to display on the home screen.\nfinal product = Product(name: 'Laptop', price: 1000); Step 3: Define Product Screen This screen displays the product details. It receives the product object as a parameter.\nclass ProductScreen extends StatelessWidget { final Product product; const ProductScreen({Key? key, required this.product}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text(product.name)), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text('Name: ${product.name}'), Text('Price: \\$${product.price}'), ], ), ), ); } } Step 4: Navigate to Product Screen Navigate to the product screen and pass the product object as a parameter.\nElevatedButton( child: Text('View Product'), onPressed: () { Navigator.of(context).push(MaterialPageRoute( builder: (context) =\u003e ProductScreen(product: product), )); }, ), Run Online Example 3: Pass Data Using Named Routes In this example below, you will learn how to pass arguments to the second screen using named routes.\nDefining Routes First, define the named routes in the MaterialApp widget:\nMaterialApp( title: 'Named Route Navigation', initialRoute: '/', routes: { '/': (context) =\u003e HomeScreen(), '/second': (context) =\u003e SecondScreen(), }, ); Passing Arguments When navigating to the second screen, you can pass arguments using the Navigator.pushNamed method:\nNavigator.pushNamed( context, '/second', arguments: 'Hello from the first screen!', ); And receive the arguments in the SecondScreen widget:\nclass SecondScreen extends StatelessWidget { @override Widget build(BuildContext context) { final String args = ModalRoute.of(context).settings.arguments; return Scaffold( appBar: AppBar( title: Text('Second Screen'), ), body: Center( child: Text(args), ), ); } } Run Online Example 4: Pass Data Using Named Routes In this example, you will learn to pass product object details to the new screen using named routes. First, create a simple app with two screens: HomeScreen and ProductScreen.\nStep 1: Create a Product Model First you need to create a simple data model for the product.\nclass Product { final String name; final double price; Product({required this.name, required this.price}); } Step 2: Sample Data Create a list of products to display on the home screen.\nfinal product = Product(name: 'Laptop', price: 1000); Step 3: Define Routes Define the routes in the MaterialApp widget.\nMaterialApp( title: 'Named Route Navigation', initialRoute: '/', routes: { '/': (context) =\u003e HomeScreen(), '/product': (context) =\u003e ProductScreen(), }, ); Step 4: Navigate to Product Screen Navigate to the product screen and pass the product object as a parameter.\nElevatedButton( child: Text('View Product'), onPressed: () { Navigator.pushNamed(context, '/product', arguments: product); }, ), Step 5: Receive Data Receive the product object in the product screen.\nclass ProductScreen extends StatelessWidget { @override Widget build(BuildContext context) { final Product product = ModalRoute.of(context)!.settings.arguments as Product; return Scaffold( appBar: AppBar(title: Text(product.name)), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text('Name: ${product.name}'), Text('Price: \\$${product.price}'), ], ), ), ); } } Run Online Challenge Create a Flutter app with 2 screens called HomeScreen and ShopScreen. Use named routes to navigate between the screens. Also pass a list of products from the HomeScreen to the ShopScreen. HomeScreen should have a button to navigate to the ShopScreen. The ShopScreen should display a list of products.\n",
    "description": "Learn how to send data between screens in your Flutter applications. This guide covers the essentials of navigating between screens with data payloads, enabling seamless data transfer and dynamic content generation. Ideal for Flutter developers aiming to enhance navigation and state management in their apps.",
    "tags": null,
    "title": "Pass Data to Other Screen",
    "uri": "/navigation-in-flutter/send-data-to-another-screen-in-flutter/"
  },
  {
    "content": "Introduction Posting data to a REST API is a common requirement for mobile applications, enabling them to send information to a server for processing or storage. This guide demonstrates how to make POST requests in Flutter, using the http package.\nSetup Ensure the http package is included in your pubspec.yaml for making HTTP requests:\ndependencies: flutter: sdk: flutter http: ^1.2.1 Example: Creating a New Post Here’s how you can post data to create a new post in a JSON placeholder API:\nimport 'package:flutter/material.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: CreatePostExample(), ); } } class CreatePostExample extends StatefulWidget { @override _CreatePostExampleState createState() =\u003e _CreatePostExampleState(); } class _CreatePostExampleState extends State\u003cCreatePostExample\u003e { Future\u003cvoid\u003e createPost(String title, String body) async { final response = await http.post( Uri.parse('https://jsonplaceholder.typicode.com/posts'), headers: \u003cString, String\u003e{ 'Content-Type': 'application/json; charset=UTF-8', }, body: jsonEncode(\u003cString, String\u003e{ 'title': title, 'body': body, 'userId': '1', }), ); if (response.statusCode == 201) { // If the server returns a 201 CREATED response, then the post was successfully created. final responseBody = jsonDecode(response.body); showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: Text(\"Post Created\"), content: Text(\"New post ID: ${responseBody['id']}\"), actions: [ MaterialButton( child: Text(\"OK\"), onPressed: () { Navigator.of(context).pop(); }, ), ], ); }, ); } else { // If the server did not return a 201 CREATED response, // then throw an exception. throw Exception('Failed to create post'); } } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Post Data Example'), ), body: Center( child: ElevatedButton( onPressed: () =\u003e createPost('Flutter', 'Posting to API from Flutter'), child: const Text('Create Post'), ), ), ); } } Run Online ",
    "description": "A complete guide on how to post data to a REST API in Flutter. This tutorial covers how to use the http package to send POST requests, handle server responses, and integrate the posted data into your Flutter app.",
    "tags": null,
    "title": "Post Data to REST API",
    "uri": "/working-with-api/post-data-to-rest-api-in-flutter/"
  },
  {
    "content": "Introduction This section will help you to learn how to publish app on app store(iOS) step by step.\nRequirements Before publishing andriod app to app store make sure you have the following requirements.\nApp Logo (1024x1024px) Screenshots iPhone(“6.7,6.5,5.5”), iPad(“12.9 6th Gen, 12.9 2nd Gen”) App Name, Description, Short Description, Subtitle, Category, Sub category, Pricing App Private Policy Support URL Marketing URL About Us Flutter App Apple developer account enrolled in developer program Mac that supports Xcode Xcode latest version Step 1: Create certificate Create a certificate in app developer then fill the form Download and install certificate Step 2: Get identifier Click the identifiers Fill the form i.e., create the bundle id Go to Apps and click new app Fill the form(name, bundle id) Step 3: Define the signing key Open the project Fill the data form in Sign In You have to define the signing key (by signing the developer account in Xcode automatically signing will be happen) Step 4: Update App Icon Open Andriod Studio and click ios Go to runnner and put the image of you app icon in assets.xcassets Step 5: Upload your App Go to Xcode and click the Build then click archive. After clicking archive the app will directly come to the TestFlight. After that, go to the AppStore and click Add Build then again click the app and click done button. If you have any remaning to fill the form you can check and fill it like Description,Support URL, Marketing URL, Contact Information. Put the link of App Privacy Policy Click to Add for Review Info Note: After 2, 3 business days your app will be approved after reviewing and it will be publishes\n",
    "description": "Learn to publish flutter app on app store step by step.",
    "tags": null,
    "title": "Publish Flutter App on App Store",
    "uri": "/publishing/publish-flutter-app-on-app-store/"
  },
  {
    "content": "Introduction RadioButtons are a type of input widget to select one option from a group. Checkbox allows multiple selections but Radio Button allows only one selection at a time.\nExample 1: Basic RadioButton In this example, learn how to create a group of radio buttons for selecting Male, Female and Others. If you have any problem try Run Online button to see the code in action.\nStep 1: Create Enum For Options We will use enhanced enum to create the options for the radio buttons.\nenum Gender { male(\"Male\"), female(\"Female\"), others(\"Others\"); // Members final String text; const Gender(this.text); } Step 2: Create State Variable It’s time to create a state variable to store the selected option.\nGender? _selectedOption = Gender.male; Step 3: Create Radio Buttons Finally, create the radio buttons using the RadioListTile widget.\nColumn( // Radio buttons children: Gender.values .map((option) =\u003e RadioListTile\u003cGender\u003e( title: Text(option.text), value: option, groupValue: _selectedOption, onChanged: (value) { setState(() { _selectedOption = value; }); }, )) .toList(), ) Run Online Example 2: Game Difficulty Selection In this example, learn how to create a group of radio buttons for selecting the game difficulty level. If you have any problem try Run Online button to see the code in action.\nStep 1: Create Enum For Options We will use enhanced enum to create the options for the radio buttons.\nenum Difficulty { easy(\"Easy\"), medium(\"Medium\"), hard(\"Hard\"); // Members final String text; const Difficulty(this.text); } Step 2: Create State Variable It’s time to create a state variable to store the selected option.\nDifficulty? _selectedDifficulty = Difficulty.easy; Step 3: Create Radio Buttons Finally, create the radio buttons using the RadioListTile widget.\nColumn( // Radio buttons children: Difficulty.values .map((option) =\u003e RadioListTile\u003cDifficulty\u003e( title: Text(option.text), value: option, groupValue: _selectedDifficulty, onChanged: (value) { setState(() { _selectedDifficulty = value; }); }, )) .toList(), ) Run Online Challenge Create a quiz app with radio buttons to select the correct answer for each question.\nQuestion: What is the capital of France? Options: - Paris - London - Berlin ",
    "description": "Dive into the RadioButton widget in Flutter with practical examples. Learn how to implement radio buttons for selecting options, custom styled radio buttons, integrating radio buttons with forms, and managing group selection. Enhance your Flutter applications with intuitive and user-friendly radio button elements.",
    "tags": null,
    "title": "RadioButton in Flutter",
    "uri": "/forms-in-flutter/radio-button-in-flutter/"
  },
  {
    "content": "Shared Preferences in Flutter Shared preferences is a simple key-value pair storage feature in Flutter that’s frequently used to permanently store small amounts of basic data. It works well for storing preferences, settings, and little quantities of user-specific information.\nSteps To Use Shared Preferences in Flutter Follow the below steps to use shared preferences in flutter.\nAdd shared_preferences package in your pubspec.yaml file. dependencies: flutter: sdk: flutter shared_preferences: ^2.2.2 Step 1: Import Package To use shared preferences in flutter, you need to import the shared_preferences package. You can import the shared_preferences package in lib/main.dart file. Add the following code in lib/main.dart file.\nimport 'package:shared_preferences/shared_preferences.dart'; Step 2: Create a SharedPreferences Helper Class In this step, you will create a helper class called shared_preferences_helper.dart. This class will be used to store and retrieve data from shared preferences. You can create this class in lib/helper/shared_preferences_helper.dart file. Add the following code in lib/helper/shared_preferences_helper.dart file.\nimport 'package:shared_preferences/shared_preferences.dart'; class SharedPreferencesHelper { static SharedPreferences? _sharedPreferences; static Future\u003cvoid\u003e init() async { if (_sharedPreferences == null) { _sharedPreferences = await SharedPreferences.getInstance(); } } // To set a string value static Future\u003cbool\u003e setString(String key, String value) { return _sharedPreferences!.setString(key, value); } // To get a string value static String? getString(String key) { return _sharedPreferences!.getString(key); } // Similarly, you can create methods for other data types. } Step 3: Initialize SharedPreferences Before using shared preferences, initialize it as a priority in the main() method. You can initialize shared preferences in lib/main.dart file. Add the following code in lib/main.dart file.\nvoid main() async { WidgetsFlutterBinding.ensureInitialized(); await SharedPreferencesHelper.init(); runApp(const MainApp()); } Step 4: Set and Get Values Now you can set and get values from shared preferences. You can set and get values from shared preferences as shown below.\n// To set a string value await SharedPreferencesHelper.setString('username', 'FlutterFan123'); // To get a string value String? username = SharedPreferencesHelper.getString('username'); Example 1: Light and Dark Theme App In this example below, you will build a light and dark theme app by using shared preferences. You will use shared preferences to store the theme value and retrieve it when the app is opened.\nimport 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await SharedPreferencesHelper.init(); runApp(MyApp()); } class MyApp extends StatefulWidget { @override _MyAppState createState() =\u003e _MyAppState(); } class _MyAppState extends State\u003cMyApp\u003e { bool _isDarkTheme = false; // initialize the theme from shared preferences @override void initState() { super.initState(); _isDarkTheme = SharedPreferencesHelper.getBool(\"isDarkTheme\") ?? false; } void _toggleTheme() { setState(() { _isDarkTheme = !_isDarkTheme; SharedPreferencesHelper.setBool(\"isDarkTheme\", _isDarkTheme); }); } @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Theme Switcher', theme: _isDarkTheme ? ThemeData.dark() : ThemeData.light(), home: Scaffold( appBar: AppBar(title: Text('Theme Switcher with SharedPreferences')), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text('Click the button below to toggle theme:'), SizedBox(height: 20), ElevatedButton( onPressed: _toggleTheme, child: Text('Toggle Theme'), ), ], ), ), ), ); } } class SharedPreferencesHelper { static SharedPreferences? _sharedPreferences; static Future\u003cvoid\u003e init() async { if (_sharedPreferences == null) { _sharedPreferences = await SharedPreferences.getInstance(); } } // To set a bool value static Future\u003cbool\u003e setBool(String key, bool value) { return _sharedPreferences!.setBool(key, value); } // To get a bool value static bool? getBool(String key) { return _sharedPreferences!.getBool(key); } } Info Note: Close and Reopen the app to see the changes.\n",
    "description": "Learn how to store data locally in flutter with the help of shared preferences",
    "tags": null,
    "title": "Shared Preferences in Flutter",
    "uri": "/local-storage/shared-preferences-in-flutter/"
  },
  {
    "content": "Tic Tac Toe Game Using Flutter In this guide, we’ll create a simple Tic Tac Toe game using Flutter. We’ll use a GridView.builder to create the game grid and manage the game state.\n1. Setup and Project Creation First, ensure Flutter is installed on your machine. Create a new Flutter project with the following command:\nflutter create tic_tac_toe_game 2. Designing the User Interface Edit the lib/main.dart file with the following code to design the game’s interface:\nimport 'package:flutter/material.dart'; void main() =\u003e runApp(TicTacToeApp()); class TicTacToeApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Tic Tac Toe', home: TicTacToeScreen(), ); } } class TicTacToeScreen extends StatefulWidget { @override _TicTacToeScreenState createState() =\u003e _TicTacToeScreenState(); } class _TicTacToeScreenState extends State\u003cTicTacToeScreen\u003e { List\u003cString\u003e board = List.filled(9, '', growable: false); String currentPlayer = 'X'; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Tic Tac Toe')), body: GridView.builder( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3), itemCount: board.length, itemBuilder: (context, index) { return GestureDetector( onTap: () =\u003e _markCell(index), child: Container( decoration: BoxDecoration( border: Border.all(color: Colors.black), ), child: Center( child: Text( board[index], style: TextStyle(fontSize: 40), ), ), ), ); }, ), ); } void _markCell(int index) { if (board[index] == '') { setState(() { board[index] = currentPlayer; currentPlayer = currentPlayer == 'X' ? 'O' : 'X'; }); } } } Run Online Explanation TicTacToeApp: Sets up the MaterialApp. TicTacToeScreen: A StatefulWidget that contains the UI and logic for the game. board: A list that represents the 3x3 grid of the game. GridView.builder: Used to create the game grid. _markCell: A function to mark a cell with the current player’s symbol. Game Logic The game alternates between two players, ‘X’ and ‘O’. Players tap on a cell to mark it with their symbol. The game continues until all cells are marked. Run the App To run the application, use the flutter run command, or press F5 in Visual Studio Code to start debugging.\n",
    "description": "Learn to create tic tac toe game using flutter practically step by step",
    "tags": null,
    "title": "Tic Tac Toe Game",
    "uri": "/create-full-apps/tic-tac-toe-game/"
  },
  {
    "content": "Network Images Network images are images that are fetched and displayed from the internet in real-time. They are important for applications that require constantly updated images, such as social media feeds, news apps, or e-commerce platforms.\nHow to Use Network Images To display an image in Flutter, you need to use the Image widget. You can use the Image widget in two ways:\nImage.network( 'https://picsum.photos/250?image=9', width: 150, height: 150, ) Image( image: NetworkImage('https://picsum.photos/250?image=9'), width: 150, height: 150, ) Example 1: Profile App In this example, we will create a profile app and add a network image to it.\nimport 'package:flutter/material.dart'; void main() { runApp(const ProfileApp()); } class ProfileApp extends StatelessWidget { const ProfileApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const MaterialApp( title: 'Flutter Tutorial', home: ProfileScreen(), ); } } class ProfileScreen extends StatelessWidget { const ProfileScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Learn App Development'), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.network(\"https://flutter-tutorial.net/images/learn_flutter.jpg\"), const SizedBox(height: 10), const Text( 'Flutter Tutorial', style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, ), ), const SizedBox(height: 10), const Text( 'https://flutter-tutorial.net', style: TextStyle( fontSize: 16, color: Colors.blue, ), ), ], ), ), ); } } Run Online ",
    "description": "In this section, you will learn how to add image from internet in flutter with practical example. You will learn how to use network images in flutter.",
    "tags": null,
    "title": "Use Internet Images in Flutter",
    "uri": "/working-with-assets/use-internet-images-in-flutter/"
  },
  {
    "content": "Useful Widgets In Flutter This section will help you to learn most useful widgets in flutter. Here you will learn the following topics:\nDrawer in Flutter, Snackbar in Flutter, Bottom Navigation Bar in Flutter, Alert Dialog in Flutter, Table in Flutter, Forms in Flutter, and Buttons in Flutter. Practice Questions Complete this section \u0026 practice this question to improve and test your flutter skill.\n",
    "description": "Learn the most useful widgets in flutter. You will learn how to use list view, grid view, stack, and other widgets in flutter.",
    "tags": null,
    "title": "Useful Widgets",
    "uri": "/useful-widgets/"
  },
  {
    "content": "What is Flutter Widgets? In Flutter, everything on the screen is a widget. Flutter widgets are the UI elements that you see on the screen e.g. button, text, image, list, etc. Widgets can be either stateful or stateless.\nTypes of Widgets in Flutter Flutter widgets are broadly categorized into:\nStateless Widget Stateful Widget Stateless Widget Stateless widgets are immutable. Once you define their properties, they remain constant and don’t change. They are the go-to choice for displaying static content like text, images, or icons.\nInfo Note: You can use stl shortcut to create a stateless widget in VS Code.\nExample of a Stateless Widget:\nclass MyStatelessWidget extends StatelessWidget { final String text; MyStatelessWidget({required this.text}); @override Widget build(BuildContext context) { return Text(text); } } Stateful Widget Stateful widgets are dynamic and can change during their lifecycle, usually in response to user interactions or real-time data updates. They are essential for content that evolves over time, such as a shopping cart’s contents. Info Note: You can use stf shortcut to create a stateful widget in VS Code.\nExample of a Stateful Widget:\nclass MyStatefulWidget extends StatefulWidget { @override _MyStatefulWidgetState createState() =\u003e _MyStatefulWidgetState(); } class _MyStatefulWidgetState extends State\u003cMyStatefulWidget\u003e { int counter = 0; @override Widget build(BuildContext context) { return ElevatedButton( onPressed: () { setState(() { counter++; }); }, child: Text('You have pressed the button $counter times.'), ); } } Stateless Vs Stateful Widgets Stateless Widgets Stateful Widgets Properties Stateless widgets remain constant and don’t change Stateful widgets can change their appearance based on events or data. Use Case For static content (e.g., buttons, icons) For dynamic content (e.g., user interactions) State No internal state Maintains internal state that can be updated Rebuild Entire widget tree rebuilt on state changes Rebuilds only the widget affected by state change Most Used Flutter Widgets Text: It is used to display text on the screen. Container: It is used to display a rectangular box on the screen. Row: It is used to display widgets in a horizontal manner. Column: It is used to display widgets in a vertical manner. Stack: It is used to display widgets on top of each other. Info Note: You can use Container widget to add padding, margin, border, background color, etc. to other widgets.\n",
    "description": "A comprehensive guide on Flutter widgets, exploring their types and practical applications.",
    "tags": null,
    "title": "Widgets in Flutter",
    "uri": "/introduction-and-basics/widgets-in-flutter/"
  },
  {
    "content": "Tic Tac Toe Game Using Flutter In this guide, we’ll create a simple Tic Tac Toe game using Flutter. We’ll use a GridView.builder to create the game grid and manage the game state.\n1. Setup and Project Creation First, ensure Flutter is installed on your machine. Create a new Flutter project with the following command:\nflutter create tic_tac_toe_game 2. Writing the Code Open the main.dart file. This is where your Flutter application starts. Replace the existing code with:\nimport 'package:flutter/material.dart'; void main() =\u003e runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Tic Tac Toe', theme: ThemeData( primarySwatch: Colors.blue, ), home: TicTacToePage(), ); } } class TicTacToePage extends StatefulWidget { @override _TicTacToePageState createState() =\u003e _TicTacToePageState(); } class _TicTacToePageState extends State\u003cTicTacToePage\u003e { late List\u003cString\u003e board; late String currentPlayer; late String winner; late bool isDraw; @override void initState() { super.initState(); _initializeGame(); } void _initializeGame() { board = List.generate(9, (_) =\u003e ''); currentPlayer = 'X'; winner = ''; isDraw = false; } void _handleTap(int index) { if (board[index] != '' || winner != '') return; // Prevent overwriting a cell and ignore taps after game over setState(() { board[index] = currentPlayer; if (_checkWinner(currentPlayer)) { winner = currentPlayer; } else if (_checkDraw()) { isDraw = true; } else { currentPlayer = currentPlayer == 'X' ? 'O' : 'X'; } }); } bool _checkWinner(String player) { // Check rows, columns and diagonals for a win for (int i = 0; i \u003c 3; i++) { if (board[i * 3] == player \u0026\u0026 board[i * 3 + 1] == player \u0026\u0026 board[i * 3 + 2] == player) { return true; } if (board[i] == player \u0026\u0026 board[i + 3] == player \u0026\u0026 board[i + 6] == player) { return true; } } if (board[0] == player \u0026\u0026 board[4] == player \u0026\u0026 board[8] == player) { return true; } if (board[2] == player \u0026\u0026 board[4] == player \u0026\u0026 board[6] == player) { return true; } return false; } bool _checkDraw() { return board.every((cell) =\u003e cell != ''); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Tic Tac Toe'), ), body: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ winner != '' ? Text('Winner: $winner', style: const TextStyle(fontSize: 30)) : isDraw ? const Text('Draw', style: TextStyle(fontSize: 30)) : Text('Current Player: $currentPlayer', style: const TextStyle(fontSize: 30)), Expanded( child: GridView.builder( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 3, ), itemCount: 9, itemBuilder: (context, index) { return GridTile( child: Container( margin: const EdgeInsets.all(10.0), decoration: BoxDecoration( border: Border.all(color: Colors.black), ), child: MaterialButton( onPressed: () =\u003e _handleTap(index), child: Text(board[index], style: const TextStyle(fontSize: 40)), ), ), ); }, ), ), MaterialButton( child: const Text('Restart Game'), onPressed: () { setState(() { _initializeGame(); }); }, ), ], ), ); } } Run Online Run the App To run the application, use the flutter run command, or press F5 in Visual Studio Code to start debugging.\n",
    "description": "Learn to create tic tac toe game using flutter practically step by step",
    "tags": null,
    "title": "Create Tic Tac Toe Game",
    "uri": "/list-and-grid/create-tic-tac-toe-game-in-flutter/"
  },
  {
    "content": "Flutter Buttons This section will help you to learn different types of buttons in flutter. Here you will learn the following topics:\nButtons in Flutter, MaterialButton in Flutter. ElevatedButton in Flutter, TextButton in Flutter, OutlinedButton in Flutter, IconButton in Flutter, FloatingActionButton in Flutter, DropdownButton in Flutter, and PopupMenuButton in Flutter. Practice Questions Complete this section \u0026 practice this question to improve and test your flutter skill.\n",
    "description": "Learn about all flutter buttons with examples. You will learn how to display TextButton, ElevatedButton, OutlinedButton, IconButton and FloatingActionButton in flutter.",
    "tags": null,
    "title": "Flutter Buttons",
    "uri": "/buttons-in-flutter/"
  },
  {
    "content": "Introduction IconButton is a type of button in Flutter that displays an icon instead of text. In this section, you will learn how to use the IconButton widget effectively, with real-world examples.\nExample 1: Simple IconButton In this example below, you will learn to create a simple IconButton with a default icon.\nIconButton( onPressed: () {}, icon: Icon(Icons.home), ) Run Online Example 2: IconButton with Custom Color In this example below, you will learn to create an IconButton with a custom color for the icon.\nIconButton( onPressed: () {}, icon: Icon(Icons.send), color: Colors.purple, ) Run Online Example 3: IconButton with Size Customization In this example below, you will learn to create an IconButton with a custom size for the icon.\nIconButton( onPressed: () {}, icon: Icon(Icons.alarm), iconSize: 30, ) Run Online Example 4: IconButton with Tooltip In this example below, you will learn to create an IconButton with tooltip. Tooltip provide additional information on hover or long press.\nIconButton( onPressed: () {}, icon: Icon(Icons.info), tooltip: 'More Info', ) Run Online Example 5: Disabled IconButton In this example below, you will learn to create a disabled button using the IconButton widget.\nIconButton( icon: Icon(Icons.block), onPressed: null, ) Run Online Challenge Create an IconButton that changes the color of the icon when pressed.\n",
    "description": "Learn how to use the IconButton widget in Flutter, with examples including default icon buttons, icon buttons with custom colors, sizes, tooltips, and disabled icon buttons. Discover the versatility of IconButton for adding interactive icons to your Flutter applications.",
    "tags": null,
    "title": "Icon Button in Flutter",
    "uri": "/buttons-in-flutter/icon-button-in-flutter/"
  },
  {
    "content": "Introduction Updating data on a server through a REST API is a common requirement for mobile applications. PUT requests are used for updating existing resources. This tutorial shows how to send PUT requests in Flutter using the http package.\nSetup Add the http package to your pubspec.yaml file:\ndependencies: flutter: sdk: flutter http: ^1.2.1 Example: Updating a Post This example demonstrates updating a post using the JSON placeholder API:\nimport 'package:flutter/material.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: UpdatePostExample(), ); } } class UpdatePostExample extends StatefulWidget { @override _UpdatePostExampleState createState() =\u003e _UpdatePostExampleState(); } class _UpdatePostExampleState extends State\u003cUpdatePostExample\u003e { Future\u003cvoid\u003e updatePost(int postId, String title, String body) async { final response = await http.put( Uri.parse('https://jsonplaceholder.typicode.com/posts/$postId'), headers: \u003cString, String\u003e{ 'Content-Type': 'application/json; charset=UTF-8', }, body: jsonEncode(\u003cString, String\u003e{ 'title': title, 'body': body, }), ); if (response.statusCode == 200) { // If the server returns a 200 OK response, then the post was successfully updated. final responseBody = jsonDecode(response.body); showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: Text(\"Post Updated\"), content: Text(\"Post ID: ${responseBody['id']} updated successfully.\"), actions: [ MaterialButton( child: Text(\"OK\"), onPressed: () { Navigator.of(context).pop(); }, ), ], ); }, ); } else { // If the server did not return a 200 OK response, // then throw an exception. throw Exception('Failed to update post'); } } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Put Data Example'), ), body: Center( child: ElevatedButton( onPressed: () =\u003e updatePost(1, 'Updated Title', 'Updated body text'), child: const Text('Update Post'), ), ), ); } } Run Online ",
    "description": "Master how to update data using PUT requests to a REST API in Flutter. This guide covers sending PUT requests with the http package, handling responses, and ensuring your Flutter app reflects the updated data.",
    "tags": null,
    "title": "Put Data to REST API in Flutter",
    "uri": "/working-with-api/put-data-to-rest-api-in-flutter/"
  },
  {
    "content": "Introduction In the previous section, you learned how to send data to another screen. Now, you will learn how to return data from the new screen to the previous screen.\nExample 1: Pizza Selection In this example, you will learn to select a pizza from a list of pizzas. When you select a pizza, it will return the selected pizza to the previous screen.\nStep 1: Define Home Screen This is the main screen of the application. It has a button to navigate to the pizza selection screen and a text widget to display the selected pizza.\nclass HomeScreen extends StatefulWidget { @override _HomeScreenState createState() =\u003e _HomeScreenState(); } class _HomeScreenState extends State\u003cHomeScreen\u003e { String? _selectedPizza; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Pizza Selection')), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ ElevatedButton( child: Text('Select Pizza'), onPressed: () async { final selectedPizza = await Navigator.of(context).push( MaterialPageRoute(builder: (context) =\u003e PizzaSelectionScreen()), ); setState(() { _selectedPizza = selectedPizza; }); }, ), SizedBox(height: 20), Text('Selected Pizza: $_selectedPizza'), ], ), ), ); } } Step 2: Define Pizza Selection Screen This screen displays a list of pizzas. When you select a pizza, it will return the selected pizza to the previous screen.\nclass PizzaSelectionScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Select Pizza')), body: ListView( children: [ ListTile( title: Text('Margherita'), onTap: () { Navigator.of(context).pop('Margherita'); }, ), ListTile( title: Text('Pepperoni'), onTap: () { Navigator.of(context).pop('Pepperoni'); }, ), ListTile( title: Text('Vegetarian'), onTap: () { Navigator.of(context).pop('Vegetarian'); }, ), ], ), ); } } Run Online Challenge Create a app with a HomeScreen and a ColorSelectionScreen. The HomeScreen should have a button to navigate to the ColorSelectionScreen where the user can select a color. Once a color is selected, the ColorSelectionScreen should return that color to the HomeScreen, which then changes its background color accordingly.\nAvailable Colors: - Red - Blue - Green ",
    "description": "This guide explores how to return data from a screen back to the previous screen in Flutter applications. Understand the steps to implement backward data passing, enabling dynamic content updates based on user interactions. Essential for developers looking to refine navigation and state management.",
    "tags": null,
    "title": "Return Data from Screen",
    "uri": "/navigation-in-flutter/return-data-from-screen-in-flutter/"
  },
  {
    "content": "Introduction The Switch widget in Flutter is a fundamental UI component used for toggling between two states, such as on/off or true/false. This article will guide you through various implementations of the Switch widget, from basic usage to more advanced scenarios including custom styling and integration with forms.\nExample 1: Basic Switch Learn how to create a simple switch that toggles a boolean value.\nSwitch( value: isSwitched, onChanged: (value) { setState(() { isSwitched = value; }); }, ), Run Online Example 2: Custom Styled Switch Customize the appearance of a switch with custom colors.\nSwitch( value: isSwitched, activeTrackColor: Colors.lightGreenAccent, activeColor: Colors.green, onChanged: (value) { setState(() { isSwitched = value; }); }, ) Run Online Example 3: Switch List Implement a list of switches, each controlling a different setting.\nvar settings = \u003cString, bool\u003e{ 'Wi-Fi': true, 'Bluetooth': false, 'Airplane Mode': false, 'Mobile Data': true, }; ListView( children: settings.keys.map((String key) { return SwitchListTile( title: Text(key), value: settings[key]!, onChanged: (bool value) { setState(() { settings[key] = value; }); }, ); }).toList(), ) Run Online Example 4: Form Switch Incorporate a switch into a form to accept terms \u0026 conditions or toggle preferences.\nForm( child: Column( children: [ SwitchListTile( title: Text(\"Accept Terms \u0026 Conditions\"), value: isAccepted, onChanged: (bool value) { setState(() { isAccepted = value; }); }, ), // Other form elements ], ), ) Run Online Example 5: Profile Visibility Switch Use a switch to control the visibility of user profile information.\nSwitchListTile( title: Text('Show Profile Publicly'), value: isProfilePublic, onChanged: (bool value) { setState(() { isProfilePublic = value; }); }, ) Run Online Challenge Create a settings page using switches to control various app features such as notifications, dark mode, location tracking, and automatic updates.\n// App settings options Map\u003cString, bool\u003e appSettings = { 'Notifications': true, 'Dark Mode': false, 'Location Tracking': true, 'Automatic Updates': false, }; ",
    "description": "Explore the Switch widget in Flutter through real-world examples. Learn how to incorporate switches for theme toggling, preference settings, custom styled switches, integrating with forms, and managing multiple switch states. Enhance your Flutter applications with intuitive and interactive switch elements.",
    "tags": null,
    "title": "Switch in Flutter",
    "uri": "/forms-in-flutter/switch-in-flutter/"
  },
  {
    "content": "Table in Flutter Table widget is a great way to display data in a table layout within your mobile app. It’s useful when you need to present data in a structured format, such as financial reports, timetables, or settings.\nExample 1: Student Record With Table In this example below, you will learn to create a table to display student information such as name, subject, and grade.\nTable( border: TableBorder.all(), // Adds a border to all cells columnWidths: \u003cint, TableColumnWidth\u003e{ 0: FixedColumnWidth(100.0), // fixed to 100.0 width 1: FlexColumnWidth(), // automatically adapts to fill the table width 2: FixedColumnWidth(100.0), // fixed to 100.0 width }, children: [ TableRow(children: [ Text('Name'), Text('Subject'), Text('Grade'), ]), TableRow(children: [ Text('Alice'), Text('Math'), Text('A'), ]), TableRow(children: [ Text('Bob'), Text('Science'), Text('B+'), ]), // Add more students and grades here ], ) Run Online DataTable In Flutter DataTable widget is a powerful widget that allows you to display tabular data with advanced features such as sorting, selection, and pagination. It is best for displaying complex tables with interactivity.\nExample 2: Student Record With DataTable In this example below, you will learn to create a DataTable to display student information such as name, subject, and grade.\nDataTable( columns: const [ DataColumn(label: Text('Name')), DataColumn(label: Text('Subject')), DataColumn(label: Text('Grade')), ], rows: const [ DataRow(cells: [ DataCell(Text('Alice')), DataCell(Text('Math')), DataCell(Text('A')), ]), DataRow(cells: [ DataCell(Text('Bob')), DataCell(Text('Science')), DataCell(Text('B+')), ]), // Add more students and grades here ], ) Run Online Example 3: Contact List App Now you will learn to create a contact list app using DataTable widget. You will define a model class called contact.dart to store contact information. Then you will build DataTable widget to display contact information.\nStep 1: Define Model Class In this step, you will define a model class called contact.dart. This class will be used to store contact information. You can define this class in lib/model/contact.dart file. Add the following code in contact.dart file.\nclass Contact { final String name; final String email; final String phone; Contact({this.name, this.email, this.phone}); } Step 2: Create Contact List In this step, you will create a list of contacts. You can define this list in lib/data/contact_data.dart file. Add the following code in contact_data.dart file.\nimport 'package:your_app_name/model/contact.dart'; List\u003cContact\u003e contacts = [ Contact(name: 'Alice', email: 'alice@domain.com', phone: '1234567890'), Contact(name: 'Bob', email: 'bob@domain.com', phone: '1234567890'), Contact(name: 'Charlie', email: 'charl@domain.com', phone: '1234567890'), // Add more contacts here ]; Step 3: Display Contact List In this step, you will display the contact list using DataTable widget. You can define this widget in lib/screens/contact_list.dart file. Add the following code in contact_list.dart file.\nimport 'package:flutter/material.dart'; import 'package:your_app_name/data/contact_data.dart'; import 'package:your_app_name/model/contact.dart'; class ContactList extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Contact List'), ), body: DataTable( columns: const [ DataColumn(label: Text('Name')), DataColumn(label: Text('Email')), DataColumn(label: Text('Phone')), ], rows: contacts.map((contact) { return DataRow(cells: [ DataCell(Text(contact.name)), DataCell(Text(contact.email)), DataCell(Text(contact.phone)), ]); }).toList(), ), ); } } Run Online Challenge Create a DataTable that displays a list of products with columns Name, Price, and Stock. The DataTable should have 5 rows of products with different names, prices, and stock values.\n",
    "description": "Learn how to create table in flutter practically with the help of examples",
    "tags": null,
    "title": "Table in Flutter",
    "uri": "/useful-widgets/table-in-flutter/"
  },
  {
    "content": "Text In Flutter Text widget is a used to display a string of text. In this section, you will learn how to use text widget, style text, align text, and handle overflow.\nExample 1: Display Text In Flutter In this example, you will learn how to display your name using Text widget.\nText('Raj Sharma') Run Online Example 2: Center Text In Flutter In this example, you will learn how to center text in flutter. In center widget, you can pass any widget as a child. Here we are passing Text widget as a child.\nCenter( child: Text('Raj Sharma'), ) Run Online Info Note: Center widget is used to center the child widget. Here child widget is Text widget.\nExample 3: Styling Text In Flutter In this example, you will learn how to style text in flutter. You will learn to change font size, font weight, and font color.\nText( 'Raj Sharma', style: TextStyle( fontSize: 24, fontWeight: FontWeight.bold, color: Colors.blue, ), ) Run Online Example 4: Align Text In Flutter In this example, you will learn how to align text in flutter. You will learn to align text to left, right, and center.\nCenter( child: Text( 'Hello I am Mark and I am a Flutter Developer at Technology Channel.', textAlign: TextAlign.center, ), ) Tip Tip: Try changing the value of textAlign property to TextAlign.left, TextAlign.right, TextAlign.justify.\nRun Online Example 5: Underline Text In Flutter In this example, you will learn how to underline text in flutter. You will learn to underline text using decoration property.\nText( 'Raj Sharma', style: TextStyle( decoration: TextDecoration.underline, ), ) Tip Tip: .\nRun Online Example 6: Text With Background Color In Flutter In this example, you will learn how to add background color to text in flutter. You will learn to add background color using backgroundColor property.\nText( 'Raj Sharma', style: TextStyle( backgroundColor: Colors.blue, fontSize: 20, ), ) Run Online Example 7: Handle Text Overflow In Flutter In this example, you will learn how to handle overflow in flutter. You will learn to handle overflow using overflow property.\nText( 'A very long text that might not fit the screen. '*10, // try commenting the below line and see the difference overflow: TextOverflow.ellipsis, ) Run Online ",
    "description": "Learn how to use text widget in flutter with real-world examples. You will also learn how to style text, align text, and handle overflow.",
    "tags": null,
    "title": "Text In Flutter",
    "uri": "/introduction-and-basics/text-in-flutter/"
  },
  {
    "content": "Introduction Cached images are images that are stored locally after the first download. Here are some of the benefits of using cached images in your Flutter application:\nFaster Loading Times: Less Network Usage: Improved User Experience: How to Use Cached Images in Flutter To use the cached_network_image package, you need to add cached_network_image package in your flutter project. Open your terminal and go to your project directory and execute the following command:\nflutter pub add cached_network_image Import the Package Now, you need to import the cached_network_image package in your flutter application. To import the cached_network_image package, open your main.dart file and add the following import statement:\nimport 'package:cached_network_image/cached_network_image.dart'; Use the Package Now, you can use the cached_network_image package in your flutter application. To use the cached_network_image package, open your main.dart file and add the following code in it:\nimport 'package:flutter/material.dart'; import 'package:cached_network_image/cached_network_image.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Use Cached Images in Flutter', home: Scaffold( appBar: AppBar( title: Text('Use Cached Images in Flutter'), ), body: Center( child: CachedNetworkImage( imageUrl: 'https://picsum.photos/250?image=9', placeholder: (context, url) =\u003e CircularProgressIndicator(), errorWidget: (context, url, error) =\u003e Icon(Icons.error), ), ), ), ); } } In this code:\nimageUrl is the URL of the image you want to cache. placeholder is a widget displayed while the image is loading. errorWidget is displayed in case of any loading error. ",
    "description": "In this section, you will learn how to cache images in your flutter application with the help of examples.",
    "tags": null,
    "title": "Use Cached Images in Flutter",
    "uri": "/working-with-assets/use-cache-images-in-flutter/"
  },
  {
    "content": "Introduction In this section, you will learn to use local fonts in your flutter application with the help of real-world example. Here are the steps to use local fonts in your app:\nStep 1: Add the Font Files To use local fonts in your app, the first step is to add the font files in your flutter project. You can download sample font files from here or you can use your own font files.\nInfo Note: Before downloading the font files, make sure you have proper license to use it.\nStep 2: Add Font Files to Your Project In project folder, create a new folder called assets and inside assets folder, create another folder called fonts. Now, place all the font files inside the fonts folder. Here is preview of the folder structure:\nfonts_in_flutter/ │ ├── assets/ │ └── fonts/ │ ├── Roboto-Black.ttf │ ├── Roboto-BlackItalic.ttf │ ├── Roboto-Bold.ttf │ ├── Roboto-BoldItalic.ttf │ ├── Roboto-Italic.ttf │ ├── Roboto-Light.ttf │ ├── Roboto-LightItalic.ttf │ ├── Roboto-Medium.ttf │ ├── Roboto-MediumItalic.ttf │ ├── Roboto-Regular.ttf │ ├── Roboto-Thin.ttf │ └── Roboto-ThinItalic.ttf │ ├── lib/ │ └── main.dart Step 3: Add Font Files to pubspec.yaml File Now, you need to add font files to the pubspec.yaml file. Go to your pubspec.yaml file and add the following code in it:\nflutter: fonts: - family: Roboto fonts: - asset: assets/fonts/Roboto-Black.ttf - asset: assets/fonts/Roboto-BlackItalic.ttf style: italic - asset: assets/fonts/Roboto-Bold.ttf - asset: assets/fonts/Roboto-BoldItalic.ttf style: italic - asset: assets/fonts/Roboto-Italic.ttf style: italic - asset: assets/fonts/Roboto-Light.ttf - asset: assets/fonts/Roboto-LightItalic.ttf style: italic - asset: assets/fonts/Roboto-Medium.ttf - asset: assets/fonts/Roboto-MediumItalic.ttf style: italic - asset: assets/fonts/Roboto-Regular.ttf - asset: assets/fonts/Roboto-Thin.ttf - asset: assets/fonts/Roboto-ThinItalic.ttf style: italic Step 4: Use the Fonts To use the fonts, you need to use the TextStyle widget. Here is how you can use the fonts:\nText( 'I am using local font', style: TextStyle( fontFamily: 'Roboto', fontSize: 20, fontWeight: FontWeight.w900, ), ) Supporting Source Code If you face any issue while using the fonts, then you can check this link for the complete source code.\nChallenge Create profile app with your photo, name, address, and phone number. Use local fonts to style the text.\n",
    "description": "In this section, you will learn how to use local fonts in your flutter application with the help of real-world example.",
    "tags": null,
    "title": "Use Local Fonts in Flutter",
    "uri": "/working-with-assets/use-local-fonts-in-flutter/"
  },
  {
    "content": "Container In Flutter Container is a box like widget that can be shaped, colored, and sized according to your needs. In this section, you will learn how to use container widget, style it, add border, padding, margin, and background color.\nKey Features of a Container Size: You can specify its height and width. Color and Decoration: You can paint it with a color or add more complex decorations like borders, rounded corners, or shadows. Alignment: It lets you align its child (what you put inside the container) to center, left, right, etc. Padding and Margin: Think of padding as the space inside the box between its edges and the content. Margin is the space outside the box, between the box and other elements. Example 1: Display Container In Flutter In this example, you will learn how to display container in flutter. In the child there is Text widget.\nContainer( child: Text('Raj Sharma'), ) Run Online Example 2: Style Container In Flutter In this example, you will learn to style container by adding padding and color to it.\nContainer( child: Text('Raj Sharma'), color: Colors.blue, padding: EdgeInsets.all(20), ) Run Online Info Note: You can use Container widget to add padding, margin, border, background color, etc. to other widgets.\nExample 3: Add Border To Container In this example, you will learn how to add border to container. You will learn to add border using Container widget.\nContainer( child: Text('Raj Sharma'), padding: EdgeInsets.all(20), decoration: BoxDecoration( border: Border.all( color: Colors.black, width: 2, ), ), ) Run Online Example 4: Add Margin \u0026 Padding To Container In this example, you will learn how to add margin and padding to container.\nContainer( child: Text('Raj Sharma'), color: Colors.blue, padding: EdgeInsets.all(20), margin: EdgeInsets.all(20), ) Run Online Example 5: Add Background Color To Container In Flutter In this example, you will learn how to add background color to container.\nContainer( child: Text('Raj Sharma'), color: Colors.blue, padding: EdgeInsets.all(20), ) Run Online Example 6: Add Shadow To Container In Flutter In this example, you will learn to add shadow to container.\nContainer( child: Text('Raj Sharma'), padding: EdgeInsets.all(20), decoration: BoxDecoration( boxShadow: [ BoxShadow( color: Colors.grey, blurRadius: 10, offset: Offset(4, 4), ), ], ), ) Run Online Example 7: Add Rounded Corners To Container In this example, you will learn how to add rounded corners to container in flutter.\nContainer( child: Text('Raj Sharma'), padding: EdgeInsets.all(20), decoration: BoxDecoration( color: Colors.blue, borderRadius: BorderRadius.circular(10), ), ) Run Online Example 8: Add Gradient To Container In this example, you will learn to add gradient to container.\nContainer( child: Text('Raj Sharma'), padding: EdgeInsets.all(20), decoration: BoxDecoration( gradient: LinearGradient( colors: [ Colors.blue, Colors.green, ], ), ), ) Run Online Example 9: Add Image To Container In Flutter In this example, you will learn to add image from internet using container in flutter.\nContainer( child: Image.network( 'https://avatars.githubusercontent.com/u/33576285?v=4', ), ) Run Online Example 10: Create Square Blue Box In this example, you will learn to create a square blue box with the text “Hello World” in the center.\nContainer( height: 100.0, // Height of the container width: 100.0, // Width of the container color: Colors.blue, // Background color alignment: Alignment.center, // Align the child to the center child: Text('Hello World'), // Child widget padding: EdgeInsets.all(10.0), // Padding inside the container margin: EdgeInsets.all(20.0), // Margin outside the container ) Run Online ",
    "description": "Learn how to use container widget in flutter with real-world examples. You will also learn how to style container, add border, add padding, add margin, and add background color.",
    "tags": null,
    "title": "Container In Flutter",
    "uri": "/introduction-and-basics/container-in-flutter/"
  },
  {
    "content": "Introduction The DateTime Picker is a widget that allows users to select a date, time, or both from a dialog. This is very useful for apps that require you to input dates or times, like scheduling events or setting reminders.\nExample 1: BirthDate Picker In this example, you will learn to create a date picker for selecting a birthdate.\nDateTime? selectedDate; Future\u003cvoid\u003e _selectDate(BuildContext context) async { final DateTime? picked = await showDatePicker( context: context, initialDate: DateTime.now(), firstDate: DateTime(1900), lastDate: DateTime.now(), ); if (picked != null \u0026\u0026 picked != selectedDate) setState(() { selectedDate = picked; }); } Run Online Example 2: Attendance Time Picker In this example, you will learn to create a time picker for selecting attendance time.\nTimeOfDay? selectedTime; Future\u003cvoid\u003e _selectTime(BuildContext context) async { final TimeOfDay? picked = await showTimePicker( context: context, initialTime: TimeOfDay.now(), ); if (picked != null \u0026\u0026 picked != selectedTime) setState(() { selectedTime = picked; }); } Run Online Example 3: Combined DateTime Picker In this example, you will learn to create a combined date and time picker.\nDateTime? selectedDateTime; Future\u003cvoid\u003e _selectDateTime(BuildContext context) async { final DateTime? picked = await showDatePicker( context: context, initialDate: DateTime.now(), firstDate: DateTime(1900), lastDate: DateTime.now(), ); if (picked != null) { final TimeOfDay? pickedTime = await showTimePicker( context: context, initialTime: TimeOfDay.now(), ); if (pickedTime != null) { setState(() { selectedDateTime = DateTime( picked.year, picked.month, picked.day, pickedTime.hour, pickedTime.minute, ); }); } } } Run Online Challenge Create application that find age from the selected birthdate and display it in the app.\n",
    "description": "This guide covers the implementation of date and time pickers in Flutter, providing examples for basic usage, customizing date and time formats, integrating both pickers in a single interface, and styling the picker dialogs. Discover how to add intuitive date and time selection to your Flutter applications.",
    "tags": null,
    "title": "DateTime Picker in Flutter",
    "uri": "/forms-in-flutter/date-time-picker-in-flutter/"
  },
  {
    "content": "Introduction Deleting data from a REST API is a critical function in many applications, allowing users to remove information from external data sources. This tutorial explains how to implement DELETE requests in Flutter using the http package.\nSetup Ensure you have the http package in your pubspec.yaml file to make HTTP requests:\ndependencies: flutter: sdk: flutter http: ^1.2.1 Example: Deleting a Post This example demonstrates how to delete a post from a JSON placeholder API. We’ll send a DELETE request and handle the response.\nimport 'package:flutter/material.dart'; import 'package:http/http.dart' as http; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: DeletePostExample(), ); } } class DeletePostExample extends StatefulWidget { @override _DeletePostExampleState createState() =\u003e _DeletePostExampleState(); } class _DeletePostExampleState extends State\u003cDeletePostExample\u003e { Future\u003cvoid\u003e deletePost(int postId) async { final response = await http.delete(Uri.parse('https://jsonplaceholder.typicode.com/posts/$postId')); if (response.statusCode == 200) { // If the server returns a 200 OK response, post is successfully deleted. showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: Text(\"Success\"), content: Text(\"Post has been deleted successfully.\"), actions: [ MaterialButton( child: Text(\"OK\"), onPressed: () { Navigator.of(context).pop(); }, ), ], ); }, ); } else { // If the server did not return a 200 OK response, // throw an exception. throw Exception('Failed to delete post'); } } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Delete Data Example'), ), body: Center( child: ElevatedButton( onPressed: () =\u003e deletePost(1), // Assuming you want to delete the post with ID 1 child: const Text('Delete Post'), ), ), ); } } Run Online ",
    "description": "Learn how to delete data from a REST API in Flutter. This guide covers the steps to send DELETE requests to a RESTful service, handle responses, and update your app's UI accordingly. Understand the nuances of working with REST APIs for deleting data in your Flutter applications.",
    "tags": null,
    "title": "Delete Data from REST API",
    "uri": "/working-with-api/delete-data-from-rest-api-in-flutter/"
  },
  {
    "content": "Introduction You already learned how to create drawer in flutter. In this section, you will learn how to implement drawer navigation in flutter.\nExample 1: Simple Drawer Navigation In this example below, there are three screens: HomePage, ContactPage, and AboutPage. We’ll add a drawer to navigate between these screens.\nStep 1: Create Contact Page \u0026 About Page First define ContactPage and AboutPage.\n// Contact Page class ContactPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Contact Page')), body: Center(child: Text('Contact Page')), ); } } // About Page class AboutPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('About Page')), body: Center(child: Text('About Page')), ); } } Step 2: Define Home Page with Drawer Now in home page, add a drawer to navigate between these screens.\nDrawer( child: ListView( padding: EdgeInsets.zero, children: [ DrawerHeader( child: Text('My App'), decoration: BoxDecoration( color: Colors.blue, ), ), ListTile( title: Text('Home'), onTap: () { Navigator.pop(context); }, ), ListTile( title: Text('Contact'), onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) =\u003e ContactPage())); }, ), ListTile( title: Text('About'), onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) =\u003e AboutPage())); }, ), ], ), ), Run Online Challenge Click on Try Online and create new screen called SettingsPage. Add a new item to the drawer to navigate to the SettingsPage.\nTry Online ",
    "description": "A comprehensive guide on implementing drawer navigation in Flutter applications. This tutorial covers the basics of adding a navigation drawer to switch between different screens such as Home, Contact, and About pages. Ideal for developers looking to enhance their app's navigational structure.",
    "tags": null,
    "title": "Drawer Navigation in Flutter",
    "uri": "/navigation-in-flutter/drawer-navigation-in-flutter/"
  },
  {
    "content": "Flutter Buttons This section will help you to learn different types of buttons in flutter. Here you will learn the following topics:\nForm in Flutter, TextFormField in Flutter, Checkbox in Flutter, Radio Button in Flutter, Switch in Flutter, Date and Time Picker in Flutter, and Form Validation in Flutter. Practice Questions Complete this section \u0026 practice this question to improve and test your flutter skill.\n",
    "description": "Learn about flutter forms with examples. You will learn how to create a form, text field, text form field, dropdown form field, date picker, and time picker in flutter.",
    "tags": null,
    "title": "Flutter Forms",
    "uri": "/forms-in-flutter/"
  },
  {
    "content": "Introduction OutlinedButton is a type of button in Flutter that displays a border around the button’s child. This guide will help you understand the OutlinedButton widget with the help of real-world examples.\nExample 1: Simple OutlinedButton In this example below, you will learn to create a simple button with text.\nOutlinedButton( onPressed: () {}, child: Text('Press Me'), ) Run Online Example 2: OutlinedButton With Icon In this example below, you will learn to create a button with an icon.\nOutlinedButton.icon( onPressed: () {}, icon: Icon(Icons.add), label: Text('Add Item'), ) Run Online Example 3: Custom Border and TextStyle In this example below, you will learn to create a button with custom border and text styles.\nOutlinedButton( onPressed: () {}, style: OutlinedButton.styleFrom( side: BorderSide(color: Colors.green, width: 2), textStyle: TextStyle(color: Colors.green, fontSize: 20), ), child: Text('Custom Style'), ) Run Online Example 4: Rounded Corners OutlinedButton In this example below, you will learn to create a button with rounded corners.\nOutlinedButton( onPressed: () {}, style: OutlinedButton.styleFrom( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(18.0), ), ), child: Text('Rounded Corners'), ) Run Online Example 5: Disabled OutlinedButton In this example below, you will learn to create a disabled button using the OutlinedButton widget.\nOutlinedButton( onPressed: null, child: Text('Disabled Button'), ) Run Online Challenge Create an OutlinedButton that changes the border color from blue to green when pressed.\n",
    "description": "This guide explores the OutlinedButton widget in Flutter, presenting examples of default outlined buttons, outlined buttons with icons, custom border and text styles, buttons with rounded corners, and disabled outlined buttons. Master the use of OutlinedButton to create boundary-defined buttons that enhance your Flutter UI.",
    "tags": null,
    "title": "Outlined Button in Flutter",
    "uri": "/buttons-in-flutter/outlined-button-in-flutter/"
  },
  {
    "content": "List and Grid Flutter Practice Questions Create a Flutter application that displays a list of 10 images of puppies in a ListView. Create a Todo List application that displays a list of todos in a ListView. Create a Flutter application that shows a Chessboard using GridView. Create a simple ListView in Flutter that displays a list of ten strings. Each item in the list should be displayed as a text widget. Display a list of numbers from 1 to 50. Each number should be shown in a separate list item. Create a ListView.builder that displays a list of names. If a name starts with the letter ‘A’, it should be displayed with a green color; otherwise, it should be displayed in red. Create a horizontal ListView that displays a list of images. Ensure that the ListView scrolls horizontally. Implement a ListView inside another ListView. The outer ListView should have three items, and each item should contain an inner ListView with five text items. Implement a GridView with a two-column layout. Populate it with 20 square containers, each with a unique color or decoration. Use GridView.builder to create a grid of items where each item has a different aspect ratio. For example, alternate between items with a 1:1 and 2:1 aspect ratio Create a GridView where the number of columns changes based on the device orientation (portrait or landscape). Implement an infinite scrolling ListView using ListView.builder, where more items are loaded when the user scrolls to the end of the list. Create a GridView.builder that displays a grid of items. When an item is tapped, it should display an alert dialog with the item’s index or other details. ",
    "description": "Practice questions related to list and grid in flutter. Solve these questions and makes yourself comfortable in flutter.",
    "tags": [
      "Practice"
    ],
    "title": "Questions for Practice 2",
    "uri": "/list-and-grid/questions-for-practice-2/"
  },
  {
    "content": "Using Google Fonts in Flutter App In this section, you will learn how to use Google fonts in your flutter application with the help of examples.\nUse Google Fonts in Flutter To use Google fonts in your flutter application, follow the below steps:\nAdd google_fonts package in your flutter project. Use google fonts in your flutter application. Add google_fonts Package To use Google fonts in your application, you need to add the google_fonts plugin. Open terminal at your project folder and execute the following command:\nflutter pub add google_fonts Run Pub Get After saving the pubspec.yaml file, run pub get in your terminal to fetch the package:\nflutter pub get Import the google_fonts Package Now, you need to import the google_fonts package in your flutter application. To import the google_fonts package, open your main.dart file and add the following import statement:\nimport 'package:google_fonts/google_fonts.dart'; Use the Google Fonts Now, you can use the Google fonts in your flutter application. To use the Google fonts, open your main.dart file and add the following code in it:\nText( 'Hello I am John Doe', style: GoogleFonts.roboto( fontSize: 20, fontWeight: FontWeight.w500, color: Colors.blue, ), ) Specifying Font Weights and Styles If you want to use specific font weights or styles that are not the default, you can specify them when you use the font.\nstyle: GoogleFonts.roboto( fontWeight: FontWeight.w700, // Bold fontStyle: FontStyle.italic, // Italic ), Full Example To use the Google fonts in your flutter application, open your main.dart file and add the following code in it:\nimport 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Use Google Fonts in Flutter', home: Scaffold( appBar: AppBar( title: Text('Google Fonts in Flutter'), ), body: Center( child: Text( 'Hello I am John Doe', style: GoogleFonts.roboto( fontSize: 20, fontWeight: FontWeight.w500, color: Colors.blue, ), ), ), )); } } ",
    "description": "In this section, you will learn how to use Google fonts in your flutter application with the help of examples.",
    "tags": null,
    "title": "Use Google Fonts in Flutter",
    "uri": "/working-with-assets/use-google-fonts-in-flutter/"
  },
  {
    "content": "Flutter Navigation In this section, you will learn how to navigate between screens in flutter.\nThis will include following topics:\nNavigation in Flutter Move to Another Screen, Move Using Named Routes, Pass Data to Another Screen, Return Data from Another Screen, Drawer Navigation, Drawer Navigation, Navigation Methods, and TabBar Navigation. Practice Questions Complete this section \u0026 practice this question to improve and test your flutter skill.\n",
    "description": "Learn how to navigate between screens in flutter. You will learn how to use navigation drawer, navigation bar, and navigation bar with tabs in flutter.",
    "tags": null,
    "title": "Flutter Navigation",
    "uri": "/navigation-in-flutter/"
  },
  {
    "content": "Introduction In this section, you will learn to build a simple quiz app in Flutter using API.\nSetup Ensure your pubspec.yaml includes dependencies for Flutter and the http package for API requests:\ndependencies: flutter: sdk: flutter http: ^1.2.1 Main Screen The main screen displays a play button that navigates to the quiz player screen.\nimport 'package:flutter/material.dart'; void main() =\u003e runApp(const QuizApp()); class QuizApp extends StatelessWidget { const QuizApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( home: MainScreen(), ); } } class MainScreen extends StatelessWidget { const MainScreen({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('Trivia Quiz')), body: Center( child: ElevatedButton( child: const Text('Play'), onPressed: () { Navigator.push( context, MaterialPageRoute(builder: (context) =\u003e const PlayerScreen()), ); }, ), ), ); } } Player Screen The player screen fetches and displays a question, presenting multiple choice answers.\nclass PlayerScreen extends StatefulWidget { const PlayerScreen({super.key}); @override _PlayerScreenState createState() =\u003e _PlayerScreenState(); } class _PlayerScreenState extends State\u003cPlayerScreen\u003e { int currentQuestionIndex = 0; int score = 0; List\u003cQuestion\u003e questions = []; Future\u003cvoid\u003e fetchQuestions() async { final response = await http.get(Uri.parse('https://opentdb.com/api.php?amount=2\u0026category=18\u0026difficulty=easy\u0026type=multiple')); if (response.statusCode == 200) { final data = json.decode(response.body); setState(() { questions = List\u003cQuestion\u003e.from(data['results'].map((question) =\u003e Question.fromJson(question))); }); } else { throw Exception('Failed to load questions'); } } @override void initState() { super.initState(); fetchQuestions(); } void checkAnswer(String selectedAnswer) { if (questions[currentQuestionIndex].correctAnswer == selectedAnswer) { score++; } if (currentQuestionIndex \u003c questions.length - 1) { setState(() { currentQuestionIndex++; }); } else { Navigator.push(context, MaterialPageRoute(builder: (context) =\u003e ScoreScreen(score: score))); } } @override Widget build(BuildContext context) { if (questions.isEmpty) { return Scaffold( appBar: AppBar(title: const Text('Question')), body: const Center(child: CircularProgressIndicator()), ); } final question = questions[currentQuestionIndex]; return Scaffold( appBar: AppBar(title: const Text('Question')), body: ListView( children: \u003cWidget\u003e[ ListTile(title: Text(question.question)), ...question.answers.map((answer) =\u003e ListTile( title: Text(answer), onTap: () =\u003e checkAnswer(answer), )).toList(), ], ), ); } } Question Model Create a model to represent a question and its answers.\nclass Question { final String question; final List\u003cString\u003e answers; final String correctAnswer; Question({required this.question, required this.answers, required this.correctAnswer}); factory Question.fromJson(Map\u003cString, dynamic\u003e json) { var incorrectAnswers = List\u003cString\u003e.from(json['incorrect_answers']); var correctAnswer = json['correct_answer']; incorrectAnswers.add(correctAnswer); incorrectAnswers.shuffle(); return Question( question: json['question'], answers: incorrectAnswers, correctAnswer: correctAnswer, ); } } Score Screen After answering questions, navigate to the results screen to display the score.\nimport 'package:flutter/material.dart'; class ScoreScreen extends StatelessWidget { final int score; ScoreScreen({super.key, required this.score}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('Score')), body: Center( child: Text('Your score is: $score', style: const TextStyle(fontSize: 24)), ), ); } } Run Online ",
    "description": "Build a Flutter quiz app using the Trivia API. This tutorial covers creating a three-screen app: a main screen with a play button, a quiz player screen, and a results screen. Learn how to fetch questions from the Trivia API and integrate them into your app.",
    "tags": null,
    "title": "Flutter Quiz App with REST API",
    "uri": "/working-with-api/flutter-quiz-app-with-rest-api/"
  },
  {
    "content": "Form Validation in Flutter If you are building a form in your Flutter application, it is essential to validate the user input data to ensure data integrity. In this section, you will learn how to validate user input data using the TextFormField widget in Flutter.\nWhy Form Validation is Important? Data Integrity: It ensures that the data entered by the user is accurate and consistent. User Experience: It provides a better user experience by guiding the user to enter valid data. Error Prevention: It helps in preventing errors and exceptions caused by invalid data. Example 1: Feedback Form with Validation In this example, you will learn to create a feedback form with a validation rule ensuring a minimum character count. If you have any problem try Run Online button to see the code in action.\n// Create a GlobalKey for the form final _formKey = GlobalKey\u003cFormState\u003e(); // Create a TextEditingController for the feedback field final _feedbackController = TextEditingController(); Form( key: _formKey, child: Column( mainAxisSize: MainAxisSize.min, children: [ TextFormField( maxLines: 5, controller: _feedbackController, decoration: const InputDecoration( hintText: 'Enter your feedback', border: OutlineInputBorder(), ), validator: (value) { if (value == null || value.isEmpty) { return 'Please enter your feedback'; } else if (value.length \u003c 10) { return 'Feedback must be at least 10 characters'; } return null; }, ), const SizedBox(height: 20), ElevatedButton( onPressed: () { if (_formKey.currentState!.validate()) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('Feedback submitted successfully!')), ); // Additional submission logic here } }, child: const Text('Submit'), ), ], ), ) Run Online Example 2: Sign-Up Form with Validation In this example, you will learn to create a sign-up form with validation to ensure users provide a valid email address and a secure password. If you have any problem try Run Online button to see the code in action.\n// Create a GlobalKey for the form final _formKey = GlobalKey\u003cFormState\u003e(); // Create TextEditingController for email and password fields final _emailController = TextEditingController(); final _passwordController = TextEditingController(); Form( key: _formKey, child: Column( mainAxisSize: MainAxisSize.min, children: [ TextFormField( controller: _emailController, decoration: const InputDecoration( labelText: 'Email', hintText: 'Enter your email', border: OutlineInputBorder(), ), validator: (value) { if (value == null || value.isEmpty) { return 'Please enter your email'; } else if (!value.contains('@')) { return 'Please enter a valid email'; } return null; }, ), const SizedBox(height: 10), TextFormField( controller: _passwordController, decoration: const InputDecoration( labelText: 'Password', hintText: 'Enter your password', border: OutlineInputBorder(), ), obscureText: true, validator: (value) { if (value == null || value.isEmpty) { return 'Please enter your password'; } else if (value.length \u003c 6) { return 'Password must be at least 6 characters'; } return null; }, ), const SizedBox(height: 20), ElevatedButton( onPressed: () { if (_formKey.currentState!.validate()) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('Sign-up successful!')), ); // Additional submission logic here } }, child: const Text('Sign Up'), ), ], ), ) Run Online Challenge Create a contact form with fields name, phone number, and email and validate according to the following rules:\nName: Required Phone Number: Required, must be 10 digits Email: Required, must be a valid email address ",
    "description": "This guide covers form validation in Flutter, focusing on the TextFormField widget. Learn how to ensure data integrity in your forms through examples of basic usage, validation techniques, password fields, styled form fields, fields with prefix and suffix icons, and more. Perfect for developers looking to enhance user experience in their Flutter applications.",
    "tags": null,
    "title": "Form Validation in Flutter",
    "uri": "/forms-in-flutter/form-validation-in-flutter/"
  },
  {
    "content": "Introduction In this section, you will learn about useful navigation methods in Flutter. Here are some useful navigation methods:\nNavigator.push() Navigator.push() is used to navigate to a new screen by pushing it onto the navigation stack.\nExample 1: Using Navigator.push() In this example below, you will learn how to navigate to a new screen using Navigator.push().\n// Navigator.push example Navigator.push( context, MaterialPageRoute(builder: (context) =\u003e AboutScreen()), ); Run Online Navigator.pushNamed() Navigator.pushNamed() is used to navigate to a new screen using a named route. Named routes are routes that are named using a string.\nExample 2: Using Navigator.pushNamed() In this example below, you will learn how to navigate to a new screen using Navigator.pushNamed().\nNavigator.pushNamed(context, '/about'); Run Online Navigator.pop() Navigator.pop() is used to return to the previous screen, effectively popping the current screen off the navigation stack. It’s akin to the back button on a device.\nExample 3: Using Navigator.pop() Navigator.pop(context); Run Online Navigator.pushReplacement() This method replaces the current screen with a new one on the navigation stack, which is useful in scenarios like a login flow where you do not want the user to return to the login screen.\nExample 4: Using Navigator.pushReplacement() Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) =\u003e HomeScreen()), ); Run Online Navigator.pushAndRemoveUntil() Navigator.pushAndRemoveUntil() pushes a new screen and removes all the previous screens until a certain condition is met. This method is handy for logging out a user, where you want to remove all screens from the stack and navigate back to the login screen.\nExample 5: Using Navigator.pushAndRemoveUntil() Navigator.pushAndRemoveUntil( context, MaterialPageRoute(builder: (context) =\u003e WelcomeScreen()), (Route\u003cdynamic\u003e route) =\u003e false, ); Run Online ",
    "description": "In this section, you will learn about useful navigation methods in Flutter. These methods are essential for navigating between screens, implementing back navigation, and managing the navigation stack.",
    "tags": null,
    "title": "Navigation Methods in Flutter",
    "uri": "/navigation-in-flutter/navigation-methods-in-flutter/"
  },
  {
    "content": "Row Widget In Flutter In Flutter, Row widget displays its children horizontally. It is very useful when placing UI side by side. This is one of the most used widget in flutter.\nExample 1: Row In Flutter In this example, the Row contains three children widgets which are Icon, Text, and Icon.\nimport 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('My First App'), ), body: const Row( children: [ Icon(Icons.star, size: 50), Text('I am learning flutter'), Icon(Icons.star, size: 50), ], ), ), ), ); } Run Online Example 2: Create Rating Bar Using Flutter In this example, you will learn to build star rating bar using row widget.\nimport 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Row In Flutter'), ), body: const Row( children: [ Icon(Icons.star, color: Colors.yellow), Icon(Icons.star, color: Colors.yellow), Icon(Icons.star, color: Colors.yellow), Icon(Icons.star, color: Colors.yellow), Icon(Icons.star_border, color: Colors.yellow), ], ), ), ), ); } Run Online Row Properties These are the most common useful properties of the Row widget which helps you control the layout of its children:\nProperty Description mainAxisAlignment Determines how the children are aligned horizontally. crossAxisAlignment Determines how the children are aligned vertically. children The widgets that are displayed inside the row. Main Axis In Row In Row, main axis determines how the children are aligned horizontally. The mainAxisAlignment property accepts the following values:\nMainAxisAlignment Values Description MainAxisAlignment.start Children are aligned at the start of the horizontal axis. MainAxisAlignment.end Children are aligned at the end of the horizontal axis. MainAxisAlignment.center Children are centered along the horizontal axis. MainAxisAlignment.spaceBetween Children have equal spacing between them. MainAxisAlignment.spaceAround Children have equal spacing between them, and also the space at the start and the end is divided evenly. MainAxisAlignment.spaceEvenly Children have equal spacing before, between, and after them. Example 3: Main Axis Alignment In this example, you see 5 stars which are in center horizontally. Run this code online and try changing center to start, end, spaceBetween, spaceAround or spaceEvenly.\nimport 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Row In Flutter'), ), body: const Row( // Try replacing \"center\" with \"start\", \"end\", \"spaceBetween\", \"spaceAround\" or \"spaceEvenly\" mainAxisAlignment: MainAxisAlignment.center, children: [ Icon(Icons.star, color: Colors.yellow), Icon(Icons.star, color: Colors.yellow), Icon(Icons.star, color: Colors.yellow), Icon(Icons.star, color: Colors.yellow), Icon(Icons.star_border, color: Colors.yellow), ], ), ), ), ); } Run Online Info Note: By default mainAxisAlignment value is mainAxisAlignment.start\nCross Axis In Row In Row, cross axis determines how the children are aligned vertically. The crossAxisAlignment property accepts the following values:\nCrossAxisAlignment Values Description CrossAxisAlignment.start Children are aligned at the top of the Row. CrossAxisAlignment.end Children are aligned at the bottom of the Row. CrossAxisAlignment.center Children are vertically centered in the Row. CrossAxisAlignment.stretch Children are forced to fill the available space vertically. CrossAxisAlignment.baseline Children are aligned by their baseline (useful for text). Example 4: Cross Axis Alignment In this example, you see 5 stars which are in center vertically. Run this code online and try changing center to start, end, stretch, baseline.\nimport 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Row In Flutter'), ), body: Container( color: Colors.green, height: double.infinity, child: const Row( // Try replacing \"center\" with \"start\", \"end\", \"stretch\" or \"baseline\" crossAxisAlignment: CrossAxisAlignment.center, children: [ Icon(Icons.star, color: Colors.yellow), Icon(Icons.star, color: Colors.yellow), Icon(Icons.star, color: Colors.yellow), Icon(Icons.star, color: Colors.yellow), Icon(Icons.star_border, color: Colors.yellow), ], ), ), ), ), ); } Run Online Info Note: By default crossAxisAlignment value is crossAxisAlignment.center\nExample 5: Using Main Axis \u0026 Cross Axis Alignment In this example, you see 5 stats which are in center horizontally and vertically. Run this code online and try changing its main axis and cross axis alignement.\nimport 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Row In Flutter'), ), body: Container( color: Colors.green, height: double.infinity, child: const Row( // Try replacing \"center\" with \"start\", \"end\", \"spaceAround\" or \"spaceEvenly\" mainAxisAlignment: MainAxisAlignment.center, // Try replacing \"center\" with \"start\", \"end\", \"stretch\" or \"baseline\" crossAxisAlignment: CrossAxisAlignment.center, children: [ Icon(Icons.star, color: Colors.yellow), Icon(Icons.star, color: Colors.yellow), Icon(Icons.star, color: Colors.yellow), Icon(Icons.star, color: Colors.yellow), Icon(Icons.star_border, color: Colors.yellow), ], ), ), ), ), ); } Run Online Overflow Issue When you put too many widgets inside a Row and they can’t fit within the screen, you’ll get an overflow error. Here are simple ways to handle this overflow issue in Flutter:\nWrap in SingleChildScrollView widget Use Expanded or Flexible widget Example 6: Wrap In SingleChildScrollView When you have many children widgets, and they can’t all fit on the screen, you might want to scroll to see the ones that are out of view. For more see the example below:\nimport 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Row In Flutter'), ), body: Container( color: Colors.green, height: double.infinity, child: SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( // Try replacing \"center\" with \"start\", \"end\", \"spaceAround\", \"spaceEvenly\" or \"spaceBetween\" mainAxisAlignment: MainAxisAlignment.center, // Try replacing \"center\" with \"start\", \"end\", \"stretch\" or \"baseline\" crossAxisAlignment: CrossAxisAlignment.center, children: List.generate( 50, (index) =\u003e const Icon(Icons.star, color: Colors.yellow)), ), ), ), ), ), ); } Run Online Example 7: Using Expanded In a Row, use Expanded to make a widget take up all the available remaining space within its parent widget. For more, see the example below:\nimport 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Row In Flutter'), ), body: Container( color: Colors.green, height: double.infinity, child: Row( // Try replacing \"center\" with \"start\", \"end\", \"spaceAround\", \"spaceEvenly\" or \"spaceBetween\" mainAxisAlignment: MainAxisAlignment.center, // Try replacing \"center\" with \"start\", \"end\", \"stretch\" or \"baseline\" crossAxisAlignment: CrossAxisAlignment.center, children: List.generate( 50, (index) =\u003e const Expanded( child: Icon(Icons.star, color: Colors.yellow))), ), ), ), ), ); } Run Online Example 8: Using Flexible Flexible allows a widget within a Row to fit its content but won’t exceed its maximum size, even if there’s extra space available. For more, see the example below:\nimport 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Row In Flutter'), ), body: Container( color: Colors.green, height: double.infinity, child: Row( // Try replacing \"center\" with \"start\", \"end\", \"spaceAround\", \"spaceEvenly\" or \"spaceBetween\" mainAxisAlignment: MainAxisAlignment.center, // Try replacing \"center\" with \"start\", \"end\", \"stretch\" or \"baseline\" crossAxisAlignment: CrossAxisAlignment.center, children: List.generate( 50, (index) =\u003e const Flexible( fit: FlexFit.loose, child: Icon(Icons.star, color: Colors.yellow))), ), ), ), ), ); } Run Online Info Note: Expanded forces its child to fill available space, while Flexible allows its child to occupy space without necessarily filling it.\n",
    "description": "Learn about flutter row widget. You will learn what is row widget in flutter, how to use row widget in flutter, and how to create a row widget in flutter.",
    "tags": null,
    "title": "Row in Flutter",
    "uri": "/introduction-and-basics/row-in-flutter/"
  },
  {
    "content": "Introduction TextButton is a simple button that contains a text label and perform an action when pressed. This guide will help you understand the TextButton with the help of real-world examples.\nExample 1: Default TextButton In this example below, you will learn to create a simple TextButton with text label.\nTextButton( onPressed: () {}, child: Text('Press Me'), ) Run Online Example 2: TextButton with Icon In this example below, you will learn to create a TextButton with an icon and text label.\nTextButton.icon( onPressed: () {}, icon: Icon(Icons.info), label: Text('More Info'), ) Run Online Example 3: Custom Color and TextStyle In this example below, you will learn to create a TextButton with custom text color and style.\nTextButton( onPressed: () {}, style: TextButton.styleFrom( foregroundColor: Colors.black, backgroundColor: Colors.yellow, ), child: Text('Custom Style'), ) Run Online Example 4: TextButton with Underline In this example below, you will learn to create a TextButton with underlined text.\nTextButton( onPressed: () {}, style: TextButton.styleFrom( textStyle: TextStyle(decoration: TextDecoration.underline), ), child: Text('Underlined Text'), ) Run Online Example 5: Disabled TextButton In this example below, you will learn to create a disabled TextButton.\nTextButton( onPressed: null, child: Text('Disabled Button'), ) Run Online Challenge Design a TextButton that toggles its text color between two colors upon each press, illustrating a simple state change.\n",
    "description": "Uncover the capabilities of the TextButton widget in Flutter, showcasing examples of default text buttons, text buttons with icons, custom color and text styles, buttons with underlines, and disabled text buttons. Learn to effectively utilize TextButton to create text-based UI elements that are both functional and stylish.",
    "tags": null,
    "title": "Text Button in Flutter",
    "uri": "/buttons-in-flutter/text-button-in-flutter/"
  },
  {
    "content": "Introduction In this section, you will learn how to use local JSON in your flutter application with the help of real-world example. Before we start, make sure you have basic knowledge of JSON. If you don’t know start from here.\nExample 1: Profile App In this example, you will learn to create a profile app using local JSON. Here are the steps to create a app:\nStep 1: Add the JSON File To use local JSON in your app, the first step is to add the JSON file in your project folder/assets/data. You can download sample JSON file from here or you can use your own JSON file.\nStep 2: Add JSON File to Your Project In project folder, create a new folder called assets and inside assets folder, create another folder called data. Now, place the JSON file inside the data folder. Here is preview of the folder structure:\njson_in_flutter/ │ ├── assets/ │ └── data/ │ └── info.json │ ├── lib/ │ └── main.dart Step 3: Add JSON File to pubspec.yaml File Now, you need to add JSON file to the pubspec.yaml file. Go to your pubspec.yaml file and add the following code in it:\nflutter: assets: - assets/data/info.json Step 4: Create Model Class Now, you need to create a model class for the JSON data. Create a new file called person.dart inside lib folder and add the following code in it:\nclass Person { final String name; final String address; final int age; final String image; final String description; // Constructor Person( {required this.name, required this.address, required this.age, required this.image, required this.description}); // Convert JSON to Person Object factory Person.fromJson(Map\u003cString, dynamic\u003e json) { return Person( name: json['name'], address: json['address'], age: json['age'], image: json['image'], description: json['description'], ); } } Step 5: Load and Decode the JSON File Now create a new file called localservice.dart inside lib folder and add the following code in it:\nimport 'dart:convert'; import 'package:flutter/services.dart'; import 'person.dart'; class LocalService { // Load and decode the JSON File Future\u003cString\u003e _loadPersonAsset() async { return await rootBundle.loadString('assets/data/info.json'); } // Load and decode the JSON File Future\u003cPerson\u003e loadPerson() async { String jsonString = await _loadPersonAsset(); // json.decode() is used to convert JSON String to JSON Map final jsonResponse = json.decode(jsonString); return Person.fromJson(jsonResponse); } } Step 6: Display the JSON Data Now, you can use the LocalService class to display the JSON data. Here is how you can use it on your main.dart file:\nimport 'package:flutter/material.dart'; import 'localservice.dart'; import 'person.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { const appTitle = 'JSON in Flutter'; return MaterialApp( title: appTitle, home: Scaffold( appBar: AppBar( title: const Text(appTitle), ), body: FutureBuilder( future: LocalService().loadPerson(), builder: (context, snapshot) { if (snapshot.hasData) { Person person = snapshot.data as Person; return Center( child: Padding( padding: const EdgeInsets.all(16.0), child: Card( elevation: 4.0, child: Padding( padding: const EdgeInsets.all(16.0), child: Column( mainAxisSize: MainAxisSize.min, children: [ CircleAvatar( backgroundImage: NetworkImage(person.image), radius: 50.0, ), const SizedBox(height: 10), Text( person.name, style: const TextStyle( fontSize: 24, fontWeight: FontWeight.bold, ), ), const SizedBox(height: 5), Text( person.address, style: TextStyle( fontSize: 16, color: Colors.grey[600], ), ), const SizedBox(height: 5), Text( 'Age: ${person.age}', style: TextStyle( fontSize: 16, color: Colors.grey[800], ), ), const SizedBox(height: 10), Text( person.description, textAlign: TextAlign.center, style: const TextStyle( fontSize: 16, fontStyle: FontStyle.italic, ), ), ], ), ), ), ), ); } else { return const Center(child: CircularProgressIndicator()); } }, ), ), ); } } Supporting Source Code If you face any issue while using the fonts, then you can check this link for the complete source code.\nChallenge Create quote app using local JSON. Use this JSON file to display the quotes.\n",
    "description": "In this section, you will learn to use local JSON in your flutter application with the help of real-world example.",
    "tags": null,
    "title": "Use Local JSON in Flutter",
    "uri": "/working-with-assets/use-local-json-in-flutter/"
  },
  {
    "content": "Introduction In this section, you will learn how to use online JSON in your flutter application with the help of real-world example. Before we start, make sure you have basic knowledge of JSON. If you don’t know start from here.\nExample 1: Profile App In this example, you will learn to create a profile app using online JSON. Here are the steps to create a app:\nStep 1: Install http Package To use online JSON in your app, the first step is to add the http package in your project. Open terminal at your project folder and execute the following command:\nflutter pub add http Step 2: Import the http Package Now, you need to import the http package in your flutter application. To import the http package, open your main.dart file and add the following import statement:\nimport 'package:http/http.dart' as http; Step 3: Create Model Class Now, you need to create a model class for the JSON data. Create a new file called person.dart inside lib folder and add the following code in it:\nclass Person { final String name; final String address; final int age; final String image; final String description; // Constructor Person( {required this.name, required this.address, required this.age, required this.image, required this.description}); // Convert JSON to Person Object factory Person.fromJson(Map\u003cString, dynamic\u003e json) { return Person( name: json['name'], address: json['address'], age: json['age'], image: json['image'], description: json['description'], ); } } Step 4: Load and Decode the JSON File Now create a new file called onlineservice.dart inside lib folder and add the following code in it:\nimport 'dart:convert'; import 'person.dart'; class OnlineService { // Load and decode the JSON File Future\u003cPerson\u003e loadPerson() async { final response = await http.get(Uri.parse('https://jsonguide.technologychannel.org/info.json')); if (response.statusCode == 200) { // json.decode() is used to convert JSON String to JSON Map final jsonResponse = json.decode(response.body); return Person.fromJson(jsonResponse); } else { throw Exception('Failed to load data from server'); } } } Step 5: Display the JSON Data Now, you can use the OnlineService class to display the JSON data. Here is how you can use it on your main.dart file:\nimport 'package:flutter/material.dart'; import 'onlineservice.dart'; import 'person.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { const appTitle = 'JSON in Flutter'; return MaterialApp( title: appTitle, home: Scaffold( appBar: AppBar( title: const Text(appTitle), ), body: FutureBuilder( future: OnlineService().loadPerson(), builder: (context, snapshot) { if (snapshot.hasData) { Person person = snapshot.data as Person; return Center( child: Padding( padding: const EdgeInsets.all(16.0), child: Card( elevation: 4.0, child: Padding( padding: const EdgeInsets.all(16.0), child: Column( mainAxisSize: MainAxisSize.min, children: [ CircleAvatar( backgroundImage: NetworkImage(person.image), radius: 50.0, ), const SizedBox(height: 10), Text( person.name, style: const TextStyle( fontSize: 24, fontWeight: FontWeight.bold, ), ), const SizedBox(height: 5), Text( person.address, style: TextStyle( fontSize: 16, color: Colors.grey[600], ), ), const SizedBox(height: 5), Text( 'Age: ${person.age}', style: TextStyle( fontSize: 16, color: Colors.grey[800], ), ), const SizedBox(height: 10), Text( person.description, textAlign: TextAlign.center, style: const TextStyle( fontSize: 16, fontStyle: FontStyle.italic, ), ), ], ), ), ), ), ); } else { return const Center(child: CircularProgressIndicator()); } }, ), ), ); } } Run Online Challenge Create quote app using online JSON. Use this JSON file to display the quotes.\n",
    "description": "In this section, you will learn to use online JSON in your flutter application with the help of real-world example.",
    "tags": null,
    "title": "Use Online JSON in Flutter",
    "uri": "/working-with-assets/use-internet-json-in-flutter/"
  },
  {
    "content": "Build Flutter Apps This section will help you to build different apps in flutter. Here you will learn to build the following apps:\nMy Profile App Simple Interest Calculator App Todo App Book Reader App Tic Tac Toe Game Practice Questions Complete this section \u0026 practice this question to improve and test your flutter skill.\n",
    "description": "Here you will learn to build 5 apps in flutter. You will learn to build my profile app, simple interest calculator app, todo app, book reader app, and tic tac toe game.",
    "tags": null,
    "title": "Build Simple Apps",
    "uri": "/create-full-apps/"
  },
  {
    "content": "Column Widget In Flutter In Flutter, Column widget displays its children vertically. It is very useful when placing UI top to bottom. This is one of the most used widgets in Flutter.\nExample 1: Column In Flutter In this example, the Column contains three children widgets which are Icon, Text, and Icon.\nimport 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('My First App'), ), body: const Column( children: [ Icon(Icons.star, size: 50), Text('I am learning flutter'), Icon(Icons.star, size: 50), ], ), ), ), ); } Run Online Example 2: Create Container Boxes In this example, you will learn to build 4 different containers inside the Column.\nimport 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Column In Flutter'), ), body: Column( children: [ Container(height: 100, width: 100, color: Colors.blue), const SizedBox(height: 5), Container(height: 100, width: 100, color: Colors.blue), const SizedBox(height: 5), Container(height: 100, width: 100, color: Colors.blue), const SizedBox(height: 5), Container(height: 100, width: 100, color: Colors.blue), ], ), ), ), ); } Run Online Column Properties These are the most common useful properties of the Column widget which help you control the layout of its children:\nProperty Description mainAxisAlignment Determines how the children are aligned vertically. crossAxisAlignment Determines how the children are aligned horizontally. children The widgets that are displayed inside the column. Main Axis In Column In Column, the main axis determines how the children are aligned vertically. The mainAxisAlignment property accepts the following values:\nMainAxisAlignment Values Description MainAxisAlignment.start Children are aligned at the start of the vertical axis. MainAxisAlignment.end Children are aligned at the end of the vertical axis. MainAxisAlignment.center Children are centered along the vertical axis. MainAxisAlignment.spaceBetween Children have equal spacing between them. MainAxisAlignment.spaceAround Children have equal spacing between them, and also the space at the start and the end is divided evenly. MainAxisAlignment.spaceEvenly Children have equal spacing before, between, and after them. Example 3: Main Axis Alignment In this example, you see 4 containers which are centered vertically. Run this code online and try changing center to start, end, spaceBetween, spaceAround or spaceEvenly.\nimport 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Column In Flutter'), ), body: Column( // Try replacing \"center\" with \"start\", \"end\", \"spaceBetween\", \"spaceAround\" or \"spaceEvenly\" mainAxisAlignment: MainAxisAlignment.center, children: [ Container(height: 100, width: 100, color: Colors.blue), const SizedBox(height: 5), Container(height: 100, width: 100, color: Colors.blue), const SizedBox(height: 5), Container(height: 100, width: 100, color: Colors.blue), const SizedBox(height: 5), Container(height: 100, width: 100, color: Colors.blue), ], ), ), ), ); } Run Online Info Note: By default mainAxisAlignment value is mainAxisAlignment.start\nCross Axis In Column In Column, the cross axis determines how the children are aligned horizontally. The crossAxisAlignment property accepts the following values:\nCrossAxisAlignment Values Description CrossAxisAlignment.start Children are aligned at the left of the Column. CrossAxisAlignment.end Children are aligned at the right of the Column. CrossAxisAlignment.center Children are vertically centered in the Column. CrossAxisAlignment.stretch Children are forced to fill the available space horizontally. CrossAxisAlignment.baseline Children are aligned by their baseline (useful for text). Example 4: Cross Axis Alignment In this example, you see 4 boxes which are centered horizontally. Run this code online and try changing center to start, end, stretch, or baseline.\nimport 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Column In Flutter'), ), body: Container( color: Colors.green, width: double.infinity, child: Column( // Try replacing \"center\" with \"start\", \"end\", \"stretch\", or \"baseline\" crossAxisAlignment: CrossAxisAlignment.center, children: [ Container(height: 100, width: 100, color: Colors.blue), const SizedBox(height: 5), Container(height: 100, width: 100, color: Colors.blue), const SizedBox(height: 5), Container(height: 100, width: 100, color: Colors.blue), const SizedBox(height: 5), Container(height: 100, width: 100, color: Colors.blue), ], ), ), ), ), ); } Run Online Info Note: By default crossAxisAlignment value is crossAxisAlignment.center\nExample 5: Using Main Axis \u0026 Cross Axis Alignment In this example, you see 4 containers which are aligned vertically in the center. Run this code online and try changing its main axis and cross axis alignment.\nimport 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Column In Flutter'), ), body: Container( color: Colors.green, width: double.infinity, child: SingleChildScrollView( scrollDirection: Axis.vertical, child: Column( // Try replacing \"center\" with \"start\", \"end\", \"spaceAround\", \"spaceEvenly\" or \"spaceBetween\" mainAxisAlignment: MainAxisAlignment.center, // Try replacing \"center\" with \"start\", \"end\", \"stretch\" or \"baseline\" crossAxisAlignment: CrossAxisAlignment.center, children: List.generate( 50, (index) =\u003e Padding( padding: const EdgeInsets.all(8.0), child: Container(height: 100, width: 100, color: Colors.white), )), ), ), ), ), ), ); } Run Online Overflow Issue When you put too many widgets inside a Column and they can’t fit within the screen, you’ll get an overflow error. Here are simple ways to handle this overflow issue in Flutter:\nWrap in SingleChildScrollView widget Use Expanded or Flexible widget Example 6: Wrap In SingleChildScrollView When you have many children widgets, and they can’t all fit on the screen, you might want to scroll to see the ones that are out of view. For more see the example below:\nimport 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Column In Flutter'), ), body: Container( color: Colors.green, width: double.infinity, child: SingleChildScrollView( scrollDirection: Axis.vertical, child: Column( // Try replacing \"center\" with \"start\", \"end\", \"spaceAround\", \"spaceEvenly\" or \"spaceBetween\" mainAxisAlignment: MainAxisAlignment.center, // Try replacing \"center\" with \"start\", \"end\", \"stretch\" or \"baseline\" crossAxisAlignment: CrossAxisAlignment.center, children: List.generate( 50, (index) =\u003e Padding( padding: const EdgeInsets.all(8.0), child: Container(height: 100, width: 100, color: Colors.white), )), ), ), ), ), ), ); } Run Online Example 7: Using Expanded In a Column, use Expanded to make a widget take up all the available remaining space within its parent widget. For more, see the example below:\nimport 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Column In Flutter'), ), body: Container( color: Colors.green, width: double.infinity, child: Column( // Try replacing \"center\" with \"start\", \"end\", \"spaceAround\", \"spaceEvenly\" or \"spaceBetween\" mainAxisAlignment: MainAxisAlignment.center, // Try replacing \"center\" with \"start\", \"end\", \"stretch\" or \"baseline\" crossAxisAlignment: CrossAxisAlignment.center, children: List.generate( 50, (index) =\u003e Expanded( child: Padding( padding: const EdgeInsets.all(8.0), child: Container(height: 100, width: 100, color: Colors.white), ))), ), ), ), ), ); } Run Online Example 8: Using Flexible Flexible allows a widget within a Column to fit its content but won’t exceed its maximum size, even if there’s extra space available. For more, see the example below:\nimport 'package:flutter/material.dart'; void main() { runApp( MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Column In Flutter'), ), body: Container( color: Colors.green, width: double.infinity, child: Column( // Try replacing \"center\" with \"start\", \"end\", \"spaceAround\", \"spaceEvenly\" or \"spaceBetween\" mainAxisAlignment: MainAxisAlignment.center, // Try replacing \"center\" with \"start\", \"end\", \"stretch\" or \"baseline\" crossAxisAlignment: CrossAxisAlignment.center, children: List.generate( 50, (index) =\u003e Flexible( fit: FlexFit.loose, child: Padding( padding: const EdgeInsets.all(8.0), child: Container(height: 100, width: 100, color: Colors.white), ))), ), ), ), ), ); } Run Online Info Note: Expanded forces its child to fill available space, while Flexible allows its child to occupy space without necessarily filling it.\n",
    "description": "Learn about flutter column widget. A column is a type of layout widget that organizes its children vertically. It lets you put widgets on top of each other and automatically adjusts their placements based on available space and limits.",
    "tags": null,
    "title": "Column in Flutter",
    "uri": "/introduction-and-basics/column-in-flutter/"
  },
  {
    "content": "Introduction In this section, you will learn to create a quote app using online JSON in flutter. Before we start, make sure you have basic knowledge of JSON. If you don’t know start from here.\nQuote JSON Link You can use JSON file from here. It contains 50+ quotes. Here is preview for first 3 quotes.\n[ { \"text\": \"The only people who never fail are those who never try.\", \"from\": \"Ilka Chase\" }, { \"text\": \"Failure is just another way to learn how to do something right.\", \"from\": \"Marian Wright Edelman\" }, { \"text\": \"I failed my way to success.\", \"from\": \"Thomas Edison\" }, ] How to Create Quote App Now you will learn to create a quote app using online JSON. Here are the steps to create a app:\nStep 1: Install http Package To use online JSON in your app, the first step is to add the http package in your project. Open terminal at your project folder and execute the following command:\nflutter pub add http Step 2: Import the http Package Now, you need to import the http package in your flutter application. To import the http package, open your main.dart file and add the following import statement:\nimport 'package:http/http.dart' as http; Step 3: Create Model Class Now, you need to create a model class for the JSON data. Create a new file called quote.dart inside lib folder and add the following code in it:\nclass Quote { final String text; final String from; // Constructor Quote({required this.text, required this.from}); // Convert JSON to Quote Object factory Quote.fromJson(Map\u003cString, dynamic\u003e json) { return Quote( text: json['text'], from: json['from'], ); } } Step 4: Load and Decode the JSON File Now create a new file called onlineservice.dart inside lib folder and add the following code in it:\nimport 'dart:convert'; import 'quote.dart'; class OnlineService { // Load and Decode JSON Future\u003cList\u003cQuote\u003e\u003e getQuotes() async { // Load JSON final response = await http.get(Uri.parse('https://jsonguide.technologychannel.org/quotes.json')); // Decode JSON final json = jsonDecode(response.body).cast\u003cMap\u003cString, dynamic\u003e\u003e(); // Convert JSON to Quote return json.map\u003cQuote\u003e((json) =\u003e Quote.fromJson(json)).toList(); } } Step 5: Create Quote Widget Now, you need to create a widget to display the quote. Create a new file called quote_widget.dart inside lib folder and add the following code in it:\nimport 'package:flutter/material.dart'; import 'quote.dart'; class QuoteWidget extends StatelessWidget { final Quote quote; const QuoteWidget({Key? key, required this.quote}) : super(key: key); @override Widget build(BuildContext context) { return Card( elevation: 4, margin: const EdgeInsets.all(8), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), child: Padding( padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( quote.text, style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold), ), const SizedBox(height: 10), Text( '- ${quote.from}', style: const TextStyle(fontSize: 16, fontStyle: FontStyle.italic), textAlign: TextAlign.right, ), ], ), ), ); } } Step 6: Display the JSON Data Now, you can use the OnlineService class to display the JSON data. Here is how you can use it on your main.dart file:\nimport 'package:flutter/material.dart'; import 'onlineservice.dart'; import 'quote.dart'; import 'quote_widget.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: FutureBuilder\u003cList\u003cQuote\u003e\u003e( future: OnlineService().getQuotes(), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return const Center(child: CircularProgressIndicator()); } if (snapshot.hasError) { return Center(child: Text('Error: ${snapshot.error}')); } if (snapshot.hasData) { final quotes = snapshot.data!; return ListView.builder( itemCount: quotes.length, itemBuilder: (context, index) { return QuoteWidget(quote: quotes[index]); }, ); } return const Center(child: Text('No data available')); }, ), ), ); } } Run Online Challenge Now create a similar app using local JSON. You can use JSON file from here.\n",
    "description": "In this section, you will learn to create a quote app using online JSON in flutter",
    "tags": null,
    "title": "Create Quote App in Flutter",
    "uri": "/working-with-assets/create-quote-app-in-flutter/"
  },
  {
    "content": "Introduction DropdownButton is a type of button in Flutter that displays a list of items when pressed. It allows users to select a single item from the list. This guide will help you understand the DropdownButton widget with the help of real-world examples.\nUse Cases Country Selection: Use a dropdown button to allow users to select a country from a list of countries. Changing App Settings: Use a dropdown button to allow users to change app settings such as language, theme, or font size. Example 1: Basic Dropdown Button In this example below, you will learn to create a basic dropdown button with a list of items. For full code, press Run Online button.\nDropdownButton\u003cString\u003e( value: dropdownValue, onChanged: (String? newValue) { setState(() { dropdownValue = newValue!; }); }, items: \u003cString\u003e['One', 'Two', 'Three', 'Four'] .map\u003cDropdownMenuItem\u003cString\u003e\u003e((String value) { return DropdownMenuItem\u003cString\u003e( value: value, child: Text(value), ); }).toList(), ) Run Online Example 2: Country Selection App In this example below, you will learn to create a country selection app using a dropdown button. For full code, press Run Online button.\nDropdownButton\u003cString\u003e( value: selectedCountry, onChanged: (String? newValue) { setState(() { selectedCountry = newValue!; }); }, items: \u003cString\u003e['India', 'USA', 'UK', 'Canada'] .map\u003cDropdownMenuItem\u003cString\u003e\u003e((String value) { return DropdownMenuItem\u003cString\u003e( value: value, child: Text(value), ); }).toList(), ) Run Online Challenge Create a dropdown button to select days of the week (Monday, Tuesday, Wednesday, etc.) and display the selected day in the app.\n",
    "description": "This tutorial delves into the DropdownButton widget in Flutter, providing examples of creating a basic dropdown button, customizing dropdown items, adding icons to dropdown items, handling item selection, and styling the dropdown button. Master the DropdownButton widget to enhance user interaction by offering selectable options in your Flutter applications.",
    "tags": null,
    "title": "Dropdown Button in Flutter",
    "uri": "/buttons-in-flutter/dropdown-button-in-flutter/"
  },
  {
    "content": "Flutter Practice Questions This section includes practice questions designed to enhance your understanding and skills in working with REST APIs in Flutter.\nCreate a application that fetches data from (https://jsonplaceholder.typicode.com/users) and displays the list of users. Create a form where users can input their name and message. Post this data to a (https://jsonplaceholder.typicode.com/posts). Display a confirmation message on successful submission. Create a Weather app in Flutter that fetches weather data from a weather API (e.g., OpenWeatherMap) and displays the current weather information for a specific location. Write a function in Flutter that converts the JSON data fetched from the REST API into a list of Dart objects. ",
    "description": "Practice questions focused on working with APIs in Flutter. Solve these questions to get comfortable with fetching, posting, updating, and deleting data from REST APIs using Flutter.",
    "tags": [
      "Practice",
      "API"
    ],
    "title": "Questions for Practice 10",
    "uri": "/working-with-api/questions-for-practice-10/"
  },
  {
    "content": "TabBar In Flutter TabBar is a widget that displays a row of tabs at the top or bottom of the app, allowing users to switch between different views or pages by tapping on them.\nExample 1: Courier Tracking App In this example, you will learn how to create a simple courier tracking app using TabBar. The app will have three tabs (In Transit, Delivered, and Pending) to display the status of the courier.\nDefaultTabController( length: 3, child: Scaffold( appBar: AppBar( title: Text('Courier Tracking'), bottom: TabBar( tabs: [ Tab(icon: Icon(Icons.directions_car), text: 'In Transit'), Tab(icon: Icon(Icons.check), text: 'Delivered'), Tab(icon: Icon(Icons.access_time), text: 'Pending'), ], ), ), body: TabBarView( children: [ Center(child: ListView(children: [Text('Parcel 21'), Text('Parcel 22')])), Center(child: ListView(children: [Text('Parcel 23'), Text('Parcel 24')])), Center(child: ListView(children: [Text('Parcel 26'), Text('Parcel 27')])), ], ), ), ) Info Note: When you run online, this code is slightly modified to enhance the presentation of the parcels.\nRun Online Example 2: Todo App In this example below, you will learn how to create a Todo App with a TabBar that has two tabs (Active and Completed) to display the tasks based on their status. Use the TabBarView to display the list of tasks for each tab.\nDefaultTabController( length: 2, child: Scaffold( appBar: AppBar( title: Text('Todo App'), bottom: TabBar( tabs: [ Tab(text: 'Active'), Tab(text: 'Completed'), ], ), ), body: TabBarView( children: [ Center(child: ListView(children: [ ListTile(title: Text('Task 1'), leading: Icon(Icons.info)), ListTile(title: Text('Task 2'), leading: Icon(Icons.info)), ])), Center(child: ListView(children: [ ListTile(title: Text('Task 3'), leading: Icon(Icons.info)), ListTile(title: Text('Task 4'), leading: Icon(Icons.info)), ])), ], ), ), ) Run Online Challenge Look at the example 2 and add trailing icons to move tasks between tabs. For example, when you tap on the trailing icon of a task in the Active tab, it should move to the Completed tab. Similarly, when you tap on the trailing icon of a task in the Completed tab, it should move to the Active tab.\n",
    "description": "Learn about TabBar widget in Flutter to create tabbed interfaces in your applications. This guide covers the basics of TabBar usage, including setup, customization, and a practical example.",
    "tags": null,
    "title": "TabBar in Flutter",
    "uri": "/navigation-in-flutter/tab-bar-in-flutter/"
  },
  {
    "content": "Flutter Local Storage This section will help you to learn about local storage in Flutter. Here you will learn the following topics:\nLocal Storage in Flutter Shared Preferences in Flutter Practice Questions Complete this section \u0026 practice this question to improve and test your flutter skill.\n",
    "description": "Here you will learn to use local storage in flutter. You will learn about shared preference, SQFLite, and Hive.",
    "tags": null,
    "title": "Local Storage In Flutter",
    "uri": "/local-storage/"
  },
  {
    "content": "Introduction The PopupMenuButton widget in Flutter is used to display a menu when pressed and allows you to select from a list of options. It’s commonly used for overflow menus, showing choices related to an item.\nExample 1: Basic Popup Menu Button In this example below, you will learn to create a basic popup menu button with a list of items. When you press the button, a menu will appear with the available options.\nPopupMenuButton\u003cint\u003e( onSelected: (int result) { setState(() { _selectedMenu = result; }); }, itemBuilder: (BuildContext context) =\u003e \u003cPopupMenuEntry\u003cint\u003e\u003e[ const PopupMenuItem\u003cint\u003e( value: 1, child: Text('About Us'), ), const PopupMenuItem\u003cint\u003e( value: 2, child: Text('Contact Us'), ), const PopupMenuItem\u003cint\u003e( value: 3, child: Text('Privacy Policy'), ), ], ) Run Online Example 2: Popup Menu Button with Icons In this example below, you will learn to create a popup menu button with icons for the menu items. When you press the button, a menu will appear with the available options, each with an icon.\nPopupMenuButton\u003cint\u003e( onSelected: (int result) { setState(() { _selectedMenu = result; }); }, itemBuilder: (BuildContext context) =\u003e \u003cPopupMenuEntry\u003cint\u003e\u003e[ const PopupMenuItem\u003cint\u003e( value: 1, child: ListTile( leading: Icon(Icons.info), title: Text('About Us'), ), ), const PopupMenuItem\u003cint\u003e( value: 2, child: ListTile( leading: Icon(Icons.phone), title: Text('Contact Us'), ), ), const PopupMenuItem\u003cint\u003e( value: 3, child: ListTile( leading: Icon(Icons.privacy_tip), title: Text('Privacy Policy'), ), ), ], ) Run Online Challenge Create a popup menu button that shows options for changing the theme of the app (Light, Dark, System Default).\n",
    "description": "Explore the PopupMenuButton widget in Flutter, including examples of creating a basic popup menu button, customizing menu items, adding icons to menu items, handling menu selection, and styling the popup menu button. Gain insights into using PopupMenuButton to implement an options menu or more actions in your Flutter applications.",
    "tags": null,
    "title": "Popup Menu Button in Flutter",
    "uri": "/buttons-in-flutter/popup-menu-button-in-flutter/"
  },
  {
    "content": "Row and Column Flutter Row and Column helps you to align its children horizontally and vertically. These widgets are important when designing the user interface for an application.\nRow Column Arranges children horizontally. Arranges children vertically. Example 1: Row \u0026 Column In this example, you will learn to use Row and Column widgets together with a CircleAvatar to create a user profile layout.\nRow( crossAxisAlignment: CrossAxisAlignment.start, children: \u003cWidget\u003e[ CircleAvatar( radius: 35, backgroundImage: NetworkImage( 'https://avatars.githubusercontent.com/u/33576285?v=4', ), ), Padding(padding: EdgeInsets.all(2.0)), Column( children: \u003cWidget\u003e[ Text( 'John Doe', style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, ), ), Text( 'Flutter Developer', style: TextStyle( fontSize: 15, ), ), ], ), ], ) Run Online Example 2: Login Form In this example, you will learn how to build a simple login form using Column and Row, along with the TextField for input fields.\nColumn( mainAxisAlignment: MainAxisAlignment.center, children: \u003cWidget\u003e[ const Row( children: \u003cWidget\u003e[ Text('Username: '), Expanded(child: TextField()), ], ), const Row( children: \u003cWidget\u003e[ Text('Password: '), Expanded( child: TextField( obscureText: true, ), ), ], ), Row( children: \u003cWidget\u003e[ Expanded( child: MaterialButton( color: Colors.blue, textColor: Colors.white, onPressed: () {}, child: const Text('Login'), ), ), ], ), ], ) Run Online Example 3: Star Pattern In this example, you will learn how to create a star pattern using Center, Column, and Row widgets, along with the Icon widget.\nCenter( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ // First row (one star in the middle) Row( mainAxisAlignment: MainAxisAlignment.center, children: [Icon(Icons.star, color: Colors.blue)], ), // Second row (one star in the middle) Row( mainAxisAlignment: MainAxisAlignment.center, children: [Icon(Icons.star, color: Colors.blue)], ), // Third row (five stars) Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon(Icons.star, color: Colors.blue), Icon(Icons.star, color: Colors.blue), Icon(Icons.star, color: Colors.blue), Icon(Icons.star, color: Colors.blue), Icon(Icons.star, color: Colors.blue), ], ), // Fourth row (one star in the middle) Row( mainAxisAlignment: MainAxisAlignment.center, children: [Icon(Icons.star, color: Colors.blue)], ), // Fifth row (one star in the middle) Row( mainAxisAlignment: MainAxisAlignment.center, children: [Icon(Icons.star, color: Colors.blue)], ), ], ), ), Run Online ",
    "description": "Learn about row and column in flutter. You will learn row widget, flutter row widget, flutter row, flutter row example, flutter row tutorial, flutter row widget example, flutter row widget tutorial, flutter row widget example, flutter row widget tutorial, column widget, flutter column widget, flutter column, flutter column example, flutter column tutorial, flutter column widget example, flutter column widget tutorial, flutter column widget example, flutter column widget tutorial",
    "tags": null,
    "title": "Row and Column in Flutter",
    "uri": "/introduction-and-basics/row-and-column-in-flutter/"
  },
  {
    "content": "Introduction In this section, you will learn to use local audio in your flutter application with the help of real-world example. You will create a simple audio player app. Here are the steps to create a app:\nStep 1: Add Audio File To Your Project You can download sample audio file from here or you can use your own audio file. Place the audio file inside assets/audio with the name sound.mp3.\nStep 2: Install audioplayers Package To use local audio in your app, the first step is to add the audioplayers package in your project. Open terminal at your project folder and execute the following command:\nflutter pub add audioplayers Step 3: Update Pubspec.yaml Assets Now, you need to update the pubspec.yaml file. Go to your pubspec.yaml file and add the following code in it:\nflutter: assets: - assets/audio/sound.mp3 Step 4: Import the audioplayers Package Now, you need to import the audioplayers package in your flutter application. To import the audioplayers package, open your main.dart file and add the following import statement:\nimport 'package:audioplayers/audioplayers.dart'; Step 5: Code for Audio Player Now, you need to create a audio player widget. Open main.dart file and add the following code in it:\nimport 'package:flutter/material.dart'; import 'package:audioplayers/audioplayers.dart'; void main() { runApp(MyApp()); } // Stateful widget to handle audio playback. class MyApp extends StatefulWidget { @override _MyAppState createState() =\u003e _MyAppState(); // State creation. } class _MyAppState extends State\u003cMyApp\u003e { final AudioPlayer audioPlayer = AudioPlayer(); // Audio player instance. @override void dispose() { audioPlayer.dispose(); // Release audio player resources. super.dispose(); } // Plays an audio file. void playAudio() async { await audioPlayer.play(AssetSource('audio/sound.mp3')); } // Stops the audio playback. void stopAudio() async { await audioPlayer.stop(); } @override Widget build(BuildContext context) { // Builds the app's UI. return MaterialApp( home: Scaffold( appBar: AppBar(title: const Text('Audio Player Example')), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: \u003cWidget\u003e[ ElevatedButton( onPressed: playAudio, child: const Text('Play Audio')), ElevatedButton( onPressed: stopAudio, child: const Text('Stop Audio')), ], ), ), ), ); } } Project Source Code If you face any problem while creating this app, you can download the source code of this project from here.\nChallenge Create a simple audio player app which can play and stop the audio file from the following URL:\nhttps://raw.githubusercontent.com/Flutter-Tutorial-Website/SimpleFlutterAudioPlayer/master/assets/audio/sound.mp3 Solution You can simply create playAudioOnline() method and call it on button press. Here is the code for playAudioOnline() method:\nvoid playAudioOnline() async { await audioPlayer.play(UrlSource('https://raw.githubusercontent.com/Flutter-Tutorial-Website/SimpleFlutterAudioPlayer/master/assets/audio/sound.mp3')); } ",
    "description": "In this section, you will learn how to use local audio in your flutter application with the help of real-world example.",
    "tags": null,
    "title": "Use Local Audio in Flutter",
    "uri": "/working-with-assets/use-local-audio-in-flutter/"
  },
  {
    "content": "How to Get Job in Flutter Getting a job as a Flutter developer involves a combination of technical proficiency, networking, and job search strategies. Here’s a step-by-step guide to help you land a job in Flutter development:\n1. Master Flutter Before you start applying for jobs, you need to master Flutter. You can learn Dart Programming Language and Flutter from our Dart Tutorial and Flutter Tutorial respectively. Make sure you have a solid understanding of the following concepts:\nDart Programming Language Skills Object Oriented Programming concepts Flutter’s widgets and the widget tree State management solutions like Provider, Riverpod, BLoC, etc. CI/CD tools like GitHub Actions, Codemagic, etc. Building small apps and gradually move to more complex projects. 2. Build a Portfolio A portfolio is a collection of your best work. It can be a website, a GitHub repository, or a mobile app. It should showcase your skills and experience in Flutter development. You can build a portfolio by working on open-source projects, contributing to existing projects, or creating your own apps.\nCreate a portfolio of Flutter projects. These could range from simple apps to more intricate ones. Use platforms like GitHub to showcase your code. It’s essential to show potential employers that you can write clean and maintainable code. Deploy a few of your apps to the App Store or Google Play to demonstrate your ability to complete the full app development cycle. 3. Create a Resume A resume is a written description of your education, professional background, and skills. When recruiters get your application, they see it right away. You can get an interview and differentiate yourself from the competition with a strong CV. Here are some tips for creating a resume that will get you noticed:\nHighlight your Flutter and Dart experience prominently. Mention other relevant skills like familiarity with CI/CD, integration with Firebase, web development, etc. Include links to your GitHub projects and deployed apps. Include objective statements that describe what you’re looking for in a job. Info Note: Don’t forget to create a LinkedIn profile. You will find it quite beneficial to network with other Flutter developers, possible employers, and other professionals in this sector.\n4. Networking Networking is a great way to find job opportunities and build relationships with other Flutter developers. Here are some tips for networking effectively:\nJoin local Flutter meetups and conferences. Attend Flutter events like Flutter Engage and Flutter Live. Connect with other Flutter developers on LinkedIn and Twitter. 5. Communication Communication is an essential skill for any developer. It’s important to be able to communicate your ideas clearly and concisely. Here are some tips for improving your communication skills:\nPractice writing emails and blog posts. Join a Toastmasters club or take public speaking classes. Read books on communication and presentation skills. 6. Job Search Once you’ve mastered Flutter and built a portfolio, it’s time to start looking for jobs. Here are some top flutter job sites where you can apply for a flutter job.\nIndeed Glassdoor LinkedIn Flutter Jobs Info Note: Customize your cover letter for each position. Address the specific requirements mentioned in the job description. Also Prepare for technical interviews. This might include coding challenges, whiteboarding sessions, or discussions about Flutter-specific topics.\n7. Stay Updated Flutter is a rapidly evolving technology. It’s important to stay up-to-date with the latest developments in the Flutter ecosystem.\n8. Consider Freelancing If you’re finding it challenging to land a full-time role initially, consider taking up freelance Flutter projects. Platforms like Upwork, Freelancer, and Toptal often have Flutter-related gigs. This will help you gain more experience and build a stronger portfolio.\n",
    "description": "Learn how to get job in flutter. You will learn how to get job in flutter for freshers.",
    "tags": null,
    "title": "How to Get Job in Flutter",
    "uri": "/how-to/how-to-get-job-in-flutter/"
  },
  {
    "content": "Flutter Assets and Data Handling Practice Questions Create a Flutter app that loads and displays an image from the assets folder. Ensure the image scales correctly in both portrait and landscape modes. Create a Flutter application that fetches and displays an image from a URL. Implement error handling for scenarios where the image cannot be loaded. Create a Flutter app that caches images from the internet and loads them from the cache on subsequent launches for faster performance. Create a Flutter application that uses a custom font from the local assets and apply it to the entire app text. Create a Flutter app that dynamically fetches and applies a Google Font to a selected text widget. Write a Flutter application that reads a local JSON file from the assets folder and displays its contents in a user-friendly format. Create a Flutter app that fetches JSON data from an online source and displays it in a ListView. Create a Flutter app that displays a list of quotes. The quotes should be stored locally and should include functionality to add, delete, and view quotes. In a Flutter app, create a feature to switch between two sets of assets (like images and fonts) based on user selection or a toggle switch. Build a Flutter application that combines local and network images in a grid layout, demonstrating effective asset management in Flutter. ",
    "description": "Practice questions for flutter. Solve these questions and makes yourself comfortable in flutter.",
    "tags": [
      "Practice"
    ],
    "title": "Questions for Practice 3",
    "uri": "/working-with-assets/questions-for-practice-3/"
  },
  {
    "content": "Stack In Flutter Imagine you’re making a sandwich. You put one ingredient on top of another, right? In Flutter, the Stack works similarly. It lets you put one thing (like a button or an image) on top of another. It’s super useful when you want things to overlap in your app’s design.\nWhen to Use Stack Buttons Over Pictures: Like a play button on a video thumbnail. Text on Images: Like captions on photos. Cool Designs: For when you want to mix things up from the usual top-down look. Info Note: The first one is at the bottom, and each new one goes on top. In a Stack, your first widget is at the bottom, and others are layered over it.\nExample 1: Basic Stack Implementation Here’s how you can create a basic Stack with overlaid elements:\nStack( alignment: Alignment.center, children: [ Container( width: 100, height: 100, color: Colors.blue, ), const Text('I’m on top!'), ], ) Run Online Example 2: Profile Picture with Online Status Indicator In this example, you will learn to create a circular profile picture with a small green dot at the bottom to indicate the user is online.\nStack( alignment: Alignment.bottomRight, children: [ const CircleAvatar( radius: 40, backgroundImage: NetworkImage( 'https://avatars.githubusercontent.com/u/33576285?v=4' ), ), DecoratedBox( decoration: BoxDecoration( color: Colors.green, shape: BoxShape.circle, border: Border.all(color: Colors.white, width: 3), ), child: const SizedBox(width: 20, height: 20), ), ], ) Run Online Positioned Widget The Positioned widget is a special type of widget used inside a Stack widget to control the position of a child widget. It has the following useful properties:\nProperty Description top Distance from the top edge of the stack. bottom Distance from the bottom edge of the stack. left Distance from the left edge of the stack. right Distance from the right edge of the stack. You can see the demo of the Positioned widget in example 3 and 4.\nExample 3: Product Image with Discount Badge In this example, you will learn to create a product image with a discount badge at the top right corner.\nStack( children: [ Image.network('https://images.pexels.com/photos/19060954/pexels-photo-19060954/free-photo-of-iphone-15-pro-max.jpeg'), Positioned( top: 10, right: 10, child: Container( padding: const EdgeInsets.all(8), color: Colors.red, child: const Text( '20% OFF', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), ), ), ), ], ) Run Online Example 4: Overlay Text on Image In this example, you will learn to overlay text on an image.\nStack( children: [ Image.network( 'https://images.pexels.com/photos/19060954/pexels-photo-19060954/free-photo-of-iphone-15-pro-max.jpeg' ), Positioned( bottom: 10, left: 10, child: DecoratedBox( decoration: BoxDecoration( color: Colors.black, borderRadius: BorderRadius.circular(4), ), child: const Padding( padding: EdgeInsets.all(8), child: Text( 'iPhone 15 Pro Max', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), ), ), ), ), ], ) Run Online ",
    "description": "In this section, you will learn what is stack in flutter and how to use it in your flutter application with the help of examples.",
    "tags": null,
    "title": "Stack in Flutter",
    "uri": "/introduction-and-basics/stack-in-flutter/"
  },
  {
    "content": "Working with API in Flutter This section will help you to learn about working with API in Flutter. Here you will learn the following topics:\nIntroduction to API and REST API, Introduction to JSON, Fetch Data from REST API, Post Data to REST API, Put Data to REST API, Delete Data from REST API, and Create Quiz App. Practice Questions Complete this section \u0026 practice this question to improve and test your flutter skill.\n",
    "description": "In this section, you will learn to work with API in Flutter. You will learn to fetch data from the internet, parse JSON data, and use the data in your app.",
    "tags": null,
    "title": "Working with API",
    "uri": "/working-with-api/"
  },
  {
    "content": "Create Counter App In Flutter In this section, you will learn how to create a simple counter app in flutter. This app will help you to understand the basic concepts of flutter. So let’s start.\nStep 1: Create Flutter Project To create a flutter project, open the command prompt and run the following command:\nflutter create counter_app Step 2: Define the Main Entry Point Open main.dart file and define the main entry point of the app.\nimport 'package:flutter/material.dart'; void main() { runApp(const CounterApp()); } Step 3: Create the CounterApp Widget Now, you need to create the CounterApp widget.\nclass CounterApp extends StatelessWidget { const CounterApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Counter App', home: CounterScreen(), ); } } Step 4: Create the CounterScreen Widget Now, create the CounterScreen widget.\nclass CounterScreen extends StatefulWidget { @override _CounterScreenState createState() =\u003e _CounterScreenState(); } class _CounterScreenState extends State\u003cCounterScreen\u003e { // Define the counter variable int _counter = 0; // Define the increment and decrement counter methods void _incrementCounter() { setState(() { _counter++; }); } void _decrementCounter() { setState(() { _counter--; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('Counter App')), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( '$_counter', style: const TextStyle(fontSize: 72), ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children:[ FloatingActionButton( onPressed: _incrementCounter, tooltip: 'Add', child: const Icon(Icons.add), ), FloatingActionButton( onPressed: _decrementCounter, tooltip: 'Subtract', child: const Icon(Icons.remove), ), ], ), ], ), ), ); } } Run Online Step 5: Run the App Now, you can run the app using the following command:\nflutter run ",
    "description": "learn to build simple counter app in flutter practically",
    "tags": null,
    "title": "Create Counter App",
    "uri": "/introduction-and-basics/create-couter-app-in-flutter/"
  },
  {
    "content": "Remove Debug Banner in Flutter To remove the debug banner in flutter, you need to set the debugShowCheckedModeBanner property to false in the MaterialApp widget.\nMaterialApp( // set this property to false debugShowCheckedModeBanner: false, ) Info Note: This change is only for visual purposes in the debug mode and does not affect the release build of your app.\nFor CupertinoApp If you are using the CupertinoApp widget, then you need to set the debugShowCheckedModeBanner property to false in the CupertinoApp widget.\nCupertinoApp( // set this property to false debugShowCheckedModeBanner: false, ) ",
    "description": "Learn how to remove debug banner in flutter. You will learn how to remove debug banner in flutter for android and ios.",
    "tags": null,
    "title": "Remove Debug Banner in Flutter",
    "uri": "/how-to/remove-debug-banner-in-flutter/"
  },
  {
    "content": "State Management in Flutter This section will help you understand the core concepts of state management with real-world examples. Here you will learn the following topics:\nIntroduction to State Management, Provider in Flutter, and Building a Quiz App with Provider. Practice Questions After completing this section, practice these questions to test your understanding and improve your skills in managing state within Flutter applications.\n",
    "description": "Understand the core concepts of state management in Flutter. Learn how to manage app state with Provider. This section covers state management introduction, Provider package, building a quiz app using Provider, and practice questions.",
    "tags": null,
    "title": "State Management",
    "uri": "/state-management/"
  },
  {
    "content": "Notification in Flutter Notifications in Flutter are messages or alerts that provides as visual or audio signals to notify users of significant events or updates inside an app. They improve the user experience of the app by attracting users with timely information, such as messages, reminders, or system related events. This section includes:\nDisplay Notification in Flutter, Display Local Notification in Flutter, Display Push Notification in Flutter. Practice Questions After completing this section, attempt the practice questions to test and solidify your knowledge on Notification in Flutter.\n",
    "description": "Explore Flutter's notification mechanisms. Understand how to display different types of notifications, from local notifications to push notifications.",
    "tags": null,
    "title": "Notification in Flutter",
    "uri": "/notification/"
  },
  {
    "content": "Basic Flutter Practice Questions Create a new Flutter application that displays “Welcome to Flutter” centered on the screen, with a font size of 24, in blue color, and with a yellow background. Describe the difference between a StatelessWidget and a StatefulWidget. Give an example of a situation where you would use each. Write a Flutter layout using a Row to create a horizontal bar of three evenly spaced buttons. Use the Stack widget to overlay text on an image. Create a Flutter application that contains an image of a puppy and a button that increases the size of the puppy (double the size each time the button is pressed). Create a Profile Screen UI Design in Flutter using Row and Column Widgets. ",
    "description": "Practice questions for dart programming language. Solve these questions and makes yourself comfortable in dart.",
    "tags": [
      "Practice"
    ],
    "title": "Questions for Practice 1",
    "uri": "/introduction-and-basics/questions-for-practice-1/"
  },
  {
    "content": "Button Widgets in Flutter: Practice Questions Create a Flutter application that displays a MaterialButton on the screen. When pressed, the button should change its color from blue to green. Implement an ElevatedButton with a shadow of 10. The button should display a Snackbar with a message “ElevatedButton Pressed” when clicked. Design a TextButton that toggles its text between “Enabled” and “Disabled” upon each click. Use a variable to manage the button’s state. Create a DropdownButton with items “Item 1”, “Item 2”, and “Item 3”. Display the selected item in a Snackbar when an item is selected. Develop a PopupMenuButton that shows three menu items: “Option 1”, “Option 2”, and “Option 3”. Handle the selection and display the chosen option in a Toast or a Snackbar. ",
    "description": "Practice questions focused on button widgets in Flutter. Tackle these questions to enhance your proficiency with various button types and their customizations in Flutter.",
    "tags": [
      "Practice"
    ],
    "title": "Questions for Practice 5",
    "uri": "/buttons-in-flutter/questions-for-practice-5/"
  },
  {
    "content": "Flutter Navigation Practice Questions Create a basic Flutter app with three screens: Home, About, and Contact. Implement navigation between these screens using MaterialPageRoute. Develop a Flutter application with a bottom navigation bar. Ensure that switching between the tabs does not rebuild the pages. Implement named route navigation in a Flutter app. Create a menu with options, and each option should navigate to a different screen using named routes. Build a multi-page form in Flutter where each step is on a different screen. Use named routes to navigate between the steps and pass data across these screens. Design a master-detail interface in Flutter where selecting an item from a list on the master page navigates to a detail page with more information about the item. Create a Flutter app with a drawer menu. Each item in the drawer should navigate to a different screen using named routes. Implement an authentication flow in Flutter. After login, redirect the user to the home screen, and ensure the back button does not navigate back to the login screen. Develop a Flutter app with a nested navigation scenario where a tab navigator is nested inside a bottom navigation bar, and demonstrate switching between nested routes. Create a Flutter app with a custom transition animation between screens. Use named routes and customize the MaterialPageRoute to achieve this. Build a Flutter application with an onboarding flow. Use named routes to navigate through the onboarding screens, and after the last screen, navigate to the main content. ",
    "description": "Practice questions for flutter navigation. Solve these questions and makes yourself comfortable in flutter.",
    "tags": [
      "Practice"
    ],
    "title": "Questions for Practice 5",
    "uri": "/navigation-in-flutter/questions-for-practice-5/"
  },
  {
    "content": "Flutter Practice Questions Create a Counter App that allows users to increment and decrement a counter, introducing you to the fundamentals of state management in Flutter. Create a Note-taking App for writing and saving notes, teaching you about file handling and persistent storage in Flutter. Create a Currency Converter App that converts currencies, involving fetching current exchange rates from an API and applying them in your application. Create a Stopwatch App with functionalities like start, stop, and reset, which will help you learn about timers and updating the UI in real-time in Flutter. Create a Basic Calculator App that performs basic arithmetic operations. This project will help you understand the nuances of layout design and handling user input in Flutter. ",
    "description": "Practice questions for building full apps in flutter. Solve these questions and makes yourself comfortable in flutter.",
    "tags": [
      "Practice"
    ],
    "title": "Questions for Practice 6",
    "uri": "/create-full-apps/questions-for-practice-6/"
  },
  {
    "content": "Form Validation Practice Questions Create a form with First Name and Last Name fields. Validate the form to ensure that both fields are not empty. Create a form with Email and Password fields. Validate the form to ensure that the email is not empty and the password is at least 6 characters long. Create a form with Phone Number and Address fields. Validate the form to ensure that the phone number is not empty and the address is at least 10 characters long. Create a form with Username and Confirm Password fields. Validate the form to ensure that both fields are not empty and the password matches the confirm password. ",
    "description": "Practice questions for form validation in flutter. Solve these questions and makes yourself comfortable in flutter.",
    "tags": [
      "Practice"
    ],
    "title": "Questions for Practice 6",
    "uri": "/forms-in-flutter/questions-for-practice-6/"
  },
  {
    "content": "Flutter Local Storage Practice Questions Build a settings page in a Flutter app that saves user preferences using Shared Preferences. Include options like theme color and notification settings. Develop a todo list application where tasks are stored and retrieved from local storage, ensuring data persistence even after the app restarts. Design a user profile screen where users can enter and save their information (like name, email, and profile picture). Use local storage to save the data. Create an app for tracking game scores that stores the high scores locally using Shared Preferences, allowing users to view their best scores over time. Build an app that allows users to select their preferred language for the app interface, and save this preference using Shared Preferences. Develop a Flutter app with the functionality to switch between light and dark themes, saving the user’s preference in Shared Preferences. Build a simple shopping app where the user’s cart items are saved in local storage, ensuring the cart remains intact even if the app is closed and reopened Design an app where users can create notes and categorize them. Use local storage to save notes and their respective categories. Implement an onboarding process for first-time users and use Shared Preferences to store a flag indicating that the user has completed the onboarding. Build a fitness app that tracks daily steps or exercise routines and saves the data locally, allowing users to view their progress over time. ",
    "description": "Local storage practice questions for flutter. Solve these questions and makes yourself comfortable in flutter.",
    "tags": [
      "Practice"
    ],
    "title": "Questions for Practice 7",
    "uri": "/local-storage/questions-for-practice-7/"
  },
  {
    "content": "Flutter Notification Practice Questions Develop a Flutter app that triggers local notifications at a specified time. Include options for scheduling and cancelling notifications. Build a Flutter application that receives push notifications using Firebase Cloud Messaging. Test with different message types. Create an app that allows users to set reminders for various tasks. Use local notifications to alert users when a task is due. Build a news application that sends push notifications to users when new articles are published or when there is breaking news. Build an app that allows users to select custom sounds for different types of notifications. Create an app where notifications come with actions (like ‘Reply’, ‘Mark as Read’, etc.), and demonstrate handling these actions within the Flutter app. ",
    "description": "Notification practice questions for flutter. Solve these questions and makes yourself comfortable in flutter.",
    "tags": [
      "Practice"
    ],
    "title": "Questions for Practice 8",
    "uri": "/notification/questions-for-practice-8/"
  },
  {
    "content": "Flutter How To? This part will teach you how to use flutter concepts to make life easier and more enjoyable.\nThis will include following topics:\nUpdate All Packages in Flutter, Add Internet Permission in Flutter, Use Google Maps in Flutter, Get Jobs in Flutter, Convert Website to Flutter App. Practice \u0026 Implement After going through these guides, implement the steps in your projects and practice to perfect your skills in Flutter.\n",
    "description": "Flutter how to section will help you to learn how to do things in flutter. You will learn how to use flutter, how to make things in flutter, and how to do things in flutter.",
    "tags": null,
    "title": "Flutter How To",
    "uri": "/how-to/"
  },
  {
    "content": "State Management Practice Questions Explain the concept of state management in Flutter and why it’s important for app development. What is the Provider package in Flutter? Describe how it works for managing state. Create a simple todo list application in Flutter using Provider where users can add, remove, and mark tasks as completed. Discuss the advantages of using Provider over global variables or inherited widgets for state management in Flutter apps. Implement a theme switching feature in a Flutter app using Provider. Users should be able to switch between light and dark themes. Describe the difference between ChangeNotifierProvider and Consumer widgets in the context of the Provider package. Give an example of how each is used. ",
    "description": "Practice questions focusing on state management and the Provider package in Flutter. Solve these questions to enhance your understanding and skills in managing state in Flutter applications.",
    "tags": [
      "Practice"
    ],
    "title": "Questions for Practice 11",
    "uri": "/state-management/practice-questions-11/"
  },
  {
    "content": "Flutter Admob Integration In this section, you will learn how to integrate different ads in your flutter application.\nThis will include following topics:\nShow Banner Ad In Flutter Show Interstitial Ad In Flutter ",
    "description": "Learn how to integrate admob in flutter. You will learn how to show banner, interstitial, rewarded, native, and app open ads in flutter.",
    "tags": null,
    "title": "Admob Integration",
    "uri": "/admob-integration/"
  },
  {
    "content": "Publishing Flutter App In this section, you will learn how to publish your flutter app on play store and app store. The learning topics are:\nPublish Flutter App On Play Store Publish Flutter App On Apple Store Practice Questions After completing this section, attempt the practice questions to test and solidify your knowledge on Flutter Security.\n",
    "description": "Learn how to publish your flutter app on play store and app store. You will learn how to create keystore, build apk, build app bundle, and publish app on play store and app store.",
    "tags": null,
    "title": "Publishing",
    "uri": "/publishing/"
  },
  {
    "content": "Flutter Practice Questions Create a Flutter application with a form that includes text fields for name, email, and phone number. Use custom styling for the form fields. Create a screen with a variety of buttons (e.g., raised, flat, icon, and floating action buttons) demonstrating different styles and functionalities. Implement a table in Flutter displaying a list of products with columns for product name, price, and quantity. Include functionality to sort the table by each column. Design a form with validation that includes fields for user registration: username, password, confirm password, and email. Display appropriate error messages for invalid inputs. Construct a dynamic form in Flutter that adds a new text field every time the user presses an ‘Add’ button. Include a ‘Submit’ button to display all entered data in a dialog box. Create a responsive Flutter layout with a table on a large screen (e.g., tablet or desktop) and a list view on smaller screens (e.g., mobile), containing the same data. Create a multi-step form in Flutter where each step is a different page in a PageView. Include ‘Next’ and ‘Previous’ buttons to navigate between the steps. Implement a custom button in Flutter that changes its color and elevation when pressed, with a smooth animation transition. Create a Flutter application that uses a DataTable widget to display user data fetched from a mock JSON API. Include features for pagination and row selection. Create a sign-in form in Flutter with animated transitions between the ‘Sign In’ and ‘Sign Up’ forms, showcasing a smooth user experience. ",
    "description": "Practice questions for flutter. Solve these questions and makes yourself comfortable in flutter.",
    "tags": [
      "Practice"
    ],
    "title": "Questions for Practice 4",
    "uri": "/useful-widgets/questions-for-practice-4/"
  },
  {
    "content": "Quiz Game Flutter Quiz By Technology Channel Take our quiz and test your flutter skill. Click on link to get started.\nStart Basic Flutter Quiz ",
    "description": "This quiz is about the flutter framework. Test your knowledge about flutter.",
    "tags": null,
    "title": "Flutter Quiz",
    "uri": "/quiz/"
  },
  {
    "content": "Congratulations!!! Congratulations on completing the flutter course. We hope you enjoyed our content and improved your flutter skill to the next level. Now you are ready to build your own flutter app, do flutter freelancing, or get a job in the flutter field.\nYou can come back to this flutter tutorial whenever you face difficulty while working.\nAlso if you like this work, please do share it with your friends. Your support can help us to provide other tutorials in the future. Also, go to the next section and check your flutter knowledge by our Quiz.\nWhat After Flutter After learning flutter, you can publish your app on the play store, app store, or web. You can also apply for a flutter job or start your own flutter project.\nTop Flutter Jobs Sites Here are some top flutter job sites where you can apply for a flutter job.\nIndeed Glassdoor LinkedIn Flutter Jobs Useful Resources Dart Tutorial If you have any questions, don’t forget to join us.\nWebsite Email: technologychannelofficial@gmail.com ",
    "description": "",
    "tags": null,
    "title": "Conclusion",
    "uri": "/conclusion/"
  },
  {
    "content": "",
    "description": "",
    "tags": null,
    "title": "Flutter Tutorial - Learn App Development",
    "uri": "/"
  },
  {
    "content": "How to Publish App On Play Store This section will help you to learn how to publish app on play store step by step.\nRequirements Before publishing android app to google play store make sure you have the following requirements.\nApp Logo (512x512px) App Banner (1024x500px) Screenshots for mobile, tablet, and Chromebook (1920x1024px, 16:9 ratio) App signing key (key.jks and key.properties) App Name and Description Privacy Policy About Us App Video (optional) App Bundle Verified Google Play Console Account Step 1: Generate App Icon Generate Icon from App Icon Generator Paste the generated icon in android/app/src/main/res folder. Step 2: Create KeyStore File You can paste the following command in the terminal to generate keystore file.\nkeytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload Enter the password and other details. You will get upload-keystore.jks file in your home directory. In my case location is\nC:/Users/iambi/upload-keystore.jks Step 3: Create Key Properties File Create a file named key.properties in the android folder and paste the following code.\nstorePassword=\u003cpassword-from-previous-step\u003e keyPassword=\u003cpassword-from-previous-step\u003e keyAlias=upload storeFile=\u003ckeystore-file-location\u003e Step 4: Update Build Gradle File Now open the android/app/build.gradle file and paste the following code.\ndef keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) } android { ... } Also, update the signingConfigs and buildTypes section.\nsigningConfigs { release { keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null storePassword keystoreProperties['storePassword'] } } buildTypes { release { signingConfig signingConfigs.release } } Step 5: Change App Name Open the android/app/src/main/AndroidManifest.xml file and change the android:label value.\n\u003cmanifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\u003e \u003capplication android:label=\"Your App Name\" android:icon=\"@mipmap/ic_launcher\"\u003e Step 6: Change App ID Open the android/app/build.gradle file and change the applicationId value.\ndefaultConfig { applicationId \"com.example.app\" ... } Step 7: Build Signed App Bundle on VS Code: flutter build appbundle -Alternatively,you Use Android Studio to build a signed app bundle.\nStep 8: Publish and Release for Google Review Fill the necessary details under section of “Set up your app”.\nGoto Create and Publish a Release(app bundle ) and Submit the release for Google’s review.\nAfter Google’s review, if no issues are found, your app will be ready for publishing.\n",
    "description": "",
    "tags": null,
    "title": "Publish Flutter App on Play Store",
    "uri": "/publishing/publish-flutter-app-on-play-store/"
  },
  {
    "content": "",
    "description": "",
    "tags": null,
    "title": "API",
    "uri": "/tags/api/"
  },
  {
    "content": "",
    "description": "",
    "tags": null,
    "title": "Categories",
    "uri": "/categories/"
  },
  {
    "content": "",
    "description": "",
    "tags": null,
    "title": "Practice",
    "uri": "/tags/practice/"
  },
  {
    "content": "",
    "description": "",
    "tags": null,
    "title": "Tags",
    "uri": "/tags/"
  }
]
