<?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 Zahid Tekbaş on Medium]]></title>
        <description><![CDATA[Stories by Zahid Tekbaş on Medium]]></description>
        <link>https://medium.com/@zahidtekbas?source=rss-919f8dfa4c34------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Zahid Tekbaş on Medium</title>
            <link>https://medium.com/@zahidtekbas?source=rss-919f8dfa4c34------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 23:56:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zahidtekbas/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[How to Obtain Information About All Running Processes in Windows]]></title>
            <link>https://medium.com/@zahidtekbas/how-to-obtain-information-about-all-running-processes-in-windows-26fdce6124e7?source=rss-919f8dfa4c34------2</link>
            <guid isPermaLink="false">https://medium.com/p/26fdce6124e7</guid>
            <category><![CDATA[cpp]]></category>
            <category><![CDATA[windows]]></category>
            <dc:creator><![CDATA[Zahid Tekbaş]]></dc:creator>
            <pubDate>Mon, 20 Jan 2025 10:27:15 GMT</pubDate>
            <atom:updated>2025-01-20T10:27:15.358Z</atom:updated>
            <content:encoded><![CDATA[<p>When developing system-level applications, obtaining detailed information about running processes can be crucial. The Windows API provides various functions that allow developers to gather data about active processes.</p><h3>Retrieving Process Information Using Windows API</h3><p>To retrieve information about all currently running processes in a Windows environment, the EnumProcesses function is used. This function is part of the Windows API and is declared in the psapi.h header file.</p><h4>Example Code to List Running Processes</h4><pre>#include &lt;windows.h&gt; // Must be imported first before tlhelp32.h<br>#include &lt;tlhelp32.h&gt;<br>#include &lt;stdio.h&gt;<br><br>int main() {<br>    HANDLE hProcessSnap;<br>    PROCESSENTRY32 pe32;<br><br>    // Take a snapshot of all processes<br>    hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);<br>    if (hProcessSnap == INVALID_HANDLE_VALUE) {<br>        printf(&quot;Failed to take snapshot of processes.&quot;);<br>        return 1;<br>    }<br><br>    pe32.dwSize = sizeof(PROCESSENTRY32);<br><br>    // Retrieve information about the first process<br>    if (!Process32First(hProcessSnap, &amp;pe32)) {<br>        printf(&quot;Failed to retrieve information about the first process.&quot;);<br>        CloseHandle(hProcessSnap);<br>        return 1;<br>    }<br><br>    do {<br>        printf(&quot;Process ID: %u\tExecutable Name: %s\n&quot;, pe32.th32ProcessID, pe32.szExeFile);<br>    } while (Process32Next(hProcessSnap, &amp;pe32));<br><br>    CloseHandle(hProcessSnap);<br>    return 0;<br>}</pre><h3>Explanation of the Code</h3><ol><li><strong>CreateToolhelp32Snapshot</strong>: Takes a snapshot of all running processes.</li><li><strong>Process32First</strong>: Retrieves information about the first process in the snapshot.</li><li><strong>Process32Next</strong>: Iterates through the remaining processes.</li><li><strong>CloseHandle</strong>: Releases the snapshot handle after processing.</li></ol><h3>Process Information Retrieved</h3><p>The PROCESSENTRY32 structure holds detailed information about each process, including:</p><pre>+-----------------+-------------------------------+<br>| Field           | Description                   |<br>+-----------------+-------------------------------+<br>| dwSize          | Size of the structure         |<br>| th32ProcessID   | Unique process identifier     |<br>| th32ThreadCount | Number of threads             |<br>| th32ParentProcessID | Parent process ID         |<br>| szExeFile       | Executable file name          |<br>+-----------------+-------------------------------+</pre><h3>Conclusion</h3><p>Using the Windows API, developers can obtain crucial information about running processes, which is essential for debugging, monitoring, and managing system resources. The example provided demonstrates how to list all active processes and extract relevant details.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26fdce6124e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Difference Between MemoryStatus and MemoryStatusEx and Their Usage]]></title>
            <link>https://medium.com/@zahidtekbas/difference-between-memorystatus-and-memorystatusex-and-their-usage-6b58c00b87bd?source=rss-919f8dfa4c34------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b58c00b87bd</guid>
            <category><![CDATA[cpp]]></category>
            <dc:creator><![CDATA[Zahid Tekbaş]]></dc:creator>
            <pubDate>Mon, 20 Jan 2025 07:10:14 GMT</pubDate>
            <atom:updated>2025-01-20T07:10:14.640Z</atom:updated>
            <content:encoded><![CDATA[<p>When developing applications, it is crucial to monitor system memory usage to optimize performance. Two key structures provided by the Windows API for this purpose are MEMORYSTATUS and MEMORYSTATUSEX. Although they serve similar purposes, there are significant differences between them in terms of functionality and usage.</p><h3>MEMORYSTATUS Structure</h3><p>The MEMORYSTATUS structure is an older and simpler structure used to obtain basic information about system memory. It is defined in the windows.h header file as follows:</p><pre>typedef struct _MEMORYSTATUS {<br>    DWORD dwLength;<br>    DWORD dwMemoryLoad;<br>    SIZE_T dwTotalPhys;<br>    SIZE_T dwAvailPhys;<br>    SIZE_T dwTotalPageFile;<br>    SIZE_T dwAvailPageFile;<br>    SIZE_T dwTotalVirtual;<br>    SIZE_T dwAvailVirtual;<br>} MEMORYSTATUS, *LPMEMORYSTATUS;</pre><p>To use this structure, the GlobalMemoryStatus function is called, which fills the structure with the current memory status of the system. Example usage:</p><pre>MEMORYSTATUS memStatus;<br>memStatus.dwLength = sizeof(MEMORYSTATUS);<br>GlobalMemoryStatus(&amp;memStatus);</pre><p><strong>Key Features of MEMORYSTATUS:</strong></p><ul><li>Provides information such as total and available physical memory, virtual memory, and page file.</li><li>Limited to 32-bit values, which may not be sufficient for modern systems with large amounts of memory.</li><li>Suitable for older applications that do not require high precision.</li></ul><h3>MEMORYSTATUSEX Structure</h3><p>The MEMORYSTATUSEX structure is a more advanced and modern version that provides more comprehensive and precise memory information. It is defined as follows:</p><pre>typedef struct _MEMORYSTATUSEX {<br>    DWORD dwLength;<br>    DWORD dwMemoryLoad;<br>    DWORDLONG ullTotalPhys;<br>    DWORDLONG ullAvailPhys;<br>    DWORDLONG ullTotalPageFile;<br>    DWORDLONG ullAvailPageFile;<br>    DWORDLONG ullTotalVirtual;<br>    DWORDLONG ullAvailVirtual;<br>    DWORDLONG ullAvailExtendedVirtual;<br>} MEMORYSTATUSEX, *LPMEMORYSTATUSEX;</pre><p>The GlobalMemoryStatusEx function is used to populate this structure:</p><pre>MEMORYSTATUSEX memStatusEx;<br>memStatusEx.dwLength = sizeof(MEMORYSTATUSEX);<br>if (GlobalMemoryStatusEx(&amp;memStatusEx)) {<br>    // Successfully retrieved memory information<br>}</pre><p><strong>Key Features of MEMORYSTATUSEX:</strong></p><ul><li>Uses 64-bit values (DWORDLONG), which makes it suitable for modern systems with large memory capacities.</li><li>Provides an additional field (ullAvailExtendedVirtual) for extended virtual memory.</li><li>Recommended for newer applications requiring detailed memory monitoring.</li></ul><h3>Implementation Example</h3><p>Below is an example program demonstrating the usage of both MEMORYSTATUS and MEMORYSTATUSEX structures:</p><pre>#include &lt;stdio.h&gt;<br>#include &lt;windows.h&gt;<br>#define DIV 1024<br><br>int main() {<br>    printf(&quot;***** The program that shows information about memory *****\n\n&quot;);<br>#ifdef _WIN64<br>    MEMORYSTATUSEX memoryInfo64;<br>    memoryInfo64.dwLength = sizeof(MEMORYSTATUSEX);<br>    GlobalMemoryStatusEx(&amp;memoryInfo64);<br>    printf(&quot;Total page file:\t %lu MB\n&quot;, (memoryInfo64.ullTotalPageFile / DIV));<br>    printf(&quot;Total page file in use:\t %lu MB\n&quot;, ((memoryInfo64.ullTotalPageFile - memoryInfo64.ullAvailPageFile) / DIV));<br>    printf(&quot;Total physical memory:\t %lu MB\n&quot;, (memoryInfo64.ullTotalPhys / DIV));<br>    printf(&quot;Total physical memory in use:\t %lu MB\n&quot;, ((memoryInfo64.ullTotalPhys - memoryInfo64.ullAvailPhys) / DIV));<br>    printf(&quot;Virtual memory:\t %lu MB\n&quot;, (memoryInfo64.ullTotalVirtual / DIV));<br>    printf(&quot;Virtual memory in use:\t %lu MB\n&quot;, ((memoryInfo64.ullTotalVirtual - memoryInfo64.ullAvailVirtual) / DIV));<br>    printf(&quot;Percentage of physical memory in use:\t %u%%\n&quot;, memoryInfo64.dwMemoryLoad);<br>#else<br>    MEMORYSTATUS memoryInfo32;<br>    memoryInfo32.dwLength = sizeof(MEMORYSTATUS);<br>    GlobalMemoryStatus(&amp;memoryInfo32);<br>    printf(&quot;Total page file:\t %zu MB\n&quot;, memoryInfo32.dwTotalPageFile / DIV);<br>    printf(&quot;Total page file in use:\t %zu MB\n&quot;, (memoryInfo32.dwTotalPageFile - memoryInfo32.dwAvailPageFile) / DIV);<br>    printf(&quot;Total physical memory:\t %zu MB\n&quot;, memoryInfo32.dwTotalPhys / DIV);<br>    printf(&quot;Total physical memory in use:\t %zu MB\n&quot;, (memoryInfo32.dwTotalPhys - memoryInfo32.dwAvailPhys) / DIV);<br>    printf(&quot;Total virtual memory:\t %zu MB\n&quot;, memoryInfo32.dwTotalVirtual / DIV);<br>    printf(&quot;Total virtual memory in use:\t %zu MB\n&quot;, (memoryInfo32.dwTotalVirtual - memoryInfo32.dwAvailVirtual) / DIV);<br>    printf(&quot;Percentage of physical memory in use:\t %u%%\n&quot;, memoryInfo32.dwMemoryLoad);<br>#endif<br>    printf(&quot;\n ***** End of the Program *****\n&quot;);<br>    system(&quot;PAUSE&quot;);<br>}</pre><h3>Comparison of MEMORYSTATUS and MEMORYSTATUSEX</h3><pre>+------------------------+-----------------+-----------------+<br>| Feature                | MEMORYSTATUS    | MEMORYSTATUSEX  |<br>+------------------------+-----------------+-----------------+<br>| Data Type Size         | 32-bit           | 64-bit          |<br>| Function Used          | GlobalMemoryStatus | GlobalMemoryStatusEx |<br>| Precision              | Limited           | High            |<br>| Extended Virtual       | Not Available     | Available       |<br>| Modern System Suitability | No              | Yes             |<br>+------------------------+-----------------+-----------------+</pre><h3>Conclusion</h3><p>If you are developing applications for modern systems, it is recommended to use MEMORYSTATUSEX due to its high precision and support for large memory sizes. However, if backward compatibility with older systems is required, MEMORYSTATUS can still be a viable option.</p><p>Choosing the right structure based on your application’s requirements will help ensure optimal performance and compatibility.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b58c00b87bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Seamlessly Redirect Users to App Stores or Testing Platforms in Flutter]]></title>
            <link>https://medium.com/@zahidtekbas/how-to-seamlessly-redirect-users-to-app-stores-or-testing-platforms-in-flutter-95eac976ba25?source=rss-919f8dfa4c34------2</link>
            <guid isPermaLink="false">https://medium.com/p/95eac976ba25</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[storeredirect]]></category>
            <category><![CDATA[app-tester]]></category>
            <category><![CDATA[testflight]]></category>
            <dc:creator><![CDATA[Zahid Tekbaş]]></dc:creator>
            <pubDate>Tue, 24 Dec 2024 18:25:19 GMT</pubDate>
            <atom:updated>2024-12-24T18:36:53.808Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q3olT-ij4CHQ8EA1cGn3ew.jpeg" /></figure><p>In modern app development, it’s crucial to provide users with an easy way to update or access test versions of your app, depending on the environment (production, development, or test). In this blog, I’ll walk you through a real-world implementation where I dynamically direct users to the appropriate store or testing platform, such as Firebase App Tester or TestFlight, based on the app environment. This logic was implemented in a Flutter application using the StoreRedirect, android_intent_plus, and url_launcher packages.</p><h3>The Problem</h3><p>You need a seamless mechanism to:</p><ul><li>Redirect users to the <strong>Google Play Store</strong> or <strong>App Store</strong> for the production environment.</li><li>Redirect testers to <strong>Firebase App Tester</strong> or <strong>TestFlight</strong> for development or testing environments.</li></ul><p>This solution needs to work dynamically depending on the app’s flavor and platform (iOS or Android).</p><h3>The Solution</h3><h4>1. Define Your App Environments</h4><p>First, configure your app flavors (e.g., production, development, and test). In Flutter, you can use dart-defines or a dedicated configuration file for this purpose. Here, I&#39;ve used F.appFlavor to determine the app&#39;s current flavor. Thanks to <a href="https://pub.dev/packages/flutter_flavorizr">flutter_flavorizr</a>, I did that easily!</p><h4>2. Install Necessary Packages</h4><p>Add the following packages to your pubspec.yaml:</p><pre>dependencies:<br>  store_redirect: ^2.0.0<br>  android_intent_plus: ^2.0.2<br>  url_launcher: ^6.1.9</pre><p>Run flutter pub get to install the dependencies.</p><h4>Add Queries to AndroidManifest</h4><p>For Android 11+ compatibility, add the following &lt;queries&gt; section to your AndroidManifest.xml to allow querying Firebase App Tester and other applications.</p><p>This ensures that your app can query the required activities or packages seamlessly.</p><pre>&lt;queries&gt;<br>    &lt;package android:name=&quot;dev.firebase.appdistribution&quot; /&gt;<br>    &lt;intent&gt;<br>        &lt;action android:name=&quot;android.intent.action.VIEW&quot; /&gt;<br>        &lt;data android:scheme=&quot;https&quot; /&gt;<br>    &lt;/intent&gt;<br>&lt;/queries&gt;</pre><h4>3. Implement the Logic</h4><p>Here’s the full implementation for redirecting users based on the app environment and platform:</p><pre>import &#39;dart:io&#39;;<br>import &#39;package:store_redirect/store_redirect.dart&#39;;<br>import &#39;package:android_intent_plus/android_intent.dart&#39;;<br>import &#39;package:url_launcher/url_launcher_string.dart&#39;;</pre><pre>class AppRedirector {<br>  static Future&lt;void&gt; redirectUser() async {<br>    // Check the app environment<br>    if (F.appFlavor == Flavor.prod) {<br>      // Redirect to the store in production<br>      StoreRedirect.redirect(<br>        androidAppId: &quot;com.example.app&quot;,<br>        iOSAppId: &quot;yourIOSAppId&quot;,<br>      );<br>    } else if (F.appFlavor == Flavor.dev) {<br>      if (Platform.isAndroid) {<br>        AndroidIntent intent = AndroidIntent(<br>          action: &#39;android.intent.action.VIEW&#39;,<br>          data: &#39;https://appdistribution.firebase.google.com/accept/&#39;, // Firebase App Tester deep link<br>          flags: &lt;int&gt;[Flag.FLAG_ACTIVITY_NEW_TASK],<br>        );<br>        await intent.launch();<br>      } else {<br>        launchUrlString(<br>          &#39;itms-beta://beta.itunes.apple.com/v1/app/yourTestAppId&#39;,<br>        );<br>      }<br>    } else if (F.appFlavor == Flavor.prodtest) {<br>      if (Platform.isAndroid) {<br>        AndroidIntent intent = AndroidIntent(<br>          action: &#39;android.intent.action.VIEW&#39;,<br>          data: &#39;https://appdistribution.firebase.google.com/accept/&#39;, // Firebase App Tester deep link<br>          flags: &lt;int&gt;[Flag.FLAG_ACTIVITY_NEW_TASK],<br>        );<br>        await intent.launch();<br>      } else {<br>        launchUrlString(<br>          &#39;itms-beta://beta.itunes.apple.com/v1/app/yourProdTestAppId&#39;,<br>        );<br>      }<br>    }<br>  }<br>}</pre><h3>How It Works</h3><p><strong>Production Environment</strong></p><ul><li>For production (Flavor.prod), we use the StoreRedirect package to send users to the appropriate app store based on their platform.</li><li><strong>Android</strong>: Redirects to Google Play Store using the app’s package ID.</li><li><strong>iOS</strong>: Redirects to the App Store using the app’s Apple ID</li></ul><p><strong>Development Environment</strong></p><ul><li>For development (Flavor.dev), testers are redirected to Firebase App Tester on Android using its deep link (https://appdistribution.firebase.google.com/accept/).</li><li>On iOS, testers are redirected to TestFlight using a custom scheme (itms-beta://).</li></ul><p><strong>Testing Environment</strong></p><ul><li>For a testing flavor (Flavor.prodtest), the same logic is applied as for development but with different TestFlight IDs.</li></ul><p><strong>Platform-Specific Handling</strong></p><ul><li>We use Platform.isAndroid and Platform.isIOS to distinguish between Android and iOS and handle each platform’s requirements appropriately.</li></ul><h3>Key Learnings</h3><p><strong>Firebase App Tester Deep Links</strong></p><ul><li>Firebase App Tester apps declare deep links for easy access, such as https://appdistribution.firebase.google.com/accept/. These links can be invoked via the android_intent_plus package.</li></ul><p><strong>TestFlight Custom Scheme</strong></p><ul><li>TestFlight apps use the itms-beta:// custom scheme, allowing you to redirect testers directly to the desired app page.</li></ul><p><strong>Dynamic Behavior Based on App Flavor</strong></p><ul><li>Using F.appFlavor, you can tailor the redirection logic dynamically based on the app&#39;s environment.</li></ul><p><strong>Cross-Platform Compatibility</strong></p><ul><li>The solution handles both Android and iOS platforms seamlessly, leveraging their specific store or testing environments.</li></ul><h3>Conclusion</h3><p>This approach ensures that users and testers are directed to the appropriate platform, whether it’s a production store or a testing environment. It simplifies the update process and improves the overall user experience, especially during beta testing or development.</p><p>Feel free to adapt this logic to your project and share your experience! If you have any questions or improvements, let me know in the comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95eac976ba25" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running AAR File From Flutter App]]></title>
            <link>https://medium.com/@zahidtekbas/running-aar-file-from-flutter-app-2ff35e3a50c3?source=rss-919f8dfa4c34------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ff35e3a50c3</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Zahid Tekbaş]]></dc:creator>
            <pubDate>Wed, 04 Sep 2024 20:18:12 GMT</pubDate>
            <atom:updated>2024-11-03T17:02:27.039Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v67-wsL7cN85JKJlmc09pg.png" /><figcaption>Featured image</figcaption></figure><p>It’s all easy and comfortable when it comes to using only Flutter and Dart but there maybe some situations that can happen such as calling AAR files from Flutter side. If you do not have sufficient experience in Android mobile development (shortly Kotlin or Java), you may feel yourself exhausted while looking for guides to implement an Android app inside a Flutter app.</p><p>Don’t worry. I will try to explain it very clear and straightforward. There are files that we need to edit in order to achieve that purpose. Here is the list of them:</p><pre>yourProject/android/settings.gradle<br>yourProject/android/app/build.gradle<br>yourProject/android/app/src/main/kotlin/com/example/app/MainActivity.kt</pre><p>First of all, we have to introduce our AAR file to Android environment. Make sure you open settings.gradle file.</p><pre>include &quot;:app&quot;<br>include &quot;:YourAARProject&quot;</pre><p>Now, let’s stay the same directory level and create a folder with the same name (YourAARProject) we defined above.</p><p>Put your .aar file inside this folder then create a build.gradle file for this project. It should look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*FeSvRELxicv34R0GzNGioA.png" /></figure><p>Open your empty build.gradle file inside YourAARProject and add these lines:</p><pre>configurations.maybeCreate(&quot;default&quot;)<br>artifacts.add(&quot;default&quot;, file(&#39;YourAAR.aar&#39;))</pre><p>Then go to your app level build.gradle file and scroll down to dependencies section there. At the top of your dependencies, add your AAR app project.</p><pre>dependencies {<br>implementation project(&#39;:YourAARProject&#39;)<br>//... Your other dependencies<br>//...<br>//...<br>}</pre><p>Make sure to add the dependencies which are used inside your AAR. This is highly important because the AAR project depends on Flutter side’s resources including styles.</p><p>I would like to give you an example of libraries that My AAR project uses:</p><pre>implementation &#39;androidx.appcompat:appcompat:1.4.0&#39;<br>implementation &#39;com.google.android.material:material:1.4.0&#39;<br>implementation &#39;androidx.constraintlayout:constraintlayout:2.1.2&#39;<br>implementation &#39;com.tbuonomo:dotsindicator:4.2&#39;<br>implementation &#39;androidx.legacy:legacy-support-v4:1.0.0&#39;<br>implementation &#39;androidx.navigation:navigation-fragment:2.4.0&#39;<br>implementation &#39;androidx.navigation:navigation-ui:2.4.0&#39;<br>implementation &#39;com.google.code.gson:gson:2.8.7&#39;<br>implementation &#39;com.squareup.retrofit2:retrofit:2.9.0&#39;<br>implementation &#39;com.squareup.retrofit2:converter-gson:2.9.0&#39;<br>implementation &#39;com.squareup.okhttp3:logging-interceptor:4.7.2&#39;<br>implementation &#39;com.squareup.okhttp3:okhttp:4.7.2&#39;</pre><p>Also, if there is a problem building your AAR file, you can adjust your buildTypes by adding shrinkResources false and minifyEnabled true. This also works if you cannot make http requests in your AAR project.</p><pre>    buildTypes {<br>        release {<br>            shrinkResources false<br>            minifyEnabled true<br>            signingConfig signingConfigs.release<br>       }<br>        debug{<br>            minifyEnabled true<br>            shrinkResources false<br>            }<br>        profile{<br>            minifyEnabled true<br>            shrinkResources false<br>        }<br>        }</pre><p>Finally, let’s write <a href="https://docs.flutter.dev/platform-integration/platform-channels">MethodChannel</a> functions and call our AAR project from Flutter side. Switch to the MainActivity.kt file and add these:</p><pre>     private val CHANNEL = &quot;com.example.app/aarchannel&quot;<br>     private val AARMETHOD = &quot;aarcall&quot;<br><br>    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {<br>        getApplicationContext().setTheme(R.style.AppFullScreenTheme);<br>        super.configureFlutterEngine(flutterEngine)<br>        MethodChannel(<br>            flutterEngine.dartExecutor.binaryMessenger,<br>            CHANNEL<br>        ).setMethodCallHandler { call, result -&gt;<br>            if (call.method == AARMETHOD) {<br>                openAAR(context,result)<br>            }<br>             else {<br>                result.notImplemented()<br>            }<br>        }<br>}<br><br> private fun openAAR(context: Context, result : MethodChannel.Result){<br>                val intent = Intent(context, com.example.aar.StartPageActivity::class.java)<br>                startActivity(intent)<br>                result.success(true)<br>  }</pre><p>Now we have defined the function which runs aar project by starting an activity from Flutter side.</p><p>At last, call this openAAR function from Flutter application by a MethodChannel.</p><pre>        var channel = const MethodChannel(&#39;com.example.app/aarchannel&#39;);<br>        await channel.invokeMethod(&quot;aarcall&quot;);</pre><p>You are now good to go! It’s a bit tricky calling AAR project from a Flutter app but when you understand how Android handles all these dependencies, resources etc. it is easy to achieve step by step.</p><p>Thank you for your time. I hope this short guide helps you!</p><p>If you find my guide helpful, you can support me with a coffee. :)</p><figure><a href="https://buymeacoffee.com/zahidtekbas"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QCQqlZr6doDP-cszzpaSpw.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ff35e3a50c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Semantics Are Crucial in Mobile Applications? (From Flutter perspective)]]></title>
            <link>https://medium.com/@zahidtekbas/why-semantics-are-crucial-in-mobile-applications-from-a-flutter-perspective-735f752977c0?source=rss-919f8dfa4c34------2</link>
            <guid isPermaLink="false">https://medium.com/p/735f752977c0</guid>
            <category><![CDATA[semantics]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Zahid Tekbaş]]></dc:creator>
            <pubDate>Tue, 23 Jul 2024 12:04:42 GMT</pubDate>
            <atom:updated>2025-01-18T10:10:03.552Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RB3I5801QJsV-L1fXROE3w.png" /><figcaption>Flutter Semantics Feature Image</figcaption></figure><p><strong>Semantics</strong>, is a concept that tells a <strong>component’s meaning</strong> programmatically. It is used by <strong>search engines</strong>, <strong>assistive technologies</strong> and <strong>semantic analysis programs</strong> <strong>to resolve meaning of application or component</strong>.</p><h3>Why Is It Crucial?</h3><p>Semantics is often disregarded when it comes to develop a mobile application from scratch. But <strong>it has an important role</strong> if you decide to <strong>use</strong> <strong>test automation</strong> or to <strong>target users who use accessibility features</strong>. It gives an headache if it’s not coded from scratch.</p><p>Implement semantics if you will be,</p><ul><li><strong>Using test automation tools</strong>,</li><li><strong>Targeting everyone</strong></li><li><strong>Using analysis softwares</strong></li></ul><h3>Using Semantics in Flutter Applications</h3><p>Let’s say you have a Text widget.</p><pre>const Text(&#39;This is a Text!&#39;)</pre><p>And wrap this widget with <a href="https://api.flutter.dev/flutter/widgets/Semantics-class.html">Semantics widget</a>.</p><pre>         Semantics(<br>            identifier: &#39;Text_Widget&#39;,<br>            value: &#39;This is a Text!&#39;,<br>            child: const Text(&#39;This is a Text!&#39;),<br>          ),</pre><p>By giving identifier, we indicate that this component is a text widget. Additionally, by adding value, we indicate that this value is written inside of text widget for people who use accessibility features.</p><p>Let’s write another example, this time we will use an image as an example.</p><pre>          Semantics(<br>            identifier: &#39;asset_image&#39;,<br>            image: true,<br>            value: &#39;Image of a car&#39;,<br>            label: &#39;An Image of car_image.png&#39;,<br>            child: Image.asset(&#39;car_image.png&#39;),<br>          ),</pre><p>We tell the widget is image by giving image parameter true and filled the other parameters related to the widget itself.</p><p>You can wrap all your widgets with semantics, because it has variety of options to satisfy accessibility features built in smart devices.</p><p>Therefore, all of your users can interact with your app effortlessly.</p><p>Thank you for your time. Have a good day. :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=735f752977c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using TSPL Commands in Flutter]]></title>
            <link>https://medium.com/@zahidtekbas/using-tspl-commands-in-flutter-137ed8b8265f?source=rss-919f8dfa4c34------2</link>
            <guid isPermaLink="false">https://medium.com/p/137ed8b8265f</guid>
            <category><![CDATA[tspl]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Zahid Tekbaş]]></dc:creator>
            <pubDate>Tue, 25 Jun 2024 15:00:09 GMT</pubDate>
            <atom:updated>2024-11-03T17:04:02.646Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello! 🙂 I want to write a short article on <strong>how to work with TSPL commands on Flutter</strong>.</p><figure><img alt="I just wanted to create an AI image for TSPL printer…" src="https://cdn-images-1.medium.com/max/1024/1*4pdTET9cAOZxKv1t8V3R9w.jpeg" /></figure><p>You want to send data to a handheld terminal via <strong>Bluetooth</strong> using a mobile application. The most popular of these writing formats is <strong>ESC</strong>, but <strong>you can’t give parameters on ESC</strong> for things like paper size.</p><p>With TSPL commands, you can <strong>predefine</strong> the <strong>dimensions</strong> of the <strong>label</strong> you will use, give <strong>starting points</strong> on this label like in a <strong>coordinate system</strong>, and while writing the desired data, you can have it automatically perform the <strong>cut-feed operation</strong> by taking into account the size of the paper.</p><p>In a small project I used the <strong>esc_pos_utils</strong> and <strong>flutter_ble_plus</strong> libraries, if you know which Bluetooth service to write data to, you don’t even need to use esc_pos_utils.</p><p>In the first stage, establish the connection between your printer device and your mobile application, and after establishing the connection, send the BluetoothDevice object to a printData function you will create.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iWEA3i9nfnzzaY6A4Jqahg.png" /><figcaption>tarih stands for date and fiyat stands for price</figcaption></figure><p>The <strong>TSPL</strong> commands I wrote in the bytes section indicate that there is a label with a <strong>width</strong> of <strong>40 mm</strong> and a <strong>height</strong> of <strong>20 mm</strong> in the thermal printer. I also specify that there is a <strong>2 mm gap</strong> between these labels. By writing <strong>SET CUTTER 1</strong>, I ensure that the cut operation is performed after printing on the label. The <strong>CLS command clears the buffer</strong>.</p><p>Also, in comments I’m notified that BluePrint() class is a custom object. So I will include it here. It is basically a wrapper around flutter_blue_plus and it helps me to write bytes into a device.</p><pre>import &#39;dart:math&#39;;<br><br>import &#39;package:flutter_blue_plus/flutter_blue_plus.dart&#39;;<br><br>extension WriteLarge on BluetoothCharacteristic {<br>  Future&lt;void&gt; writeLarge(List&lt;int&gt; value, int mtu, {int timeout = 15}) async {<br>    int chunk = mtu - 3;<br>    try {<br>      for (int i = 0; i &lt; value.length; i += chunk) {<br>        List&lt;int&gt; subvalue = value.sublist(i, min(value.length, i + chunk));<br>        await write(subvalue, withoutResponse: false, timeout: timeout);<br>      }<br>    } catch (e) {<br>      print(&quot;exception in writeLarge&quot;);<br>      print(e.toString());<br>    }<br>  }<br>}<br><br>class BluePrint {<br>  BluePrint({this.chunkLen = 512});<br><br>  final int chunkLen;<br>  final _data = List&lt;int&gt;.empty(growable: true);<br><br>  void add(List&lt;int&gt; data) {<br>    _data.addAll(data);<br>  }<br><br>  List&lt;List&lt;int&gt;&gt; getChunks() {<br>    final chunks = List&lt;List&lt;int&gt;&gt;.empty(growable: true);<br>    for (var i = 0; i &lt; _data.length; i += chunkLen) {<br>      chunks.add(_data.sublist(i, min(i + chunkLen, _data.length)));<br>    }<br>    return chunks;<br>  }<br><br>  Future&lt;void&gt; printData(BluetoothDevice device) async {<br>    final data = getChunks();<br>    final characs = await _getCharacteristics(device);<br>    var services = characs.where((element) =&gt; element.properties.write == true || element.properties.writeWithoutResponse == true).toList();<br>    for (var i = 0; i &lt; services.length; i++) {<br>      if (services[i].properties.writeWithoutResponse) {<br>        if (await _tryPrint(services[i], data, await device.mtu.first)) {<br>          break;<br>        }<br>      }<br>    }<br>  }<br><br>  Future&lt;bool&gt; _tryPrint(<br>    BluetoothCharacteristic charac,<br>    List&lt;List&lt;int&gt;&gt; data,<br>    int mtuSize,<br>  ) async {<br>    for (var i = 0; i &lt; data.length; i++) {<br>      try {<br>        await charac.writeLarge(data[i], mtuSize);<br>      } catch (e) {<br>        print(e.toString());<br>        return false;<br>      }<br>    }<br>    return true;<br>  }<br><br>  Future&lt;List&lt;BluetoothCharacteristic&gt;&gt; _getCharacteristics(<br>    BluetoothDevice device,<br>  ) async {<br>    final services = await device.discoverServices();<br>    final res = List&lt;BluetoothCharacteristic&gt;.empty(growable: true);<br>    for (var i = 0; i &lt; services.length; i++) {<br>      res.addAll(services[i].characteristics);<br>    }<br>    return res;<br>  }<br>}</pre><p>The Text command allows you to write the desired text at the specified coordinates. So, <strong>what do the numbers and figures next to it mean?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*aCrZ55C7Uftu0gcarVaX5Q.png" /><figcaption>TSPL commands &amp; explanations</figcaption></figure><p>To adjust the <strong>font size</strong>, determine the <strong>x-y coordinates</strong>, and set the <strong>horizontal-vertical multipliers</strong>, I am presenting the above screenshot from the <a href="https://www.pos-shop.ru/upload/iblock/ebd/ebd9bed075d1b925be892b297590fc18.pdf">TSPL document</a> I have.</p><p>When you execute your logic, the terminal prints label with the data you passed to it.</p><p>I hope this article helps you with your ESC and TSPL questions. If you can switch your device’s command to TSPL, everything becomes <strong>more structured</strong> than ESC. <strong>Thus, I strongly suggest you to use TSPL</strong>.</p><p>Good luck. 🙂</p><p>If you find this guide helpful, please support me with a coffee. :)</p><figure><a href="https://buymeacoffee.com/zahidtekbas"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QCQqlZr6doDP-cszzpaSpw.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=137ed8b8265f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>