<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mustafa Ali Dikçinar on Medium]]></title>
        <description><![CDATA[Stories by Mustafa Ali Dikçinar on Medium]]></description>
        <link>https://medium.com/@mdikcinar?source=rss-18111d4ef749------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BTPkNI5YmiCBUFXuMzT45A.png</url>
            <title>Stories by Mustafa Ali Dikçinar on Medium</title>
            <link>https://medium.com/@mdikcinar?source=rss-18111d4ef749------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 07:38:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mdikcinar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Mastering Client-Side Git Hooks: A Guide for Teams]]></title>
            <link>https://medium.com/teamkraken/mastering-client-side-git-hooks-a-guide-for-teams-66b41d45c67e?source=rss-18111d4ef749------2</link>
            <guid isPermaLink="false">https://medium.com/p/66b41d45c67e</guid>
            <category><![CDATA[git-hooks]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Mustafa Ali Dikçinar]]></dc:creator>
            <pubDate>Mon, 23 Dec 2024 16:28:40 GMT</pubDate>
            <atom:updated>2024-12-24T06:25:20.569Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*8wJtylOHSWZqFCuwJ1_aFg.jpeg" /></figure><p>Git hooks are a versatile feature that can transform your development workflow by automating essential tasks. They ensure consistency across teams by enforcing coding standards, prevent errors by catching issues like failing tests or improper branch names before they affect the repository, and boost efficiency by automating repetitive tasks. This makes Git hooks an indispensable tool for maintaining a smooth and reliable development process.</p><p>This guide is aimed at developers who are familiar with Git and want to enhance their workflow using client-side Git hooks. If you’re new to Git, you may want to explore basic Git concepts first.</p><p><em>Note: Some of the examples here include Flutter-specific parts. I intentionally left them in so that you can adapt a similar approach for the framework you work with.</em></p><h4>What Are Git Hooks?</h4><p>Git hooks are scripts that Git executes before or after events such as committing, merging, or pushing code. They live in the .git/hooks directory of a repository and are triggered automatically when their associated event occurs. There are two main types of Git hooks:</p><ol><li><strong>Client-side hooks</strong>: Run on the developer’s machine to handle operations like commits and merges.</li><li><strong>Server-side hooks</strong>: Run on the server to enforce rules during events like receiving a push.</li></ol><p>With Git hooks, teams can:</p><ul><li>Automate code quality checks (e.g., linting and formatting).</li><li>Run automated tests to catch issues early.</li><li>Enforce commit message formats.</li><li>Automatically update documentation or changelogs.</li></ul><h4>Client-Side Git Hooks for Teams</h4><p><a href="https://git-scm.com/book/ms/v2/Customizing-Git-Git-Hooks">There are 14 client-side hooks available</a>, each serving a specific purpose. They can be used to streamline workflows, enforce coding standards, and minimize errors.</p><p>Some of the most useful client-side hooks include:</p><ul><li><strong>pre-commit</strong>: Runs before a commit is created.</li><li><strong>prepare-commit-msg</strong>: Modifies the commit message before it is shown in the editor.</li><li><strong>commit-msg</strong>: Validates the commit message.</li><li><strong>post-commit</strong>: Runs after a commit is created.</li><li><strong>pre-push</strong>: Runs before code is pushed to a remote repository.</li><li><strong>pre-merge-commit</strong>: Executes before a merge commit is created.</li><li><strong>post-checkout</strong>: Runs after a git checkout operation, useful for handling changes when switching branches.</li><li><strong>post-merge</strong>: Runs after a successful merge operation, allowing you to automate tasks like cleaning up or testing after merges.</li></ul><p>By using these hooks effectively, teams can ensure consistency and improve the quality of their code.</p><p>In this article, I will give examples for the <strong>pre-commit</strong>, <strong>prepare-commit-msg</strong>, and <strong>pre-push</strong> hooks, showing how to implement them in your workflow.</p><h4>Where to Place Git Hooks</h4><p>While the default location for Git hooks is the .git/hooks directory, this isn&#39;t ideal for teams because hooks placed there aren&#39;t shared across repositories. Instead, it&#39;s better to store your Git hooks in a centralized location within your project directory. This ensures consistency and makes it easier for team members to use the same hooks.</p><p>For Flutter projects (or any other projects), a good practice is to keep hooks under a bin/git_hooks folder. This keeps them organized alongside other project scripts such as Fastlane or CI/CD configurations, which might also be under the bin folder. Additionally, any common shell file can be placed under bin/scripts for shared functionality.</p><p><strong>Example directory structure:</strong></p><pre>project/<br>├── bin/<br>│   ├── git_hooks/<br>│   │   ├── pre-commit<br>│   │   ├── pre-push<br>│   │   ├── prepare-commit-msg<br>│   ├── scripts/<br>│   │   └── common.sh<br>│   └─── fastlane/<br>└── lib/</pre><h3>A Common Shell File for Reusability</h3><p>To avoid duplicating code across multiple hook scripts, you can use a common shell file (common.sh) to store shared configurations and utility functions. This file can include:</p><ul><li><strong>Color codes</strong> for better readability in terminal output.</li><li><strong>Path exports</strong> to ensure the hooks can find project-specific tools or dependencies.</li><li><strong>Reusable functions</strong> for tasks like printing error messages or running checks.</li></ul><p>Here’s an example common.sh placed under bin/scripts/common.sh: <a href="https://gist.github.com/mdikcinar/bf22cdc15b479fa6559fc078dc11f5f4">Gist</a></p><ul><li><em>Replace </em><strong><em>team_prefix </em></strong><em>with your team’s specific prefix</em></li></ul><pre>#!/bin/bash<br><br># Colors for terminal output<br>YELLOW=$&#39;\033[0;33m&#39;  # Yellow color for warnings<br>GREEN=$&#39;\033[0;32m&#39;   # Green color for success messages<br>RED=$&#39;\033[0;31m&#39;     # Red color for error messages<br>PURPLE=$&#39;\033[0;35m&#39;  # Purple color for prompts/questions<br>RESET=$&#39;\033[0m&#39;      # Reset color to default<br>BLUE=$&#39;\033[0;34m&#39;    # Blue color for info<br>BLACK=$&#39;\033[0;30m&#39;   # Black color for additional styling<br>CYAN=$&#39;\033[0;36m&#39;    # Cyan color for highlights<br>BI_BLUE=$&#39;\033[1;94m&#39; # Bright blue for emphasis<br><br># Error message and user prompt<br>errorMsg=&#39;An error happened.&#39;<br>question=&#39;Do you want to continue with errors?&#39;<br><br># Project directory setup<br>project_dir=&quot;$(git rev-parse --show-toplevel)&quot;<br>export PATH=&quot;$PATH:$project_dir/.fvm/flutter_sdk/bin&quot;<br><br># Team-specific prefix (e.g., JIRA project key)<br>team_prefix=&#39;TEAM&#39;  # Replace TEAM with your team&#39;s specific prefix, such as ABC, XYZ, AMT<br><br># Function: Ask user if they want to continue despite errors<br># Provides a prompt to continue or abort depending on the environment<br>askBeforeContinue() {<br>   errorMsg=&quot;$1&quot;<br>   if [[ &quot;$SHLVL&quot; -eq 1 ]]; then<br>       clean_message=$(remove_ansi_codes &quot;$errorMsg&quot;)<br>       # Running in VSCode terminal (macOS specific example with AppleScript)<br>       result=$(osascript -e &quot;tell application \&quot;System Events\&quot; to display dialog \&quot;$clean_message\n$question\&quot; buttons {\&quot;No\&quot;, \&quot;Yes\&quot;} default button \&quot;Yes\&quot; with icon caution with title \&quot;Git Hooks\&quot;&quot; button returned of result)<br><br>       if [[ $result != &#39;button returned:Yes&#39; ]]; then<br>           print_error_message &quot;${RED}Push aborted!! Because of errors${RESET}&quot;<br>           exit 1<br>       fi<br>   else<br>       # Running in a system terminal<br>       echo &quot;$errorMsg&quot;<br>       read -e -p &quot;${PURPLE}pre-commit: ${YELLOW}$question [y/N] ${RESET}&quot; answer &lt; /dev/tty<br>       case ${answer:0:1} in<br>           y|Y )<br>               echo &quot;${PURPLE}pre-commit:${RESET} ${GREEN}Continuing...${RESET}&quot;;;<br>           * )<br>               echo &quot;${PURPLE}pre-commit:${RESET} ${RED}Aborting push!${RESET}&quot;<br>               exit 1;;<br>       esac<br>   fi<br>}<br><br># Function: Remove ANSI codes from a string<br>remove_ansi_codes() {<br>    local input=&quot;$1&quot;<br>    # ANSI escape codes for colors and formatting<br>    echo &quot;$input&quot; | sed -E &#39;s/\x1B\[[0-9;]*[mK]//g&#39;<br>}<br><br># Function to print error message based on SHLVL<br>print_error_message() {<br>    errorMsg=&quot;$1&quot;<br>    if [[ &quot;$SHLVL&quot; -eq 1 ]]; then<br>        clean_message=$(remove_ansi_codes &quot;$errorMsg&quot;)<br>        echo &quot;$clean_message&quot;<br>    else<br>        echo &quot;$errorMsg&quot;<br>    fi<br>}</pre><h3>Using prepare-commit-msg Hook for Consistent Commit Messages</h3><p><strong>When it runs:</strong> Before a commit message editor opens with a default or user-supplied message.</p><p>A prepare-commit-msg Git hook is a powerful tool to standardize commit messages across a team. It ensures commit messages are formatted correctly and include essential details, such as issue references, to maintain traceability.</p><p>Below is an example prepare-commit-msg script for your project: <a href="https://gist.github.com/mdikcinar/4a6e5879258f9fbfb3d079ca43fef300">Gist</a></p><pre>#!/bin/sh<br><br># Load shared configurations and utility functions<br>source bin/scripts/common.sh<br><br># Arguments passed to the hook<br>COMMIT_MSG_FILE=$1<br>COMMIT_SOURCE=$2<br>SHA1=$3<br><br># Extract the current branch name<br>#!/bin/bash<br>branch_name=`git rev-parse --abbrev-ref HEAD`<br>commit_msg=$(cat $COMMIT_MSG_FILE)<br><br># Define the list of valid commit prefixes<br>allowed_commit_prefixes=(&quot;feat&quot; &quot;refactor&quot; &quot;fix&quot; &quot;docs&quot; &quot;release&quot; &quot;chore&quot; &quot;test&quot; &quot;perf&quot; &quot;revert&quot; &quot;ci&quot; &quot;build&quot; &quot;Merge&quot;)<br><br># Dynamically create the regex from the list<br>regex_commit_start=&quot;^($(IFS=\|; echo &quot;${allowed_commit_prefixes[*]}&quot;)): .*&quot;<br><br># Validation logic<br>if [[ ! $commit_msg =~ $regex_commit_start ]]; then<br>  errorMsg=&quot;${PURPLE}prepare-commit-msg:${YELLOW} Your commit message must start with one of these prefixes: ${GREEN}$(IFS=,; echo &quot;&#39;${allowed_commit_prefixes[*]}&#39;, feat: example&quot;)${RESET}&quot;<br>  print_error_message &quot;$errorMsg&quot;<br>  echo &quot;${PURPLE}prepare-commit-msg:${YELLOW} Current commit message: ${GREEN}$commit_msg${RESET}&quot;<br>  exit 1<br>fi<br><br># Regex to check if commit message ends with an issue key (e.g., TEAM-123)<br>regex_commit_end=&#39;^.*\(${team_prefix}-[0-9]+\)$&#39;<br>if [[ ! $commit_msg =~ $regex_commit_end ]]; then<br>    # Extract the issue key from the branch name (e.g., feature/TEAM-123)<br>    issue=$(echo &quot;$branch_name&quot; | awk -F/ &#39;{print $2}&#39;)<br>    # Append the issue key to the commit message if it exists<br>    if [ -n &quot;$issue&quot; ]; then<br>        echo &quot;$commit_msg ($issue)&quot; &gt; $COMMIT_MSG_FILE<br>    else<br>        errorMsg=&quot;${PURPLE}prepare-commit-msg:${YELLOW} Your commit message must end with an issue key in parentheses, e.g., ${GREEN}&#39;feat: example commit (${team_prefix}-123)&#39;${RESET}&quot;<br>        print_error_message &quot;$errorMsg&quot;<br>        exit 1<br>    fi<br>fi<br><br># Explanation:<br># 1. `regex_commit_start`: Ensures the commit message starts with a standard type.<br>#    Example valid message: &quot;feat: Add login feature&quot;<br># 2. `regex_commit_end`: Ensures the commit message ends with a JIRA issue key.<br>#    Example valid message: &quot;feat: Add login feature (${team_prefix}-123)&quot;<br># 3. If the issue key is missing, it tries to extract it from the branch name (e.g., feature/${team_prefix}-123).<br># 4. Automatically appends the extracted issue key if valid.<br><br># Notes:<br># - Update `team_prefix` in `common.sh` to match your team&#39;s JIRA prefix.<br># - Ensure branch names follow the patterns like `feature/&lt;issue-key&gt;`, `bugfix/&lt;issue-key&gt;` for automatic detection.</pre><h4>How It Works</h4><p><strong>1 — Prefix Validation:</strong> The script checks that the commit message begins with a valid prefix, such as feat:, fix:, or docs:. This ensures that all commit messages are categorized appropriately.</p><p><strong>Example:</strong></p><ul><li>❌ added login functionality</li><li>✅ feat: add login functionality</li></ul><p><strong>2 — Issue Key Enforcement and Automation:</strong> The script ensures that the commit message ends with a Jira issue key (e.g., TEAM-123) in parentheses. If the issue key is not present, it attempts to extract it from the branch name and adds automatically end of the commit message (e.g., feature/TEAM-123).</p><p><strong>Example:</strong></p><ul><li>❌ feat: add login functionality</li><li>✅ feat: add login functionality (${team_prefix}-123)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*XkNOnbWgwVxa7bWsThgU_g.png" /></figure><h3>Using pre-commit Hook for Branch Naming and Restrictions</h3><p><strong>When it runs:</strong> Before git commit is executed.</p><p>The pre-commit Git hook can enforce rules for branch naming and restrict direct commits to protected branches such as master or devlopment. This helps maintain a clean Git history and reduces potential conflicts.</p><p>Below is an example pre-commit script for your project: <a href="https://gist.github.com/mdikcinar/17c91e3b9af5fd5dcf6d900607431201">Gist</a></p><pre>#!/bin/sh<br><br># Load shared configurations and utility functions<br>source bin/scripts/common.sh<br><br># List of protected branches<br>protected_branches=(&quot;master&quot; &quot;development&quot;)<br><br># Get the current branch name<br>branch=$(git branch --show-current)<br><br># Prevent direct commits to protected branches<br>if [[ &quot; ${protected_branches[@]} &quot; =~ &quot; $branch &quot; ]]; then<br>    errorMsg=&quot;${PURPLE}pre-commit: ${YELLOW}You are not allowed to commit directly to the ${GREEN}&#39;$branch&#39;${YELLOW} branch.${RESET}&quot;<br>    print_error_message &quot;$errorMsg&quot;<br>    echo &quot;${PURPLE}pre-commit: ${YELLOW}Please create a new branch and submit a pull request instead.${RESET}&quot;<br>    exit 1<br>fi<br><br># Validate branch name format for new branches<br>#!/bin/bash<br>branch_name=`git rev-parse --abbrev-ref HEAD`<br><br>allowed_branch_types=(&quot;feature&quot; &quot;bugfix&quot; &quot;hotfix&quot; &quot;release&quot;)<br>regex_branch_name=&quot;^($(IFS=\|; echo &quot;${allowed_branch_types[*]}&quot;))/${team_prefix}-[0-9]+$&quot;<br><br>if ! [[ $branch_name =~ $regex_branch_name ]]; then<br>    errorMsg=&quot;${PURPLE}pre-commit: ${GREEN}$branch_name ${YELLOW}branch name must start with one of ${GREEN}&#39;$(IFS=,; echo &quot;${allowed_branch_types[*]}&quot;)/${team_prefix}-&#39;, followed by one or more digits.${RESET}&quot;<br>    askBeforeContinue &quot;$errorMsg&quot;<br>fi</pre><h4>How It Works</h4><p><strong>1 — Protected Branches:</strong> The script prevents direct commits to master or development branches, ensuring all changes are made through feature branches and pull requests.</p><p><strong>Example:</strong></p><ul><li>❌ Commit directly to master</li><li>✅ Commit to feature/TEAM-123</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8GH5MriVJ48hehFJpcW4Zw.png" /></figure><p><strong>2 — Branch Name Validation:</strong> For new branches, the script ensures the branch name follows the convention, such as feature/TEAM-123, bugfix/TEAM-456, etc. This helps identify the purpose and related issue of the branch easily.</p><p><strong>Example:</strong></p><ul><li>❌ my-branch</li><li>✅ feature/TEAM-123</li></ul><p><strong>3 — Prompt for Invalid Names:</strong> If a branch name does not match the expected format, the script prompts the user to continue or abort the commit. This avoids accidental commits with unclear branch names.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Vb59jN_mGnmxqgO_QqP9A.png" /></figure><h3>Using pre-push Hook for Running Tests and Analyzers</h3><p><strong>When it runs:</strong> Before executing git push .</p><p>The pre-push Git hook is a safeguard to ensure code quality before changes are pushed to the remote repository. It runs automated tests and analyzers, preventing potential issues from reaching the repository but these checks are better suited for CI/CD pipelines, as they can significantly increase the time it takes to push changes, especially for large projects or extensive test suites.</p><p>Below is an example pre-push script for your project: <a href="https://gist.github.com/mdikcinar/295837da78b066a8429d9b977a53032b">Gist</a></p><pre>#!/bin/sh<br><br># Load shared configurations and utility functions<br>source bin/scripts/common.sh<br><br># Prompt user to decide if analyzer and tests should run<br>askBeforeRunAnalysesAndTest() {<br>   if [[ &quot;$SHLVL&quot; -eq 1 ]]; then<br>    # Running in VSCODE terminal<br>    result=$(osascript -e &#39;tell application &quot;System Events&quot; to display dialog &quot;Do you want to run analyzer and tests?&quot; buttons {&quot;No&quot;, &quot;Yes&quot;} default button &quot;Yes&quot; with icon caution with title &quot;Git Hooks&quot;&#39; button returned of result)<br><br>    if [[ $result == &#39;button returned:Yes&#39; ]]; then<br>      echo &quot;User clicked Yes&quot;<br>    else<br>      # User clicked No or closed the dialog<br>      exit 0<br>    fi<br>  else<br>    # Running in system terminal<br>    read -e -p &quot;${PURPLE}pre-push: ${YELLOW}Do you want to run analyzer? [y/N] ${RESET}&quot; answer &lt; /dev/tty<br>    case ${answer:0:1} in<br>        y|Y ) <br>            echo &quot;${PURPLE}pre-push: ${GREEN}Continuing...${RESET}&quot;;;<br>        * ) echo &quot;${PURPLE}pre-push: ${GREEN}Continuing without analyze and test!${RESET}&quot;; exit 0;;<br>    esac<br>  fi<br>}<br><br># Run Flutter tests<br>runFlutterTests() {<br>    echo &quot;${PURPLE}pre-push: ${YELLOW}Running Flutter Tests...${RESET}&quot;<br>    flutter test<br>    status_analyze=$?<br>    if [ $status_analyze -ne 0 ]; then<br>        print_error_message &quot;${PURPLE}pre-push: ${RED}Some tests failed.${RESET}&quot;<br>        exit 1<br>    else<br>        echo &quot;${PURPLE}pre-push: ${GREEN}All tests passed!${RESET}&quot;<br>    fi<br>}<br><br># Run Dart analyzer<br>runDartAnalyzer() {<br>    echo &quot;${PURPLE}pre-push: ${YELLOW}Running Dart Analyzer...${RESET}&quot;<br>    output_analyze=$(flutter analyze 2&gt;&amp;1)<br>    status_analyze=$?<br>    # Print the output of the analyze command<br>    echo &quot;$output_analyze&quot;<br>    if [ $status_analyze -ne 0 ]; then<br>        askBeforeContinue &quot;${PURPLE}pre-push: ${RED}Analyzer found issues.${RESET}&quot;<br>    fi<br>    echo &quot;${PURPLE}pre-push: ${GREEN}Dart analyzer passed! No issues found!${RESET}&quot;<br>}<br><br># Check for unused files and codes<br>runUnusedCheck() {<br>    local check_type=$1<br>    echo &quot;${PURPLE}pre-push: ${YELLOW}Checking unused $check_type...${RESET}&quot;<br>    output=$(dart run dart_code_linter:metrics check-unused-$check_type lib 2&gt;&amp;1)<br>    status_analyze=$?<br>    echo &quot;$output&quot;<br>    if [ $status_analyze -ne 0 ]; then<br>        echo &quot;${PURPLE}pre-push: ${RED}Some unused $check_type found.${RESET}&quot;<br>        askBeforeContinue &quot;Unused $check_type detected.&quot;<br>    else<br>        echo &quot;${PURPLE}pre-push: ${GREEN}Unused $check_type check passed!${RESET}&quot;<br>    fi<br>}<br><br># Execution starts here<br>askBeforeRunAnalysesAndTest<br>runFlutterTests<br>runDartAnalyzer<br>runUnusedCheck &quot;files&quot;<br>runUnusedCheck &quot;code&quot;</pre><h3>How to Enable Hooks</h3><p>To enable hooks for your repository, create a script (hooks.sh) under bin/scripts/ and use it to configure Git to use a custom hooks directory.</p><pre>#!/bin/bash<br><br>source ./common.sh<br><br>CUSTOM_HOOKS_PATH=&quot;$project_dir/bin/git_hooks&quot;<br><br>echo &quot;${PURPLE}hooks.sh: ${YELLOW}Hooks are enabling...${RESET}&quot;;<br>git config core.hooksPath &quot;$CUSTOM_HOOKS_PATH&quot;<br>chmod -R +x &quot;$CUSTOM_HOOKS_PATH&quot;<br>echo &quot;${PURPLE}hooks.sh: ${GREEN}Hooks are enabled.${RESET}&quot;;<br></pre><h3>Troubleshooting Git Hooks: Common Issues and Solutions</h3><p>If you encounter the error <strong>“Not authorized to send Apple event to System Events”</strong> while using Git hooks, particularly in pre-push hooks, it’s likely due to macOS privacy settings. To resolve this,</p><p>Go to <strong>System Preferences &gt; Security &amp; Privacy &gt; Privacy</strong>. In the <strong>Automation</strong> section, make sure the necessary permissions are enabled for terminal or your development environment to interact with <strong>System Events</strong>.</p><p>Additionally, because configuring system events can be challenging on macOS, and since I personally prefer using the console, I wasn’t able to fully optimize the system events in the pre-push hook. Therefore, I recommend using the console directly for push-related tasks instead of relying on the pre-push hook.</p><h3>Thanks for Reading!</h3><p>I hope this guide has helped you understand the potential of client-side Git hooks for automating and enforcing best practices in your development workflow. If you have any ideas or improvements, feel free to share them in the comments. Together, we can create even better solutions for quality and efficiency!</p><p>⭐️ I also would like to thank Team Kraken review this article.</p><p>💙 You can find me on <a href="https://twitter.com/mdikcinar">Twitter</a> and <a href="https://www.linkedin.com/in/mdikcinar/">Linkedin</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66b41d45c67e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/teamkraken/mastering-client-side-git-hooks-a-guide-for-teams-66b41d45c67e">Mastering Client-Side Git Hooks: A Guide for Teams</a> was originally published in <a href="https://medium.com/teamkraken">Team Kraken</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Boost Your Flutter Development with These Essential VSCode Extensions]]></title>
            <link>https://medium.com/teamkraken/boost-your-flutter-development-with-these-essential-vscode-extensions-be0ee35701ac?source=rss-18111d4ef749------2</link>
            <guid isPermaLink="false">https://medium.com/p/be0ee35701ac</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[vscode-extension]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Mustafa Ali Dikçinar]]></dc:creator>
            <pubDate>Tue, 22 Oct 2024 10:39:00 GMT</pubDate>
            <atom:updated>2024-10-22T10:39:00.004Z</atom:updated>
            <content:encoded><![CDATA[<p>As a Flutter developer, having the right tools can significantly enhance your productivity and code quality. Visual Studio Code (VSCode) is a popular choice among developers due to its rich ecosystem of extensions. In this article, we’ll explore some must-have VSCode extensions that can streamline your Flutter development workflow.</p><h3>General Extensions</h3><h3>VSCode Icons</h3><p><a href="https://marketplace.visualstudio.com/items?itemName=vscode-icons-team.vscode-icons"><strong>VSCode Icons</strong></a> enhances your workspace by replacing the default file and folder icons with a wide variety of customizable icons. It supports numerous file types, making project navigation clearer and more visually appealing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*69vby7KoGBO5D6XDs2vdIg.gif" /></figure><h3>Better Comments</h3><p>Enhance the readability of your code by categorizing comments into alerts, queries, TODOs, and more with <a href="https://marketplace.visualstudio.com/items?itemName=aaron-bond.better-comments"><strong>Better Comments</strong></a>. This extension color-codes your comments, making it easier to identify different types of annotations at a glance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*dt0ryLQcGRBFXtYtNPnJeQ.png" /></figure><h3>Code Spell Checker</h3><p>Avoid embarrassing typos in your codebase with the <a href="https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker"><strong>Code Spell Checker</strong></a>. This lightweight extension highlights spelling errors in your comments and strings. It also offers various language options that can be especially useful when adding localizations. For example, you can use the <a href="https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker-turkish"><strong>Turkish — Code Spell Checker</strong></a> to ensure accuracy when working in Turkish or other supported languages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*ncFQTNsT_rBVHce4NpdRMg.gif" /></figure><h3>Error Lens</h3><p>Don’t miss any errors or warnings in your code with <a href="https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens"><strong>Error Lens</strong></a>. This extension brings diagnostics to your attention by highlighting them directly in the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*OcjSKpCmJhl9-1NOGBdhAQ.png" /></figure><h3>Project Manager</h3><p>Easily switch between projects without leaving VSCode using <a href="https://marketplace.visualstudio.com/items?itemName=alefragnani.project-manager"><strong>Project Manager</strong></a>. It allows you to organize and access your projects efficiently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*vF0xDGmBdifxhD5f__JyUQ.png" /></figure><h3>SVG Preview</h3><p>Work with SVG files seamlessly using the <a href="https://marketplace.visualstudio.com/items?itemName=SimonSiefke.svg-preview"><strong>SVG Preview</strong></a> extension. It provides a live preview of your SVG files within VSCode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PXBEIZmS1umjmKGd3rOOrA.gif" /></figure><h3>Version Lens</h3><p>Keep your dependencies up to date with <a href="https://marketplace.visualstudio.com/items?itemName=pflannery.vscode-versionlens"><strong>Version Lens</strong></a>. This extension shows the latest version of packages directly in your pubspec.yaml file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/407/1*yTDqdHHl6dFS04Al1Kpecw.gif" /></figure><h3>LottieFiles for VSCode</h3><p>Integrate Lottie animations into your Flutter apps with ease using <a href="https://marketplace.visualstudio.com/items?itemName=lottiefiles.vscode-lottie"><strong>LottieFiles for VSCode</strong></a>. Browse, preview, and insert animations without leaving your editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2c35rEsfj45yvwjS5LkXAA.png" /></figure><h3>GitHub Copilot</h3><p>Boost your coding efficiency with <a href="https://marketplace.visualstudio.com/items?itemName=GitHub.copilot"><strong>GitHub Copilot</strong></a>, an AI pair programmer that provides real-time code suggestions. It helps you write code faster by offering intelligent completions and automating repetitive tasks. While GitHub Copilot is a paid service, students can access it for free through the <a href="https://education.github.com/pack"><strong>GitHub Student Developer Pack</strong></a>, making it a great resource for learning and building projects at no extra cost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*nNTk5DTlEZyxIJZNwIi09A.png" /></figure><h3>Trailing Spaces</h3><p>Ensure clean code by highlighting and removing unnecessary trailing spaces with the <a href="https://marketplace.visualstudio.com/items?itemName=shardulm94.trailing-spaces"><strong>Trailing Spaces</strong></a> extension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/128/1*Tx2FCSaugxyBN78dqRI7PA.png" /></figure><h3>Markdown Preview Enhanced</h3><p>Write and preview Markdown files with enhanced features using <a href="https://marketplace.visualstudio.com/items?itemName=shd101wyy.markdown-preview-enhanced"><strong>Markdown Preview Enhanced</strong></a>. It supports diagrams, formulas, and more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UJLCCn7xhwbTcGrRzhoMSA.png" /></figure><h3>Polacode or CodeSnap</h3><p>Create beautiful code snapshots for your documentation or blog posts with <a href="https://marketplace.visualstudio.com/items?itemName=jeff-hykin.polacode-2019"><strong>Polacode</strong></a> or <a href="https://marketplace.visualstudio.com/items?itemName=adpyke.codesnap"><strong>CodeSnap</strong></a>. These extensions generate stylized images of your code snippets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*svapWsg8BDeRWMu7ExxS_A.gif" /></figure><h3>change-case</h3><p>Easily change the case of your text selections with the <a href="https://marketplace.visualstudio.com/items?itemName=wmaurer.change-case"><strong>change-case</strong></a> extension. It supports various case conversions like camelCase, snake_case, and more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*mlhkVnC37sL8XHytACkLEw.gif" /></figure><h3>GitHub Pull Requests</h3><p>Manage your GitHub pull requests directly from VSCode using the <a href="https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github"><strong>GitHub Pull Requests</strong></a> extension. Review, comment, and merge without switching context.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0YhwewNDP63a0UWh2Q_2Xw.gif" /></figure><h3>GitLens</h3><p>Supercharge your Git capabilities with <a href="https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens"><strong>GitLens</strong></a>. It provides insights into code authorship, changes, and history.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*gRPPBZdeCw8zueO0H0atcQ.png" /><figcaption>Inline and Status Bar Blame</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*bG3-to0p4Wzt3GpiQ9YMug.png" /><figcaption>Rich Hovers</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*REuvyv9m0iK_I9HVBGvuYQ.gif" /><figcaption>Revision Navigation</figcaption></figure><h3>Atom One Dark and Light Theme</h3><p><em>Personal Suggestion</em></p><p>Elevate your coding environment with the <a href="https://marketplace.visualstudio.com/items?itemName=akamud.vscode-theme-onedark"><strong>Atom One Dark</strong></a><strong> and </strong><a href="https://marketplace.visualstudio.com/items?itemName=akamud.vscode-theme-onelight"><strong>Light Theme</strong></a>. This theme offers a clean and visually appealing interface that can reduce eye strain during long coding sessions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xQPP33RfbGOlzYawfFFx5g.png" /></figure><h3>Dart and Flutter Extensions</h3><h3>Dart Data Class Generator</h3><p>Simplify the creation of Dart data classes with the <a href="https://marketplace.visualstudio.com/items?itemName=ricardo-emerson.dart-data-class-tools"><strong>Dart Data Class Generator</strong></a>. It automatically generates boilerplate code for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ulgcyJI6E3WYMHt7b8v55w.gif" /></figure><h3>BLoC</h3><p>If you’re using the BLoC state management pattern, the <a href="https://marketplace.visualstudio.com/items?itemName=FelixAngelov.bloc"><strong>BLoC</strong></a> extension provides snippets and tools to streamline your workflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*4KGxhFGRq9RUPhL3ftL_4Q.gif" /></figure><h3>Flutter Helpers</h3><p>Enhance your Flutter development with <a href="https://marketplace.visualstudio.com/items?itemName=aksharpatel47.vscode-flutter-helper"><strong>Flutter Helpers</strong></a>. It offers utilities and shortcuts to speed up your coding process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*uTwp8Cn4-YPOuJrQ5XCjxg.gif" /></figure><h3>Pubspec Assist</h3><p>Manage your dependencies effortlessly with <a href="https://marketplace.visualstudio.com/items?itemName=jeroen-meijer.pubspec-assist"><strong>Pubspec Assist</strong></a>. It helps you add, update, or remove packages from your pubspec.yaml file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*hJL89-dt31-UucKFzgmnew.gif" /></figure><h3>Pubspec Dependency Search</h3><p>Quickly search for packages without leaving VSCode using <a href="https://marketplace.visualstudio.com/items?itemName=everettjf.pubspec-dependency-search"><strong>Pubspec Dependency Search</strong></a>. It integrates pub.dev search functionality into your editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*9kckvYShEZbfJ1zsfH-wyQ.png" /></figure><h3>Flutter Coverage</h3><p>Measure your code coverage with <a href="https://marketplace.visualstudio.com/items?itemName=Flutterando.flutter-coverage"><strong>Flutter Coverage</strong></a>. It integrates coverage reporting into VSCode, helping you write better-tested code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*trDajnU_OfAi7UCBZB_g4A.gif" /></figure><h3>Awesome Flutter Snippets</h3><p>Speed up your Flutter development with <a href="https://marketplace.visualstudio.com/items?itemName=Nash.awesome-flutter-snippets"><strong>Awesome Flutter Snippets</strong></a>. It provides a collection of useful code snippets for Flutter and Dart.</p><h3>Dart Barrel File Generator</h3><p>Generate barrel files for folders containing dart files with <a href="https://marketplace.visualstudio.com/items?itemName=miquelddg.dart-barrel-file-generator">Dart Barrel File Generator</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oM3xlRP6EaRM5us-IFAkeA.gif" /></figure><h3>Flutter Color</h3><p>Simplify color selection in your Flutter projects with <a href="https://marketplace.visualstudio.com/items?itemName=circlecodesolution.ccs-flutter-color"><strong>Flutter Color</strong></a>. This extension provides a convenient color picker directly within VSCode, allowing you to easily choose and insert colors into your code without switching context. It enhances your Flutter development workflow by making color management more intuitive and efficient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*qvFujOa7CMyheHw5bpshaA.jpeg" /></figure><h3>Bonus: Amazon Q — VSCode integration</h3><p><a href="https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-getting-started-installing.html">Amazon Q</a> integrates seamlessly with terminal environments, providing developers with enhanced features like <strong>autocomplete</strong>, <strong>syntax highlighting</strong>, and <strong>intelligent suggestions. </strong>These features make it easier to work efficiently within the terminal by offering real-time command suggestions, smart completions, and context-aware inputs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JaonF4ke6i74IDQdL63U8g.gif" /></figure><p>Before using these extensions, make sure to read their descriptions, as each one offers a variety of powerful features that can greatly enhance your workflow.</p><p>By integrating these extensions into your VSCode setup, you can improve your productivity, maintain cleaner code, and streamline your Flutter development process. Additionally, I’ve compiled all these packages into an <strong>Extension Pack</strong> for your convenience, which you can easily install via the link below:</p><p><a href="https://marketplace.visualstudio.com/items?itemName=team-kraken.kraken-flutter-extension-pack"><strong>Kraken Flutter Extension Pack</strong></a></p><p>If you think there are other useful extensions that should be included, feel free to leave a comment. We’ll be happy to add them to the pack!</p><p>Happy coding!</p><p>🎉 Thanks for reading my article.</p><p>⭐️ I also would like to thank Team Kraken review this article.</p><p>💙 You can find me on <a href="https://twitter.com/mdikcinar">Twitter</a> and <a href="https://www.linkedin.com/in/mdikcinar/">Linkedin</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be0ee35701ac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/teamkraken/boost-your-flutter-development-with-these-essential-vscode-extensions-be0ee35701ac">Boost Your Flutter Development with These Essential VSCode Extensions</a> was originally published in <a href="https://medium.com/teamkraken">Team Kraken</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Assetleri Şifreleme]]></title>
            <link>https://medium.com/teamkraken/flutter-assetleri-%C5%9Fifreleme-bb1103aa7d41?source=rss-18111d4ef749------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb1103aa7d41</guid>
            <category><![CDATA[assets]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[şifreleme]]></category>
            <category><![CDATA[encription]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Mustafa Ali Dikçinar]]></dc:creator>
            <pubDate>Tue, 01 Oct 2024 11:18:32 GMT</pubDate>
            <atom:updated>2024-10-01T11:18:32.319Z</atom:updated>
            <content:encoded><![CDATA[<p>Merhabalar, daha önceden İngilizce olarak paylaşmış olduğum makalemi Türkçe olarak da sizlerle paylaşmak istedim.</p><p>Bu makalede assetlerimizi şifreleyerek nasıl güvende tutabileceğimizden bahsedeceğim.</p><p><strong>Peki neden Assetlerimizi şiflemeye ihtiyaç duyuyoruz?</strong></p><p>Bildiğiniz üzere, uygulamamızı derledikten sonra uygulama paketini zip yardımı ile açtığımızda içerisinde bulunan assetlere rahatça erişebiliyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*ESpGEwF3-iyV4A-3krTEOw.gif" /><figcaption>Non encypted assets</figcaption></figure><p>Fakat ya gizli tutmak istediğimiz özel assetlerimiz var ise nasıl bir yol izlemeliyiz?</p><ul><li>Bunun için <a href="https://pub.dev/packages/encrypt">Encrypt</a> paketine bir göz atıp neler yapabileceğimize bir bakalım</li></ul><p><strong>Encrypt paketi yardımıyla Assetlerimizi şifreleme</strong></p><p>Başlamadan önce şifrelemede kullanacağımız bir anahtar(<em>secure-key</em>) üretmemiz gerekiyor. Bir anahtar üretebilmek için Dart üzerine encrypt paketini ekliyoruz. Bir terminal açıp aşağıdaki adımları izleyelim.</p><pre>dart pub global activate encrypt</pre><p>Paketi kurduktan sonra aşağıdaki terminal kumutu ile anahtarımızı üretelim.</p><pre>secure-random</pre><p>Buna benzer bir anahtar elde etmiş olmalıyız.</p><blockquote><em>yA7exe4ZFq5g2St1VDDexMJ5yr+8w+0RWivkfIrUVmc=</em></blockquote><p>Bu anahtarı bi yere not edelim, ilerideki adımlarda kullanacağız.</p><p>Şimdi bir Dart projesi oluşturup Asset dosyalarımızı şifreleyelim. Bunun için Github’da paylaşmış olduğum <a href="https://github.com/mdikcinar/file_encryption">Örnek Dart Projesi</a>’ni direkt olarak kullanabilir veya aşağıdaki kodları inceleyerek kendi şifreleme algoritmanızı yazabilirsiniz.</p><p>Benim paylaşmış olduğum, aşağıda da kodları bulunan örnek şu şekilde çalışmaktadır.</p><ul><li>Şifrelemek istediğimiz Assetlerimizi <em>Input</em> klasörüne taşıyoruz.</li><li>Main koddaki anahtarı(<em>secure-key)</em> daha önceki adımlarda üretmiş olduğumuz anahtar ile değiştiriyoruz.</li><li>Projeyi çalıştırıyoruz.</li><li>Oluşan <em>Output</em> klasöründeki şifrelenmiş Assetlerimizi Flutter projemize taşıyoruz.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3dfc3bae5ec4a857db50ade19959191c/href">https://medium.com/media/3dfc3bae5ec4a857db50ade19959191c/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8eb8f72ebfc3024b2358180ccb2c4bb8/href">https://medium.com/media/8eb8f72ebfc3024b2358180ccb2c4bb8/href</a></iframe><p>Assetlerimizi şifreleme işlemini tamamladık, ancak bu dosyaları şifrelediğimiz için elbette direkt olarak kullanamayacağız. Dosyalarımızın şifresini Flutter projemizin çalışma anında çözüp, anlaşılabilir duruma tekrar geri getirmeliyiz.</p><p><strong>Flutter projemizde Assetlerimizin şifrelerinizi çözelim</strong></p><p>İlk olarak, Flutter projemizde dosyalarımızı şifrelemek için de kullandığımız <a href="https://pub.dev/packages/encrypt">Encrypt</a> paketini pubspec.yaml’a ekleyelim.</p><pre>encrypt: ^5.0.1</pre><p>Bir singleton şifre çözme servisi(<em>DecryptionService) oluşturalım.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b05ae2fed70e8e128af077ce4419c50/href">https://medium.com/media/8b05ae2fed70e8e128af077ce4419c50/href</a></iframe><p><em>Not: Kullandığımız şifreleme anahtarını kod içerisinde, yani yukarıdaki örnekteki gibi tutmanızı önermiyorum. Bu konu güvenlik için önemli ve merak ediyor iseniz şu makaleye göz atabilirsiniz. </em><a href="https://codewithandrea.com/articles/flutter-api-keys-dart-define-env-files/"><em>Flutter’da anahtarlarımızı nasıl daha güvenli halde tutarız</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MxfnWVAS7KH4FKBt5ahEQA.png" /></figure><p>Son olarak, yaptığımız şifre çözme işlemi asenkron bir işlem olduğundan dolayı UI tarafında bunu ele almamız gerekiyor. Bu yüzden bu örnekte bir FutureBuilder kullandım.</p><p>Tebrikler, dosyalarımız artık daha güvende💙</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/1*EWzPcPH3dYJBMu-DTmf_9w.png" /></figure><p><strong>Sonuç</strong></p><p>Flutter’da Asset klasörüne atmış olduğumuz dosyaların güvenliği üzerine sizlere bir fikir vermek istedim, umarım bunu başarabilmişimdir :)</p><p>🎉 Makalemi okuduğunuz için teşekkürler, sıradaki makalelerde görüşmek üzere.</p><p>💙 Beni <a href="https://twitter.com/mdikcinar">Twitter</a> ve <a href="https://www.linkedin.com/in/mdikcinar/">Linkedin</a> üzerinden takip edebilir, sorularınız varsa yöneltebilirsiniz.</p><p>👉🏻 Bu makalenin kaynak kodlarına <a href="https://github.com/mdikcinar/file_encryption">Github</a> üzerinden ulaşabilirsiniz.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb1103aa7d41" width="1" height="1" alt=""><hr><p><a href="https://medium.com/teamkraken/flutter-assetleri-%C5%9Fifreleme-bb1103aa7d41">Flutter Assetleri Şifreleme</a> was originally published in <a href="https://medium.com/teamkraken">Team Kraken</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reducing Build Runner Code Generation Time in Flutter]]></title>
            <link>https://medium.com/teamkraken/reducing-build-runner-code-generation-time-in-flutter-39dd08b1ecb8?source=rss-18111d4ef749------2</link>
            <guid isPermaLink="false">https://medium.com/p/39dd08b1ecb8</guid>
            <category><![CDATA[build-runner]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[code-generation]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Mustafa Ali Dikçinar]]></dc:creator>
            <pubDate>Mon, 29 Jul 2024 08:53:10 GMT</pubDate>
            <atom:updated>2024-07-29T08:53:10.186Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6aCPd_5OH9AVRjmZHaS6xg.png" /></figure><p>Flutter is a popular framework for building cross-platform mobile applications. One of the challenges that developers face when working with Flutter is build runner time. The build runner is responsible for running tasks such as code generation, compilation, and other tasks required to build the application. The build runner time can be a bottleneck, especially during development, where developers need to rebuild the application frequently. In this article, we will explore a simple strategy that developers can use to reduce build runner time in Flutter.</p><p><strong>Use builders to generate code for multiple folders</strong></p><p>If you have code generation tasks that need to be performed on multiple folders, you can use Builders. Builders allow developers to define custom code generation tasks and associate them with specific directories in their project. To use Builders, developers need to define a build.yaml file in the root directory of their project. The build.yaml file contains configuration information for the Builder, including the directories it should operate on and the commands it should execute.</p><p>Here’s an example build.yaml file that defines a Builder that generates code for specified folders and files.</p><pre>targets:<br>  $default:<br>    builders:<br>      json_serializable:<br>        enabled: true<br>        options:<br>          field_rename: snake<br>        generate_for:<br>          - &quot;lib/core/**&quot;<br>          - &quot;lib/features/**&quot;<br>      injectable_generator|injectable_builder:<br>        enabled: true<br>        generate_for:<br>          - &quot;lib/**&quot;<br>      envied_generator|envied:<br>        generate_for:<br>          - &quot;lib/env.dart&quot;<br>      auto_route_generator|autoRouteGenerator:<br>        enabled: true<br>        generate_for:<br>          - &quot;lib/routes/router.dart&quot;</pre><blockquote>Example contains builders for these packages<br><a href="https://pub.dev/packages/json_serializable"><em>JsonSerializable</em></a><em>: </em>For handling JSON. The builders generate code when they find members annotated with classes defined in <a href="https://pub.dev/packages/json_annotation">json_annotation</a>.<br><a href="https://pub.dev/packages/injectable_generator"><em>InjectableGenerator</em></a><em>: </em>A generator for <a href="https://pub.dev/packages/injectable">injectable</a> library.<br><a href="https://pub.dev/packages/envied_generator"><em>EnviedGenerator:</em></a><em> </em>A generator for for <a href="https://pub.dev/packages/envied">envied</a> library.<br><a href="https://pub.dev/packages/auto_route_generator"><em>AutoRouteGenerator</em></a><em>: </em>A generator for <a href="https://pub.dev/packages/auto_route">auto_route</a> library.</blockquote><p>Also the files that includes code generation can be tagged with *.gen.dart and set generate for path for that files. This will also help to reduce the code generation time.</p><p><a href="https://github.com/dart-lang/build/blob/master/docs/build_yaml_format.md">Read more</a> about build.yaml files.</p><p><strong>Conclusion</strong></p><p>With this simple strategy our Build Runner code generation time is reduced about half.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6OkBpIeVuQZU3QDEhBOUXg.png" /><figcaption>Before — After</figcaption></figure><p>🎉 Thanks for reading my article.</p><p>⭐️ I also would like to thank Team Kraken review this article.</p><p>💙 You can find me on <a href="https://twitter.com/mdikcinar">Twitter</a>, <a href="https://www.linkedin.com/in/mdikcinar/">Linkedin</a> and <a href="https://github.com/mdikcinar">Github</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39dd08b1ecb8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/teamkraken/reducing-build-runner-code-generation-time-in-flutter-39dd08b1ecb8">Reducing Build Runner Code Generation Time in Flutter</a> was originally published in <a href="https://medium.com/teamkraken">Team Kraken</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Asset Encryption]]></title>
            <link>https://medium.com/teamkraken/flutter-asset-encryption-e8d6797bcd0e?source=rss-18111d4ef749------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8d6797bcd0e</guid>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[assets]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Mustafa Ali Dikçinar]]></dc:creator>
            <pubDate>Mon, 21 Nov 2022 15:10:36 GMT</pubDate>
            <atom:updated>2023-01-09T08:35:27.613Z</atom:updated>
            <content:encoded><![CDATA[<p>Keep your assets safe.</p><p>Hi, in this article I will explain how to keep your assets safe with encryption.</p><p><strong>Why We Need Asset Encryption?</strong></p><p>As you know, when we compile our app it is easy to get assets from inside the app package. For example, we can easily reach the assets and use them when we open an apk file with WinRAR(or you can change .apk to .zip).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*ESpGEwF3-iyV4A-3krTEOw.gif" /><figcaption>Non encypted assets</figcaption></figure><p>But what if we have own created assets that we want to keep them private?</p><ul><li>Well, to do that we can use <a href="https://pub.dev/packages/encrypt">Encrypt</a> package!</li></ul><p><strong>Let’s Encrypt Our Assets</strong></p><p>First of all, we need a <em>secure-key</em> to encrypt our files. To generate a secure key, we need to activate encrypt as globally. Open a terminal window and follow these steps.</p><pre>dart pub global activate encrypt</pre><p>then generate a secure-key</p><pre>secure-random</pre><p>you should get a key someting like this</p><blockquote><em>yA7exe4ZFq5g2St1VDDexMJ5yr+8w+0RWivkfIrUVmc=</em></blockquote><p>keep it somewhere we will need that.</p><p>Now we need to create a Dart project to encrypt our assets. <a href="https://github.com/mdikcinar/file_encryption">Here</a> is my example Dart project. You can directly use it to encrypt your files or create your encrypter by look into my code.</p><ul><li>Move your assets to the <em>Input</em> folder.</li><li>Set your <em>secure-key</em> that we generated before</li><li>Run the project</li><li>Move encrypted Assets from <em>Output</em> folder to your Flutter project</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3dfc3bae5ec4a857db50ade19959191c/href">https://medium.com/media/3dfc3bae5ec4a857db50ade19959191c/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8eb8f72ebfc3024b2358180ccb2c4bb8/href">https://medium.com/media/8eb8f72ebfc3024b2358180ccb2c4bb8/href</a></iframe><p>Now we encrypted our assets, we will not be able to use them directly because these are encrypted now. We need to decrypt them on runtime while using on Flutter project.</p><p><strong>Decrypt Assets on Flutter Side</strong></p><p>Open your Flutter project and add <a href="https://pub.dev/packages/encrypt">Encrypt</a> package to pubspec.yaml.</p><pre>encrypt: ^5.0.1</pre><p>Create a singleton <em>DecryptionService</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b05ae2fed70e8e128af077ce4419c50/href">https://medium.com/media/8b05ae2fed70e8e128af077ce4419c50/href</a></iframe><p><em>Note: I strongly suggest you don’t keep your secure key hard coded. You can read more </em><a href="https://codewithandrea.com/articles/flutter-api-keys-dart-define-env-files/"><em>How to Store API Keys in Flutter.</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MxfnWVAS7KH4FKBt5ahEQA.png" /></figure><p>I used <em>FutureBuilder</em> for this example and of course many things can be refactored, but these refactors are not our focus right now :)</p><p>Well, finally it worked like a charm 💙</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/1*EWzPcPH3dYJBMu-DTmf_9w.png" /></figure><p><strong>Conclusion</strong></p><p>I have tried to give an idea of how encryption can be applied to our assets. I hope I achieved that.</p><p>🎉 Thanks for reading my article.</p><p>⭐️ I also would like to thank <a href="https://twitter.com/BGoktugOzdemir">@BGoktugOzdemir</a> and <a href="https://twitter.com/UmithanGuldemir">@UmithanGuldemir</a> review this article.</p><p>💙 You can find me on <a href="https://twitter.com/mdikcinar">Twitter</a> and <a href="https://www.linkedin.com/in/mdikcinar/">Linkedin</a>.</p><p>👉🏻 You can find all the source code on <a href="https://github.com/mdikcinar/file_encryption">Github</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8d6797bcd0e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/teamkraken/flutter-asset-encryption-e8d6797bcd0e">Flutter Asset Encryption</a> was originally published in <a href="https://medium.com/teamkraken">Team Kraken</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>