Google search engine
Home Blog Page 6

Explore SOLID Principles In Flutter

0

I have been writing about design patterns for the past few articles, and I had promised to continue the series by concentrating on how they are used in Flutter development. I think it’s essential to comprehend the SOLID principles. There is always space for a deeper comprehension, even if we believe we already comprehend these concepts.

In this blog, we will Explore SOLID Principles In Flutter. We will see how to work on a deep dive guide for your Flutter applications.

If you’re looking for the best Flutter app development company for your mobile application then feel free to contact us at — support@flutterdevs.com.


Table Of Contents:

Introduction

What are the SOLID Principles?

Conclusion



Introduction:

A collection of five design guidelines known as the SOLID principles aids programmers in producing scalable and maintainable software. When creating your Flutter apps, you can use them, as they are extensively relevant in object-oriented programming.

What are the SOLID Principles?

Robert C. Martin, sometimes known as Uncle Bob, presented the SOLID principles in his paper Design Principles and Design Patterns. The goal of these guidelines was to improve the readability, adaptability, and maintainability of software designs. SOLID is an acronym that stands for:

  1. S: Single Responsibility Principle (SRP)
  2. O: Open-Closed Principle (OCP)
  3. L: Liskov Substitution Principle (LSP)
  4. I: Interface Segregation Principle (ISP)
  5. D: Dependency Inversion Principle (DIP)

By reducing dependencies between software components, these concepts offer a method for decoupling software and increasing its modularity, flexibility, and adaptability to changes. Although they can be applied to other paradigms, object-oriented programming is where they are most frequently used.

=> Single Responsibility Principle (SRP):
The Single Responsibility Principle (SRP) states that there should only be one justification for a class to change. Let’s look at an example to better grasp this idea.

Issue:-

class User {
  String name;
  String email;

  User(this.name, this.email);

  void changeEmail(String newEmail) {
    if (validateEmail(newEmail)) {
      this.email = newEmail;
    } else {
      print('Invalid email');
    }
  }

  bool validateEmail(String email) {
    return email.contains('@');
  }
}

The User class in the code above violates the Single Responsibility Principle (SRP) since it has two duties: email validation and user data management.

Solution:-

class User {
  String name;
  String email;

  User(this.name, this.email);

  void changeEmail(String newEmail) {
    if (EmailValidator.validate(newEmail)) {
      this.email = newEmail;
    } else {
      print('Invalid email');
    }
  }
}

class EmailValidator {
  static bool validate(String email) {
    return email.contains('@');
  }
}

The User class is now only in charge of handling user data, while the EmailValidator class is solely in charge of email validation. The Single Responsibility Principle (SRP) is upheld here.

=> Open-Closed Principle (OCP):
Software entities (classes, modules, functions, etc.) should be open for expansion but closed for modification under the Open-Closed Principle (OCP). Let’s look at an example to better grasp this idea

Issue:-

class Languages {
  void languages(String language) {
    switch (language) {
      case 'English':
        print('Hello!');
        break;
      case 'Spanish':
        print('Hola!');
        break;
      default:
        print('Language not supported');
    }
  }
}

The Open-Closed Principle (OCP) will be broken if I add a new language because I will need to change the languages() procedure.

Solution:-
By developing distinct classes for every language that implement a common Languages interface, we may resolve this issue.

abstract class Languages {
  void greet();
}

class EnglishLanuages implements Languages {
  @override
  void lanuages() {
    print('Hello!');
  }
}

class SpanishLanguages implements Languages {
  @override
  void languages() {
    print('Hola!');
  }
}

class FrenchLanguages implements Languages {
  @override
  void languages() {
    print('Bonjour!');
  }
}

class HindiLanguages implements Languages {
  @override
  void languages() {
    print("Namaste!");
  }
}

The Languages interface is now closed for modification (we are not required to change the Languages interface or any of the existing classes), but it is open for extension (we can add other languages by establishing new classes). The Open-Closed Principle is followed here.

=> Liskov Substitution Principle (LSP):
The Liskov Substitution Principle (LSP) states that each instance of a derived (child) class ought to be interchangeable with an instance of its base (parent) class without compromising the program’s validity. Let’s look at an example to better grasp this idea.

Issue:-

class AquaticAnimals {
  void fly() {
    print('Swim...');
  }
}

class Bird extends AquaticAnimals {
  @override
  void fly() {
    throw Exception('Birds can\'t swim!');
  }
}

Although the code above indicates that the Bird class is a subclass of AquaticAnimals, it lacks some of the capabilities of AquaticAnimals, such as the ability to swim. We may run into problems that violate the Liskov Substitution Principle (LSP) when we try to substitute a bird for an aquatic animal.

Solution:-

abstract class AquaticAnimals {
  void eat();
}

abstract class SwimAquaticAnimals extends AquaticAnimals {
  void swim();
}

abstract class NonSwimAquaticAnimals extends AquaticAnimals {}

class Whale implements SwimAquaticAnimals {
  @override
  void eat() {
    print("Eating...");
  }

  @override
  void fly() {
    print('Swim...');
  }
}

class Bird implements NonSwimAquaticAnimals {
  @override
  void eat() {
    print("Eating...");
  }
}

Now, an aquatic animals can always be replaced by a SwimAquaticAnimals, and an aquatic animal may always be replaced by a NonSwimAquaticAnimals. The Liskov Substitution Principle (LSP) is upheld here.

=> Interface Segregation Principle (ISP):
The Interface Segregation Principle (ISP) states that it is preferable to design smaller, more targeted interfaces for particular use cases rather than a single, comprehensive interface that encompasses all potential approaches. Let’s look at an example to better grasp this idea.

Issue:-

abstract class Bird {
  void eat();
  void sleep();
  void fly();
}

The Bird interface in the code above has several duties. A bird must use one of these techniques even if it is not necessary (for example, a dog cannot fly). The Interface Segregation Principle (ISP) is broken by this.

Solution:-
By developing distinct interfaces for every duty, we can resolve this.

abstract class Eater {
  void eat();
}

abstract class Sleeper {
  void sleep();
}

abstract class Flyer {
  void fly();
}

class Bird implements Eater, Sleeper, Flyer {
  @override
  void eat() {
    print("Eating..");
  }

  @override
  void sleep() {
    print("Sleeping..");
  }

  @override
  void fly() {
    print("Flying..");
  }
}

class Dog implements Eater, Sleeper {
  @override
  void eat() {
    print("Eating..");
  }

  @override
  void sleep() {
    print("Sleeping..");
  }
}

A bird can now implement only the interfaces it needs, and each interface has a single responsibility. This complies with the principle of interface segregation.

=> Dependency Inversion Principle (DIP):
The Dependency Inversion Principle (DIP) states that both high-level and low-level modules should rely on abstractions rather than on one another. Let’s look at an example to better grasp this idea.

Issue:-

class WeatherService {
  String getWeather() {
    return "Sunny";
  }
}

class WeatherReporter {
  WeatherService _weatherService;

  WeatherReporter(this._weatherService);

  void reportWeather() {
    String weather = _weatherService.getWeather();
    print('The weather is $weather');
  }
}

The WeatherReporter class in the code above depends directly on the WeatherService class. The WeatherReporter class must be changed if we wish to alter how we obtain the weather (for instance, by utilising a different weather provider). The Dependency Inversion Principle (DIP) is broken by this.

Solution:-
By developing a WeatherProvider interface and making WeatherReporter rely on it rather than the actual WeatherService, we can resolve this issue.

abstract class WeatherProvider {
  String getWeather();
}

class WeatherService implements WeatherProvider {
  @override
  String getWeather() {
    return "Sunny";
  }
}

class WeatherReporter {
  WeatherProvider _weatherProvider;

  WeatherReporter(this._weatherProvider);

  void reportWeather() {
    String weather = _weatherProvider.getWeather();
    print('The weather is $weather');
  }
}

Instead of relying on the actual WeatherService, the WeatherReporter class now depends on the abstraction (WeatherProvider). Simply create a new class that implements WeatherProvider if we wish to modify how we obtain the weather. The WeatherReporter class doesn’t need to be changed. The Dependency Inversion Principle (DIP) is followed here.

Conclusion:

In the article, I have explained the basic structure of SOLID Principles in Flutter; you can modify this code according to your choice. This was a small introduction to SOLID Principles in Flutter on User Interaction from my side, and it’s working using Flutter.

I hope this blog will provide you with sufficient information on trying up Explore SOLID Principles in your Flutter projects. We will show you what an Introduction is?. A collection of rules known as the SOLID principles can assist you in writing code that is reliable and easy to maintain. It’s crucial to use them sensibly and avoid making things too complicated. You must comprehend these principles’ goals and use them correctly to improve the calibre of your software design if you want to get the most out of them.. So please try it.

❤ ❤ Thanks for reading this article ❤❤

If I got something wrong? Let me know in the comments. I would love to improve.

Clap 👏 If this article helps you.


From Our Parent Company Aeologic

