<?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: Seif Almotaz Bellah</title>
    <description>The latest articles on DEV Community by Seif Almotaz Bellah (@seifalmotaz).</description>
    <link>https://dev.to/seifalmotaz</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%2F833854%2F35b9e465-39e8-449a-8c76-956a8098d5ee.jpeg</url>
      <title>DEV Community: Seif Almotaz Bellah</title>
      <link>https://dev.to/seifalmotaz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/seifalmotaz"/>
    <language>en</language>
    <item>
      <title>Stop Generating "AI Slop": The Developer's Guide to Google Stitch</title>
      <dc:creator>Seif Almotaz Bellah</dc:creator>
      <pubDate>Mon, 22 Dec 2025 02:37:01 +0000</pubDate>
      <link>https://dev.to/seifalmotaz/stop-generating-ai-slop-the-developers-guide-to-google-stitch-jen</link>
      <guid>https://dev.to/seifalmotaz/stop-generating-ai-slop-the-developers-guide-to-google-stitch-jen</guid>
      <description>&lt;p&gt;The release of "Stitch with Google," powered by Gemini 2.5, has triggered a massive shift in how we build UIs. We are moving from an &lt;strong&gt;imperative&lt;/strong&gt; model (manually pushing pixels in Figma) to a &lt;strong&gt;declarative&lt;/strong&gt; one (describing intent and letting the AI render it).&lt;/p&gt;

&lt;p&gt;But there is a catch.&lt;/p&gt;

&lt;p&gt;If you use "naive" prompts, you get "naive" results—generic, vanilla interfaces that look like every other AI-generated template. To get production-ready code, you need to stop asking for "a cool website" and start engineering your prompts with semantic precision.&lt;/p&gt;

&lt;p&gt;This guide acts as a taxonomy for high-fidelity prompting in Stitch. We’ll move beyond the basics and look at how to control aesthetic, structure, and code output to build interfaces that actually look like they were designed by a human.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Anatomy of a High-Fidelity Prompt
&lt;/h2&gt;

&lt;p&gt;Stitch doesn't just "paste" images together; it tokenizes your prompt into categories. If you leave a category out, the AI "hallucinates" the missing parameters based on the most common (read: boring) data it has.&lt;/p&gt;

&lt;p&gt;To avoid the "AI Slop" look, your prompt needs four distinct layers, acting like a CSS stylesheet:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Context:&lt;/strong&gt; Who is this for? (e.g., "Fintech app" triggers different colors than "Children's game").&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Structure:&lt;/strong&gt; The layout topology (e.g., "Bento grid," "Sidebar navigation").&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Aesthetic:&lt;/strong&gt; The "vibe" (e.g., "Vintage," "Brutalist").&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tech Stack:&lt;/strong&gt; The execution medium (e.g., "Tailwind CSS," "Dark Mode").&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Naive vs. Expressive Prompting
&lt;/h3&gt;

