<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: MATTHEW ADETOYESE</title>
    <description>The latest articles on DEV Community by MATTHEW ADETOYESE (@adepto).</description>
    <link>https://dev.to/adepto</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F440351%2F681b2eba-1ac9-4a4a-9b89-a49f123c83e5.jpeg</url>
      <title>DEV Community: MATTHEW ADETOYESE</title>
      <link>https://dev.to/adepto</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adepto"/>
    <language>en</language>
    <item>
      <title>Improving Accessibility in Flutter Apps: A Comprehensive Guide</title>
      <dc:creator>MATTHEW ADETOYESE</dc:creator>
      <pubDate>Sat, 19 Oct 2024 23:49:44 +0000</pubDate>
      <link>https://dev.to/adepto/improving-accessibility-in-flutter-apps-a-comprehensive-guide-1jod</link>
      <guid>https://dev.to/adepto/improving-accessibility-in-flutter-apps-a-comprehensive-guide-1jod</guid>
      <description>&lt;p&gt;As mobile applications increasingly become an integral part of daily life, ensuring that apps are accessible to everyone is essential. Accessibility in mobile apps ensures that people with disabilities, such as visual impairments, motor disabilities, and hearing impairments, can use the app effectively. In this article, we will delve deep into various strategies to improve accessibility in Flutter apps, providing an inclusive experience for all users.&lt;/p&gt;

&lt;p&gt;Why Accessibility Matters&lt;br&gt;
Accessibility isn’t just about catering to a niche audience; it’s about offering an inclusive experience for everyone. According to the World Health Organization (WHO), over one billion people worldwide live with some form of disability. By making your app accessible, you ensure that you’re not excluding these users. Moreover, implementing accessibility can significantly enhance the overall user experience for everyone, not just those with disabilities.&lt;/p&gt;

&lt;p&gt;Let’s explore the various strategies to improve accessibility in Flutter apps.&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Semantic Labels: Enhancing Screen Reader Support
&lt;/h2&gt;

&lt;p&gt;For users who rely on screen readers, providing meaningful labels to interactive elements like buttons, icons, and images is crucial. Flutter offers a powerful Semantics widget that provides this kind of labeling.&lt;/p&gt;

