<?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 Rob Yeates on Medium]]></title>
        <description><![CDATA[Stories by Rob Yeates on Medium]]></description>
        <link>https://medium.com/@robyeatesuk?source=rss-4bec9d876b31------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*4j8aEoHUA7r-vAgE</url>
            <title>Stories by Rob Yeates on Medium</title>
            <link>https://medium.com/@robyeatesuk?source=rss-4bec9d876b31------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 20:28:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@robyeatesuk/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[Stepper Widget — Flutter Basics]]></title>
            <link>https://medium.com/@robyeatesuk/stepper-widget-flutter-basics-c8bc7fb74d27?source=rss-4bec9d876b31------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8bc7fb74d27</guid>
            <dc:creator><![CDATA[Rob Yeates]]></dc:creator>
            <pubDate>Thu, 05 Oct 2023 21:14:38 GMT</pubDate>
            <atom:updated>2023-10-05T21:14:38.413Z</atom:updated>
            <content:encoded><![CDATA[<h3>Stepper Widget — Flutter Basics</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S5sVu3Dm6c7MP0u6W9Ra2Q.png" /><figcaption>Stepper Widget in Flutter</figcaption></figure><p>In this article, we’ll take a comprehensive look at the Flutter Stepper Widget, a valuable tool for guiding users through step-by-step processes in your app. We’ll explore how to set up and customize the Stepper Widget, and ensure that the “Next” and “Back” buttons work seamlessly.</p><h3>The Stepper Widget — A Step Towards Better User Experience</h3><p>The Stepper widget in Flutter is your go-to solution for displaying progress through a sequence of steps. It’s particularly useful in various scenarios, such as guiding users through multi-step forms, surveys, registration processes, or interactive tutorials. The Stepper Widget simplifies complex workflows and enhances user experience.</p><h3>Setting Up the Stepper</h3><p>Before we delve into the implementation of the Stepper Widget, let’s set up our Flutter project and create the necessary variables. To control the progress and navigation between steps, we’ll start by defining an integer variable:</p><pre>int _currentStep = 0;</pre><p>This _currentStep variable will keep track of the active step, allowing smooth navigation between the different steps of our Stepper.</p><h3>Creating a Basic Stepper</h3><p>Now, let’s create a basic Stepper Widget. To do this, use the Stepper class and provide it with an array of steps. Each step is represented by a Step widget, which can have a title, content, and other properties to define its appearance and behaviour.</p><p>Here’s how you can set up a basic Stepper:</p><pre>Stepper(<br>  currentStep: _currentStep,<br>  onStepContinue: () {<br>    if (_currentStep &lt; _stepperSteps.length - 1) {<br>      setState(() {<br>        _currentStep++;<br>      });<br>    }<br>  },<br>  onStepCancel: () {<br>    if (_currentStep &gt; 0) {<br>      setState(() {<br>        _currentStep--;<br>      });<br>    }<br>  },<br>  steps: _stepperSteps, // An array of Step widgets<br>)</pre><p>In this code, the currentStep property determines the active step, while the onStepContinue and onStepCancel callbacks control step navigation. When the user presses &quot;Next,&quot; we increment _currentStep if it&#39;s not the last step; when the user presses &quot;Back,&quot; we decrement it if it&#39;s not the first step.</p><h3>Defining Steps</h3><p>Each Step widget can be customized to represent a particular step in your process. Here&#39;s an example of how you can define a step:</p><pre>Step(<br>  title: Text(&#39;Step 1&#39;),<br>  content: Text(&#39;This is the content of Step 1&#39;),<br>  isActive: _currentStep == 0,<br>)</pre><p>In the Step widget, you set a title and content to explain the purpose of the step. The isActive property highlights the current step. We&#39;ve used _currentStep == 0 to activate Step 1 when _currentStep is 0.</p><h3>Making the Buttons Work</h3><p>To ensure that the “Next” and “Back” buttons work correctly, it’s crucial to manage the widget’s state. The code provided in this article relies on the setState method to update the _currentStep variable and trigger a widget rebuild.</p><p>Here’s the complete code, including the state management, for your reference:</p><pre>class MyStepperWidget extends StatefulWidget {<br>  @override<br>  _MyStepperWidgetState createState() =&gt; _MyStepperWidgetState();<br>}<br><br>class _MyStepperWidgetState extends State&lt;MyStepperWidget&gt; {<br>  int _currentStep = 0;<br><br>  @override<br>  Widget build(BuildContext context) {<br>    List&lt;Step&gt; _stepperSteps = [<br>      Step(<br>        title: Text(&#39;Step 1&#39;),<br>        content: Text(&#39;This is the content of Step 1&#39;),<br>        isActive: _currentStep == 0,<br>      ),<br>      Step(<br>        title: Text(&#39;Step 2&#39;),<br>        content: Text(&#39;This is the content of Step 2&#39;),<br>        isActive: _currentStep == 1,<br>      ),<br>    ];<br><br>    return Scaffold(<br>      appBar: AppBar(<br>        title: Text(&#39;Stepper Example&#39;),<br>      ),<br>      body: Stepper(<br>        currentStep: _currentStep,<br>        onStepContinue: () {<br>          if (_currentStep &lt; _stepperSteps.length - 1) {<br>            setState(() {<br>              _currentStep++;<br>            });<br>          }<br>        },<br>        onStepCancel: () {<br>          if (_currentStep &gt; 0) {<br>            setState(() {<br>              _currentStep--;<br>            });<br>          }<br>        },<br>        steps: _stepperSteps,<br>      ),<br>    );<br>  }<br>}</pre><p>In this example, the _currentStep variable is correctly managed with setState. If you&#39;re experiencing issues with the buttons in your implementation, make sure that your code structure is similar to this example and that it&#39;s encapsulated within a StatefulWidget.</p><h3>Conclusion</h3><p>With the Stepper Widget in Flutter, you can create interactive, user-friendly step-by-step interfaces for various purposes. Whether you’re building forms, surveys, tutorials, or any process with multiple stages, the Stepper Widget simplifies navigation and enhances the user experience. By following the guidelines outlined in this article, you’ll be well on your way to implementing Steppers effectively in your Flutter app.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8bc7fb74d27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter | Building a QR code scanner for Web, Android & iOS]]></title>
            <link>https://medium.com/@robyeatesuk/flutter-building-a-qr-code-scanner-for-web-android-ios-267429dfe2ff?source=rss-4bec9d876b31------2</link>
            <guid isPermaLink="false">https://medium.com/p/267429dfe2ff</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[pubdev]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <dc:creator><![CDATA[Rob Yeates]]></dc:creator>
            <pubDate>Sat, 19 Mar 2022 18:56:49 GMT</pubDate>
            <atom:updated>2022-07-26T14:26:00.668Z</atom:updated>
            <content:encoded><![CDATA[<p>Utilising mobile_scanner, jsQR and a custom overlay.</p><h3>Introduction</h3><p>In this post, we will create a functioning QR code scanner with just one package from <a href="https://pub.dev/">pub.dev</a>. This package makes use of AVFoundation for iOS, CameraX for Android, and jsQR for the web. We will also add a custom overlay over the scanner to make it less like just a camera, and more like an actual scanner.</p><p>The package replaces the highly popular qr_code_scanner that has been moved into maintenance mode due to the underlying frameworks no longer being maintained (<a href="https://github.com/zxing/zxing">zxing</a> &amp; <a href="https://github.com/mikebuss/MTBBarcodeScanner">MTBBarcodeScanner</a>).</p><h3>Dependencies</h3><p>Our project pubspec.yaml file plugin dependencies consist of:</p><pre><strong>dependencies:</strong><br><strong>  ....<br>  mobile_scanner: ^1.0.0</strong></pre><ul><li><a href="https://pub.dev/packages/mobile_scanner"><strong>mobile_scanner:</strong></a> A universal barcode and QR code scanner for Flutter based on MLKit.</li></ul><h3>Prerequisites</h3><h4><strong>Android Min SDK</strong></h4><p>mobile_scanner requires an SDK version of 21 above to work on Android, check that the minSdkVersion is set to 21 or higher at <strong>android/app/build.gradle</strong>.</p><pre>defaultConfig {<br>  ...<br>  minSdkVersion 21<br>}</pre><h4><strong>Granting camera permission on Android &amp; iOS</strong></h4><p>For the scanner to work, the camera must have permission to activate. Make sure these permissions are correctly set in the respective locations:</p><pre><strong>Android: android/app/src/main/AndroidManifest.xml</strong><br>&lt;uses-permission android:name=&quot;android.permission.CAMERA&quot;/&gt;</pre><pre><strong>iOS: ios/Runner/Info.plist<br></strong>&lt;key&gt;NSCameraUsageDescription&lt;/key&gt;<br>&lt;string&gt;To capture QR Codes&lt;/string&gt;</pre><h4>Adding the jsQR library</h4><p>Scanning the web requires its own JavaScript library to work, luckily there already is one to use instead of creating your own! (<strong>Note:</strong> Scanning on the web is currently limited and can only do QR codes and not barcodes)</p><p>Add the script in the <strong>web/index.html </strong>file, after the main script for main.dart.js.</p><pre> ...<br> loadMainDartJs();<br> }<br> &lt;/script&gt;</pre><pre><strong>&lt;script src=&quot;https://cdn.jsdelivr.net/npm/jsqr@1.4.0/dist/jsQR.min.js&quot;&gt;&lt;/script&gt;</strong></pre><p>Once added, rebuild your Flutter application, a hot restart will not load the new JavaScript.</p><h3>Scanner Screen</h3><p>Let&#39;s now actually get something on the app; Adding an initial scanner widget is very simple, we will import the package by adding<strong>import</strong> &#39;package:mobile_scanner/mobile_scanner.dart&#39;;at the start of the file and then inserting the MobileScanner() widget into our code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/92ee7a6641171354fea179e1a7acfb4d/href">https://medium.com/media/92ee7a6641171354fea179e1a7acfb4d/href</a></iframe><p>With this, we now get a camera presence on the screen, and if you show a QR code or barcode (Android or iOS) to the camera it will scan it and currently display it within the debug console.</p><p>MobileScanner comes with the parameter ‘allowDuplicates’, this is defaulted to false to stop the issue of the scanner scanning multiple scans in a very short time, causing things like pop() to fire lots of times.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*qHWYxbmIRHiGG9EGN6CulA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*vfvCjL-AJWCgFyQWZIrFRQ.png" /><figcaption>Scanner on Web and Android</figcaption></figure><h4>Adding user controls</h4><p>This is a great start, lets&#39;s now add some controls for the user so they can turn on the flash or switch the camera around. To control the camera, we must provide a controller MobileScannerController cameraController = MobileScannerController();that will be used to change the state of the camera and functionality.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/02ce4211d035066ab1953e4ed2288623/href">https://medium.com/media/02ce4211d035066ab1953e4ed2288623/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*37yv0yQrGLYccVN6X4nEmg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*6oVt1YBceSvnbfueZevuKA.png" /><figcaption>Scanner with user controls</figcaption></figure><h3>Scanner Overlay</h3><p>Now, let’s add an overlay on the QR camera’s screen. We make a new file called qr_overlay.dart to hold the overlay. This will be a stateless widget because nothing within it will need to be changed after it has been built. ColorFiltered is used to cut out the centre hole in the overlay, and Paint is used to create the white rounded border lines.</p><p>Every build includes a check of the screen’s width and height, allowing us to construct a larger cutout for larger screens and a smaller cutout for smaller devices.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae29d14cdc53bd40575d742983b70c85/href">https://medium.com/media/ae29d14cdc53bd40575d742983b70c85/href</a></iframe><h4>Putting the overlay over the camera</h4><p>To set the overlay over the camera, we’ll use the stack widget to place it on top. Because the last item in the stack widget list will always be at the front, the overlay widget will be placed after the MobileScanner within the stack.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fbf80dab9faef40af762e23e055a5c6d/href">https://medium.com/media/fbf80dab9faef40af762e23e055a5c6d/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*RyG9-i-B9WmVamWEL8FGBA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*DQAbCV3av6LyRp_ZatdHUA.png" /><figcaption>Final QR scanner with an overlay</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=267429dfe2ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>