&lt;p&gt;The difference between a junior and senior prompt engineer is &lt;strong&gt;specificity&lt;/strong&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Naive Prompt (Don't do this)&lt;/th&gt;
&lt;th&gt;Expressive Prompt (Do this)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Aesthetic&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;"Make it look cool."&lt;/td&gt;
&lt;td&gt;"Apply a retro-futurist aesthetic with neon accents, CRT scanline textures, and cyberpunk typography."&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Layout&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;"Show some photos."&lt;/td&gt;
&lt;td&gt;"Arrange images in a bento box grid with varying aspect ratios, rounded corners, and hover-state scaling."&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Color&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;"Use blue."&lt;/td&gt;
&lt;td&gt;"Utilize a monochromatic indigo palette with electric blue highlights and matte black backgrounds."&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Tech&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;"Make a website."&lt;/td&gt;
&lt;td&gt;"Generate a responsive landing page using Tailwind CSS utility classes and glassmorphism card effects."&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  decoding the "Vibe": Aesthetic Semantics
&lt;/h2&gt;

&lt;p&gt;The most powerful lever you have is the style modifier. Using precise art-history or design terms works better than vague adjectives.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Vintage vs. Retro
&lt;/h3&gt;

&lt;p&gt;These are often used interchangeably, but they trigger completely different rendering paths.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Vintage&lt;/strong&gt; implies authenticity, age, and texture (paper grain, ink bleed).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retro&lt;/strong&gt; implies a modern homage (80s Synthwave, pixel art).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Vintage Prompt:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Design a recipe app with a vintage aesthetic. Use textured paper backgrounds, hand-drawn illustrations of ingredients, and classic serif typography reminiscent of a 19th-century cookbook. Ensure the UI controls look like analog paper tags.

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The Retro Prompt:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Create a retro music player interface inspired by the 1980s Walkman. Use tactile buttons, chrome textures, and a synthwave neon color palette against a dark background. Use monospaced fonts for the tracklist.

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

&lt;/div&gt;



&lt;p&gt;![Insert screenshot of Vintage vs Retro comparison here]&lt;/p&gt;

&lt;h3&gt;
  
  
  2. The "Cultured" Aesthetic
&lt;/h3&gt;

&lt;p&gt;If you want that high-end, Awwwards-style look, use words like "Editorial," "Bespoke," or "Museum-curatorial." This tells Stitch to maximize whitespace and restrict the color palette.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Cultured Prompt:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Design a cultured, editorial-style landing page for an architecture firm. Prioritize massive whitespace, elegant serif typography for headlines (e.g., Playfair Display), and full-width monochromatic photography. The vibe should be museum-curatorial.

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Brutalism &amp;amp; Neubrutalism
&lt;/h3&gt;

&lt;p&gt;For edgy, Gen Z-focused brands, Brutalism instructs the AI to ignore standard conventions like rounded corners and soft shadows.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Neubrutalist Prompt:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Generate a Neo-brutalist e-commerce store. Use clashing high-contrast colors (yellow and black), thick black borders around all containers, monospaced typography, and hard, unblurred drop shadows to create a sticker-like effect.

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

&lt;/div&gt;






&lt;h2&gt;
  
  
  Structural Semantics: Defining the Layout
&lt;/h2&gt;

&lt;p&gt;Don't let the AI guess the layout. It will almost always give you a single-column stack. Give it a blueprint.&lt;/p&gt;

&lt;h3&gt;
  
  
  The "Bento Box" Grid
&lt;/h3&gt;

&lt;p&gt;Popularized by Apple and Linear, this organizes content into a unified grid of rectangular tiles.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prompt:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Create a personal portfolio using a Bento box grid layout. Divide the screen into rectangular tiles of varying sizes: a large square for the profile photo, a wide rectangle for the 'About Me' text, and smaller square tiles for social media links. Use rounded corners and soft gap spacing.

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Masonry Layout
&lt;/h3&gt;

&lt;p&gt;Perfect for image-heavy feeds (like Pinterest).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prompt:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Design a photography feed using a masonry layout. Allow images to retain their original aspect ratios, creating a staggered, waterfall effect. Ensure infinite scroll behavior is implied.

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

&lt;/div&gt;






&lt;h2&gt;
  
  
  Lighting &amp;amp; Materiality: Beyond Flat Design
&lt;/h2&gt;

&lt;p&gt;Modern UI isn't flat; it has physics. You can use photography terms to control how light hits your UI elements.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Glassmorphism:&lt;/strong&gt; Simulates frosted glass (iOS style).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Neumorphism:&lt;/strong&gt; Simulates extruded soft plastic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cinematic Lighting:&lt;/strong&gt; Creates dramatic depth.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Glassmorphism Prompt:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Design a weather app using glassmorphism. Place translucent white cards over a dynamic, colorful abstract background. Apply a high background blur (backdrop-filter) and a subtle white outline to each card.

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

&lt;/div&gt;



&lt;p&gt;![Insert screenshot of Glassmorphism UI here]&lt;/p&gt;




&lt;h2&gt;
  
  
  Technical Constraints: Getting Production Code
&lt;/h2&gt;

&lt;p&gt;Stitch exports code, so speak to it like a developer. If you want Tailwind, ask for it explicitly.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tailwind:&lt;/strong&gt; "Use standard Tailwind spacing (p-4, m-8) and slate-900 colors."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Material Design 3:&lt;/strong&gt; "Use dynamic color tokens and standard MD3 elevation."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Responsive:&lt;/strong&gt; "Mobile-first, stack elements vertically on small screens."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Code-Ready Prompt:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Design a landing page using Tailwind CSS utility classes. Use a split-screen layout for desktop and a vertical stack for mobile. Style buttons with 'rounded-full' and 'hover:bg-blue-600'.

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

&lt;/div&gt;






&lt;h2&gt;
  
  
  The Refinement Loop
&lt;/h2&gt;

&lt;p&gt;Your first prompt won't be perfect. The power of Stitch is in the conversational iteration.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Anchor:&lt;/strong&gt; "Create a mobile app for a coffee shop with a vintage industrial vibe."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inject:&lt;/strong&gt; "Add a bottom nav bar with icons for Home, Order, and Profile."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tune-up:&lt;/strong&gt; "Make the buttons fully rounded with a coffee-brown color. Change the background to a textured paper grain."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fix:&lt;/strong&gt; "The design is too modern. Revert to the vintage theme. Use serif fonts for headers and add a sepia filter."&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  📋 Copy-Paste Prompt Templates
&lt;/h2&gt;

&lt;p&gt;Here are three "Master Templates" you can copy right now to get started.&lt;/p&gt;

&lt;h3&gt;
  
  
  Template A: High-End E-Commerce ("Cultured")
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Design a responsive web homepage for a high-end furniture brand. The aesthetic should be cultured and minimalist, inspired by Scandinavian design.
Layout: Use a split-screen hero section with a large editorial photo on the left and elegant serif typography (e.g., Bodoni) on the right.
Content: Below the hero, use a masonry grid to showcase products with generous whitespace around each item.
Colors: Use a monochromatic beige and charcoal palette.
Tech: Style buttons with sharp edges and a 1px solid black border (ghost buttons).

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Template B: Crypto Dashboard ("Retro-Futurist")
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Create a mobile crypto dashboard app with a Retro-Futurist / Cyberpunk vibe.
Background: Deep midnight blue with a faint grid pattern overlay.
Elements: Neon green and electric purple for data lines.
Cards: Apply glassmorphism (translucent blur) with a thin holographic border.
Font: Monospaced font for all numbers to mimic a terminal.
Navigation: Bottom tab bar with glowing icons.

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Template C: Recipe Journal ("Vintage")
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Design a recipe sharing app with a Vintage aesthetic, evoking an old handwritten journal.
Texture: Apply a paper grain texture to the background.
Typography: Handwritten script for titles, legible serif for instructions.
Colors: Warm cream, sepia, and faded ink blue.
UI Elements: Style buttons to look like stamped ink or paper tags.
Layout: Single-column card view where each card looks like a physical recipe card.

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

&lt;/div&gt;






&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Design is becoming a linguistic act. Your role is evolving from "creator of artifacts" to "curator of specifications." By mastering terms like &lt;strong&gt;Masonry&lt;/strong&gt;, &lt;strong&gt;Glassmorphism&lt;/strong&gt;, and &lt;strong&gt;Neubrutalism&lt;/strong&gt;, you unlock the ability to generate UIs that don't just work—they feel human.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Have you tried Stitch yet? Drop your best prompt in the comments below!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ui</category>
      <category>vibecoding</category>
      <category>webdev</category>
      <category>ai</category>
    </item>
    <item>
      <title>Why Still Use Django Over FastAPI?</title>
      <dc:creator>Seif Almotaz Bellah</dc:creator>
      <pubDate>Thu, 04 Jul 2024 21:54:13 +0000</pubDate>
      <link>https://dev.to/seifalmotaz/why-still-use-django-over-fastapi-5b0d</link>
      <guid>https://dev.to/seifalmotaz/why-still-use-django-over-fastapi-5b0d</guid>
      <description>&lt;p&gt;As a developer, I continue to use Django despite all the hype around FastAPI. You might be thinking, "Dude, why complicate things? Just use FastAPI and make it simple." Let's dive into this topic by discussing some use case scenarios where Django still shines.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Work Context
&lt;/h2&gt;

&lt;p&gt;I work as a freelancer on various projects and also in a company setting. My primary role is as a mobile application developer using Dart/Flutter. This means that my work often involves creating MVPs (Minimum Viable Products) and startup projects that need to go into production as quickly as possible. This requires a software engineer to be mindful of several factors:&lt;/p&gt;

&lt;h3&gt;
  
  
  Developer Time and Popularity
&lt;/h3&gt;

&lt;p&gt;First, there's the cost of developer time and the popularity of the language or framework being used. Choosing a well-known and widely-used framework can save time and resources in the long run.&lt;/p&gt;

&lt;h3&gt;
  
  
  Speed and Efficiency
&lt;/h3&gt;

&lt;p&gt;Second, time is of the essence. As a developer, my main focus is on reducing the time spent developing and maintaining project code. This includes writing code, deploying it, migrating it, and testing it. Additionally, I need to be able to fix bugs quickly and add features as soon as possible, especially for startups. There's simply no time to be constantly migrating database schemas or worrying about the code not starting.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution: Why Django?
&lt;/h2&gt;

&lt;p&gt;To address these challenges, I focus on a few key points:&lt;/p&gt;

&lt;h3&gt;
  
  
  Using Python
&lt;/h3&gt;

&lt;p&gt;Python is incredibly popular due to its ease of use and the robust libraries it offers. This makes it easy to get developers up to speed and working on a project quickly, especially if the project is well-documented (which, as a diligent software engineer, I ensure it is! 😊).&lt;/p&gt;

&lt;h3&gt;
  
  
  Using Django
&lt;/h3&gt;

&lt;p&gt;As part of the Python ecosystem, Django is a robust framework that many rely on for production-ready applications. While it does have its downsides, which we'll discuss later, it offers several benefits that make it a solid choice over FastAPI:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ORM (Object-Relational Mapping)&lt;/strong&gt;: Django's ORM simplifies database interactions, allowing for effortless migrations and providing an array of field types that cover almost every need a developer might have.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Admin Panel&lt;/strong&gt;: The Django admin panel is one of my favorite features. It saves a tremendous amount of time for startups and clients by providing a ready-made interface to manage application data. While a custom admin panel might be necessary down the line, the default admin panel is a great starting point for early-stage projects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Extensions&lt;/strong&gt;: Django has a rich ecosystem of extensions that can be easily integrated, further speeding up the development process.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Authentication&lt;/strong&gt;: Built-in authentication support in Django simplifies the implementation of user management, saving time and effort.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Additionally, Django signals are a crucial feature for me. They provide a way to trigger events and execute code in response to changes in the data, eliminating the need to create a custom system for it.&lt;/p&gt;

&lt;h2&gt;
  
  
  APIs for Mobile Applications
&lt;/h2&gt;

&lt;p&gt;Given that I primarily develop mobile applications, APIs are a crucial part of my work. To be fair, FastAPI does offer a significant benefit with its OpenAPI generated schema. This feature greatly enhances developer productivity by providing automatically generated API documentation. Front-end developers appreciate this as it allows them to get API docs quickly and use client-side generators with the OpenAPI file/code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Combining Django with Django Ninja
&lt;/h3&gt;

&lt;p&gt;To leverage this benefit, I use Django Ninja. While I'm not a fan of Django REST Framework (DRF) due to its performance and reliance on "magic," Django Ninja strikes a balance. It's similar to FastAPI in its simplicity and effective use of type hinting, but it doesn't overload with unnecessary features. Django Ninja also utilizes Pydantic for data validation, which adds to its robustness.&lt;/p&gt;

&lt;h2&gt;
  
  
  Embracing the Magic of Django
&lt;/h2&gt;

&lt;p&gt;A lot of senior backend developers tend to dislike the "magic" that Django offers. However, as an experienced software engineer, I see this magic as a good thing—especially when you understand how it works behind the scenes. By reading the Django documentation and gaining familiarity with other frameworks like Flask, FastAPI, and SQLAlchemy, you can demystify the magic. This understanding enables you to appreciate the productivity boost that Django's abstractions provide.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Cons of Django
&lt;/h2&gt;

&lt;p&gt;While Django has many strengths, it's important to be aware of its limitations, especially when choosing it for a project. Here are some cons from my perspective, particularly in the context of building MVPs:&lt;/p&gt;

&lt;h3&gt;
  
  
  Async Code
&lt;/h3&gt;

&lt;p&gt;Although Django 5 has introduced support for async code, it remains a fundamentally synchronous framework. Many of its components are not optimized for asynchronous operations, which can be a limitation if your project requires extensive async functionality.&lt;/p&gt;

&lt;h3&gt;
  
  
  Performance and Memory Usage
&lt;/h3&gt;

&lt;p&gt;Django can be resource-intensive. A bare metal project using Django typically consumes at least 40 MB of RAM, which can be a lot compared to other frameworks. This can be a concern if you're working on a project with strict memory usage requirements.&lt;/p&gt;

&lt;h3&gt;
  
  
  Real-Time Capabilities
&lt;/h3&gt;

&lt;p&gt;Django is not the best choice for applications that depend heavily on real-time features like WebSockets or Server-Sent Events (SSE). For projects requiring real-time communication, Python as a whole might not be the best option. In such cases, I would prefer using Node.js or Go, depending on the specific project requirements.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;In conclusion, while FastAPI presents compelling advantages in API generation and performance, Django remains my preferred choice for backend development in mobile application MVP projects. Its robust ecosystem, ease of use within the Python ecosystem, and productivity-enhancing features like the admin panel outweigh its limitations in async operations and real-time capabilities. Understanding these trade-offs ensures I can effectively choose and utilize Django for projects requiring rapid development and scalability.&lt;/p&gt;

</description>
      <category>python</category>
      <category>django</category>
      <category>fastapi</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Navigating Environment Variables in Flutter Projects: Strategies for Effective Integration</title>
      <dc:creator>Seif Almotaz Bellah</dc:creator>
      <pubDate>Sun, 07 Jan 2024 15:32:47 +0000</pubDate>
      <link>https://dev.to/seifalmotaz/navigating-environment-variables-in-flutter-projects-strategies-for-effective-integration-1638</link>
      <guid>https://dev.to/seifalmotaz/navigating-environment-variables-in-flutter-projects-strategies-for-effective-integration-1638</guid>
      <description>&lt;p&gt;In this blog post, we'll explore how to make your Flutter development environment more efficient by adjusting environment variables. There are two ways to do this. First, you can specify variables directly in the run command using &lt;code&gt;--dart-define=SOME_VAR=SOME_VALUE&lt;/code&gt;. Alternatively, you can store them in a JSON file and then parse the file within your Flutter application.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are environment variables &amp;amp; why use them?
&lt;/h2&gt;

&lt;p&gt;Environment variables are like secret codes for your computer, storing important information needed by different apps. They help control how programs run and behave. Imagine them as flexible tools that let you configure and customize your software without changing the code. Developers love them for securing things like API keys or database credentials, managing these details outside the code for better security and adaptability.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to get environment variables in Dart
&lt;/h2&gt;

&lt;p&gt;In Dart, there are two ways to get environment variables. The first way is using &lt;code&gt;String.fromEnvironment&lt;/code&gt; or &lt;code&gt;bool.fromEnvironment&lt;/code&gt; functions (there are similar ones for &lt;code&gt;int&lt;/code&gt; and &lt;code&gt;double&lt;/code&gt;). The second, simpler method is using &lt;code&gt;Platform.environment&lt;/code&gt;. Let's compare them:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;String.fromEnvironment&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Purpose:&lt;/strong&gt; Access environment variables defined during compilation or running using &lt;code&gt;--dart-define&lt;/code&gt; flags.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scope:&lt;/strong&gt; Dart code only.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Usage:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;apiUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fromEnvironment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'API_URL'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;defaultValue:&lt;/span&gt; &lt;span class="s"&gt;'http://localhost:8080'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Platform.environment&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Purpose:&lt;/strong&gt; Access platform-specific environment variables.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scope:&lt;/strong&gt; Dart code and platform channels.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Usage:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;  &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;sdkVersion&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Platform&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'FLUTTER_SDK_VERSION'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key Differences:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Source:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;String.fromEnvironment:&lt;/strong&gt; &lt;code&gt;--dart-define&lt;/code&gt; flags during compilation or running.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Platform.environment:&lt;/strong&gt; Platform-specific variables.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Visibility:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;String.fromEnvironment:&lt;/strong&gt; Dart code only.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Platform.environment:&lt;/strong&gt; Dart code and platform channels.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Mutability:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;String.fromEnvironment:&lt;/strong&gt; Constant (set at compile time).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Platform.environment:&lt;/strong&gt; Dynamic (changeable at runtime).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;When to Use Each:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;strong&gt;String.fromEnvironment&lt;/strong&gt; for:

&lt;ul&gt;
&lt;li&gt;Sensitive information.&lt;/li&gt;
&lt;li&gt;Values changing based on build configurations.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Use &lt;strong&gt;Platform.environment&lt;/strong&gt; for:

&lt;ul&gt;
&lt;li&gt;Platform-specific settings.&lt;/li&gt;
&lt;li&gt;Communicating with native code.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Best Practices:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keep sensitive info in environment variables using &lt;code&gt;--dart-define&lt;/code&gt; flags.&lt;/li&gt;
&lt;li&gt;Don't hardcode sensitive values.&lt;/li&gt;
&lt;li&gt;Use a separate config file for env variables in production.&lt;/li&gt;
&lt;li&gt;Consider a dependency injection framework for managing env variables in larger projects.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Setting environment variables through the run command:
&lt;/h3&gt;

&lt;p&gt;Enhancing your Flutter development environment can be as easy as tweaking the run command. By adding &lt;code&gt;--dart-define=SOME_VAR=SOME_VALUE&lt;/code&gt;, you're telling Flutter to use specific values during execution. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;flutter run &lt;span class="nt"&gt;--dart-define&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;your_actual_api_key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This method lets you customize environment variables on the fly, making your development process more efficient.&lt;/p&gt;

&lt;h3&gt;
  
  
  Simplifying with a JSON file:
&lt;/h3&gt;

&lt;p&gt;For a more organized approach, create a JSON file (let's call it &lt;code&gt;env.json&lt;/code&gt;) to store your variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"SOME_VAR"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"SOME_VALUE"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"SOME_VAR_2"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"SOME_VALUE_2"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, when running Flutter, use the &lt;code&gt;--dart-define-from-file&lt;/code&gt; flag to parse variables from this JSON:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;flutter run &lt;span class="nt"&gt;--dart-define-from-file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;env.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This method is great for managing multiple variables, enhancing the organization and readability of your configuration. It's a win for a smoother development environment in Flutter.&lt;/p&gt;

&lt;h4&gt;
  
  
  VS Code
&lt;/h4&gt;

&lt;p&gt;To incorporate custom Flutter commands like &lt;code&gt;--dart-define&lt;/code&gt; and define the path for an environment file in Visual Studio Code, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the launch.json file by clicking on the "Run and Debug" button, then selecting the settings icon.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fppxrvule8htw3vnp8b1a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fppxrvule8htw3vnp8b1a.png" alt="Setting icon" width="370" height="221"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Inside the launch.json file, locate the configurations section.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add the desired args, such as &lt;code&gt;--dart-define=BASE_URL=http://localhost:3000&lt;/code&gt;, within the configuration you want. For instance:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"testapp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="nl"&gt;"request"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"launch"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dart"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
           &lt;/span&gt;&lt;span class="s2"&gt;"--dart-define=BASE_URL=http://localhost:3000"&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="nl"&gt;"env"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
           &lt;/span&gt;&lt;span class="nl"&gt;"VAR_EXAMPLE"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"VALUE"&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ensure the values match your project structure.&lt;/p&gt;

&lt;p&gt;This allows you to customize your Flutter project settings directly within Visual Studio Code, enhancing your development experience.&lt;/p&gt;

&lt;p&gt;As you can observe, we've included an "env" key. This is a feature introduced by Visual Studio Code to facilitate the management of your environment variables.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In conclusion, optimizing your Flutter development environment through environment variable adjustments, be it in run commands or a JSON file, offers efficiency and flexibility. Recognizing their significance for securing sensitive data and adapting to various configurations is crucial. Dart's tools like &lt;code&gt;String.fromEnvironment&lt;/code&gt; and &lt;code&gt;Platform.environment&lt;/code&gt; provide dynamic control, while Visual Studio Code simplifies integration through its launch.json file. This streamlines the process, enhancing the security and efficiency of Flutter applications. Choosing the method that aligns with your project's needs contributes to a more seamless and productive development experience.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>development</category>
      <category>env</category>
    </item>
    <item>
      <title>Flutter Project Architecture: Organizing for Clarity and Efficiency</title>
      <dc:creator>Seif Almotaz Bellah</dc:creator>
      <pubDate>Sat, 30 Dec 2023 16:36:57 +0000</pubDate>
      <link>https://dev.to/seifalmotaz/flutter-project-architecture-organizing-for-clarity-and-efficiency-3fh5</link>
      <guid>https://dev.to/seifalmotaz/flutter-project-architecture-organizing-for-clarity-and-efficiency-3fh5</guid>
      <description>&lt;p&gt;Hey Flutter devs! 👋 Let's dive into an approach for organizing your Flutter project to ensure clean and maintainable code. I'll guide you through my preferred project structure, naming conventions, and some useful tips.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Structure Unveiled
&lt;/h2&gt;

&lt;p&gt;Let's start with the breakdown of my project structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- core
  -- api
  -- models
  -- helpers
  -- utils
  -- constants
- pages
- services
- components (shared among all pages)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Pages Unveiled
&lt;/h3&gt;

&lt;p&gt;Maintaining order is key, especially with multiple pages. Take a user CRUD as an example, organize it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pages/
|-- users/
    |-- update/
        |-- update.dart (UI widget)
        |-- controller.dart (GetX controller)
        |-- components (page-specific components)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pay attention to naming! For the widget file, I go for &lt;code&gt;UsersUpdatePage&lt;/code&gt;, making it crystal clear that it's about updating users. This aids in autocomplete, making your coding life a breeze.&lt;/p&gt;

&lt;h3&gt;
  
  
  Controller Chronicles
&lt;/h3&gt;

&lt;p&gt;Always keep logic away from UI. In the &lt;code&gt;controller.dart&lt;/code&gt; file, meet the &lt;code&gt;UsersUpdateController&lt;/code&gt;. Functions like &lt;code&gt;onPressed&lt;/code&gt; and &lt;code&gt;onTap&lt;/code&gt; find their home here.&lt;/p&gt;

&lt;h3&gt;
  
  
  Components Realm
&lt;/h3&gt;

&lt;p&gt;For components specific to a page, create a folder within the page, like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pages/
|-- users/
    |-- update/
        |-- components/ (components specific to this page)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For shared components used across all pages, maintain a separate folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;components/ (shared components used across all pages)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Services Hub
&lt;/h3&gt;

&lt;p&gt;Global controllers or providers, like &lt;code&gt;AuthProvider&lt;/code&gt;, find their spot here. Stick to the same naming conventions and logic separation as in the pages.&lt;/p&gt;

&lt;h3&gt;
  
  
  Constants Abode
&lt;/h3&gt;

&lt;p&gt;For constants, such as API base URLs or color themes, create a folder. Keep it tidy and organized.&lt;/p&gt;

&lt;h2&gt;
  
  
  Coding Hacks
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Global Storage&lt;/strong&gt;: Using &lt;code&gt;GetStorage&lt;/code&gt; or &lt;code&gt;SharedPreferences&lt;/code&gt;, create a class. It provides a readable way to handle keys and avoids typos.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;StorageProvider&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="kd"&gt;get&lt;/span&gt; &lt;span class="n"&gt;userToken&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;getStorage&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;read&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="s"&gt;'userToken'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
     &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kd"&gt;set&lt;/span&gt; &lt;span class="n"&gt;userToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;getStorage&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'userToken'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
     &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;removeUserToken&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;getStorage&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'userToken'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Models Folder&lt;/strong&gt;: Keep models like &lt;code&gt;UserModel&lt;/code&gt; in the models folder. If using &lt;code&gt;JsonSerializable&lt;/code&gt;, organize generated code in a &lt;code&gt;generated&lt;/code&gt; folder, simply by adding this code to your build.yaml file:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;targets&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;$default&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;builders&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;source_gen:combining_builder&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;options&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;build_extensions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;^lib/core/models/{{}}.dart"&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;lib/core/models/generated/{{}}.g.dart"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Logic in Controllers: The Saga of Separation
&lt;/h2&gt;

&lt;p&gt;One of the core principles in software development is the &lt;strong&gt;separation of concerns&lt;/strong&gt;. In Flutter, clean separation of UI and logic is achieved by placing logic in controllers.&lt;/p&gt;

&lt;h4&gt;
  
  
  1. &lt;strong&gt;UI in UsersUpdatePage:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Focus solely on the presentation layer when designing the UI in the &lt;code&gt;UsersUpdatePage&lt;/code&gt; widget. Craft visual elements, arrange widgets, and define the layout. Keep complex logic away.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UsersUpdatePage&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatelessWidget&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Scaffold&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;appBar:&lt;/span&gt; &lt;span class="n"&gt;AppBar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;title:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Update User'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="nl"&gt;body:&lt;/span&gt; &lt;span class="n"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="c1"&gt;// UI elements here&lt;/span&gt;
      &lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2. &lt;strong&gt;Functions in Controller:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;For functions related to user updates, create a corresponding controller, like &lt;code&gt;UsersUpdateController&lt;/code&gt;. Move functions like &lt;code&gt;onPressed&lt;/code&gt; or &lt;code&gt;onTap&lt;/code&gt; here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UsersUpdateController&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;GetxController&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Controller logic here&lt;/span&gt;

  &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;updateUser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Logic for updating user&lt;/span&gt;
    &lt;span class="c1"&gt;// Access data, call APIs, perform validations, etc.&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;// Other functions related to the update process&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  3. &lt;strong&gt;Benefits of Separation:&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Readability and Maintainability:&lt;/strong&gt; UI remains clean. Developers grasp and modify the presentation layer without being overwhelmed by complex business logic.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reusability:&lt;/strong&gt; Controllers can be reused across multiple pages or components, making it easy to maintain and scale your project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Testing:&lt;/strong&gt; Separating logic into controllers facilitates unit testing.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  4. &lt;strong&gt;Example: Using the Controller in UI:&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UsersUpdatePage&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatelessWidget&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;UsersUpdateController&lt;/span&gt; &lt;span class="n"&gt;_controller&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;UsersUpdateController&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Scaffold&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;appBar:&lt;/span&gt; &lt;span class="n"&gt;AppBar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;title:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Update User'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="nl"&gt;body:&lt;/span&gt; &lt;span class="n"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;children:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
          &lt;span class="c1"&gt;// UI elements here&lt;/span&gt;
          &lt;span class="n"&gt;ElevatedButton&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="nl"&gt;onPressed:&lt;/span&gt; &lt;span class="n"&gt;_controller&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;updateUser&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Update'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
          &lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;],&lt;/span&gt;
      &lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach keeps your codebase organized, modular, and easy to maintain, crucial for scalability.&lt;/p&gt;

&lt;h2&gt;
  
  
  Private Variables: Mastering Control and Modularity
&lt;/h2&gt;

&lt;p&gt;In Flutter, managing your application's state is vital, and as projects grow, controlling your variables becomes essential. Private variables and accessor functions (getters and setters) play a significant role in achieving an organized and maintainable codebase.&lt;/p&gt;

&lt;h4&gt;
  
  
  1. &lt;strong&gt;Why Private Variables?&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Private variables, denoted by an underscore &lt;code&gt;_&lt;/code&gt;, are not accessible outside the declaring class. This encapsulation ensures that the internal state of your controller is not directly manipulated from other parts of your codebase.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. &lt;strong&gt;Getter and Setter Functions:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Use getter and setter functions to interact with private variables. This adds control over how data is accessed and modified.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UsersUpdateController&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;GetxController&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Private variable&lt;/span&gt;
  &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;_userName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// Getter&lt;/span&gt;
  &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="kd"&gt;get&lt;/span&gt; &lt;span class="n"&gt;userName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;_userName&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// Setter&lt;/span&gt;
  &lt;span class="kd"&gt;set&lt;/span&gt; &lt;span class="n"&gt;userName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;_userName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// Other functions can now access _userName via the getter and setter&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  3. &lt;strong&gt;Benefits of Encapsulation:&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Controlled Access:&lt;/strong&gt; Private variables restrict direct access, allowing you to manage when and how data is modified.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Data Validation:&lt;/strong&gt; Setter functions enable you to add validation logic.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Centralized Logic:&lt;/strong&gt; All logic related to a specific variable is centralized within the controller.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  4. &lt;strong&gt;Example Usage:&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UsersUpdatePage&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatelessWidget&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;UsersUpdateController&lt;/span&gt; &lt;span class="n"&gt;_controller&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;UsersUpdateController&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Scaffold&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;appBar:&lt;/span&gt; &lt;span class="n"&gt;AppBar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;title:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Update User'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="nl"&gt;body:&lt;/span&gt; &lt;span class="n"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;children:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
          &lt;span class="c1"&gt;// UI elements here&lt;/span&gt;
          &lt;span class="n"&gt;TextField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="nl"&gt;onChanged:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;newName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;_controller&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;userName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;newName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="c1"&gt;// Use _controller.userName to access the variable indirectly&lt;/span&gt;
          &lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;],&lt;/span&gt;
      &lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By adopting this approach, you maintain control over your variables, ensure data consistency, and enhance the modularity of your Flutter project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Widget Naming Odyssey: Clarity and Consistency