Aeologic Technologies is a leading AI-driven digital transformation company in India, helping businesses unlock growth with AI automation, IoT solutions, and custom web & mobile app development. We also specialize in AIDC solutions and technical manpower augmentation, offering end-to-end support from strategy and design to deployment and optimization.

Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.

Feel free to connect with us:
And read more articles from FlutterDevs.com.

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! For any flutter-related queries, you can connect with us on FacebookGitHubTwitter, and LinkedIn.

We welcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.




Block Screenshots and Screen Recording in Flutter

Introduction

With the rise of data breaches and privacy concerns, securing sensitive content within mobile applications has become more crucial than ever. Apps that handle confidential information, such as financial apps, healthcare applications, and secure messaging platforms, must prevent unauthorized screen captures and recordings.

Flutter, by default, does not provide a built-in method to block screenshots or screen recording. However, by leveraging platform-specific implementations, we can enforce screen security efficiently.

This guide covers multiple approaches to prevent screenshots and screen recording in Flutter for Android and iOS, ensuring your app complies with security best practices.

If you’re looking for the best Flutter app development company for your mobile application then feel free to contact us at — support@flutterdevs.com.


Table of Contents:

Introduction

Why Prevent Screenshots and Screen Recording?

Methods to Prevent Screenshots and Screen Recording in Flutter

Code Implementation

Limitations

Future Scope

Conclusion


1. Why Prevent Screenshots and Screen Recording?

Apps that handle sensitive information (e.g., finance, messaging, healthcare) need protection against unauthorized screenshots and recordings. Some key reasons include:

  • Data Privacy: Prevent users from capturing sensitive content.
  • Data Protection: Restrict users from capturing sensitive content. Compliance with Security Regulations: Some industries mandate strict privacy policies (e.g., HIPAA, GDPR, PCI DSS).
  • Preventing Data Leaks: Screenshots of sensitive data can be shared easily, leading to security risks.
  • User Trust and Experience: Enhancing security ensures user confidence in using your app for confidential tasks.

2. Methods to Prevent Screenshots and Screen Recording in Flutter

Blocking screenshots and screen recording requires platform-specific configurations because Flutter does not provide a direct implementation method. The solutions vary for Android and iOS:

1. Using screen_protector Package (Flutter Plugin)

  • Platform: Android & iOS
  • Screenshots Blocked? Yes
  • Screen Recording Blocked? No
  • Implementation Complexity: Easy

Description:

  • The screen_protector the plugin prevents screenshots on both Android and iOS.
  • It does not prevent screen recording, but can notify when recording starts on iOS.
  • Simple and quick integration using a Flutter package.
  • Ideal for basic security needs where blocking screenshots is the priority.

2. Using FLAG_SECURE in Android

  • Platform: Android
  • Screenshots Blocked? Yes
  • Screen Recording Blocked? Yes
  • Implementation Complexity: Medium

Description:

  • The FLAG_SECURE flag in Android prevents both screenshots and screen recording at the system level.
  • Ensures full security but may cause issues with certain accessibility features.
  • Requires adding the flag at the Activity or Window level.
  • Best for financial, streaming, and secure content apps.

3. Using Black Overlay Trick (Android)

  • Platform: Android
  • Screenshots Blocked? No
  • Screen Recording Blocked? Yes
  • Implementation Complexity: Advanced

Description:

  • Instead of directly preventing recording, this method overlays a black transparent layer on top of the UI.
  • When screen recording is detected, the app replaces the UI with a black screen.
  • Requires more complex implementation but is useful when FLAG_SECURE is not an option.

4. Using UIScreen.capturedDidChangeNotification in iOS

  • Platform: iOS
  • Screenshots Blocked? No
  • Screen Recording Blocked? Yes (Detect Only)
  • Implementation Complexity: Medium

Description:

  • iOS does not allow blocking screen recording at the system level but provides an API to detect when recording starts.
  • Developers can use UIScreen.main.isCaptured to check for active screen recording.
  • When recording is detected, the app can:
  • Display a blur effect.
  • Hide sensitive content.
  • Show an alert.
  • Suitable for privacy-sensitive apps where warning the user is enough.

5. Using Transparent Overlay to Prevent Screenshots (iOS Only)

  • Platform: iOS
  • Screenshots Blocked? Yes
  • Screen Recording Blocked? No
  • Implementation Complexity: Medium

Description:

  • iOS does not provide a direct way to block screenshots.
  • A common workaround is placing a transparent overlay over the screen.
  • When a user takes a screenshot, the overlay appears in the screenshot instead of the actual content.
  • Best for hiding sensitive content from screenshots but does not prevent screen recording.

Key Takeaways:

  • The screen_protector package is the easiest option, but it does not block screen recording.
  • FLAG_SECURE in Android is the best solution for complete security.
  • The Black Overlay Trick can be used for more advanced Android security.
  • iOS allows only detection of screen recording, not blocking.
  • Using a transparent overlay in iOS is a good workaround to block screenshots.

Each method has its own advantages and limitations, and the best approach depends on your app’s security requirements.


3. Code Implementation:

Method 1: Using screen_protector Package (Easy Approach)

The screen_protector package provides a straightforward way to block screenshots and blur the app preview in the recent apps screen. However, it does not prevent screen recording.

Step 1: Install the Package

Add the dependency in pubspec.yaml:

dependencies:
screen_protector: ^1.4.2+1

Run:

flutter pub get

Step 2: Implement Screen Protection Service

Create a new file:
 📂 lib/services/screen_protection_service.dart

import 'package:screen_protector/screen_protector.dart';
class ScreenProtectionService {
  /// Enable screenshot protection and blur recent apps preview
  static Future<void> enableProtection() async {
    try {
      await ScreenProtector.preventScreenshotOn();
      await ScreenProtector.protectDataLeakageOn(); // Blurs recent apps preview
      print("Screen protection enabled");
    } catch (e) {
      print("Error enabling screen protection: $e");
    }
  }
 /// Disable screenshot protection
  static Future<void> disableProtection() async {
    try {
      await ScreenProtector.preventScreenshotOff();
      await ScreenProtector.protectDataLeakageOff();
      print("Screen protection disabled");
    } catch (e) {
      print("Error disabling screen protection: $e");
    }
  }
}

Step 3: Apply the Protection in main.dart

import 'package:flutter/material.dart';
import 'services/screen_protection_service.dart';

void main() {
  runApp(const MyApp());
  ScreenProtectionService.enableProtection();
}
class MyApp extends StatelessWidget {
  const MyApp({super.key});
@override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(title: const Text("Screen Protection Demo")),
        body: Center(
          child: ElevatedButton(
            onPressed: () async {
              await ScreenProtectionService.disableProtection();
            },
            child: const Text("Disable Protection"),
          ),
        ),
      ),
    );
  }
}

Prevents screenshots and blurs recent app preview
Does NOT block screen recording

Method 2: Using FLAG_SECURE in Android (Best for Android)

The FLAG_SECURE flag is the most effective way to prevent both screenshots and screen recordings on Android devices.

Step 1: Modify MainActivity.kt

📂 android/app/src/main/kotlin/com/example/yourapp/MainActivity.kt

import android.os.Bundle
import io.flutter.embedding.android.FlutterActivity
import android.view.WindowManager

class MainActivity: FlutterActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        window.setFlags(
            WindowManager.LayoutParams.FLAG_SECURE,
            WindowManager.LayoutParams.FLAG_SECURE
        )
    }
}

Prevents screenshots and screen recording on Android
Cannot be bypassed easily

Method 3: Detect Screen Recording on iOS

iOS does not provide a built-in method to block screen recording, but we can detect when a recording is in progress and take action.

Step 1: Modify AppDelegate.swift

📂 ios/Runner/AppDelegate.swift

import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {

NotificationCenter.default.addObserver(
self,
selector: #selector(screenRecordingChanged),
name: UIScreen.capturedDidChangeNotification,
object: nil
)

return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}

@objc func screenRecordingChanged() {
if UIScreen.main.isCaptured {
print("Screen recording detected! Taking necessary action.")
// Hide sensitive UI elements or log out user
}
}
}

Detects if screen recording is active on iOS
Cannot block screen recording automatically


4. Limitations

While blocking screenshots and screen recordings is a strong first step in protecting user data, developers must be aware of the inherent limitations of these methods and plan accordingly.

1. Cannot Prevent External Cameras

Even if your app successfully blocks all digital capture methods (screenshots, screen recordings), there’s no technical way to stop someone from using another physical device (like a phone or DSLR) to record your app screen. This is a physical-world limitation and needs non-technical mitigation strategies like watermarking or access restrictions.

2. Some Screen Recorders Can Bypass Restrictions

Certain third-party apps or system-level tools, especially on rooted Android or jailbroken iOS devices, can circumvent security flags like FLAG_SECURE. Although rare, this poses a potential loophole in your protection strategy. Developers targeting high-security apps (banking, fintech, confidential tools) should be cautious and consider app integrity checks (e.g., SafetyNet, App Attest).

3. Performance Considerations

Polling for screen capture states (like using UIScreen.main.isCaptured in iOS) frequently in real-time can introduce performance overhead. Developers should consider:

  • Listening to notification-based events instead of polling.
  • Throttling UI updates on detection.
  • Offloading detection logic to isolated components or background services.