&lt;p&gt;For example, instead of merely displaying an icon that may be visually recognizable, you can wrap it in a Semantics widget to give it a clear description for screen readers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Semantics(
  label: 'Submit button',
  child: ElevatedButton(
    onPressed: () {},
    child: Text('Submit'),
  ),
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By adding a semantic label, screen readers will read out “Submit button” when the user navigates to this element. This helps users understand the purpose of the element without needing to see it visually.&lt;/p&gt;

&lt;p&gt;Semantic Hints&lt;br&gt;
In addition to labels, semantic hints guide users on how to interact with a widget. For example, you can provide hints on how to use a custom button or action:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Semantics(
  label: 'Play',
  hint: 'Double tap to play the video',
  child: Icon(Icons.play_arrow),
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This enhances the accessibility experience by giving clear instructions, making the app more intuitive.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Ensuring High Contrast: Improving Readability
&lt;/h2&gt;

&lt;p&gt;Users with visual impairments often struggle with low-contrast text and elements. To make your Flutter app more accessible, it’s important to ensure that there is a sufficient contrast ratio between text and its background. The Web Content Accessibility Guidelines (WCAG) recommend a minimum contrast ratio of 4.5:1 for regular text and 3:1 for larger text.&lt;/p&gt;

&lt;p&gt;Flutter’s ThemeData allows you to define colors with good contrast ratios. Here’s an example of how to set high-contrast colors:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
ThemeData(
  brightness: Brightness.dark,
  primaryColor: Colors.black,
  accentColor: Colors.yellow, // High contrast accent color
  textTheme: TextTheme(
    bodyText1: TextStyle(color: Colors.white),
    headline6: TextStyle(color: Colors.yellowAccent),
  ),
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use online tools like the WCAG contrast checker to verify that your color choices meet accessibility standards.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Large Touch Targets: Ease of Interaction
&lt;/h2&gt;

&lt;p&gt;People with motor impairments may find it challenging to interact with small touch targets. Flutter guidelines recommend making interactive elements, such as buttons and icons, at least 48x48 logical pixels in size.&lt;/p&gt;

&lt;p&gt;To create buttons with appropriately large touch targets, ensure that your interactive areas are not too small:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
GestureDetector(
  onTap: () {},
  child: Container(
    width: 48,
    height: 48,
    child: Icon(Icons.add),
  ),
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes sure that even users with limited dexterity can interact with the app without unnecessary frustration.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Text Scaling: Respecting User Preferences
&lt;/h2&gt;

&lt;p&gt;Different users have varying needs when it comes to font sizes. Some users, especially those with visual impairments, prefer larger text for better readability. Flutter respects the device’s font scaling settings by default, but it’s essential to ensure your app handles these settings appropriately.&lt;/p&gt;

&lt;p&gt;Use Flutter’s Text widget with scalable text styles to respect user preferences for text size:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
Text(
  'This is scalable text',
  style: Theme.of(context).textTheme.bodyText1,
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Avoid hardcoding font sizes. Instead, leverage Flutter’s MediaQuery to dynamically adjust text sizes based on user settings:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
Text(
  'Dynamic text',
  style: TextStyle(fontSize: MediaQuery.of(context).textScaleFactor * 16),
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures that your app remains readable, no matter the user’s chosen text size.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Keyboard Navigation: Accessible Beyond Touch
For some users, especially those using assistive devices or apps on desktop platforms, keyboard navigation is critical. In Flutter, it’s important to allow users to navigate through the app using a keyboard, focusing on elements, and interacting with them.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can use FocusNode and FocusTraversalGroup to manage keyboard focus and navigation within your app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
FocusTraversalGroup(
  policy: OrderedTraversalPolicy(),
  child: Column(
    children: [
      FocusableActionDetector(
        onFocusChange: (focused) {
          // Handle focus change
        },
        child: TextField(),
      ),
      FocusableActionDetector(
        child: ElevatedButton(onPressed: () {}, child: Text('Submit')),
      ),
    ],
  ),
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This enables smooth keyboard navigation across the app, making it accessible to users who rely on non-touch input methods.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Screen Readers and Semantics: Enhancing Voice Guidance
&lt;/h2&gt;

&lt;p&gt;Screen readers are vital for users with visual impairments. In addition to adding semantic labels, you should also use widgets like ExcludeSemantics and MergeSemantics to manage what is exposed to the screen reader.&lt;/p&gt;

&lt;p&gt;For example, if you don’t want a particular widget to be accessible to a screen reader:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ExcludeSemantics(
  child: Icon(Icons.ac_unit),
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the other hand, if you want to combine several widgets into one semantic unit, you can use MergeSemantics:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MergeSemantics(
  child: Row(
    children: [
      Icon(Icons.volume_up),
      Text('Volume'),
    ],
  ),
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will treat the icon and text as a single entity for screen readers, improving the clarity of information delivered.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Descriptive Alt Text for Images
&lt;/h2&gt;

&lt;p&gt;For images, it’s important to provide descriptive alt text for users who rely on screen readers. Without a proper description, images may be skipped or poorly interpreted by assistive technologies.&lt;/p&gt;

&lt;p&gt;Use the Semantics widget to describe images clearly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Semantics(
  label: 'Logo of the company',
  child: Image.asset('assets/logo.png'),
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This simple step ensures that users who can’t see the image still understand its content or purpose.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Reducing Motion: Consideration for Motion Sensitivity
&lt;/h2&gt;

&lt;p&gt;Some users are sensitive to excessive animations or motion, which may cause discomfort or dizziness. You can use Flutter’s MediaQuery.of(context).reduceMotion to check if users have opted to reduce motion in their system settings, and then adjust animations accordingly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (MediaQuery.of(context).reduceMotion) {
  // Provide a simplified animation or skip it
} else {
  // Use the full animation
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures a comfortable experience for users who may be affected by motion sensitivity.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Accessible Forms: Clear Labeling and Feedback
Accessible forms are crucial, especially for users with cognitive impairments or those using screen readers. Ensure that every input field has a clear label, and provide helpful feedback for validation errors.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use Flutter’s InputDecoration to add labels and error messages to form fields:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TextField(
  decoration: InputDecoration(
    labelText: 'Username',
    errorText: 'Username is required',
  ),
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Clear, descriptive error messages and input labels ensure that users can interact with your forms without confusion.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10. Testing Accessibility: Iterating for Perfection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, accessibility is not a one-time task but an ongoing process. To ensure that your Flutter app is truly accessible, test it using accessibility tools like the built-in screen readers (TalkBack on Android, VoiceOver on iOS) or Flutter’s flutter_accessibility command.&lt;/p&gt;

&lt;p&gt;Regularly check your app for accessibility issues and fix them promptly. By continuously iterating and improving, you’ll create an inclusive experience for all users.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Accessibility in Flutter apps is crucial for creating an inclusive experience for users with diverse needs. By using semantic labels, ensuring high contrast, respecting text scaling, supporting keyboard navigation, and testing accessibility features, you can make your app accessible to all.&lt;/p&gt;

&lt;p&gt;Making your app more accessible doesn’t just help users with disabilities; it improves the overall user experience for everyone. By prioritizing accessibility, you create an app that is more user-friendly, intuitive, and welcoming to all types of users. In the long run, this boosts user satisfaction and broadens your app’s audience, making accessibility a worthwhile investment in your app's development.&lt;/p&gt;

&lt;p&gt;Thank you&lt;br&gt;
Matthew Adetoyese&lt;/p&gt;

</description>
      <category>humancomputing</category>
      <category>ai</category>
      <category>performance</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Implementing a Security Screen Overlay in Flutter</title>
      <dc:creator>MATTHEW ADETOYESE</dc:creator>
      <pubDate>Wed, 29 May 2024 23:01:38 +0000</pubDate>
      <link>https://dev.to/adepto/implementing-a-security-screen-overlay-in-flutter-24g2</link>
      <guid>https://dev.to/adepto/implementing-a-security-screen-overlay-in-flutter-24g2</guid>
      <description>&lt;p&gt;In mobile application development, security and privacy are paramount. One common security feature is the ability to obscure or blur the app's screen when it is minimized or sent to the background. This ensures that sensitive information is not visible when the app is not actively being used. In this article, we will explore how to implement such a feature in a Flutter application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;br&gt;
To follow along with this tutorial, you should have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A basic understanding of Flutter and Dart.&lt;/li&gt;
&lt;li&gt;Flutter installed on your development machine.&lt;/li&gt;
&lt;li&gt;A Flutter project set up.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Step-by-Step Guide
&lt;/h2&gt;

&lt;p&gt;Step 1: Set Up Your Flutter Project&lt;/p&gt;

&lt;p&gt;If you haven't already set up a Flutter project, you can do so by running the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;flutter create security_overlay_app
cd security_overlay_app

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the project in your preferred IDE or code editor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Add Dependencies
&lt;/h2&gt;

&lt;p&gt;Ensure you have the necessary dependencies in your pubspec.yaml file. For this tutorial, we will use the default Flutter dependencies.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dependencies:
  flutter:
    sdk: flutter

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3: Create a Stateful Widget
&lt;/h2&gt;

&lt;p&gt;Create a StatefulWidget that will observe the app lifecycle changes. This widget will handle showing and hiding the security screen.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:flutter/material.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() =&amp;gt; _MyAppState();
}

class _MyAppState extends State&amp;lt;MyApp&amp;gt; with WidgetsBindingObserver {
  bool _isInBackground = false;

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addObserver(this);
  }

  @override
  void dispose() {
    WidgetsBinding.instance.removeObserver(this);
    super.dispose();
  }

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    setState(() {
      _isInBackground = state == AppLifecycleState.paused;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Stack(
        children: [
          HomeScreen(),
          if (_isInBackground)
            Positioned.fill(
              child: Container(
                color: Colors.white,
                child: Center(
                  child: Text(
                    'App in Background',
                    style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
                  ),
                ),
              ),
            ),
        ],
      ),
    );
  }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Implement the Lifecycle Observer
&lt;/h2&gt;

&lt;p&gt;In the _MyAppState class, we implement the WidgetsBindingObserver to listen to app lifecycle changes. Specifically, we are interested in when the app goes to the background (i.e., when the AppLifecycleState is paused).&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Overlay a Security Screen
&lt;/h2&gt;

&lt;p&gt;Using a Stack widget, we overlay a security screen when the app is in the background. The Stack widget allows us to layer widgets on top of each other. We conditionally display a white container with a "App in Background" message when _isInBackground is true.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: Create the Home Screen
&lt;/h2&gt;

&lt;p&gt;For demonstration purposes, we'll create a simple HomeScreen widget that represents the main content of the app.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class HomeScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Home Screen'),
      ),
      body: Center(
        child: Text('This is the home screen'),
      ),
    );
  }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 7: Run the App
&lt;/h2&gt;

&lt;p&gt;Run the app using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;flutter run

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the app is running, minimize it or send it to the background. You should see the security overlay appear, obscuring the app's content.&lt;/p&gt;

&lt;p&gt;Customizing the Security Screen&lt;br&gt;
You can customize the security screen to match your app's branding and design requirements. For example, you can replace the plain white container with a blurred background or an image. Here's an example with a blurred background:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'dart:ui';

...

if (_isInBackground)
  Positioned.fill(
    child: BackdropFilter(
      filter: ImageFilter.blur(sigmaX: 5.0, sigmaY: 5.0),
      child: Container(
        color: Colors.white.withOpacity(0.5),
        child: Center(
          child: Text(
            'App in Background',
            style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
          ),
        ),
      ),
    ),
  ),

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Conclusion&lt;br&gt;
In this article, we've learned how to implement a security screen overlay in a Flutter application. This feature helps protect sensitive information by obscuring the app's content when it is not actively being used. By using the WidgetsBindingObserver and a Stack widget, we can effectively manage app lifecycle changes and display a customized security screen. Feel free to extend and customize this implementation to suit your app's specific needs.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Avoiding the Dreaded Grey Error Screen in Flutter: Custom Error Handling</title>
      <dc:creator>MATTHEW ADETOYESE</dc:creator>
      <pubDate>Mon, 16 Oct 2023 14:39:33 +0000</pubDate>
      <link>https://dev.to/adepto/avoiding-the-dreaded-grey-error-screen-in-flutter-custom-error-handling-1okg</link>
      <guid>https://dev.to/adepto/avoiding-the-dreaded-grey-error-screen-in-flutter-custom-error-handling-1okg</guid>
      <description>&lt;p&gt;Introduction&lt;/p&gt;

&lt;p&gt;Flutter, the open-source UI software development kit created by Google, has gained immense popularity among developers for its ability to create stunning, cross-platform mobile applications. While developing apps with Flutter is a rewarding experience, encountering errors is an inevitable part of the journey. One common issue that developers face is the notorious "grey error screen" that can leave users puzzled and frustrated.&lt;/p&gt;

&lt;p&gt;This article discusses a strategy for avoiding the grey error screen and provides a solution that gracefully handles errors by creating a custom error screen using the CustomErrorScreen widget.&lt;/p&gt;

&lt;p&gt;The Grey Error Screen Problem&lt;/p&gt;

&lt;p&gt;The grey error screen is something that no Flutter developer wants users to see. When an error occurs, Flutter displays a screen with a grey background and cryptic error messages, which is far from a user-friendly experience. This screen is typically seen during the development phase when debugging is enabled, and in production, it appears as a blank screen.&lt;/p&gt;

&lt;p&gt;To address this issue and ensure that your users have a better experience, you can implement custom error handling using the CustomErrorScreen widget.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Custom Error Handling with CustomErrorScreen&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;The CustomErrorScreen widget is designed to replace the default grey error screen and provide a more informative and user-friendly experience when an error occurs in your Flutter app. To implement this custom error handling approach, follow these steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Import the Necessary Dependencies&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Start by importing the required packages, which include flutter/foundation.dart and flutter/material.dart. You'll need these to build your custom error screen.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Create the App CustomErrorScreen Widget&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Define the CustomErrorScreen widget, which takes errorDetails as a required parameter. This widget will be displayed when an error occurs instead of the dreaded grey screen in release mode of the Red in debug mode&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class AppCustomErrorScreen extends StatelessWidget {
  final FlutterErrorDetails? errorDetails;

  const AppCustomErrorScreen({
    Key? key,
    required this.errorDetails,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // Custom error screen contents
    return Scaffold(
      backgroundColor: Colors.white,
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Image.asset('assets/error_illustration.png'),

            Text(
              kDebugMode
                  ? errorDetails.summary.toString()
                  : "Your error message here....",
              textAlign: TextAlign center,
              style: const TextStyle(color: Colors.black, fontSize: 14),
            ),
          ],
        ),
      ),
    );
  }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The CustomErrorScreen widget is designed to display a more user-friendly error message when kDebugMode is false, which is typically the case in production.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Implement Custom Error Handling in Your App&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally, you can integrate the AppCustomErrorScreen widget into your app to replace the default error handling screen. This is achieved in the MyApp widget, as shown below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return   MaterialApp(
        builder: (context, Widget? e) {
          ErrorWidget.builder = (FlutterErrorDetails? e) {
            return CustomErrorScreen(
              errorDetails: e!,
            );
          };
          return e!;
        },
        debugShowCheckedModeBanner: false,
        title: 'Your App Name',
        theme: yourTheme,
        home: const SplashScreen(),
      ),
    );

}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