&lt;/h2&gt;

&lt;h4&gt;
  
  
  1. &lt;strong&gt;Page Widgets:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;For pages, follow a clear and descriptive naming convention. Combine the feature name, action, and "Page."&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UsersUpdatePage&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatelessWidget&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Widget code&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2. &lt;strong&gt;Component Widgets:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;For reusable components within a page, keep names concise but descriptive.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserNameInput&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatelessWidget&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Widget code&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Controller Naming Expedition: Organization and Readability
&lt;/h2&gt;

&lt;h4&gt;
  
  
  1. &lt;strong&gt;Page Controllers:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Follow a similar pattern for page controllers, incorporating the feature and action.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UsersUpdate&lt;/span&gt;

&lt;span class="n"&gt;Controller&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;GetxController&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Controller logic&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2. &lt;strong&gt;Component Controllers:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;If you have controllers specifically for components, consider appending "Controller" to the component's name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserNameInputController&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;GetxController&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Controller logic&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Components Naming Journey: Specificity and Reusability
&lt;/h2&gt;

&lt;h4&gt;
  
  
  1. &lt;strong&gt;Page-Specific Components:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;For components specific to a page, keep the naming within the page's context.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pages/
|-- users/
    |-- update/
        |-- components/
            |-- user_name_input.dart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2. &lt;strong&gt;Shared Components:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;If a component is shared among multiple pages, consider a more general name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;components/
    |-- custom_button.dart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Key Takeaways:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Descriptive and Consistent:&lt;/strong&gt; Maintain a consistent and descriptive naming convention for widgets, controllers, and components.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Combine Feature and Action:&lt;/strong&gt; Incorporate both the feature and the action into the names for better clarity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Contextual Naming:&lt;/strong&gt; Consider the context of components, especially when organizing them within specific pages or making them reusable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Readability is Key:&lt;/strong&gt; Prioritize readability over brevity. Clear names make code more accessible and understandable.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;By keeping it simple, following consistent naming conventions, and separating concerns, your Flutter project will be clean, maintainable, and a joy to work on. Happy coding! 🚀&lt;/p&gt;