4. Practical Workarounds

When traditional screen-blocking mechanisms fall short, here are some developer-centric solutions:

  • Watermarking Sensitive Screens
     Embed user information (username, timestamp) or generic watermarks to deter unauthorized sharing of screen recordings or screenshots.
  • AI-Powered Real-time Detection (Experimental)
     Train a model to detect unusual on-screen behavior or pixel duplication that resembles screen capture.
  • Blur or Mask Sensitive Content
     Temporarily replace confidential areas with placeholders when suspicious behavior is detected.

5. Future Scope

The security landscape continues to evolve. Developers should anticipate future threats and opportunities by staying proactive.

 1. AI-based External Camera Detection

In the near future, we might see machine learning models integrated into apps to analyze real-time camera feed reflections or light changes to detect potential external recording attempts — though privacy regulations could affect such capabilities.

2. Blockchain for Screen Data Integrity

For applications dealing with legal, financial, or intellectual property content, integrating blockchain can ensure that:

  • Access logs are immutable.
  • Any screen interaction (including screenshots) can be cryptographically traced and verified. This approach is not about prevention, but post-event accountability.

3. Evolving Flutter Plugins

As the Flutter ecosystem matures, we can expect:

  • Plugins that offer cross-platform UI masking.
  • Built-in screen detection hooks.
  • Integrations with native security APIs (like Android SafetyNet or iOS App Attest).

Flutter’s open-source nature and rapidly growing community make this space promising.

 6. Conclusion: 

Developer Takeaways

Preventing screenshots and screen recordings in Flutter is an essential aspect of app security, particularly for apps that deal with:

  • Financial data
  • Private conversations
  • Sensitive documents
  • Media rights protection (e.g., streaming platforms)

While no single method provides absolute protection, combining tools like:

  • screen_protector plugin
  • FLAG_SECURE flag
  • iOS detection APIs
  • UI-level overlays

…offers a multi-layered defense.

As developers, it’s our responsibility to:

  • Understand platform limitations
  • Stay updated on OS-level changes
  • Proactively add additional security layers such as authentication, encryption, watermarking, and access logging

Security is not a feature — it’s a process.

With the right strategies and ongoing vigilance, developers can greatly reduce the risks of data leaks and protect user trust.


❤ ❤ Thanks for reading this article ❤❤

If I got something wrong? Let me know in the comments. I would love to improve.

Clap 👏 If this article helps you.


From Our Parent Company Aeologic

Aeologic Technologies is a leading AI-driven digital transformation company in India, helping businesses unlock growth with AI automation, IoT solutions, and custom web & mobile app development. We also specialize in AIDC solutions and technical manpower augmentation, offering end-to-end support from strategy and design to deployment and optimization.

Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.

Feel free to connect with us:
And read more articles from FlutterDevs.com.

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire Flutter developer for your cross-platform Flutter mobile app project hourly or full-time as per your requirement! For any flutter-related queries, you can connect with us on Facebook, GitHub, Twitter, and LinkedIn.

We welcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.


How to Send Emails Using SMTP Integration in FlutterFlow?

0

Sending emails directly from your FlutterFlow app is a powerful way to enhance user experience — whether it’s for sending welcome messages, password recovery links, contact form submissions, or order confirmations. In this guide, you’ll learn how to send emails using SMTP (Simple Mail Transfer Protocol) integration in FlutterFlow.

🧩 What is SMTP?

SMTP stands for Simple Mail Transfer Protocol, and it’s the standard technology used to send emails across the internet. With SMTP integration in FlutterFlow, you can connect your app to popular email services like:

  • Gmail
  • Outlook
  • Zoho
  • Mailgun
  • SendGrid (with SMTP support)
  • Any custom SMTP server

When to Use SMTP in FlutterFlow

Use SMTP in FlutterFlow when you need to:

  • Send contact form responses
  • Trigger automated emails (welcome, verification, thank you)
  • Handle feedback or support tickets
  • Notify users of important actions

⚙️ Prerequisites

Before setting up SMTP in FlutterFlow:

  • You need access to an SMTP email service provider.
  • You need your SMTP credentials:
  • SMTP Host (e.g., smtp.gmail.com)
  • SMTP Port (usually 587 or 465)
  • Username (email address)
  • Password or App Password (for Gmail)
  • Sender email

🔐 Note: Never expose your SMTP credentials in public environments.

How to Configure SMTP in FlutterFlow?

Step 1: Go to the Actions Flow

  • Open your FlutterFlow project.
  • Select a widget (like a button) where the email should be triggered.
  • Go to the Actions tab.
  • Choose “Add Action” > Backend Call > Send Email (SMTP).

Step 2: Enter SMTP Configuration

You’ll be asked to provide the following details:

FieldDescriptionSMTP ServerE.g., smtp.gmail.comSMTP PortUsually 587 for TLS or 465 for SSLUsernameYour email addressPasswordApp-specific password (especially for Gmail)From EmailSender’s emailTo EmailRecipient’s email (can be user input)SubjectSubject of the emailBodyThe email message content (use dynamic values too)

Step 3: Test It

  • Deploy your app or run in test mode.
  • Trigger the email event (e.g., press a “Send” button).
  • Check the recipient inbox for the test email.

Troubleshooting Tips

  • Gmail SMTP Issue: You might need to enable 2FA and create an App Password for it to work.
  • Invalid Credentials: Double-check username and password.
  • Blocked Ports: Ensure the port (587 or 465) is open.
  • Spam Folder: Emails may land in spam during testing — mark them as not spam.

Security Best Practices

  • Never store SMTP credentials in plain text or expose them in your UI.
  • Use environment variables or Firebase Remote Config (if needed for advanced use cases).
  • Always use TLS/SSL encryption to send emails securely.

Use Case Examples

  1. Contact Us Form
  • Collects name, email, and message
  • Sends the form to your email using SMTP

2. Welcome Email

  • Triggered after a new user registers
  • Includes a custom greeting with their name

3. Order Confirmation

  • Sends a confirmation message after a product is purchased

Conclusion

FlutterFlow’s built-in SMTP email action makes it incredibly easy to send professional emails without writing any backend code. It’s perfect for automating communications, improving UX, and adding business-grade features to your FlutterFlow app.

With just a few steps, you can connect to Gmail, Outlook, or any SMTP-compatible service — and send real-time, dynamic emails directly from your app.

From Our Parent Company Aeologic

Aeologic Technologies is a leading AI-driven digital transformation company in India, helping businesses unlock growth with AI automation, IoT solutions, and custom web & mobile app development. We also specialize in AIDC solutions and technical manpower augmentation, offering end-to-end support from strategy and design to deployment and optimization.

Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.

Feel free to connect with us:
And read more articles from FlutterDevs.com.

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire Flutterflow developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! For any flutter-related queries, you can connect with us on Facebook, GitHub, Twitter, and LinkedIn.

We welcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.

Explore Decorator Design Pattern In Dart

0

One of the well-known design patterns, the Decorator one, explains how to design flexible and reusable object-oriented software by resolving common design issues. We’ll cover the decorator design pattern, a structural design pattern often referred to as a wrapper.

This blog will Explore Decorator Design Pattern In Dart. We see how to execute a demo program in your applications.

If you’re looking for the best Flutter app development company for your mobile application then feel free to contact us at — support@flutterdevs.com.


Table Of Contents::

What is the Decorator Design Pattern?

When to use?

Code Implement

Drawbacks

Conclusion



What is the Decorator Design Pattern?:

“Design Patterns, Elements of Reusable Object-Oriented Software,” a book, dynamically assigns additional responsibilities to an object. When it comes to expanding functionality, decorators offer a flexible alternative to subclassing.

Let’s try to understand this with a real-world example that might make more sense: suppose you order a plain coffee from a coffee shop. Here, coffee acts as a class object. You want to spice up your coffee now. You request that some milk be added. The barista pours some milk into your coffee. Here, the milk enhances your coffee without altering it in any way.

You decide later that you also want some sugar. Sugar is added to your coffee by the barista. Another decorator is sugar. It enhances your coffee even more without altering the milk or coffee.

In this scenario, your coffee is the object, and milk and sugar are the decorators. To put it more succinctly, the Decorator design pattern does not alter the structure of objects but rather adds new functionality to them.

When to use?:

  • When would you like to add new responsibilities to an object transparently and dynamically?
  • Because there are too many separate extensions, subclassing is not a realistic way to increase functionality.
  • When would you like to assign tasks to objects in layers or phases?
  • When you need to add optional functionality but yet want to keep a class focused on a particular task.

Code Implement:

A basic coffee is called plain coffee. Asking the barista to add more milk or sugar is what ExtraMilkDecorator and ExtraSugarDecorator do. Without changing the original PlainCoffee, they can modify the coffee’s price and description.

abstract class Coffee {
  String get description;
  double get cost;
}

class PlainCoffee implements Coffee {
  @override
  String get description => 'Plain Coffee';

  @override
  double get cost => 60.0;
}

