<?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 Ajay Kamble on Medium]]></title>
        <description><![CDATA[Stories by Ajay Kamble on Medium]]></description>
        <link>https://medium.com/@ajay.kamble119?source=rss-5781678c582c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5BsDPWbAk3UySDYbpGEjSg.jpeg</url>
            <title>Stories by Ajay Kamble on Medium</title>
            <link>https://medium.com/@ajay.kamble119?source=rss-5781678c582c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 13:56:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ajay.kamble119/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[Creating a Markdown Text form Field in Flutter: A Step-by-Step Guide]]></title>
            <link>https://medium.com/techskool/create-a-markdown-textformfield-in-flutter-929209ae2c02?source=rss-5781678c582c------2</link>
            <guid isPermaLink="false">https://medium.com/p/929209ae2c02</guid>
            <category><![CDATA[textformfield]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[markdown-editor]]></category>
            <dc:creator><![CDATA[Ajay Kamble]]></dc:creator>
            <pubDate>Sun, 07 May 2023 16:50:42 GMT</pubDate>
            <atom:updated>2023-10-06T08:04:53.821Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U5w7SG6BxQwqCwpfQxwBLQ.jpeg" /></figure><p>Flutter is a popular mobile application development framework that allows developers to create beautiful and efficient user interfaces. One of the most important components of any user interface is text input fields. In this blog post, we will explore how to use the TextFormField widget to create a markdown text input field in a Flutter application.</p><p>TextFormField is a pre-built widget in Flutter that provides a convenient way to create text input fields. With TextFormField, you can create text fields with various properties such as controller, validation, keyboard type, and input formatting.</p><h3>What is Markdown?</h3><p>Markdown is a lightweight markup language that is used to format text. It is widely used in documentation and is supported by many platforms such as GitHub, Bitbucket, and Stack Overflow. Markdown is simple and easy to learn, and it can be converted into HTML or other formats.</p><p>Let’s take example of Whatsapp.</p><p>WhatsApp allows you to format text inside your messages.</p><p><strong>1. Italic : </strong>To <em>italicize</em> your message, place an underscore on both sides of the text: _text_</p><p><strong>2. Bold : </strong>To bold your message, place an asterisk on both sides of the text: *text*</p><p><strong>3. Strikethrough : </strong>To strikethrough your message, place a tilde on both sides of the text: ~text~</p><p><strong>4. Monospace : </strong>To monospace your message, place three backticks on both sides of the text: ```text```</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DiKpD_MLysd9FFbkBomJJQ.jpeg" /><figcaption>Markdown text in WhatsApp</figcaption></figure><h3>How to Use the TextFormField Widget in Flutter</h3><p>You can refer to this link to explore <a href="https://api.flutter.dev/flutter/material/TextFormField-class.html">TextFormField</a></p><h3>Let’s Get Started</h3><p>First we will create TextFormField widget</p><pre>TextFormField(<br>  keyboardType: TextInputType.multiline,<br>  minLines: 10,<br>  maxLines: 15,<br>),</pre><p>Now we need to add controller to TextFormField. we will create a object of TextEditingController</p><pre>final TextEditingController _editTextController = TextEditingController();</pre><p>Assign this _editTextController object to the controller property of TextFormField</p><pre>TextFormField(<br>  controller: _editTextController,<br>  keyboardType: TextInputType.multiline,<br>  minLines: 10,<br>  maxLines: 15,<br>)</pre><figure><img alt="sdf" src="https://cdn-images-1.medium.com/max/542/1*BIT2tQmc9UYJiCxK1SA6hA.png" /><figcaption>TextFormField example</figcaption></figure><p>If we see the implementation of TextEditingController class. It has method called TextSpan buildTextSpan({required BuildContext context, TextStyle? style, required bool withComposing}) by overriding this method customize appearance of text.</p><p>Now we will create regular expression to detect patterns such bold, italic, mentions, hashtags.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*-Mqd6gv0SqqgdZMNdpfDvw.png" /><figcaption>TextFormField before applying style</figcaption></figure><p><strong>Regular Expressions</strong></p><p><strong>1.Bold : </strong>\*(.*?)\* if we found this pattern in text we will set textstyle as TextStyle(fontWeight : FontWeight.bold)</p><p><strong>2.Italic : </strong>_(.*?)\_ if we found this pattern in text we will set TextStyle as TextStyle(fontStyle : FontStyle.italic)</p><p><strong>3.StrikeThrough Text : </strong>~(.*?)~ if we found this pattern in text we will set TextStyle as TextStyle(decoration: TextDecoration.lineThrough)</p><p><strong>4.Mentions : </strong>@.\w+ if we detect this pattern in text we will set TextStyle as TextStyle(color:Colors.blue)</p><p><strong>5.HashTags : </strong>#.\w+ if we detect this pattern in text we will set TextStyle as TextStyle(color:Colors.blue)</p><h3>Step 1 : Create CustomTextEditingController by extending TextEditingController class</h3><p>In this class we will create constructor with Map&lt;String, TextStyle&gt; as a parameter and key for the map will be regular expression and value for the map will be TextStyle for the pattern.</p><p>Also we will override buildTextSpan method from TextEditingController class</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa555de4c2e7543550cd0013a113879b/href">https://medium.com/media/aa555de4c2e7543550cd0013a113879b/href</a></iframe><p>CustomTextEditingController class have a variable called pattern .</p><p>we will initialize this variable by joining all the key’s of map by pipe operator | .</p><h3><strong>Step 2 : Implementation of </strong><strong>buildTextSpan method</strong></h3><p>We will get current text of TextFormField in text variable which is declared in TextEditingController class</p><p>Now we can use method called splitMapJoin to detect patterns in text.</p><p>This method has 3 parameters</p><ol><li>Pattern (regx object) that we have already inside constructor of CustomTextEditingController class.</li><li>onMatch Callback : This callback gives matched pattern</li><li>onNonMatch Callback: This callback gives non matched text</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce1bc3607d50925c4e7b78007977c29e/href">https://medium.com/media/ce1bc3607d50925c4e7b78007977c29e/href</a></iframe><p>Above code helps to get style based onpattern matched with text</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01fb1aa6253a17361b2f063c228bee06/href">https://medium.com/media/01fb1aa6253a17361b2f063c228bee06/href</a></iframe><p>The above code will help you to remove special characters we have used to format text</p><p>Now we have TextStyle as well as parsed text. we will create object of TextSpan along with formatText and matched TextStyle</p><pre>TextSpan(<br>  text: formatText,<br>  style: style!.merge(myStyle),<br>)</pre><p>We will add this object to the List&lt;InlineSpan&gt;.</p><p>Inside onNonMatch we will create object of TextSpan with default textStyle and add it to List&lt;InlineSpan&gt;.</p><p>At the end we will return TextSpan(style: style, children: children); from buildTextSpan method</p><p>That’s It.</p><h3>Step 3 : Create object of Custom TextEditing Controller</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ddccfb6c0c5cc03d01c8fd29d5645fa9/href">https://medium.com/media/ddccfb6c0c5cc03d01c8fd29d5645fa9/href</a></iframe><p>Assign Above object to TextFormField</p><pre>TextFormField(<br>  controller: _editTextController,<br>  keyboardType: TextInputType.multiline,<br>  minLines: 10,<br>  maxLines: 15,<br>),</pre><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*4KHfkugIz1busaqAkrmx_g.png" /><figcaption>TextFormfield after applying style</figcaption></figure><p><strong>Source Code:</strong></p><p><a href="https://github.com/Ajaykamble/MarkDownTextFormField">GitHub - Ajaykamble/MarkDownTextFormField</a></p><p>Enjoyed the read? Show your appreciation with a clap! For more insights, hit that Follow button. 😊😊</p><p>If you’re looking for assistance in creating cutting-edge products with Flutter, please feel free to reach out to me on <a href="https://www.linkedin.com/in/ajay-kamble-67a5291ba/">LinkedIn</a>. I’d be happy to assist you in building something innovative.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=929209ae2c02" width="1" height="1" alt=""><hr><p><a href="https://medium.com/techskool/create-a-markdown-textformfield-in-flutter-929209ae2c02">Creating a Markdown Text form Field in Flutter: A Step-by-Step Guide</a> was originally published in <a href="https://medium.com/techskool">TechSkool</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Conditional Imports in flutter for Cross-Platform Development]]></title>
            <link>https://medium.com/techskool/adding-conditional-imports-in-flutter-for-cross-platform-development-5d7b6bff689c?source=rss-5781678c582c------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d7b6bff689c</guid>
            <dc:creator><![CDATA[Ajay Kamble]]></dc:creator>
            <pubDate>Sun, 23 Apr 2023 13:51:16 GMT</pubDate>
            <atom:updated>2023-09-25T19:55:21.035Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UZ6KI2mitDjCldisqoYXtg.png" /></figure><p>Diving into the world of Flutter, you’re met with a robust cross-platform framework that effortlessly bridges the gap between mobile, web, and desktop applications. But what happens when you need to sprinkle in a bit of platform-specific magic?</p><p>In today’s article, we’ll embark on a journey to master conditional imports for Flutter’s diverse platforms, from mobile to web to Windows.</p><p><strong>Why do we need conditional imports?</strong></p><p>Conditional imports in Flutter are used to import platform-specific code or packages based on the platform your application is running on.</p><p>Flutter supports the following platforms:</p><ul><li>Android</li><li>iOS</li><li>Web</li><li>Windows</li><li>macOS</li><li>Linux</li></ul><p>Flutter uses the dart.io.Platform class to determine the current platform. This class has a isAndroid, isIOS, isLinux, isMacOS, isWindows, and isFuchsia properties that return a boolean value indicating whether the application is running on that platform.</p><p><strong>Let me walk you through example of displaying native dialog.</strong></p><p>Here, we are targeting android, ios, weband windowsplatform.</p><p>In below example, we have imported the properties kIsWeb and TargetPlatform from the flutter/foundation.dart package. We utilize the kIsWeb property to ascertain whether the application is operating on the web platform. Similarly, we employ the TargetPlatform property to determine if the application is running on Android or other platforms.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/55c01dc69f4d172157a42f0f233bd5d3/href">https://medium.com/media/55c01dc69f4d172157a42f0f233bd5d3/href</a></iframe><p>It’s important to note that while Flutter provides the widget AlertDialog for displaying alerts on Android and CupertinoAlertDialog for iOS, there is currently no implementation available for web and Windows platforms.</p><p>Hence, let’s write down our own implementation.</p><h3>Creating a JavaScript Function to Trigger Alerts in HTML</h3><p>We will create javaScript method with parameter to call alert method under script tag in web/index.html page.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/446ecd6a12a17a0963686633221dae0f/href">https://medium.com/media/446ecd6a12a17a0963686633221dae0f/href</a></iframe><p><strong>Windows Implementation</strong></p><p>For windows we will use method channel to call native code. open flutter_windows.cpp which is located at windows/runner/ find OnCreate() method in this file</p><p>paste following code in between RegisterPlugins(flutter_controller_-&gt;engine()); and SetChildContent(flutter_controller_-&gt;view()-&gt;GetNativeWindow());</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/700f3dc50931095fcb9f1cb0e4124d13/href">https://medium.com/media/700f3dc50931095fcb9f1cb0e4124d13/href</a></iframe><p>Now we need to create two methods.</p><ol><li>To get Argument passed from flutter</li><li>To display native dialog</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/543533e4ccb5754024897403d77a3b52/href">https://medium.com/media/543533e4ccb5754024897403d77a3b52/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eacb1e32172d4c349f84a26f814f836d/href">https://medium.com/media/eacb1e32172d4c349f84a26f814f836d/href</a></iframe><p>Let’s Test now..</p><p>First we will run this Android platform</p><p><strong>OH! we got an error</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nXS-wQlLfxkp7ujicsQH5g.png" /></figure><p>We are utilizing the dart.js package to invoke JavaScript code, but unfortunately, this package isn’t accessible on the Android platform. To address this issue, we must now employ conditional imports.</p><p>Now we will create abstract class called CustomPlatform create method displayAlert inside it</p><p><strong>custom_platform.dart</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a464ac14310414ef6b33106260556d2/href">https://medium.com/media/8a464ac14310414ef6b33106260556d2/href</a></iframe><p>Create a file named “platform_helper.dart” to obtain an instance of the CustomPlatform class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5765c20bb8b93a78b5f62e20e2584bf3/href">https://medium.com/media/5765c20bb8b93a78b5f62e20e2584bf3/href</a></iframe><p>Create two classes: one for the web platform and the other for all other platforms. Implement the CustomPlatform interface in both classes.</p><p><strong>web_platform.dart</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c1fa1a78792342b85a26b206cfaf96f/href">https://medium.com/media/6c1fa1a78792342b85a26b206cfaf96f/href</a></iframe><p><strong>other_platform.dart</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f951cfab3fdc3b0dd418b79b264417a/href">https://medium.com/media/9f951cfab3fdc3b0dd418b79b264417a/href</a></iframe><p><em>Note: we have created global method called </em><em>getInstance() that returning instance of each class with </em><em>CustomPlatform type</em></p><p><strong>web_platform.dart</strong></p><pre>CustomPlatform getInstance() =&gt; CustomPlatformWeb();</pre><p><strong>other_platform.dart</strong></p><pre>CustomPlatform getInstance() =&gt; CustomPlatformOther();</pre><p>Now we need to modify our custom_platform.dart file. create a factory constructor to return above objects in CustomPlatform class and import getInstance method based on platform type.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09043adc928472d5c41111b3bb9637ee/href">https://medium.com/media/09043adc928472d5c41111b3bb9637ee/href</a></iframe><p>We use two libraries, dart.library.html and dart.library.io, to figure out which platform our application is running on. If it’s running on the web, dart.library.html becomes true, and for other platforms, dart.library.io becomes true.</p><p>In our custom_platform.dart file, we can use these conditions to decide where to import the getInstance method from. If our app is on the web, it’ll import from web_platform.dart, otherwise, from other_platform.dart.</p><p>Now we need to modify out MyApp class</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb9736f7a3e4553ece11a8bb372879c8/href">https://medium.com/media/eb9736f7a3e4553ece11a8bb372879c8/href</a></iframe><p>That’s it.</p><h3>Output</h3><p>Now we will try running our application on different platforms.</p><p><strong>Windows</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Id9oA1C-7FLGz4x58Fm5IA.png" /><figcaption>Windows screenshot</figcaption></figure><p><strong>Web</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6-ijgP-X7IZZG3in_H04zA.png" /><figcaption>Web screenshot</figcaption></figure><p><strong>Android</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*mFjLJywSjHidBbw48sqDgA.png" /><figcaption>Android screenshot</figcaption></figure><p><strong>Source Code</strong></p><p><a href="https://github.com/Ajaykamble/flutter_conditional_importing">GitHub - Ajaykamble/flutter_conditional_importing</a></p><p><strong>Conclusion:</strong></p><p>Conditional importing is a useful technique that can help optimize your Flutter app’s performance and minimize its size. By selectively importing only the code that you need, you can reduce the size of your app and improve its performance.</p><p>If you’re looking for assistance in creating cutting-edge products with Flutter, please feel free to reach out to me on <a href="https://www.linkedin.com/in/ajay-kamble-67a5291ba/">LinkedIn</a>. I’d be happy to assist you in building something innovative.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d7b6bff689c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/techskool/adding-conditional-imports-in-flutter-for-cross-platform-development-5d7b6bff689c">Conditional Imports in flutter for Cross-Platform Development</a> was originally published in <a href="https://medium.com/techskool">TechSkool</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>