&lt;p&gt;This article is written with a help of AI for organizing the article context ✌️.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>codequality</category>
    </item>
    <item>
      <title>How to use S3 services with python</title>
      <dc:creator>Seif Almotaz Bellah</dc:creator>
      <pubDate>Tue, 06 Sep 2022 23:12:28 +0000</pubDate>
      <link>https://dev.to/seifalmotaz/how-to-use-s-with-puthon-2g05</link>
      <guid>https://dev.to/seifalmotaz/how-to-use-s-with-puthon-2g05</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;h5&gt;
  
  
  Hi, in this article we will discuss how to connect vultr object storage with python.
&lt;/h5&gt;

&lt;blockquote&gt;
&lt;p&gt;You can also use (digitalocean, aws or etc..)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h5&gt;
  
  
  In the beginning, What is Object Storage?
&lt;/h5&gt;

&lt;p&gt;Object Storage is Vultr's S3-compatible, web-accessible cloud object storage service for storing and retrieving file objects. &lt;br&gt;
Objects can be accessed privately or publicly, over the web. Use cases for cloud object storage including:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Share Files like ( images, videos, pdf, ...etc)
&lt;/li&gt;
&lt;li&gt;Share software or business files&lt;/li&gt;
&lt;li&gt;Share static website hosting for assets such as images, JavaScript, CSS, or media files&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Summary, When you need to handle vast numbers of file objects without having to manage or grow the underlying filesystem, object storage is suitable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;h4&gt;
  
  
  How to create object storage