class CoffeeDecorator implements Coffee {
  final Coffee coffee;
  CoffeeDecorator(this.coffee);

  @override
  String get description => coffee.description;

  @override
  double get cost => coffee.cost;
}

class ExtraMilkDecorator extends CoffeeDecorator {
  ExtraMilkDecorator(super.coffee);

  @override
  String get description => '${coffee.description} + Extra Milk';

  @override
  double get cost => coffee.cost + 15.0;
}

class ExtraSugarDecorator extends CoffeeDecorator {
  ExtraSugarDecorator(super.coffee);

  @override
  String get description => '${coffee.description} + Extra Sugar';

  @override
  double get cost => coffee.cost + 20.0;
}

void main() {
  Coffee coffee = PlainCoffee();
  print("${coffee.description}: \$${coffee.cost}");

  coffee = ExtraMilkDecorator(coffee);
  print("${coffee.description}: \$${coffee.cost}");

  coffee = ExtraSugarDecorator(coffee);
  print("${coffee.description}: \$${coffee.cost}");
}

When we run the application, we ought to get the screen’s output like the underneath console output.

Plain Coffee: $60.0
Plain Coffee + Extra Milk: $75.0
Plain Coffee + Extra Milk + Extra Sugar: $95.0

Process finished with exit code 0

Drawbacks:

  • A complicated codebase that is difficult to maintain can result from overusing the Decorator pattern.
  • A more complex class hierarchy is produced by creating multiple minor classes for every new functionality.
  • It necessitates numerous small classes, all of which are fairly similar to one another, potentially making the design unduly complex.

Conclusion:

In the article, I have explained the Decorator Design Pattern basic structure in a dart; you can modify this code according to your choice. This was a small introduction to the Decorator Design Pattern On User Interaction from my side, and it’s working using Dart.

I hope this blog will provide you with sufficient information on trying the Explore Decorator Design Pattern In Dart in your projects. One of the most widely used design patterns for dynamically adding additional functionality to an object without altering its structure is the Decorator pattern.

It provides a versatile substitute for subclassing, especially when handling numerous independent extensions.ut it’s crucial to utilise this approach sparingly because excessive use might result in a complicated and challenging-to-maintain codebase. Despite these difficulties, the Decorator design can greatly improve your code’s readability and modularity when applied properly. So please try it.

❤ ❤ Thanks for reading this article ❤❤

If I got something wrong? Let me know in the comments. I would love to improve.

Clap 👏 If this article helps you.


From Our Parent Company Aeologic

Aeologic Technologies is a leading AI-driven digital transformation company in India, helping businesses unlock growth with AI automation, IoT solutions, and custom web & mobile app development. We also specialize in AIDC solutions and technical manpower augmentation, offering end-to-end support from strategy and design to deployment and optimization.

Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.

Feel free to connect with us:
And read more articles from FlutterDevs.com.

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire Flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! For any flutter-related queries, you can connect with us on FacebookGitHubTwitter, and LinkedIn.

We welcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.


Implement Folding Scroll In Flutter

Flutter, almost everything is a widget — even format models are widgets. The photos, symbols, and text in a Flutter application are on the widgets. Anyway, things you don’t see are extra widgets, similar to the rows, columns, and grids that arrange, oblige and align the conspicuous widgets.

In this blog, we will explore implementing a Folding Scroll In Flutter. We will see how to implement a demo program of the folding scroll and create a folding (horizontal) scroll of a list view using PageView.builder in your Flutter applications.

If you’re looking for the best Flutter app development company for your mobile application then feel free to contact us at — support@flutterdevs.com.


Table Of Contents:

Introduction

Constructor

Properties

Code Implement

Code File

Conclusion

GitHub Link



Introduction:

PageView.builder makes a scrollable list that works page by page utilizing widgets spurred on interest. This constructor is proper for page visits with an enormous (or boundless) number of children because the builder is called exclusively for those children that are noticeable.

Giving a non-null itemCount allows the PageView to figure the most extreme scroll extent.

Demo Module::

The above demo video shows how to implement Folding Scroll in a flutter. It shows how the Folding Scroll will work using the PageView.builder in your flutter applications. It shows when the user swipe left to right then, images will scroll and overlap with other images. It will be shown on your device.

Constructor:

To utilize PageView.builder, you need to call the constructor underneath:

PageView.builder({
Key? key,
this.scrollDirection = Axis.horizontal,
this.reverse = false,
PageController? controller,
this.physics,
this.pageSnapping = true,
this.onPageChanged,
required IndexedWidgetBuilder itemBuilder,
ChildIndexGetter? findChildIndexCallback,
int? itemCount,
this.dragStartBehavior = DragStartBehavior.start,
this.allowImplicitScrolling = false,
this.restorationId,
this.clipBehavior = Clip.hardEdge,
this.scrollBehavior,
this.padEnds = true,
})

All fields marked with @required must not be empty in the above Constructor.

Properties:

There are some properties of PageView.builder are:

  • > itemBuilder: This property is called only with indices greater than or equal to zero and less than itemcount.
  • > restorationId: This property is used to take in a string as the object. It is used to save the scroll position and later restore it.
  • > clipBehavior: This property is used to the content will be clipped (or not) according to this option.
  • > padEnds: This property is used to add padding to both ends of the list.
  • > scrollDirection: This property is used to the axis along which the page view scrolls. Defaults to [Axis.horizontal].
  • > onPageChanged: This property is used to call whenever the page in the center of the viewport changes.

Implementation:

Step 1: Add the assets

Add assets to pubspec — yaml file.

assets:
- assets/

Step 2: Run flutter packages get in the root directory of your app.

How to implement code in dart file :

You need to implement it in your code respectively:

Create a new dart file called dummy_data_model.dart inside the lib folder.

In this dart file, we will create a dummyDataModel. Inside we will add the array of the item.

var dummyDataModel = [
"assets/demo_1.png",
"assets/img.png",
"assets/logo.png",
"assets/demo_2.png",
"assets/powered_by.png",
"assets/demo_3.png",
"assets/demo_4.png",
];

Create a new dart file called page_view_item.dart inside the lib folder.

In this dart file, we will create PageViewItem class. In this class, we will add int index, string image, and double width. In the build method, we will return Inkwell. Inside, we will add onTap and its child we will add a Card widget. In this widget, we will add elevation, shape, and Image. asset().

import 'package:flutter/material.dart';

class PageViewItem extends StatelessWidget {
final int index;
final String img;
final double width;

const PageViewItem({
Key? key,
required this.index,
required this.width,
required this.img,
}) : super(key: key);

@override
Widget build(BuildContext context) {
return InkWell(
onTap: () => print(index),
child: Card(
elevation: 8,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(1.0),
),
child: Image.asset(
img,
fit: BoxFit.fill,
width: width,
),
),
);
}
}

Create a new dart file called home_page.dart inside the lib folder.

First, we will create a double variable _page equal to zero, and the index of the left-most element of it to be displayed.

double _page = 0;
int get _firstItemIndex => _page.toInt();

Presently, we configure our page view and make the PageController where we give the viewportFraction. It characterizes the negligible portion of the viewport that each page ought to possess. Defaults to 1.0, implying each page fills the viewport in the looking over heading.

final _controller = PageController(
viewportFraction: 0.5,
);

Now, we will calculate the width of the single items on the pageview.

late final _itemWidth =
MediaQuery.of(context).size.width * _controller.viewportFraction;

Then, we will create an initState() method. In this method, we will add the controller inside the initState.

@override
void initState() {
super.initState();
_controller.addListener(() => setState(() {
_page = _controller.page!;
}));
}

In the body, we will add a Column widget with crossAxisAlignment and mainAxisAlignment as the center. Inside, the widget we will add the Stack widget.

Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(height: 10,),
Stack(
children: [
Positioned.fill(
child: Align(
alignment: Alignment.centerLeft,
child: SizedBox(
height: 200,
width: _itemWidth,
child: FractionallySizedBox(
child: PageViewItem(
index: _firstItemIndex,
width: _itemWidth,
img: dummyDataModel[_firstItemIndex],
),
),
),
),
),
SizedBox(
height: 200,
child: PageView.builder(
padEnds: false,
controller: _controller,
itemBuilder: (context, index) {
return Opacity(
opacity: index <= _firstItemIndex ? 0 : 1,
child: PageViewItem(
index: index,
width: _itemWidth,
img: dummyDataModel[index],
),
);
},
itemCount: dummyDataModel.length,
),
),
],
),
],
),

In this Stack widget, we will add FractionallySizedBox. Inside, we will add PageViewItem class. In this class, we will add index, width, and img. Then, we will add SizedBox with height. Its child, we will add PageView.builder. Inside, we will add padEnds, controller, itemBuilder and itemCount.

When we run the application, we ought to get the screen’s output like the underneath screen capture.

Final Output

Code File:

import 'package:flutter/material.dart';

import 'dummy_data_model.dart';
import 'page_view_item.dart';

class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);

@override
State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
double _page = 0;

int get _firstItemIndex => _page.toInt();