&lt;/h4&gt;

&lt;p&gt;Select the Objects menu at the top of the &lt;a href="https://my.vultr.com/" rel="noopener noreferrer"&gt;Vultr customer portal&lt;/a&gt; to navigate to the object storage subscription listing, then use the &lt;a href="https://my.vultr.com/objectstorage/" rel="noopener noreferrer"&gt;Add Object Storage&lt;/a&gt; form to deploy. After deployment, view your access keys on the &lt;a href="https://my.vultr.com/objectstorage/" rel="noopener noreferrer"&gt;subscription listing page&lt;/a&gt;.&lt;/p&gt;

&lt;h6&gt;
  
  
  If you have any question about object storage see this &lt;a href="https://www.vultr.com/docs/vultr-object-storage" rel="noopener noreferrer"&gt;article&lt;/a&gt;.
&lt;/h6&gt;

&lt;h3&gt;
  
  
  Installing requirements
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Create new Object storage with Vultr.&lt;/li&gt;
&lt;li&gt;Download and Install Python from the &lt;a href="https://www.python.org/" rel="noopener noreferrer"&gt;python.org&lt;/a&gt; .&lt;/li&gt;
&lt;li&gt;Installing boto3 with pip line:

&lt;ol&gt;
&lt;li&gt;  Open cmd for Windows or terminal from MacOS.&lt;/li&gt;
&lt;li&gt;  And type  &lt;code&gt;pip install boto3&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;/ol&gt;