final _controller = PageController(Hire flutter developer
viewportFraction: 0.5,
);

late final _itemWidth =
MediaQuery.of(context).size.width * _controller.viewportFraction;

@override
void initState() {
super.initState();
_controller.addListener(() => setState(() {
_page = _controller.page!;
}));
}

@override
void dispose() {
super.dispose();
}

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[200],
appBar: AppBar(
automaticallyImplyLeading: false,
title: const Text("Flutter Folding Scroll Demo"),
backgroundColor: Colors.cyan,
centerTitle: true,
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(
height: 10,
),
Stack(
children: [
Positioned.fill(
child: Align(
alignment: Alignment.centerLeft,
child: SizedBox(
height: 200,
width: _itemWidth,
child: FractionallySizedBox(
child: PageViewItem(
index: _firstItemIndex,
width: _itemWidth,
img: dummyDataModel[_firstItemIndex],
),
),
),
),
),
SizedBox(
height: 200,
child: PageView.builder(
padEnds: false,
controller: _controller,
itemBuilder: (context, index) {
return Opacity(
opacity: index <= _firstItemIndex ? 0 : 1,
child: PageViewItem(
index: index,
width: _itemWidth,
img: dummyDataModel[index],
),
);
},
itemCount: dummyDataModel.length,
),
),
],
),
],
),
);
}
}

Conclusion:

In the article, I have explained the basic structure of Folding Scroll in a flutter; you can modify this code according to your choice. This was a small introduction to Folding Scroll On User Interaction from my side, and it’s working using Flutter.

I hope this blog will provide you with sufficient information on trying up the Folding Scroll in your Flutter projects. We will show you what an Introduction is?. Show the properties and constructor of Folding Scroll. Make a demo program for working in your Flutter applications. So please try it.

❤ ❤ Thanks for reading this article ❤❤

If I got something wrong? Let me know in the comments. I would love to improve.

Clap 👏 If this article helps you.


GitHub Link:

find the source code of the Flutter Folding Scroll Demo:

GitHub – flutter-devs/flutter_folding_scroll_demo
A new Flutter project. This project is a starting point for a Flutter application. A few resources to get you started…github.com


From Our Parent Company Aeologic

Aeologic Technologies is a leading AI-driven digital transformation company in India, helping businesses unlock growth with AI automation, IoT solutions, and custom web & mobile app development. We also specialize in AIDC solutions and technical manpower augmentation, offering end-to-end support from strategy and design to deployment and optimization.

Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.

Feel free to connect with us:
And read more articles from FlutterDevs.com.

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! For any flutter-related queries, you can connect with us on FacebookGitHubTwitter, and LinkedIn.

We welcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.


Stripe Subscriptions in Flutter

0

Introduction

Subscription-based monetization models have gained significant traction in the mobile app industry, enabling businesses to establish a sustainable revenue stream while offering premium content, exclusive features, or ongoing services to users. Instead of relying on one-time purchases, subscriptions allow developers to maintain a steady income while providing users a seamless experience.

Stripe is one of the most powerful and developer-friendly payment gateways available. It is known for its robust security features, seamless integration capabilities, and support for various payment methods. Businesses widely use it for recurring billing and subscription management.

In this guide, we will walk through the step-by-step process of implementing Stripe subscriptions in a Flutter application. The tutorial will cover:

  • Setting up a Stripe account and configuring subscription products
  • Integrating Stripe’s payment gateway in a Flutter app
  • Implementing a backend service for handling subscriptions
  • Managing subscription cancellations, upgrades, and downgrades
  • Following best practices for efficient subscription-based monetization
  • Comparing Stripe with alternative payment solutions
  • Identifying limitations and exploring the future scope of subscription payments

By the end of this guide, you will have a fully functional subscription model integrated into your Flutter application.

If you’re looking for the best Flutter app development company for your mobile application then feel free to contact us at — support@flutterdevs.com.


Table of Contents

Introduction

Setting Up Stripe for Subscriptions

Integrating Stripe Subscriptions in Flutter

Limitations of Stripe Subscriptions

Best Practices for Subscription Implementation

Future Scope of Subscription Payments

Conclusion

Reference


1. Setting Up Stripe for Subscriptions

Before integrating Stripe subscriptions into Flutter, it is necessary to configure the Stripe platform, create a subscription product, and obtain essential API keys.

Step 1.1: Create a Stripe Account

To get started, create an account on Stripe’s official website. This process involves business verification and requires the submission of basic business details.

  1. Visit the Stripe website and sign up for an account.
  2. Complete the business verification process, including linking a bank account for payouts.
  3. Navigate to the Developers section and locate the API Keys tab.
  4. Note down the following keys:
  • Publishable Key: Used in the Flutter frontend for initializing Stripe.
  • Secret Key: Used in the backend to securely process transactions.

Step 1.2: Enable Stripe Billing and Create a Subscription Product

Stripe Billing is the service responsible for handling recurring payments. It enables businesses to set up subscriptions with flexible pricing models.

  1. Log in to the Stripe Dashboard and go to the Billing section.
  2. Click on Products and then select Add a Product.
  3. Enter details such as:
  • Product Name (e.g., “Premium Membership”)
  • Description (e.g., “Unlock exclusive app features with a monthly subscription.”)
  • Pricing Model: Choose Recurring
  • Billing Cycle: Select Monthly or Yearly

4. Save the product and copy the generated Price ID, as it will be needed when creating subscriptions in Flutter.


2. Integrating Stripe Subscriptions in Flutter

Now that Stripe is set up, we will integrate it into a Flutter application by installing the necessary dependencies and configuring the payment flow.

Step 2.1: Install Required Dependencies

To integrate Stripe, add the following dependencies in your pubspec.yaml file:

dependencies:
flutter_stripe: ^10.0.0
http: ^0.14.0
provider: ^6.0.0

Run the following command to install the packages:

flutter pub get

Step 2.2: Initialize Stripe in Flutter

To enable Stripe’s functionality in the Flutter app, initialize it in main.dart using the publishable key obtained earlier.

import 'package:flutter_stripe/flutter_stripe.dart';
import 'package:flutter/material.dart';

void main() {
Stripe.publishableKey = "your_publishable_key_here";
runApp(MyApp());
}

Step 2.3: Setting Up a Backend for Subscription Management

Stripe requires backend logic to handle customer creation, subscription activation, and billing. This backend can be implemented using Node.js, Firebase Functions, or Python.

Example: Backend API for Creating a Subscription (Node.js)

const express = require("express");
const stripe = require("stripe")("your_secret_key");

const app = express();
app.use(express.json());

app.post("/create-subscription", async (req, res) => {
try {
const customer = await stripe.customers.create({
email: req.body.email,
});

const subscription = await stripe.subscriptions.create({
customer: customer.id,
items: [{ price: "price_id_from_stripe_dashboard" }],
expand: ["latest_invoice.payment_intent"],
});

res.json({ subscriptionId: subscription.id });
} catch (error) {
res.status(500).send(error.message);
}
});

app.listen(3000, () => console.log("Server running on port 3000"));

Step 2.4: Handling Subscription Payment in Flutter

Once the backend API is in place, call it from the Flutter app to initiate a subscription.

import 'package:flutter_stripe/flutter_stripe.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';

Future<void> createSubscription(String email) async {
try {
final response = await http.post(
Uri.parse("https://your-backend.com/create-subscription"),
body: jsonEncode({"email": email}),
headers: {"Content-Type": "application/json"},
);

final data = jsonDecode(response.body);
print("Subscription successfully created: ${data["subscriptionId"]}");
} catch (error) {
print("Error creating subscription: $error");
}
}

Step 2.5: Managing Subscriptions (Cancellation & Modifications)

To enhance the user experience, we should allow users to cancel, upgrade, or downgrade their subscriptions.

Cancel a Subscription (Backend — Node.js)

app.post("/cancel-subscription", async (req, res) => {
try {
await stripe.subscriptions.update(req.body.subscriptionId, {
cancel_at_period_end: true,
});
res.json({ message: "Subscription cancellation scheduled" });
} catch (error) {
res.status(500).send(error.message);
}
});

Flutter Function to Cancel a Subscription

Future<void> cancelSubscription(String subscriptionId) async {
try {
final response = await http.post(
Uri.parse("https://your-backend.com/cancel-subscription"),
body: jsonEncode({"subscriptionId": subscriptionId}),
headers: {"Content-Type": "application/json"},
);

final data = jsonDecode(response.body);
print(data["message"]);
} catch (error) {
print("Error canceling subscription: $error");
}
}

3. Limitations of Stripe Subscriptions

  1. Backend Dependency: Stripe subscriptions require a backend for creating customers, handling payment events, and managing renewals.
  2. Compliance Requirements: Applications using Stripe must adhere to PCI-DSS security standards and SCA authentication for payments.
  3. Regional Restrictions: Stripe is not available in some countries, limiting its global accessibility.
  4. Webhook Management: Developers must implement webhook listeners to handle real-time updates regarding subscription status.

4. Best Practices for Subscription Implementation

  1. Use Test Mode Before Deployment: Stripe provides test keys to simulate transactions before going live.
  2. Handle Payment Failures Gracefully: Implement retry mechanisms and notify users when payments fail.
  3. Monitor Webhooks for Real-Time Updates: Webhooks help in tracking subscription renewals, cancellations, and failures.
  4. Allow Easy Cancellations to Maintain Trust: Users should be able to cancel their subscription without friction.
  5. Secure API Keys and Payment Data: Never expose Stripe’s secret key in the frontend. Use backend authentication for handling payments.

5. Future Scope of Subscription Payments

  1. Artificial Intelligence in Pricing Models: AI-driven pricing strategies can personalize subscription plans based on user behavior.
  2. Blockchain-Based Payments: Cryptocurrency transactions for subscriptions could enhance transparency and reduce processing fees.
  3. Serverless Payment Handling: Payment systems may shift towards fully serverless architectures, simplifying implementation.
  4. Cross-App Subscription Bundling: Users may be able to purchase a single subscription covering multiple services across different applications.

6. Conclusion

Stripe simplifies subscription-based payments in Flutter, providing a secure and efficient solution. With its global reach, automated billing management, and developer-friendly APIs, it remains a top choice for subscription-based applications. Following best practices and optimizing ad placements can ensure higher conversion rates and long-term customer retention.

7. Reference

flutter_stripe | Flutter package
Flutter library for Stripe. Supports PaymentSheets, Apple & Google Pay, SCA, PSD2 and much more.pub.dev

Flutter Stripe
Flutter library for Stripe.docs.page


❤ ❤ Thanks for reading this article ❤❤

If I got something wrong? Let me know in the comments. I would love to improve.

Clap 👏 If this article helps you.


From Our Parent Company Aeologic

Aeologic Technologies is a leading AI-driven digital transformation company in India, helping businesses unlock growth with AI automation, IoT solutions, and custom web & mobile app development. We also specialize in AIDC solutions and technical manpower augmentation, offering end-to-end support from strategy and design to deployment and optimization.

Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.

Feel free to connect with us:
And read more articles from FlutterDevs.com.

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire Flutter developer for your cross-platform Flutter mobile app project hourly or full-time as per your requirement! For any flutter-related queries, you can connect with us on Facebook, GitHub, Twitter, and LinkedIn.

We welcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.


Implementing State Management in FlutterFlow

State management is a crucial part of any Flutter or FlutterFlow application. It refers to how you manage and maintain the state of your UI components — essentially how your app responds to user interactions, backend updates, and internal logic changes. In FlutterFlow, managing state becomes easier thanks to its built-in tools and visual interface.

Let’s walk through the essentials of state management in FlutterFlow, the available tools, and how you can implement it effectively in your project.

What is State in FlutterFlow?

In simple terms, state is any data that can change in your app — like user input, page navigation, visibility of a widget, toggle switches, or fetched data from APIs or Firebase. FlutterFlow offers multiple ways to handle and update this data without having to write complex Flutter code manually.

🛠Types of State Management in FlutterFlow

1. Local State (UI State)

Local State is used to manage state within a specific page or widget. For example, toggling a switch or showing/hiding a container based on a boolean value.

  •  Ideal for: temporary state, like modal visibility or tab selection.
  •  Managed directly using FlutterFlow’s Variables panel under Page State.

Example:

  • You can create a local boolean variable like isVisible to control whether a widget is shown or hidden.
  • Update this variable on button tap, and the UI will rebuild accordingly.

2. App State (Global State)

App State is used to manage global variables that need to persist and be shared across different pages/screens.

  •  Ideal for: user authentication info, selected language, user preferences.
  • Accessible anywhere in your app.

Example:

When a user logs in, store their username and userID in App State. These can then be used on different screens like profile, dashboard, or order history.

3. Firebase-Connected State

If you’re using Firebase, FlutterFlow offers powerful tools to bind your UI elements directly to Firebase collections and documents.

  •  Ideal for: displaying live data such as user profiles, product listings, orders, etc.
  • Automatically updates when the backend changes (real-time sync with Firebase).

Example:

Display a list of products from a Firestore collection using a ListView connected to a Firebase query.

4. Custom Functions (Advanced State Updates)

If you need more control, you can define custom functions in Dart within FlutterFlow. These functions can modify state, perform calculations, or run conditional logic.

  •  Ideal for: complex state changes, API data manipulation, calculations.
  • ⚙️ Use them inside Actions → Run Custom Function.

5. Bloc Pattern (For Advanced Flutter Developers)

While FlutterFlow simplifies state management, advanced users may integrate Bloc/Cubit using the Custom Code section. This is ideal for teams who want fine-grained control and clean architecture.

How to Use State Variables in FlutterFlow Step-by-Step:

1. Create a State Variable

  • Go to the Variables panel.
  • Choose Local, App, or Component State.
  • Name your variable and assign an initial value.

2. Update the State

  • Use the Action Editor to modify state (e.g., on button press → Update Variable).

3. Bind State to Widgets

  • Use the variable in visibility conditions, text values, or widget properties.

4. Observe State Changes

  • FlutterFlow will automatically update the UI when the state changes.

Real-Life Use Cases

  • Toggle between light/dark mode using a state variable.
  • Update cart items in an e-commerce app using local state variables.
  • Store user login info in App State for persistent access.
  • Fetch and display user profile details from Firebase using state-driven widgets.

Best Practices

  • Use Local State for page-specific or temporary UI behavior.
  • Use App State for global data you need across the app.
  • Keep Firebase collections optimized for fast querying and updates.
  • Group state logically and use meaningful names for clarity.

Conclusion

State management may seem complex at first, but FlutterFlow simplifies the process with a visual and intuitive approach. Whether you’re creating a basic form or a dynamic, real-time dashboard, managing state correctly is key to building responsive and efficient apps.

By leveraging FlutterFlow’s built-in state tools, you can develop scalable and user-friendly applications—without diving deep into boilerplate code. And for more advanced needs, FlutterFlow offers the flexibility to integrate custom Dart logic, giving you the best of both no-code and low-code development.

From Our Parent Company Aeologic

Aeologic Technologies is a leading AI-driven digital transformation company in India, helping businesses unlock growth with AI automation, IoT solutions, and custom web & mobile app development. We also specialize in AIDC solutions and technical manpower augmentation, offering end-to-end support from strategy and design to deployment and optimization.

Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.

Feel free to connect with us:
And read more articles from FlutterDevs.com.

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire Flutterflow developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! For any flutter-related queries, you can connect with us on Facebook, GitHub, Twitter, and LinkedIn.

We welcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.

Dismissible In Flutter

0

In Flutter, assuming you want to make a widget that can be dismissed, you can wrap the widget as the child of Dismissible. A dismissible Widget in Flutter is typically used to wrap each list item with the goal that it tends to be excused, either horizontally or vertically direction.

This blog will explore the Dismissible In Flutter. We perceive how to execute a demo program. We will figure out how to utilize the widget, including how to show the confirmation dialog, set backgrounds that will be shown when the child is being dismissed, and set dismissed directions in your Flutter applications.

If you’re looking for the best Flutter app development company for your mobile application then feel free to contact us at — support@flutterdevs.com.


Table Of Contents::

Introduction

Constructor

Properties

Code Implement

Code File

Conclusion



Introduction:

A widget can be dismissed by dragging in the demonstrated direction. Dragging or hurling this widget in the DismissDirection makes the child slide out of view.

Demo Module ::

This demo video shows how to use the dismissible in a flutter and shows how a dismissible will work in your flutter applications. We will show a user dragging or fingering by dismissing a widget. It will be shown on your devices.

Constructor:

To utilize Dismissible, you need to call the constructor underneath:

You are required to pass the key (Key) and child (Widget). key turns out to be vital since the widget can be taken out from the widget list. If there are different dismissible widgets, ensure each has a unique key.

const Dismissible({
required Key key,
required this.child,
this.background,
this.secondaryBackground,
this.confirmDismiss,
this.onResize,
this.onUpdate,
this.onDismissed,
this.direction = DismissDirection.horizontal,
this.resizeDuration = const Duration(milliseconds: 300),
this.dismissThresholds = const <DismissDirection, double>{},
this.movementDuration = const Duration(milliseconds: 200),
this.crossAxisEndOffset = 0.0,
this.dragStartBehavior = DragStartBehavior.start,
this.behavior = HitTestBehavior.opaque,
})

Be mindful not to involve the index as a key as dismissing a widget can change the index of different widgets. The second required property is a child where you want to pass the widget that can be dismissed.

Another significant property is onDismissed. It’s a callback function tolerating one boundary of type DismissDirection. Inside, you can characterize what to do after the widget has been dismissed. For instance, you can eliminate the widget from the list.

Properties:

There are some properties of Dismissible are:

  • > key — This property is used to control if it should be replaced.
  • > child — This property is used below this widget in the tree.
  • > background — This property is used to stack behind the child. It secondaryBackground is set, it’s only shown when the child is being dragged down or to the right.
  • secondaryBackground — This property is used to stack behind the child. It’s only shown when the child is being dragged up or to the left.
  • > confirmDismiss— This property is used to allow the app to confirm or veto a pending dismissal.
  • > onResize — This property is used for the callback that will be called when the widget changes size.
  • > onDismissed — This property is used for the callback that will be called when the widget has been dismissed.
  • > direction — This property is used to the direction in which the widget can be dismissed. Defaults to DismissDirection.horizontal.
  • > resizeDuration — This property is used to the amount of time the widget will spend contracting before onDismissed is called. Defaults to const Duration(milliseconds: 300).
  • > dismissThresholds — This property is used to the offset threshold the item has to be dragged to be considered dismissed. Defaults to const <DismissDirection, double>{}.
  • > movementDuration — This property is used to the duration to dismiss or back to the original position if not dismissed. Defaults to const Duration(milliseconds: 200).
  • > crossAxisEndOffset — This property is used to the end offset across the main axis after the card is dismissed. Defaults to 0.0.
  • > dragStartBehavior — This property is used for how the drag start behavior is handled. Defaults to DragStartBehavior.start.

How to implement code in dart file :

You need to implement it in your code respectively:

Create a new dart file called main.dart inside the lib folder.

We will make a basic ListView where the thing can be dismissed. The ListView is made utilizing the accompanying values.

 List<String> items = [
"Watch",
"Jeans",
"Shirt",
"T-Shirt",
"Cup",
"Shoes",
"Cap",
"Shorts",
"Trouser",
"Lower",
];

Here is the code for building the ListView. The itemBuilder, which is utilized to construct the list of items, returns a Dismissible. Notwithstanding the required arguments (key and child), an onDismissed callback is additionally passed. The model tells you the best way to set various actions for every direction.

ListView.builder(
itemCount: items.length,
padding: const EdgeInsets.symmetric(vertical: 16),
itemBuilder: (BuildContext context, index) {
return Dismissible(
key: Key('item ${items[index]}'),
onDismissed: (DismissDirection direction) {
if (direction == DismissDirection.startToEnd) {
print("Add to favorite");
} else {
print('Remove item');
}

setState(() {
items.removeAt(index);
});
},
child: ListTile(
leading: const Icon(
Icons.card_giftcard_rounded,
color: Colors.black,
),
title: Text(
items[index],
style: TextStyle(
color: Colors.black.withOpacity(.6), fontSize: 18),
),
subtitle: Text(
"This Gift is For you",
style: TextStyle(color: Colors.green.withOpacity(.6)),
),
),
);
}
),

When we run the application, we ought to get the screen’s output like the underneath screen capture.

Output

> Showing Confirmation

Dismissible is frequently utilized for deleting an activity. On the off chance that you think the performed activity is critical and can’t be scattered, it’s smarter to show affirmation before the activity is characterized inside onDismissed is performed.

You can do it by passing confirmDismissCallback to the constructor. A callback acknowledges one parameter of type DismissDirection and returns Future<bool>. The below model shows an AlertDialog where the client can confirm to delete the item or cancel the action.

confirmDismiss: (DismissDirection direction) async {
return await showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("Remove Gift"),
content: const Text("Are you sure you want to remove this item?"),
actions: <Widget>[
ElevatedButton(
onPressed: () => Navigator.of(context).pop(true),
child: const Text("Yes")),
ElevatedButton(
onPressed: () => Navigator.of(context).pop(false),
child: const Text("No"),
),
],
);
},
);
}

> Setting Backgrounds

The default dismiss direction is horizontal. You can swipe to the right or left. Swiping left or right might result in an alternate action, relying upon what you characterize in the onDismissed callback. Flutter additionally permits you to set various widgets that will be shown when the child is being dismissed.

Utilize the background to characterize the widget to be shown when the child is swiped to the right and the secondary background for the widget when the child is swiped to the left. Assuming you just set the background, it will be utilized for the two directions.

background: Container(
color: Colors.blue,
child: Padding(
padding: const EdgeInsets.all(15),
child: Row(
children: const [
Icon(Icons.favorite, color: Colors.red),
SizedBox(
width: 8.0,
),
Text('Move to favorites',
style: TextStyle(color: Colors.white)),
],
),
),
),
secondaryBackground: Container(
color: Colors.red,
child: Padding(
padding: const EdgeInsets.all(15),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: const [
Icon(Icons.delete, color: Colors.white),
SizedBox(
width: 8.0,
),
Text('Move to trash',
style: TextStyle(color: Colors.white)),
],
),
),
),

When we run the application, we ought to get the screen’s output like the underneath screen capture.

Final Output

Code File:

import 'package:flutter/material.dart';
import 'package:flutter_dismissible_demo/splash_screen.dart';

void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primarySwatch: Colors.teal,
),
debugShowCheckedModeBanner: false,
home: const Splash(),
);
}
}

class DismissibleDemo extends StatefulWidget {
const DismissibleDemo({Key? key}) : super(key: key);

@override
State<DismissibleDemo> createState() => _DismissibleDemoState();
}

class _DismissibleDemoState extends State<DismissibleDemo> {
List<String> items = [
"Watch",
"Jeans",
"Shirt",
"T-Shirt",
"Cup",
"Shoes",
"Cap",
"Shorts",
"Trouser",
"Lower",
];

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.teal,
centerTitle: true,
automaticallyImplyLeading: false,
title: const Text("Flutter Dismissible Demo"),
),
body: ListView.builder(
itemCount: items.length,
padding: const EdgeInsets.symmetric(vertical: 16),
itemBuilder: (BuildContext context, int index) {
return Dismissible(
background: Container(
color: Colors.blue,
child: Padding(
padding: const EdgeInsets.all(15),
child: Row(
children: const [
Icon(Icons.favorite, color: Colors.red),
SizedBox(
width: 8.0,
),
Text('Move to favorites',
style: TextStyle(color: Colors.white)),
],
),
),
),
secondaryBackground: Container(
color: Colors.red,
child: Padding(
padding: const EdgeInsets.all(15),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: const [
Icon(Icons.delete, color: Colors.white),
SizedBox(
width: 8.0,
),
Text('Move to trash',
style: TextStyle(color: Colors.white)),
],
),
),
),
key: ValueKey<String>(items[index]),
onDismissed: (DismissDirection direction) {
setState(() {
items.removeAt(index);
});
},
confirmDismiss: (DismissDirection direction) async {
if (direction == DismissDirection.startToEnd) {
return await showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("Add Gift to Cart"),
content: const Text(
"Are you sure you want to add this gift in your cart"),
actions: <Widget>[
ElevatedButton(
onPressed: () => Navigator.of(context).pop(true),
child: const Text("Yes")),
ElevatedButton(
onPressed: () => Navigator.of(context).pop(false),
child: const Text("No"),
),
],
);
},
);
} else {
return await showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("Remove Gift"),
content: const Text(
"Are you sure you want to remove this gift item?"),
actions: <Widget>[
ElevatedButton(
onPressed: () => Navigator.of(context).pop(true),
child: const Text("Yes")),
ElevatedButton(
onPressed: () => Navigator.of(context).pop(false),
child: const Text("No"),
),
],
);
},
);
}
},
child: ListTile(
leading: const Icon(
Icons.card_giftcard_rounded,
color: Colors.black,
),
title: Text(
items[index],
style: TextStyle(
color: Colors.black.withOpacity(.6), fontSize: 18),
),
subtitle: Text(
"This Gift is For you",
style: TextStyle(color: Colors.green.withOpacity(.6)),
),
),
);
},
));
}
}

Conclusion:

In the article, I have explained the Dismissible basic structure in a flutter; you can modify this code according to your choice. This was a small introduction to Dismissible User Interaction from my side, and it’s working using Flutter.

I hope this blog will provide you with sufficient information on Trying the Dismissible in your flutter projectsWe will show you what the Introduction is and what are the construction and properties of the Dismissible and make a demo program for working with Dismissible in your flutter applications. So please try it.

❤ ❤ Thanks for reading this article ❤❤

If I got something wrong? Let me know in the comments. I would love to improve.

Clap 👏 If this article helps you.


From Our Parent Company Aeologic

Aeologic Technologies is a leading AI-driven digital transformation company in India, helping businesses unlock growth with AI automation, IoT solutions, and custom web & mobile app development. We also specialize in AIDC solutions and technical manpower augmentation, offering end-to-end support from strategy and design to deployment and optimization.

Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.

Feel free to connect with us:
And read more articles from FlutterDevs.com.

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire Flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on FacebookGitHubTwitter, and LinkedIn for any flutter-related queries.

We welcome feedback and hope you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.


How to Debug and Fix Errors in FlutterFlow Projects?

0

Debugging is an essential part of app development, and even though FlutterFlow simplifies the process, errors and issues can still arise. Understanding how to debug and fix errors effectively can save you time and frustration. This guide will cover common errors, debugging techniques, and solutions to ensure your FlutterFlow project runs smoothly.

1. Understanding Common Errors in FlutterFlow

Before diving into debugging, let’s look at some of the most common errors developers face when working with FlutterFlow:

a. API & Backend Issues

  • API calls failing due to incorrect endpoints, parameters, or authentication issues.
  • Incorrect Firebase database rules restricting access to read/write data.
  • Missing API keys or incorrect configurations.

b. UI & Navigation Errors

  • Widgets not displaying correctly due to layout issues.
  • Page navigation not working because of incorrect route settings.
  • Overlapping UI elements causing bad user experience.

c. State Management Issues

  • Data not updating in real-time due to improper Firestore integration.
  • Variables and states not persisting when switching pages.
  • Conditional visibility not working properly due to incorrect logic.

d. Performance & Optimization Issues

  • Slow app performance due to unoptimized images or inefficient queries.
  • Excessive API calls causing rate limits.
  • App crashes due to memory overload.

2. Debugging Tools in FlutterFlow

FlutterFlow provides built-in tools and third-party integrations to help debug your app efficiently.

a. Run/Test Mode in FlutterFlow

  • Use the Run Mode feature to preview your app and check for UI errors.
  • The Test Mode allows you to simulate API requests and check real-time data flow.

b. Debug Console & Error Logs

  • The debug console in FlutterFlow helps identify errors related to API calls, database connections, and UI rendering.
  • If your app crashes, check the error logs to find the exact issue.

c. Firebase Debugging

  • Use Firebase Emulator Suite to test Firestore, Authentication, and Functions locally.
  • Check Firebase Console → Logs for errors in authentication and Firestore queries.

d. Browser Console for Web Apps

  • If debugging a FlutterFlow web app, open the browser’s developer console (Chrome: Ctrl + Shift + I → Console tab) to check for warnings and errors.

3. Fixing Errors in FlutterFlow

a. Debugging API & Backend Issues

 Problem: API call is not returning data.
 Solution:

  1. Check if the API endpoint URL is correct.
  2. Verify that API headers and parameters match the API documentation.
  3. Enable CORS if your API restricts cross-origin requests.
  4. Use Postman or cURL to test the API before integrating it into FlutterFlow.

 Problem: Firestore database data is not loading.
 Solution:

  1. Check Firebase rules (Firebase → Firestore → Rules). Example of an open rule:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}

2. Verify that the Firestore collection name matches what you are using in FlutterFlow.

3. Enable Firebase logs to see database read/write failures.

b. Fixing UI & Navigation Errors

 Problem: Button click doesn’t navigate to the next page.
 Solution:

  1. Check if the navigation action is correctly set (onClick → Navigate to Page).
  2. Ensure the destination page exists in the project.
  3. Use debug mode to inspect page transitions.

 Problem: UI elements are not displaying correctly.
 Solution:

  1. Use Container → Debug Mode to inspect layouts.
  2. Check padding, margin, and constraints to avoid overlapping.
  3. Ensure visibility conditions are correct (if using conditional rendering).

c. Resolving State Management Issues

 Problem: Data disappears when navigating between pages.
 Solution:

  1. Use App State variables instead of local state variables for persistent data.
  2. Check if data is being cleared on navigation (avoid resetting variables unnecessarily).
  3. Use Firestore Streams for real-time updates instead of manual fetches.

 Problem: Toggle switch/button not updating UI correctly.
 Solution:

  1. Ensure the widget is connected to a state variable.
  2. Use Set State Action to refresh UI elements dynamically.
  3. If using Firestore, verify that data updates are reflected in real-time.

d. Fixing Performance & Optimization Issues

 Problem: App is running slowly.
 Solution:

  1. Optimize Firestore queries by using where clauses to fetch only relevant data.
  2. Reduce API calls by caching responses or using local state storage.
  3. Compress images using WebP format instead of PNG/JPEG.

 Problem: App is crashing unexpectedly.
 Solution:

  1. Open Flutter DevTools to check memory usage and leaks.
  2. Enable error tracking in Firebase Crashlytics.
  3. Check if any dependencies conflict with each other.

4. Best Practices to Avoid Errors in FlutterFlow

To prevent issues before they occur, follow these best practices:

a. Use Version Control

  • Always save different versions of your project in GitHub or Firebase Hosting.
  • Keep a backup before making major changes.

b. Test Features in Stages

  • Instead of building everything at once, test UI components and API calls separately.
  • Use FlutterFlow’s Run Mode frequently to check for early issues.

c. Follow Firebase & API Documentation

  • Read the official Firebase & API documentation before integrating them into your app.
  • Keep track of API updates to avoid deprecated methods.

d. Monitor Logs & Analytics

  • Use Google Analytics for Firebase to track user interactions and errors.
  • Regularly check Firestore logs for failed queries and permission issues.

Conclusion

Debugging in FlutterFlow is straightforward if you follow a structured approach. By identifying common errors, using built-in debugging tools, and applying best practices, you can quickly resolve issues and build a stable FlutterFlow app. Whether it’s fixing API issues, UI glitches, or performance problems, proper debugging will save time and enhance user experience.

From Our Parent Company Aeologic

Aeologic Technologies is a leading AI-driven digital transformation company in India, helping businesses unlock growth with AI automation, IoT solutions, and custom web & mobile app development. We also specialize in AIDC solutions and technical manpower augmentation, offering end-to-end support from strategy and design to deployment and optimization.

Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.

Feel free to connect with us:
And read more articles from FlutterDevs.com.

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire Flutterflow developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! For any flutter-related queries, you can connect with us on Facebook, GitHub, Twitter, and LinkedIn.

We welcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.

List Of Dates Between Two Given Dates In Flutter & Dart

0

While creating applications with Flutter and Dart, there may be circumstances where you want to separate a list of dates between two given dates.

This article will explore the List Of Dates Between Two Given Dates In Flutter & Dart. We will perceive how to execute a demo program and we are going to learn about how we can use it in your applications.

If you’re looking for the best Flutter app development company for your mobile application then feel free to contact us at — support@flutterdevs.com.


Table Of Contents::

Using a For loop

Using List.generate()

Conclusion



Using a For loop:

In this underneath example, we’ll characterize a function named getDaysInBetween that takes two contentions, startDate, and endDate, and returns a list of dates between them including the limits.

The code:

List<DateTime> getDaysInBetween(DateTime startDate, DateTime endDate) {
List<DateTime> days = [];
for (int i = 0; i <= endDate.difference(startDate).inDays; i++) {
days.add(startDate.add(Duration(days: i)));
}
return days;
}

// try it out
void main() {
DateTime startDate = DateTime(2023, 5, 5);
DateTime endDate = DateTime(2023, 5, 15);

List<DateTime> days = getDaysInBetween(startDate, endDate);

// print the result without time
days.forEach((day) {
print(day.toString().split(' ')[0]);
});
}

When we run the application, we ought to get the screen’s output like the underneath screen Console Output.

2023-05-05
2023-05-06
2023-05-07
2023-05-08
2023-05-09
2023-05-10
2023-05-11
2023-05-12
2023-05-13
2023-05-14
2023-05-15

Process finished with exit code 0

Using List.generate():

You can get a list of dates between two given dates by utilizing the List.generate() technique and pass the number of days between the beginning and end date as the length parameter.

The code:

List<DateTime> getDaysInBetween(DateTime startDate, DateTime endDate) {
final daysToGenerate = endDate.difference(startDate).inDays + 1;
return List.generate(daysToGenerate, (i) => startDate.add(Duration(days: i)));
}

// try it out
void main() {
DateTime startDate = DateTime(2023, 5, 10);
DateTime endDate = DateTime(2023, 5, 15);

List<DateTime> days = getDaysInBetween(startDate, endDate);

// print the result without time
days.forEach((day) {
print(day.toString().split(' ')[0]);
});
}

When we run the application, we ought to get the screen’s output like the underneath screen Console Output.

2023-05-11
2023-05-12
2023-05-13
2023-05-14
2023-05-15

Process finished with exit code 0

Conclusion:

In the article, I have explained the list of dates between two given dates in Flutter & Dart; you can modify this code according to your choice. This was a small introduction to List Of Dates Between Two Given Dates In Flutter & Dart User Interaction from my side, and it’s working using Flutter.

I hope this blog will provide you with sufficient information on Trying the List Of Dates Between Two Given Dates In Flutter & Dart of your projects. So please try it.

❤ ❤ Thanks for reading this article ❤❤

If I got something wrong? Let me know in the comments. I would love to improve.

Clap 👏 If this article helps you.


From Our Parent Company Aeologic

Aeologic Technologies is a leading AI-driven digital transformation company in India, helping businesses unlock growth with AI automation, IoT solutions, and custom web & mobile app development. We also specialize in AIDC solutions and technical manpower augmentation, offering end-to-end support from strategy and design to deployment and optimization.

Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.

Feel free to connect with us:
And read more articles from FlutterDevs.com.

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire Flutter developer for your cross-platform Flutter mobile app project hourly or full-time as per your requirement! For any flutter-related queries, you can connect with us on FacebookGitHubTwitter, and LinkedIn.

We welcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy how you use Flutter to build beautiful, interactive web experiences.


By Shaiq khan on June 14, 2023.

Canonical link

Exported from Medium on December 4, 2023.