&lt;h3&gt;
  
  
  What is boto3?
&lt;/h3&gt;

&lt;p&gt;Boto3 is the Software Development Kit (SDK) for Python, which allows Python developers to write software that makes use of services like Vultr Object Storage.&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's get started:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Open your favorite code editor. &lt;/li&gt;
&lt;li&gt;Create a new python file with any name.&lt;/li&gt;
&lt;li&gt;Let's code:&lt;/li&gt;
&lt;/ul&gt;

&lt;h6&gt;
  
  
  First thing first we must get the Acess Key &amp;amp; Secret Key from your object storage page from &lt;a href="https://my.vultr.com/objectstorage/" rel="noopener noreferrer"&gt;subscription listing page&lt;/a&gt;.
&lt;/h6&gt;

&lt;p&gt;And let us save it in variable:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;object_storage_config = {
    'region_name': 'ewr1',
    'endpoint_url': 'https://ewr1.vultrobjects.com',
    'aws_access_key_id': 'Your_access_key',
    'aws_secret_access_key': 'Your_secret_key'
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
  
  
  How to upload a file to your file dir:
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import boto3
client = boto3.client('s3', **object_storage_config)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Now we have connected to vultr s3 object storage&lt;/strong&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  Let us upload a file to object storage but first we must create a new bucket:
&lt;/h6&gt;

&lt;p&gt;Objects are stored in buckets. Before you can begin uploading objects, you need to create at least one bucket. Buckets are similar to folders on a file system.&lt;br&gt;
Know more in this article &lt;a href="https://www.vultr.com/docs/vultr-object-storage" rel="noopener noreferrer"&gt;article&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now we create a new bucket:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client.create_bucket(Bucket="bucket_name")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now upload file with boto3:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client.upload_file("file_name", "bucket_name", "object_name.extention")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Example code for the above:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import boto3

object_storage_config = {
    'region_name': 'ewr1',
    'endpoint_url': 'https://ewr1.vultrobjects.com',
    'aws_access_key_id': 'Your_access_key',
    'aws_secret_access_key': 'Your_secret_key'
}

client = boto3.client('s3', **object_storage_config)
client.create_bucket(Bucket="uploaded_images")
client.upload_file("./images/logo.png", "uploaded_images", "logo.png")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
  
  
  What about Multipart files
&lt;/h4&gt;

&lt;p&gt;We can upload a multipart file with function &lt;strong&gt;upload_fileobj&lt;/strong&gt;.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client.upload_fileobj(file, "bucket_name", "object_name.extention")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import boto3
object_storage_config = {
    'region_name': 'ewr1',
    'endpoint_url': 'https://ewr1.vultrobjects.com',
    'aws_access_key_id': 'Your_access_key',
    'aws_secret_access_key': 'Your_secret_key'
}

client = boto3.client('s3', **object_storage_config)
# WE ALREADY CREATED BUCKET
with open("FILE_NAME", "rb") as file:
    client.upload_fileobj(file, "uploaded_images", "logo.png")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now we have uploaded a file to s3 storage but we have a problem. The problem is that the files we have uploaded are in private mode and there is no one can access them without an access key.&lt;br&gt;
We have two options to solve this first to make the files in the public mode when we upload it and second we can create a Presigned URL.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Presigned URLs?
&lt;/h3&gt;

&lt;p&gt;Vultr users who can access the object will generate a pre-signed URL. The generated URL will be delivered to unauthorized users. The pre-signed URL can be entered in a browser or used in an HTML web page or application. Credentials that use a pre-signed URL are the credentials of the Vultr user who generated the URL.&lt;br&gt;
pre-signed URLs are valid for the limited time specified when the URL was generated.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;response = client.generate_presigned_url(
    'get_object', 
    Params={'Bucket': "bucket_name", 'Key': "object_name"},
    ExpiresIn=expiration
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;Expiration: Time in seconds for the presigned URL to remain valid&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import boto3
object_storage_config = {
    'region_name': 'ewr1',
    'endpoint_url': 'https://ewr1.vultrobjects.com',
    'aws_access_key_id': 'Your_access_key',
    'aws_secret_access_key': 'Your_secret_key'
}

client = boto3.client('s3', **object_storage_config)
response = client.generate_presigned_url('get_object', Params={'Bucket': "uploaded_images", 'Key': "logo.png"}, ExpiresIn=3600)
print(response)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Option two is to upload the file in public mode
&lt;/h3&gt;

&lt;p&gt;We can do that by adding &lt;strong&gt;ExtraArgs&lt;/strong&gt; to &lt;strong&gt;upload_file&lt;/strong&gt; or &lt;strong&gt;upload_fileobj&lt;/strong&gt; function.&lt;br&gt;&lt;br&gt;
Example:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import boto3

object_storage_config = {
        'region_name': 'ewr1',
        'endpoint_url': 'https://ewr1.vultrobjects.com',
        'aws_access_key_id': 'Your_access_key',
        'aws_secret_access_key': 'Your_secret_key'
}

client = boto3.client('s3', **object_storage_config)
client.create_bucket(Bucket="uploaded_images")
client.upload_file("./images/logo.png", "uploaded_images", "logo2.png", ExtraArgs={"ACL": "public-read"})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>python</category>
      <category>aws</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Cruky library first README</title>
      <dc:creator>Seif Almotaz Bellah</dc:creator>
      <pubDate>Mon, 04 Apr 2022 15:51:42 +0000</pubDate>
      <link>https://dev.to/seifalmotaz/cruky-library-first-readme-1ja2</link>
      <guid>https://dev.to/seifalmotaz/cruky-library-first-readme-1ja2</guid>
      <description>&lt;h2&gt;
  
  
  Info
&lt;/h2&gt;

&lt;p&gt;Cruky is a server-side library for the dart ecosystem to help you create your API as fast as possible. We want to make server-side apps with modern style and fast &lt;code&gt;high performance&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The main reason why I built this is that all libraries are focused on the Flutter ecosystem and not on dart lang&lt;br&gt;
and this makes the library have fewer futures than other frameworks or libraries like (Django, FastAPI, ROR, ..etc)&lt;br&gt;
So I decided that I will make a new library that focuses on Dart and get the maximum performance using dart:mirrors and code generators together to get the best usage of the dart.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Inspired by server-side frameworks like (Django, Flask, FastAPI, ROR)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Get started
&lt;/h2&gt;

&lt;p&gt;You can see the todo example in the examples file it's very clear to understand.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Install Dart from &lt;a href="https://dart.dev/" rel="noopener noreferrer"&gt;Dart.dev&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install the Cruky package with &lt;code&gt;dart pub global activate cruky&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create dart project with  &lt;code&gt;dart create nameOfProject&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;open the project with your favorite IDE like  &lt;code&gt;vscode&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;And let's get started&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Start adding the entrypoint app&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:cruky/cruky.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyApp&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;ServerApp&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="kt"&gt;List&lt;/span&gt; &lt;span class="kd"&gt;get&lt;/span&gt; &lt;span class="n"&gt;routes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="n"&gt;exampleWithGETRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's add our first route method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Route&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'/'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;exampleWithGetRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ReqCTX&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Json&lt;/span&gt;&lt;span class="p"&gt;({});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the &lt;code&gt;Route&lt;/code&gt; annotation to specify the route path, and add the method under it we can use the &lt;code&gt;Future&lt;/code&gt; method or regular method (async or sync).&lt;/p&gt;

&lt;h2&gt;
  
  
  Return data from the method
&lt;/h2&gt;

&lt;p&gt;You can return a List or map for now and the response content type is just JSON for now.&lt;/p&gt;

&lt;h2&gt;
  
  
  Return specific status code
&lt;/h2&gt;

&lt;p&gt;you can return the specific status code with the map like that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Route&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'/'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;exampleWithGetRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ReqCTX&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Json&lt;/span&gt;&lt;span class="p"&gt;({},&lt;/span&gt; &lt;span class="mi"&gt;201&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Now serve the app
&lt;/h2&gt;

&lt;p&gt;we can serve a simple app with this code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;runApp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="nl"&gt;debug:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;You can run with &lt;code&gt;cruky serve&lt;/code&gt;,&lt;br&gt;
This will run the file in &lt;code&gt;./lib/main.dart&lt;/code&gt;&lt;br&gt;
with &lt;code&gt;hot reload&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Note: In production mode better to use the &lt;code&gt;dart run&lt;/code&gt; command&lt;br&gt;
for less ram use and better performance.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  You can disable hot reload with:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;runApp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="nl"&gt;debug:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now Cruky will run the app with hot-reload if any thing changed in lib folder.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's add some middleware
&lt;/h2&gt;

&lt;p&gt;We can add a before and after middleware.&lt;br&gt;
The before middleware runs before calling the main route method handler,&lt;br&gt;
And the after middleware is the opposite.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="nd"&gt;@BeforeMW&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;middlewareExample&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ReqCTX&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;headerValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Token'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Not Auth'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;MW&lt;/code&gt; is the short of MiddleWare.&lt;br&gt;
The annotiation defines the type of middleware, There is two types &lt;code&gt;BeforeMW&lt;/code&gt; amd &lt;code&gt;AfterMW&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can access the header values with the &lt;code&gt;headerValue&lt;/code&gt; function, if you want the full access you can get the main &lt;code&gt;HttpRequest&lt;/code&gt; data with &lt;code&gt;req.native&lt;/code&gt; or the response with &lt;code&gt;req.response&lt;/code&gt; as &lt;code&gt;HttpResponse&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you want to not execute the next function you can (The main route method) you can return a response like in the example.&lt;/p&gt;

&lt;p&gt;Now we will add this middleware to global middlewares in the app and any route under it well have the same middleware.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyApp&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;ServerApp&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="kt"&gt;List&lt;/span&gt; &lt;span class="kd"&gt;get&lt;/span&gt; &lt;span class="n"&gt;routes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="n"&gt;exampleWithGETRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;];&lt;/span&gt;

  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="kt"&gt;List&lt;/span&gt; &lt;span class="kd"&gt;get&lt;/span&gt; &lt;span class="n"&gt;middlewares&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;middlewareExample&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt; &lt;span class="c1"&gt;/// add this&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or you can add the middleware scoped for a route like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Route&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'/'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;middlewareExample&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="n"&gt;exampleWithGetRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ReqCTX&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Json&lt;/span&gt;&lt;span class="p"&gt;({},&lt;/span&gt; &lt;span class="mi"&gt;201&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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