<?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 Maria Elijah on Medium]]></title>
        <description><![CDATA[Stories by Maria Elijah on Medium]]></description>
        <link>https://medium.com/@elijahmaria04?source=rss-3fe9ca633e2a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*SKfHuBpgg1VGjhpGiMFCxQ.jpeg</url>
            <title>Stories by Maria Elijah on Medium</title>
            <link>https://medium.com/@elijahmaria04?source=rss-3fe9ca633e2a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 17:46:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@elijahmaria04/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[Flutter: Stack Widget]]></title>
            <link>https://medium.com/geekculture/flutter-stack-widget-bfdcf4c47212?source=rss-3fe9ca633e2a------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfdcf4c47212</guid>
            <category><![CDATA[flutter-widget]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[stack]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Maria Elijah]]></dc:creator>
            <pubDate>Thu, 23 Sep 2021 15:02:45 GMT</pubDate>
            <atom:updated>2021-09-26T16:57:28.065Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*5AfXYCQ74D3-WKcK" /><figcaption>image from unsplash.com</figcaption></figure><blockquote>Hello guys! Welcome to another article on flutter app development. In my previous article, we created a beautiful design using custom paint. In this article, we’ll implement another functionality to the existing code with the help of the <strong><em>Stack</em></strong> widget. I will be using the splash page for a password manager app I developed months back to explain this Stack widget.</blockquote><p>Stack is a widget that takes multiple widgets and allows us to order them from bottom to top on the screen. In the Stack, the first item is the bottommost and the last is the topmost. It is useful if you want to overlap widgets and display where needed. The stack widget makes our UI more attractive.</p><p>Each child needs to be positioned or aligned in the stack widget, or else it ends up in the top left corner by default. There are two types of a child in a stack: <strong>positioned and non-positioned.</strong></p><p><strong>A positioned child </strong>is wrapped in a positioned widget that has at least one non-null property. This widget is placed relative to the stack according to its top, right, bottom, and left properties.</p><p><strong>A non-positioned child</strong> is not wrapped in a positioned widget. Instead, it is positioned according to <a href="https://api.flutter.dev/flutter/widgets/Stack/alignment.html">alignment</a> (which defaults to the top-left corner in left-to-right environments and the top-right corner in right-to-left environments). The first child in the stack takes up the size while the other children are placed on it.</p><p>The size of the Stack is the size of the largest child in the layer. So if the bottommost child takes the whole screen, then the Stack&#39;s size is the whole screen.</p><h4>Stack Constructor:</h4><pre>Stack(<br>{Key key,<br>AlignmentGeometry alignment: AlignmentDirectional.topStart,<br>TextDirection textDirection,<br>StackFit fit: StackFit.loose,<br>Overflow overflow: Overflow.clip,<br>Clip clipBehavior: Clip.hardEdge,<br>List&lt;Widget&gt; children: const &lt;Widget&gt;[]}<br>)</pre><p>1. Alignment: defines the position of its children. The default value is topStart. Here are the other values of alignment:</p><pre><em>topLeft - align to top left corner.<br>topCenter - align to center point along the top edge.<br>topRight - align to top right corner.<br>centerLeft - align to center point along the left edge.<br>center - align to center point, both horizontally and vertically.<br>centerRight - align to center point along the right edge.<br>bottomLeft - align to bottom left corner.</em></pre><p>2. TextDirection: place the text from <em>ltr</em>(left to right) or <em>rtl</em>(right to left).</p><p>3. Fit: determines how the non-positioned children resize to fit the stack. There have three types of this property: <em>loose</em>, <em>expand, </em>and <em>passthrough.</em></p><ul><li><strong>loose</strong>: set the child widget size small.</li><li><strong>expand</strong>: Expand the size of children as much as possible.</li><li><strong>passthrough</strong>: set the child widget in a relative position depending on its parent’s position.</li></ul><p>4. Overflow: controls the children&#39;s widgets, whether visible or clipped when its content overflowing outside the stack.</p><p>5. ClipBehaviour: determines whether the content will be clipped or not.</p><blockquote>Let’s have a view of how non- positioned children works in Stack.</blockquote><p>Below is an example of non-positioned children inside the Stack.</p><pre>import &#39;package:flutter/material.dart&#39;;</pre><pre>void main() {<br>  runApp(MyApp());<br>}</pre><pre>class MyApp extends StatefulWidget {<br>  @override<br>  _MyAppState createState() =&gt; _MyAppState();<br>}</pre><pre>class _MyAppState extends State&lt;MyApp&gt; {</pre><pre>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      home: Scaffold(<br>        appBar: AppBar(<br>          title: Text(&#39;Stack Widget:non-position children&#39;),<br>        ),<br>        body: Container(<br>            child: Stack(<br>          children: &lt;Widget&gt;[<br>            Container(<br>              width: 120,<br>              height: 120,<br>              color: Colors.<em>purple</em>,<br>            ),<br>            Container(<br>              width: 90,<br>              height: 90,<br>              color: Colors.<em>pink</em>,<br>            ),<br>            Container(<br>              width: 70,<br>              height: 70,<br>              color: Colors.<em>amber</em>,<br>            ),<br>          ],<br>        )),<br>      ),<br>    );<br>  }<br>}</pre><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*v4wt9aCpFFSM77ySgATwMw.jpeg" /><figcaption>image depicting non-positioned Stack</figcaption></figure><p>In the article, we’ll implement a positioned stack. So, let’s jump right in!</p><p>We want to achieve the design below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*9TMkJHHn1pVjCRS_ghPaAA.jpeg" /></figure><p>First, add the image folder inpubspec.yaml file.</p><pre>assets:<br>  - images/</pre><p>Next, add the stack widget ( this will be a child to the Custom painter)</p><pre>child: Stack(<br>  children: [<br>    Positioned(<br>      top: 20,<br>      left: -90,<br>      child: CircleAvatar(<br>        radius: 110,<br>        backgroundImage: AssetImage(&#39;images/face1.jpeg&#39;),<br>        //backgroundColor: Color(0xfffdea3a),<br>      ),<br>    ),<br>    Positioned(<br>      top: 70,<br>      right: -40,<br>      child: CircleAvatar(<br>        radius: 70,<br>        backgroundImage: AssetImage(&#39;images/face4.jpg&#39;),<br>        //backgroundColor: Color(0xfffdea3a),<br>      ),<br>    ),</pre><p><strong>Code Explanation</strong></p><p>Positioned()widget allows us to give each child a defined space or location. top() and right()properties are used to achieve the design.</p><p>CircleAvatar() widget comes built-in with the flutter SDK. It’s basically a circle where we can put a backdrop color, a background image, or some text. It usually depicts a user by using his image or initials. Although we may create a comparable widget from the ground up, this widget is useful for rapid application development. It gives us a circle shape as its name implies so you don’t have to write code to get a circled shape unlike using a container widget.</p><p>The radiusproperty holds a <em>double </em>value as the parameter to decide the size of <em>CircleAvatar </em>in terms of its radius.</p><p>ThebackgroundImageproperty holds <em>ImageProvider&lt;T extends Object&gt; class (final) </em>as the parameter. This property applies a background image to the <em>CircleAvatar</em> widget.</p><p><strong>Constructor Of CircleAvatar Class:</strong></p><pre>const CircleAvatar(<br>{Key key,<br>Widget child,<br>Color backgroundColor,<br>ImageProvider&lt;Object&gt; backgroundImage,<br>void onBackgroundImageError(<br>dynamic exception,<br>StackTrace stackTrace<br>),<br>Color foregroundColor,<br>double radius,<br>double minRadius,<br>double maxRadius}<br>)</pre><p>Up next, run the app.</p><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*WIMbQSL9N6ouAedwwZAhrQ.jpeg" /><figcaption>code output</figcaption></figure><p>Next, add the bottom container wrapped in Positioned()widget.</p><pre>Positioned(<br>  bottom: 30,<br>  left: 80,<br>  child: Container(<br>    height: MediaQuery.<em>of</em>(context).size.height * 40,<br>    child: Column(<br>      mainAxisAlignment: MainAxisAlignment.end,<br>      mainAxisSize: MainAxisSize.max,<br>      crossAxisAlignment: CrossAxisAlignment.center,<br>      children: [<br>        Text(<br>          &#39;Secure your Data from \n \t \t \t \t the Others&#39;,<br>          style: TextStyle(<br>            fontWeight: FontWeight.<em>bold</em>,<br>            fontSize: 22,<br>            color: Color(0xff404040).withOpacity(0.6),<br>          ),<br>        ),<br>        SizedBox(<br>          height: 20,<br>        ),<br>        Container(<br>          width: 100,<br>          child: LinearProgressIndicator(<br>            value: 0.85,<br>            backgroundColor: Color(0xfffbfaff).withOpacity(0.6),<br>            valueColor:<br>                AlwaysStoppedAnimation(Color(0xff404040)),<br>          ),<br>        ),<br>        SizedBox(<br>          height: 20,<br>        ),<br>        Container(<br>          height: 40,<br>          width: 200,<br>          decoration: BoxDecoration(<br>            borderRadius: BorderRadius.all(<br>              Radius.circular(25),<br>            ),<br>            boxShadow: [<br>              BoxShadow(<br>                  color: Color(0xffffffff).withOpacity(0.3),<br>                  offset: Offset.<em>zero</em>,<br>                  blurRadius: 1,<br>                  spreadRadius: 2),<br>            ],<br>            color: Color(0xff404040).withOpacity(0.6),<br>          ),<br>          constraints: BoxConstraints(maxHeight: 40),<br>          //alignment: Alignment.centerLeft,<br>          child: Text(<br>            &#39;Get started&#39;,<br>            style: TextStyle(<br>              fontWeight: FontWeight.<em>bold</em>,<br>              fontSize: 20,<br>              color: Color(0xffffffff),<br>            ),<br>            textAlign: TextAlign.center,<br>          ),<br>        ),<br>      ],<br>    ),<br>  ),<br>)</pre><p><strong>Code Explanation</strong></p><p>The Positioned()widget holds the Container()widget inside the Stack()widget. The Container()widget takes Column()widget as its child. The Column()widget takes a list of widgets placed horizontally. We have Text()widget for text and LinearProgressIndicator()widget.</p><p>The LinearProgressIndicator()widget is used to show the progress of the task in a horizontal line.</p><p>Finally, run the app.</p><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*9TMkJHHn1pVjCRS_ghPaAA.jpeg" /><figcaption>final output</figcaption></figure><blockquote>Wow! that was a lot😊.</blockquote><p>In this article, We’ve learned how to use stack class in Flutter. Please feel free to ask any questions in the response section below.<br>Keep Coding 😊!!!</p><p>Check the source code <a href="https://github.com/funmi-cod/password_manager_app/blob/main/lib/splashPage.dart"><strong>here</strong></a></p><p>❤ ❤ Thanks for staying till the end. ❤❤</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/0*xOPkLQy0PVJbnaB4" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfdcf4c47212" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/flutter-stack-widget-bfdcf4c47212">Flutter: Stack Widget</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter: Custom Paint]]></title>
            <link>https://medium.com/geekculture/flutter-custom-paint-27c4aba498?source=rss-3fe9ca633e2a------2</link>
            <guid isPermaLink="false">https://medium.com/p/27c4aba498</guid>
            <category><![CDATA[custom-painter-flutter]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Maria Elijah]]></dc:creator>
            <pubDate>Mon, 23 Aug 2021 10:02:52 GMT</pubDate>
            <atom:updated>2021-08-23T10:02:52.872Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*04eyx6VzSpldxwA9" /><figcaption>Image from <a href="https://images.unsplash.com/photo-1513364776144-60967b0f800f?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8YXJ0JTIwYnJ1c2h8ZW58MHx8MHx8&amp;ixlib=rb-1.2.1&amp;w=1000&amp;q=80">Unsplash</a></figcaption></figure><p>In flutter, some UI designs cannot be derived from the regular shapes widget. This is where Custom Paint comes into play. Custom Paint is a widget that provides you board (calledcanvas), a brush (called paint), a board size (called size) and, a pathfor drawing the shapes.</p><blockquote>In this article, we will learn how to draw custom shapes in flutter app by leveraging on Custom Paint. This will make your UI more attractive.</blockquote><p>At the end of this article, we will achieve the result from the picture below. You can find the Github source at the end of this article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*vtowQ6vbbpGRUUVin0Kvzg.jpeg" /><figcaption>final output</figcaption></figure><p>Let’s set up our flutter application.</p><p>Create a new flutter project custompaint</p><pre><br>import &#39;package:flutter/material.dart&#39;;</pre><pre>import &#39;package:custompaint/home.dart&#39;;</pre><pre>void main() {<br>  runApp(MyApp());<br>}<br><br>class MyApp extends StatelessWidget {<br>  const MyApp({Key? key}) : super(key: key);<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      title: &#39;Drawing Custom shapes&#39;,<br>      debugShowCheckedModeBanner: false,<br>      home: Home(),<br>    );<br>  }<br>}</pre><p><strong>Next, create the</strong>Home<strong>properties.</strong></p><pre>class Home extends StatefulWidget {<br>  const Home({Key? key}) : super(key: key);<br><br>  @override<br>  _HomeState createState() =&gt; _HomeState();<br>}<br><br>class _HomeState extends State&lt;Home&gt; {<br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      body: SafeArea(<br>        child: SingleChildScrollView(<br>          child: Container(<br>            height: MediaQuery.of(context).size.height,<br>            width: MediaQuery.of(context).size.width,<br>            color: Color(0xfffbfaff),<br>            child: CustomPaint(<br>              painter: BackgroundPaint(),<br>            ),<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>We wrapped the application to a Container and set its background to defined color. Then we have the CustomPaint which takes the BackgroundPaint() as the painter .</p><p>BackgroundPaint() is a custom class we will be creating that contains our drawing.</p><h4>Custom Paint class</h4><p>Below is the class Structure for the drawing.</p><pre>class BackgroundPainter extends CustomPainter {<br>  @override<br>  void paint(Canvas canvas, Size size) {<br>    var paint = Paint();<br>    // <em>TODO: Set properties to paint<br><br>    </em>var path = Path();<br><br>    // <em>TODO: Draw your path<br><br>    </em>canvas.drawPath(path, paint);<br>  }<br><br>  @override<br>  bool shouldRepaint(CustomPainter oldDelegate) =&gt; true;<br>}</pre><p>The class provides canvas, path, size, and paint. Use the picture below for a better understanding of thesizevariable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/0*85NJmpQkubO7Ibmv.png" /><figcaption>image depicting size variable</figcaption></figure><p>Our design wants to draw a curve from 25% of the app width and end the curve at 85% of the app height. Then, line it up and paint the path.</p><p><strong>Up Next, create the</strong> CustomPainter <strong>properties</strong></p><pre>class BackgroundPaint extends CustomPainter {<br>  @override<br>  void paint(Canvas canvas, Size size) {<br>    // <em>TODO: implement paint<br>    </em>final height = size.height;<br>    final width = size.width;<br><br>    Paint paint = Paint()<br>      ..style = PaintingStyle.fill<br>      ..isAntiAlias = true<br>      ..color = Color(0xff404040);<br><br>    Path myPath = Path();<br><br>    myPath.moveTo(width * 0.25, 0);<br><br>    //myPath.quadraticBezierTo(<br>    //width * 0.70, height * 0.20, width * 0.40, height * 0.35);<br>    myPath.quadraticBezierTo(<br>        width * 0.7, height * 0.15, width * 0.4, height * 0.3);<br>    myPath.quadraticBezierTo(<br>        width * 0.15, height * 0.45, width * 0.4, height * 0.65);<br>    myPath.quadraticBezierTo(<br>        width * 0.51, height * 0.75, width * 1, height * 0.85);<br>    //myPath.quadraticBezierTo(<br>    //width * 0.2, height * 0.75, width * 1, height * 0.75);<br>    myPath.lineTo(width * 25, 0);<br>    myPath.lineTo(width, 0);<br><br>    canvas.drawPath(myPath, paint);<br>  }<br><br>  @override<br>  bool shouldRepaint(covariant CustomPainter oldDelegate) =&gt; true;<br>}</pre><h4>Code Explanation</h4><p>First, we created two variables(height and width) and assign them to the app height and width. Then, we define our paintgiving it a color and fill style to fill up the pathdrawn.</p><p>Next, we definedpathand provide the method to draw our design.</p><p>moveTo()method takes two parameters: x and y. We start the pathfrom 25%(0.25) width with a height of 0.</p><p>quadraticBezierTo()method takes four parameters (X1, Y1, X2, Y2). The control point is X1 and Y1. The final point is X2 and Y2.</p><pre>myPath.quadraticBezierTo(<br>        width * 0.7, height * 0.15, width * 0.4, height * 0.3);</pre><p>Here,quadraticBezierTo() take X1 = width * 0.7 and Y1= height * 0.15 as the control point then draw a curve to point (X2 = width * 0.4, Y2 = height * 0.3).</p><p>Finally, we need to line up thepathto fill it with ourpaint.</p><pre>myPath.lineTo(width * 25, 0);<br>    myPath.lineTo(width, 0);</pre><p>lineTo()method takes two parameters: x and y. Here, lineTo()starts from point (X = width * 25, Y = 0) and line up to the end with point(X = width, height = 0).</p><p>Then, we call cavas to draw the path using our definedpathandpaint.</p><pre>canvas.drawPath(myPath, paint);</pre><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*vtowQ6vbbpGRUUVin0Kvzg.jpeg" /><figcaption>final result</figcaption></figure><p><em>Let me share my little secret with you</em>😉😊</p><blockquote>When working with Custom Paint make sure you sketch out your design. This will save you a lot of time spent on debugging😰.</blockquote><p>Check the source code <a href="https://github.com/funmi-cod/custompaint">here</a>.</p><p>In the next article, we will add more functionalities to this design by leveraging Stack. See you there😊!</p><p>❤ ❤ Thanks for staying till the end. ❤❤</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*jGRllsTCENbQqmo7" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27c4aba498" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/flutter-custom-paint-27c4aba498">Flutter: Custom Paint</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Welcome back to Flutter App work#2]]></title>
            <link>https://medium.com/geekculture/my-welcome-back-to-flutter-app-work-2-4b851d9ecbbb?source=rss-3fe9ca633e2a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b851d9ecbbb</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[firebaseauthentication]]></category>
            <category><![CDATA[firebase]]></category>
            <dc:creator><![CDATA[Maria Elijah]]></dc:creator>
            <pubDate>Wed, 04 Aug 2021 08:02:50 GMT</pubDate>
            <atom:updated>2021-08-06T01:09:40.724Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*u77a9QO03UbH8NOj.jpg" /><figcaption>image from morioh.com</figcaption></figure><p>This article is a continuation of the previous <a href="https://medium.com/geekculture/my-welcome-back-to-flutter-app-work-1-ec26dec8e4cb"><strong>article</strong></a> that I wrote about the same topic. If you have not read that, please go ahead and give it a read so that you can follow along with this one.<br>Whether you’re developing a simple application or building your dream app, authentication helps you personalize the experience with user-specific information. It’s also a crucial component for privacy and security.</p><blockquote>🤔 Did you know?</blockquote><blockquote>Firebase Authentication is a pre-configured backend service that makes it easy to integrate with a mobile app using an SDK. You don’t have to maintain any backend infrastructure for the authentication process. Firebase supports integration with popular identity providers such as Google, Facebook, Twitter, and GitHub.</blockquote><p>In this article, we will integrate authentication using Firebase in our flutter app.</p><blockquote>Let’s set up Firebase.</blockquote><p>Step 1: Create Firebase project<br>To integrate Firebase with a Flutter project, we have to create a new Firebase project by going to the console. Then, add a new project and give it a name(preferably your flutter project’s name). Once created, you will be directed to your Firebase project dashboard like the image below. Although, I’ve already added a Firebase project displayed in the picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*SvsJthyFX2KxFvV5DCaUMg.png" /><figcaption>firebase dashboard</figcaption></figure><p>Step 2: Set up Firebase for Android and iOS</p><p>To use Firebase with Android, or iOS you have to complete some configurations for each platform. See the complete configuration guides below:</p><ul><li><a href="https://firebase.flutter.dev/docs/installation/android">Android installation</a></li><li><a href="https://firebase.flutter.dev/docs/installation/ios">iOS installation</a></li></ul><p>Now that we have the basic setup for using Firebase, let’s dive into our Flutter app.</p><p><strong>Adding Firebase plugins</strong></p><p>In your pubspec.yaml , add the following plugins:</p><pre>firebase_core: ^1.3.0<br>firebase_auth: ^2.0.0</pre><ul><li><a href="https://pub.dev/packages/firebase_core">firebase_core</a>, which is required to use any Firebase service in a Flutter app</li><li><a href="https://pub.dev/packages/firebase_auth">firebase_auth</a> to get access to Firebase Authentication services</li></ul><p><strong>Initialize Firebase App</strong></p><p>Before using any Firebase service within the Flutter app, you need to initialize <a href="https://firebase.google.com/docs/reference/js/firebase.app.App">Firebase App</a>.</p><p>In the Auth.dart , add this method to initialize Firebase App:</p><pre>Future&lt;FirebaseApp&gt; _initializeFirebase() async {<br>    FirebaseApp firebaseApp = await Firebase.initializeApp();<br>    return firebaseApp;<br>}</pre><p>Since the method is asynchronous we will use FutureBuilder inside the build method</p><pre>child: Scaffold(<br>  body: FutureBuilder(<br>    future: _inializeFirebase(),<br>    builder: (context, snapshot) {<br>      if (snapshot.connectionState == ConnectionState.done) {<br>        return Container(<br>          color: Colors.<em>white</em>,<br>          child: CustomPaint(<br>            painter: BackgroundPaint(),</pre><p>Up next, create a new dart file called authentication.dart and define a new method called registerUsingEmailPassword() for new users to register.</p><pre>class Authentication {<br>  // For registering a new user<br>  static Future&lt;User?&gt; <em>registerUsingEmailPassword</em>({<br>    required String email,<br>    required String password,<br>  }) async {<br>    FirebaseAuth auth = FirebaseAuth.<em>instance</em>;<br>    User? user;<br><br>    try {<br>      UserCredential userCredential = await auth.createUserWithEmailAndPassword(<br>        email: email,<br>        password: password,<br>      );<br><br>      user = userCredential.user;<br>      // ignore: deprecated_member_use<br>      await user!.updateProfile(displayName: email);<br>      await user.reload();<br>      user = auth.currentUser;<br>    } on FirebaseAuthException catch (e) {<br>      if (e.code == &#39;weak-password&#39;) {<br>        print(&#39;The password provided is too weak.&#39;);<br>      } else if (e.code == &#39;email-already-in-use&#39;) {<br>        print(&#39;The account already exists for that email.&#39;);<br>      }<br>    } catch (e) {<br>      print(e);<br>    }<br><br>    return user;<br>  }</pre><p>In the above code, we register a new user using the email and password and include a conditional statement to catch errors.</p><p>Next, define a new method calledsignInUsingEmailPassword(), passing the user email and password for registered users:</p><pre>// For signing in an user (have already registered)<br>static Future&lt;User?&gt; <em>signInUsingEmailPassword</em>({<br>  required String email,<br>  required String password,<br>}) async {<br>  FirebaseAuth auth = FirebaseAuth.<em>instance</em>;<br>  User? user;<br><br>  try {<br>    UserCredential userCredential = await auth.signInWithEmailAndPassword(<br>      email: email,<br>      password: password,<br>    );<br>    user = userCredential.user;<br>  } on FirebaseAuthException catch (e) {<br>    if (e.code == &#39;user-not-found&#39;) {<br>      print(&#39;No user found.&#39;);<br>    } else if (e.code == &#39;wrong-password&#39;) {<br>      print(&#39;Wrong password&#39;);<br>    }<br>  }<br><br>  return user;<br>}</pre><p>The email and password help to generate the User object provided by Firebase. The Userobject will be used to retrieve any additional data (e.g., user name, profile picture, etc.) stored in that account.</p><p>The signOut()method logs out a user. Creating a signout method is not needed since it’s just a single line of code.</p><pre>FirebaseAuth.instance.signOut();</pre><p>For email verification, we will use the sendEmailVerification() method on the User object:</p><pre>user.sendEmailVerification();</pre><p>Next, define a validator for the form</p><p>In the previous article, we created a login/sign-up page containing two form fields: email and password. Now, we’ll create a validator for each one. The validators will help to check whether the user has entered any inappropriate value in a specific field and show an error accordingly.</p><p>Create a new file called validator.dart, define a class Validator, and specify two methods inside it (each of which will take a String as a parameter):</p><pre>class Validator {<br>  static String? <em>validateEmail</em>({required String? email}) {<br>    if (email == null) {<br>      return null;<br>    }<br><br>    RegExp emailRegExp = RegExp(<br>        r&quot;^[a-zA-Z0-9.!#$%&amp;&#39;*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?)*$&quot;);<br><br>    if (email.isEmpty) {<br>      return &#39;Email can\&#39;t be empty&#39;;<br>    } else if (!emailRegExp.hasMatch(email)) {<br>      return &#39;Enter a correct email&#39;;<br>    }<br><br>    return null;<br>  }<br><br>  static String? <em>validatePassword</em>({required String? password}) {<br>    if (password == null) {<br>      return null;<br>    }<br><br>    if (password.isEmpty) {<br>      return &#39;Password can\&#39;t be empty&#39;;<br>    } else if (password.length &lt; 6) {<br>      return &#39;Enter a password with length at least 6&#39;;<br>    }<br><br>    return null;<br>  }<br>}</pre><p>In the Auth.dartdefine a GlobalKey:</p><pre>final _formKey = GlobalKey&lt;FormState&gt;();</pre><p>Specify the key in the form</p><pre>child: Form(<br>  key: _formKey,<br>  child: Column(<br>    mainAxisAlignment: MainAxisAlignment.center,<br>    children: [<br>      TextFormField(<br>        controller: _emailTextController,<br>        // ignore: missing_return<br>        focusNode: _focusEmail,<br>        validator: (value) =&gt;<br>            Validator.<em>validateEmail</em>(email: value),<br>        decoration: InputDecoration(<br>          labelText: &#39;email&#39;,<br>          labelStyle: TextStyle(<br>              color: Colors.<em>white</em>,<br>              fontSize: 16,<br>              fontWeight: FontWeight.<em>w400</em>),<br>          filled: true,<br>          contentPadding: EdgeInsets.symmetric(<br>              vertical: 0, horizontal: 16),<br>          border: OutlineInputBorder(<br>            borderRadius: BorderRadius.only(<br>              topLeft: Radius.circular(25),<br>              topRight: Radius.circular(25),<br>            ),<br>            borderSide: BorderSide(<br>              width: 0,<br>              style: BorderStyle.none,<br>            ),<br>          ),</pre><p>We called the validator method to check if the email is valid. We will do the same for the password field</p><pre>TextFormField(<br>  controller: _passwordTextController,<br>  focusNode: _focusPassword,<br>  validator: (value) =&gt;<br>      Validator.<em>validatePassword</em>(<br>          password: value),<br>  decoration: InputDecoration(<br>    labelText: &#39;password&#39;,<br>    labelStyle: TextStyle(<br>        color: Colors.<em>white</em>,<br>        fontSize: 16,<br>        fontWeight: FontWeight.<em>w400</em>),<br>    filled: true,<br>    contentPadding: EdgeInsets.symmetric(<br>        vertical: 0, horizontal: 16),<br>    border: OutlineInputBorder(<br>      borderRadius: BorderRadius.only(<br>        bottomLeft: Radius.circular(25),<br>        bottomRight: Radius.circular(25),<br>      ),<br>      borderSide: BorderSide(<br>        width: 0,<br>        style: BorderStyle.none,<br>      ),<br>    ),<br>  ),<br>  obscureText: true,<br>),</pre><p>Inside the <strong>login</strong> button, we called FireAuth.signInUsingEmailPassword()to perform the login process using Firebase Authentication.</p><pre>_isProcessing<br>    ? LoadingIndicator()<br>    : GestureDetector(<br>        onTap: () async {<br>          _focusEmail.unfocus();<br>          _focusPassword.unfocus();<br>          if (_formKey.currentState!<br>              .validate()) {<br>            setState(() {<br>              _isProcessing = true;<br>            });<br>            User? user = await Authentication<br>                .<em>signInUsingEmailPassword</em>(<br>                    email:<br>                        _emailTextController<br>                            .text,<br>                    password:<br>                        _passwordTextController<br>                            .text);<br>            setState(() {<br>              _isProcessing = false;<br>            });<br>            if (user != null) {<br>              Navigator.<em>of</em>(context)<br>                  .pushReplacement(<br>                MaterialPageRoute(<br>                  builder: (context) =&gt;<br>                      HomePage(user: user),<br>                ),<br>              );<br>            }<br>          }<br>        },<br>        child: Container(<br>          height: 40,<br>          decoration: BoxDecoration(<br>            borderRadius: BorderRadius.all(<br>              Radius.circular(25),<br>            ),<br>            color: Color(0xff8705bf),<br>            boxShadow: [<br>              BoxShadow(<br>                  offset: Offset(0, 3),<br>                  blurRadius: 3,<br>                  spreadRadius: 2,<br>                  color: Color(0xffbf63d8)),<br>            ],<br>          ),<br>          child: Center(<br>            child: Text(<br>              &#39;login&#39;.toUpperCase(),<br>              style: TextStyle(<br>                fontWeight: FontWeight.<em>bold</em>,<br>                fontSize: 24,<br>                color: Colors.<em>white</em>,<br>              ),<br>            ),<br>          ),</pre><p>The signup page will also contain a form similar to the login page.</p><p>Wow! That was a lot. Now, we have successfully integrated Firebase Authentication with our Flutter app. As you know, Firebase Authentication not only provides the backend infrastructure for authenticating users easily but also the predefined methods for auto-login and email verification. With Firebase, there’s a lot more to explore.</p><p>One last step to go!</p><p>We need to create a profile setting page to verify email and also, add a profile image.</p><p>Create a new dart file <strong>profile_setting.dart</strong></p><p>First, we will need the image_picker <a href="https://pub.dev/packages/image_picker">plugin</a> for picking images via Camera and Photo Library.</p><p>Step 1: Add the plugin to your pubspec.yaml file.</p><pre>image_picker: ^0.8.2</pre><p>Step 2: configure native settings</p><p>On the Android platform, no configuration is needed. For iOS, open the Info.plist file found under IOS/Runner folder and add the following keys.</p><pre>&lt;key&gt;NSPhotoLibraryUsageDescription&lt;/key&gt;<br>&lt;string&gt;Allow access to photo library&lt;/string&gt;</pre><pre>&lt;key&gt;NSCameraUsageDescription&lt;/key&gt;<br>&lt;string&gt;Allow access to camera to capture photos&lt;/string&gt;</pre><pre>&lt;key&gt;NSMicrophoneUsageDescription&lt;/key&gt;<br>&lt;string&gt;Allow access to microphone&lt;/string&gt;</pre><p>Step 3: Create UI for profile_setting.dart</p><pre>import &#39;dart:io&#39;;<br><br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:image_picker/image_picker.dart&#39;;<br>import &#39;package:font_awesome_flutter/font_awesome_flutter.dart&#39;;<br><br>class Settings extends StatefulWidget {<br> @override<br>  _SettingsState createState() =&gt; _SettingsState();<br>}<br><br>class _SettingsState extends State&lt;Settings&gt; {<br>  File? _avatarImage;<br><br>  final picker = ImagePicker();<br><br>  // create two functions to pick image from gallery/camera<br><br>// create a future function. store the result in a variable of File<br>// as it will return the image Path<br>Future pickImageFromGallery() async {<br>  final pickedFile = await picker.pickImage(<br>    source: ImageSource.gallery,<br>    imageQuality: 50,<br>  );<br><br>  setState(() {<br>    _avatarImage = File(pickedFile!.path);<br>  });<br>}<br><br>Future pickImageFromCamera() async {<br>  XFile? pickedFile = await picker.pickImage(<br>    source: ImageSource.camera,<br>    imageQuality: 50,<br>  );<br><br>  setState(() {<br>    _avatarImage = pickedFile as File;<br>  });<br>}<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(<br>        backgroundColor: Colors.<em>white</em>,<br>        leading: IconButton(<br>          icon: Icon(<br>            FontAwesomeIcons.<em>arrowLeft</em>,<br>            color: Color(0xff8705bf),<br>          ),<br>          onPressed: () {<br>            Navigator.<em>pop</em>(context);<br>          },<br>        ),<br>      ),</pre><p>In the class state, we declare a File variable to hold the image picked by the user. Then, we create two functions to pick images via Camera and Photo Library.</p><pre>body: Padding(<br>  padding: const EdgeInsets.all(10.0),<br>  child: Container(<br>    color: Colors.<em>white</em>,<br>    child: Column(<br>      mainAxisAlignment: MainAxisAlignment.center,<br>      crossAxisAlignment: CrossAxisAlignment.stretch,<br>      children: [<br>        SizedBox(<br>          height: 100,<br>        ),<br>        Center(<br>          child: GestureDetector(<br>            onTap: () =&gt; _displayPicker(context),<br>            child: CircleAvatar(<br>              radius: 55,<br>              // ignore: unnecessary_null_comparison<br>              child: _avatarImage != null<br>                  ? ClipOval(<br>                      child: SizedBox(<br>                        width: 120,<br>                        height: 120,<br>                        child: Image.file(<br>                          _avatarImage!,<br>                          fit: BoxFit.fill,<br>                        ),<br>                      ),<br>                    )<br>                  : Container(<br>                      decoration: BoxDecoration(<br>                        color: Colors.<em>grey</em>.shade200,<br>                        borderRadius: BorderRadius.circular(50),<br>                      ),<br>                      width: 100,<br>                      height: 100,<br>                      child: Icon(<br>                        Icons.<em>camera_alt_rounded</em>,<br>                        color: Colors.<em>grey</em>.shade400,<br>                      ),<br>                    ),<br>            ),<br>          ),<br>        ),</pre><p>We create a CircleAvatar,wrap its child with ClipOvarto clip the image and a camera icon is displayed if no picture is selected.</p><pre>// create a function for displaying a bottom sheet for the user<br>// To choose the option of camera or gallery.<br>void _displayPicker(context) {<br>  showModalBottomSheet(<br>    context: context,<br>    builder: (BuildContext bc) {<br>      return SafeArea(<br>        child: Container(<br>          child: Wrap(<br>            children: &lt;Widget&gt;[<br>              ListTile(<br>                  leading: new Icon(Icons.<em>photo_library</em>),<br>                  title: new Text(&#39;Gallery&#39;),<br>                  onTap: () {<br>                    pickImageFromGallery();<br>                    Navigator.<em>of</em>(context).pop();<br>                  }),<br>              ListTile(<br>                leading: new Icon(Icons.<em>photo_camera</em>),<br>                title: new Text(&#39;Camera&#39;),<br>                onTap: () {<br>                  pickImageFromCamera();<br>                  Navigator.<em>of</em>(context).pop();<br>                },<br>              ),<br>            ],<br>          ),<br>        ),<br>      );<br>    },<br>  );<br>}</pre><p>When the CircleAvatar is tapped, a container is displayed right at the bottom to choose the option of camera or gallery. Then the selected image is displayed in the CircleAvatar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*qRhTsCd7ES_fBfxm5JgX6w.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*BESfIVHuGQbw7tKXEFoAaQ.jpeg" /></figure><p>Now, let’s write some codes to verify user email.</p><p>First, add the following code. The User object will help retrieve the user’s data.</p><pre>final User user;<br>const Settings({required this.user});</pre><p>Create a variable <strong>_currentUser </strong>and initialize it in the <strong>initState().</strong></p><pre>var _currentUser;<br>bool _isSendingVerification = false;<br><br>@override<br>void initState() {<br>  // <em>TODO: implement initState<br>  </em>_currentUser = widget.user;<br>  super.initState();<br>}</pre><p>The button for sending email verification is as follows:</p><pre>Text(<br>  &#39;${_currentUser.email}&#39;,<br>  style: Theme.<em>of</em>(context).textTheme.bodyText1,<br>),<br>SizedBox(<br>  height: 16,<br>),<br>_currentUser.emailVerified<br>    ? Text(<br>        &#39;Email verified&#39;,<br>        style: Theme.<em>of</em>(context)<br>            .textTheme<br>            .bodyText1!<br>            .copyWith(color: Colors.<em>green</em>),<br>      )<br>    : Text(<br>        &#39;Email not verified&#39;,<br>        style: Theme.<em>of</em>(context)<br>            .textTheme<br>            .bodyText1!<br>            .copyWith(color: Colors.<em>red</em>),<br>      ),<br>SizedBox(<br>  height: 16,<br>),<br>_isSendingVerification<br>    ? CircularProgressIndicator()<br>    : Row(<br>        mainAxisSize: MainAxisSize.min,<br>        children: [<br>          GestureDetector(<br>            onTap: () async {<br>              setState(() {<br>                _isSendingVerification = true;<br>              });<br>              await _currentUser.sendEmailVerification();<br>              setState(() {<br>                _isSendingVerification = false;<br>              });<br>            },<br>            child: Text(<br>              &#39;Verify email&#39;,<br>              style: TextStyle(<br>                  color: Color(0xff8705bf),<br>                  fontSize: 16,<br>                  fontWeight: FontWeight.<em>bold</em>),<br>            ),<br>          ),<br>          SizedBox(<br>            width: 8.0,<br>          ),<br>          IconButton(<br>            onPressed: () async {<br>              User? user =<br>                  await Authentication.<em>refreshUser</em>(_currentUser);<br>              if (user != null) {<br>                setState(() {<br>                  _currentUser = user;<br>                });<br>              }<br>            },<br>            icon: Icon(<br>              Icons.<em>refresh_rounded</em>,<br>              color: Color(0xff8705bf),<br>            ),<br>          ),<br>        ],<br>      ),</pre><p>Once the email is verified, the text widget’s color changes from red to green.</p><h4>Conclusion</h4><p>You’ll never know how good you can be until you start it. It’s okay to get errors but the awesome part is you get it solved. So, Keep Coding!</p><p>Check the project code <a href="https://github.com/funmi-cod/fashionapp">here</a>.</p><p><a href="https://github.com/funmi-cod/fashionapp">https://github.com/funmi-cod/fashionapp</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/245/0*uiGgmi8zJbHv5uST" /></figure><p>❤ ❤ Thanks for staying till the end. ❤❤</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*b31hiO4ynbDLRrXWEFF4aQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b851d9ecbbb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/my-welcome-back-to-flutter-app-work-2-4b851d9ecbbb">My Welcome back to Flutter App work#2</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Welcome back to Flutter App work#1]]></title>
            <link>https://medium.com/geekculture/my-welcome-back-to-flutter-app-work-1-ec26dec8e4cb?source=rss-3fe9ca633e2a------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec26dec8e4cb</guid>
            <category><![CDATA[flutter-widget]]></category>
            <category><![CDATA[flutter-form]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <dc:creator><![CDATA[Maria Elijah]]></dc:creator>
            <pubDate>Mon, 02 Aug 2021 17:02:24 GMT</pubDate>
            <atom:updated>2021-08-03T04:27:56.665Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/730/0*yQ6-JYBVLb03iGSR.png" /><figcaption>image for LogRocket.blog</figcaption></figure><blockquote>Yeah! I’m super excited to share my Flutter journey here. I started flutter three years ago. Along the way, I stopped for some reasons best known to me. Back then, I remember always looking through the internet for the slightest design work like I literally couldn’t create a simple container with a bunch of text or pictures without looking through the internet. My tech friend ( Big bro) would say: ‘Little girl, you’re skipping the basics’ He was right. One morning I was on IG came across this beautiful UI design which we’ll be creating in this article — my welcome back to flutter design. To cut it short, I develop the UI design from scratch and also integrate authentication using firebase. All in a day! I couldn’t believe it but yeah, I did it.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*mpvuPpTUIB5u_D5NZ_8syw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*-BImeqm3UVmk3NPxMo4HAA.jpeg" /><figcaption>UI designs</figcaption></figure><p>In this article, we’ll create the UI design which is the login/sign-up page and the homepage. Here are the topics we will cover:</p><ol><li>Custom Painter</li><li>Popup Menu</li><li>ClipRRect</li><li>ListVIew.Builder</li></ol><p>At this point, I am assuming you know the basics of <em>Flutter….</em> Though I will try to explain the basics as much as I can along the way. So, let&#39;s jump right in!</p><p>Create a new flutter project and name it. Clean up the codes in the main.dartfile and delete the test file.</p><p>In the main.dartfile, we’ll have the following codes</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:google_fonts/google_fonts.dart&#39;;<br>import &#39;package:designapp/auth.dart&#39;;<br><br>void main() {<br>  runApp(DesignApp());<br>}<br><br>class DesignApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      title: &#39;Fashion Hub App&#39;,<br>      debugShowCheckedModeBanner: false,<br>      theme: ThemeData(<br>        textTheme: GoogleFonts.<em>mPlusRounded1cTextTheme</em>(),<br>        primarySwatch: Colors.<em>deepPurple</em>,<br>        visualDensity: VisualDensity.<em>adaptivePlatformDensity</em>,<br>        appBarTheme: AppBarTheme(backgroundColor: Colors.<em>white</em>),<br>      ),<br>      home: Auth(),<br>    );<br>  }<br>}</pre><p>DesignApp gets the app fired up which is our root widget that returns a MaterialApp . Let&#39;s go ahead and define the Auth widget, what we mentioned in the home property of the MaterialApp.</p><p>In the Auth.dart , this is the design we want to achieve</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*-BImeqm3UVmk3NPxMo4HAA.jpeg" /><figcaption>image depicting Auth page</figcaption></figure><p>Step 1: Create the purple background with the curve edge</p><pre>import &#39;package:flutter/cupertino.dart&#39;;<br>import &#39;package:flutter/gestures.dart&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br><br>class Auth extends StatefulWidget {<br>  @override<br>  _AuthState createState() =&gt; _AuthState();<br>}<br>class _AuthState extends State&lt;Auth&gt; {<br>  <br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      body: Container(<br>        color: Colors.<em>white,<br>           </em>child: CustomPaint(<br>              painter: BackgroundPaint(),),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>Here we have a scaffold if you are new to flutter; Scaffold manages the layout of components of a material design app. Now we need to define the Widget Authcontentthat’s the body property of our Scaffold.</p><p>Next, we wrapped the body property to a Container and set its background to white. Then we have the CustomPaint that takes the BackgroundPaint() as the painter .</p><p>BackgroundPaint() is a custom class we will be creating that contains our drawing.</p><p>Here is the class structure for drawing:</p><pre><strong>class </strong>BackgroundPaint <strong>extends </strong>CustomPainter {<br> @override<br> <strong>void </strong>paint(Canvas canvas, Size size) {<br> <strong>var </strong>paint = Paint();<br> // TODO: Set properties to paint</pre><pre> <strong>var </strong>path = Path();</pre><pre> // TODO: Draw your path</pre><pre> canvas.drawPath(path, paint);<br> }</pre><pre> @override<br> bool shouldRepaint(CustomPainter oldDelegate) {<br> <strong>return true</strong>;<br> }<br>}</pre><p>In this class, we have:</p><ol><li>The canvas that is our <strong>board.</strong></li><li>The size that is our <strong>board size.</strong></li><li>The paint that is our <strong>brush.</strong></li><li>The path that is our <strong>drawing.</strong></li></ol><p>To have a deep understanding of how the size variable works, do use the diagram below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/0*oLF1iwrZWIdDzDIg.png" /><figcaption>explanation of size variable</figcaption></figure><p>Let’s edit the above code.</p><pre>class BackgroundPaint extends CustomPainter {<br>  @override<br>  void paint(Canvas canvas, Size size) {<br>    // <em>TODO: implement paint<br>    </em>final height = size.height;<br>    final width = size.width;<br><br>    Paint paint = Paint()<br>      ..style = PaintingStyle.fill<br>      ..isAntiAlias = true<br>      ..color = Color(0xff8705bf);<br><br>    Path upperPath = Path();<br><br>    upperPath.moveTo(0, height * 0.55);<br>    upperPath.quadraticBezierTo(<br>        width * 0.70, height * 0.72, width, height * 0.5);<br><br>    upperPath.lineTo(width, 0);<br>    upperPath.lineTo(0, 0);<br><br>    canvas.drawPath(upperPath, paint);<br>  }<br><br>  @override<br>  bool shouldRepaint(covariant CustomPainter oldDelegate) =&gt; true;<br>}</pre><p>Here, we set our paint (<strong>brush</strong>) properties. Then, move from point 0 to 55% of the container’s height.</p><p>Next, draw a curved shape on the container; we’ll use the method<strong> </strong>quadraticBezierTo(double x1, double y1, double x2, double y2) . Then, move the path from the current point to the given point (x2,y2), using (x1,y1) as the control point.</p><p>Finally, we draw a line from the start point to the width of the container.</p><p>Step 2: Create the Form for Login page</p><pre>child: Column(<br>    mainAxisAlignment: MainAxisAlignment.center,<br>    crossAxisAlignment: CrossAxisAlignment.stretch,<br>    children: [<br>      Center(<br>        child: RichText(<br>          text: TextSpan(<br>            text: &#39;Welcome to   &#39;,<br>            style: TextStyle(<br>              color: Colors.<em>white</em>,<br>              fontSize: 18,<br>              fontWeight: FontWeight.<em>w200</em>,<br>            ),<br>            children: [<br>              TextSpan(<br>                text: &#39;\nFashion Hub&#39;,<br>                style: TextStyle(<br>                    color: Color(0xffbf63d8),<br>                    fontSize: 40,<br>                    fontWeight: FontWeight.<em>bold</em>,<br>                    height: 1),<br>              ),<br>            ],<br>          ),<br>        ),<br>      ),<br>      Padding(<br>        padding: const EdgeInsets.all(50.0),<br>        child: Container(<br>          decoration: BoxDecoration(<br>            borderRadius: BorderRadius.all(<br>              Radius.circular(25),<br>            ),<br>            color: Colors.<em>white70</em>,<br>            boxShadow: [<br>              BoxShadow(<br>                  offset: Offset.<em>zero</em>,<br>                  blurRadius: 2,<br>                  spreadRadius: 3,<br>                  color: Colors.<em>white10</em>),<br>            ],<br>          ),<br>          constraints: BoxConstraints(maxHeight: 300, maxWidth: 400),<br>          child: Padding(<br>            padding: const EdgeInsets.all(20.0),<br>            child: Center(<br>              child: Form(<br>                child: Column(<br>                  mainAxisAlignment: MainAxisAlignment.center,<br>                  children: [<br>                    TextFormField(<br>                      decoration: InputDecoration(<br>                        labelText: &#39;email&#39;,<br>                        labelStyle: TextStyle(<br>                            color: Colors.<em>white</em>,<br>                            fontSize: 16,<br>                            fontWeight: FontWeight.<em>w400</em>),<br>                        filled: true,<br>                        contentPadding: EdgeInsets.symmetric(<br>                            vertical: 0, horizontal: 16),<br>                        border: OutlineInputBorder(<br>                          borderRadius: BorderRadius.only(<br>                            topLeft: Radius.circular(25),<br>                            topRight: Radius.circular(25),<br>                          ),<br>                          borderSide: BorderSide(<br>                            width: 0,<br>                            style: BorderStyle.none,<br>                          ),<br>                        ),<br>                      ),<br>                    ),<br>                    TextFormField(<br>                      decoration: InputDecoration(<br>                        labelText: &#39;password&#39;,<br>                        labelStyle: TextStyle(<br>                            color: Colors.<em>white</em>,<br>                            fontSize: 16,<br>                            fontWeight: FontWeight.<em>w400</em>),<br>                        filled: true,<br>                        contentPadding: EdgeInsets.symmetric(<br>                            vertical: 0, horizontal: 16),<br>                        border: OutlineInputBorder(<br>                          borderRadius: BorderRadius.only(<br>                            bottomLeft: Radius.circular(25),<br>                            bottomRight: Radius.circular(25),<br>                          ),<br>                          borderSide: BorderSide(<br>                            width: 0,<br>                            style: BorderStyle.none,<br>                          ),<br>                        ),<br>                      ),<br>                      obscureText: true,<br>                    ),<br>                    SizedBox(<br>                      height: 20,<br>                    ),<br>                    GestureDetector(<br>                      onTap: () {},<br>                      child: Container(<br>                        height: 40,<br>                        decoration: BoxDecoration(<br>                          borderRadius: BorderRadius.all(<br>                            Radius.circular(25),<br>                          ),<br>                          color: Color(0xff8705bf),<br>                          boxShadow: [<br>                            BoxShadow(<br>                                offset: Offset(0, 3),<br>                                blurRadius: 3,<br>                                spreadRadius: 2,<br>                                color: Color(0xffbf63d8)),<br>                          ],<br>                        ),<br>                        child: Center(<br>                          child: Text(<br>                            &#39;login&#39;.toUpperCase(),<br>                            style: TextStyle(<br>                              fontWeight: FontWeight.<em>bold</em>,<br>                              fontSize: 24,<br>                              color: Colors.<em>white</em>,<br>                            ),<br>                          ),<br>                        ),<br>                      ),<br>                    ),<br>                    SizedBox(<br>                      height: 20,<br>                    ),<br>                    RichText(<br>                      text: TextSpan(<br>                        text: &#39;Don\&#39;t have an account?&#39;,<br>                        style: TextStyle(<br>                            color: Color(0xffbf63d8),<br>                            fontSize: 16,<br>                            fontWeight: FontWeight.<em>w100</em>),<br>                        children: &lt;TextSpan&gt;[<br>                          TextSpan(<br>                            text: &#39;Sign up&#39;,<br>                            style: TextStyle(<br>                                color: Color(0xff8705bf),<br>                                fontSize: 16,<br>                                fontWeight: FontWeight.<em>bold</em>),<br>                            recognizer: TapGestureRecognizer()<br>                              ..onTap = () {},<br>                          ),<br>                        ],<br>                      ),<br>                    ),<br>                  ],<br>                ),<br>              ),<br>            ),<br>          ),<br>        ),<br>      ),<br>    ]),</pre><p>Here, we create a Column that wraps the Form.</p><p>Within theonTap()function, add the following code to navigate to the SignUp() page</p><pre>Navigator.<em>of</em>(context)<br>    .pushReplacement(<br>  MaterialPageRoute(<br>    builder: (BuildContext<br>            context) =&gt;<br>        SignUp(),</pre><p>Step 3: Create the Signup page</p><pre>child: CustomPaint(<br>  painter: BackgroundPaint(),<br>  child: Column(<br>      mainAxisAlignment: MainAxisAlignment.center,<br>      crossAxisAlignment: CrossAxisAlignment.stretch,<br>      children: [<br>        Center(<br>          child: RichText(<br>            text: TextSpan(<br>              text: &#39;Welcome to   &#39;,<br>              style: TextStyle(<br>                color: Colors.<em>white</em>,<br>                fontSize: 18,<br>                fontWeight: FontWeight.<em>w200</em>,<br>              ),<br>              children: [<br>                TextSpan(<br>                  text: &#39;\nFashion Hub&#39;,<br>                  style: TextStyle(<br>                      color: Color(0xffbf63d8),<br>                      fontSize: 40,<br>                      fontWeight: FontWeight.<em>bold</em>,<br>                      height: 1),<br>                ),<br>              ],<br>            ),<br>          ),<br>        ),<br>        Padding(<br>          padding: const EdgeInsets.all(50.0),<br>          child: Container(<br>            decoration: BoxDecoration(<br>              borderRadius: BorderRadius.all(<br>                Radius.circular(25),<br>              ),<br>              color: Colors.<em>white70</em>,<br>              boxShadow: [<br>                BoxShadow(<br>                    offset: Offset.<em>zero</em>,<br>                    blurRadius: 2,<br>                    spreadRadius: 3,<br>                    color: Colors.<em>white10</em>),<br>              ],<br>            ),<br>            constraints: BoxConstraints(maxHeight: 300, maxWidth: 400),<br>            child: Padding(<br>              padding: const EdgeInsets.all(20.0),<br>              child: Center(<br>                child: Form(<br>                  child: Column(<br>                    mainAxisAlignment: MainAxisAlignment.center,<br>                    children: [<br>                      TextFormField(<br>                        decoration: InputDecoration(<br>                          labelText: &#39;email&#39;,<br>                          labelStyle: TextStyle(<br>                              color: Colors.<em>white</em>,<br>                              fontSize: 16,<br>                              fontWeight: FontWeight.<em>w400</em>),<br>                          filled: true,<br>                          contentPadding: EdgeInsets.symmetric(<br>                              vertical: 0, horizontal: 16),<br>                          border: OutlineInputBorder(<br>                            borderRadius: BorderRadius.only(<br>                              topLeft: Radius.circular(25),<br>                              topRight: Radius.circular(25),<br>                            ),<br>                            borderSide: BorderSide(<br>                              width: 0,<br>                              style: BorderStyle.none,<br>                            ),<br>                          ),<br>                        ),<br>                      ),<br>                      TextFormField(<br>                        decoration: InputDecoration(<br>                          labelText: &#39;password&#39;,<br>                          labelStyle: TextStyle(<br>                              color: Colors.<em>white</em>,<br>                              fontSize: 16,<br>                              fontWeight: FontWeight.<em>w400</em>),<br>                          filled: true,<br>                          contentPadding: EdgeInsets.symmetric(<br>                              vertical: 0, horizontal: 16),<br>                          border: OutlineInputBorder(<br>                            borderRadius: BorderRadius.only(<br>                              bottomLeft: Radius.circular(25),<br>                              bottomRight: Radius.circular(25),<br>                            ),<br>                            borderSide: BorderSide(<br>                              width: 0,<br>                              style: BorderStyle.none,<br>                            ),<br>                          ),<br>                        ),<br>                        obscureText: true,<br>                      ),<br>                      SizedBox(<br>                        height: 20,<br>                      ),<br>                      GestureDetector(<br>                        onTap: () {},<br>                        child: Container(<br>                          height: 40,<br>                          decoration: BoxDecoration(<br>                            borderRadius: BorderRadius.all(<br>                              Radius.circular(25),<br>                            ),<br>                            color: Color(0xff8705bf),<br>                            boxShadow: [<br>                              BoxShadow(<br>                                  offset: Offset(0, 3),<br>                                  blurRadius: 3,<br>                                  spreadRadius: 2,<br>                                  color: Color(0xffbf63d8)),<br>                            ],<br>                          ),<br>                          child: Center(<br>                            child: Text(<br>                              &#39;Sign Up&#39;,<br>                              style: TextStyle(<br>                                fontWeight: FontWeight.<em>bold</em>,<br>                                fontSize: 24,<br>                                color: Colors.<em>white</em>,<br>                              ),<br>                            ),<br>                          ),<br>                        ),<br>                      ),<br>                      SizedBox(<br>                        height: 20,<br>                      ),<br>                    ],<br>                  ),<br>                ),<br>              ),<br>            ),<br>          ),<br>        ),<br>      ]),<br>),</pre><p>So far we have created the Login/Signup page.</p><p>Step 4: Createhomepage.dartfile.</p><p>Here is the design we want to create.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*C2QNG5ZIFjQjHSUUvl7tvg.jpeg" /><figcaption>image depicting the Home page</figcaption></figure><blockquote>Let’s start right on!</blockquote><pre>import &#39;package:designapp/utils/recom_pics.dart&#39;;<br>import &#39;package:flutter/cupertino.dart&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br><br>class HomePage extends StatefulWidget {<br>  <br>  @override<br>  _HomePageState createState() =&gt; _HomePageState();<br>}<br>class _HomePageState extends State&lt;HomePage&gt;<br>    with SingleTickerProviderStateMixin {<br>  int selectedIndex = 0;<br>  var menuList = [&#39;Settings&#39;, &#39;Sign out&#39;];<br>  <br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      backgroundColor: Colors.<em>white</em>,<br>      appBar: AppBar(<br>        leading: PopupMenuButton(<br>          elevation: 40,<br>          shape: RoundedRectangleBorder(<br>            borderRadius: BorderRadius.all(<br>              Radius.circular(25),<br>            ),<br>          ),<br>          icon: Icon(<br>            Icons.<em>menu_rounded</em>,<br>            color: Colors.<em>black45</em>,<br>          ),<br>          enabled: true,<br>          onSelected: (value) async {<br>          },<br>          itemBuilder: (context) =&gt; [<br>            PopupMenuItem(<br>              child: Text(<br>                &#39;Settings&#39;,<br>                style: TextStyle(<br>                    color: Color(0xff8705bf),<br>                    fontSize: 16,<br>                    fontWeight: FontWeight.<em>w200</em>),<br>              ),<br>              value: 1,<br>            ),<br>            PopupMenuItem(<br>              child: Text(<br>                &#39;Sign out&#39;,<br>                style: TextStyle(<br>                    color: Color(0xff8705bf),<br>                    fontSize: 16,<br>                    fontWeight: FontWeight.<em>w200</em>),<br>              ),<br>              value: 2,<br>            ),<br>          ],<br>        ),<br>        elevation: 0,<br>        actions: [<br>          IconButton(<br>            onPressed: () {},<br>            icon: Icon(<br>              Icons.<em>search_rounded</em>,<br>              color: Colors.<em>black45</em>,<br>            ),<br>          )<br>        ],<br>      ),</pre><p>Here, we define a menu list for the popupMenuButton. Then, we create an AppBar that contains the popupMenuButtonwith actionsproperty.</p><p>Next, create the body properties and add this list in your app state.</p><pre>List&lt;String&gt; categoryList = [&#39;Recommendation&#39;, &#39;New Models&#39;, &#39;2021 Show&#39;];</pre><p>Then:</p><pre>body: SafeArea(<br>  child: SingleChildScrollView(<br>    child: Padding(<br>      padding: const EdgeInsets.all(15.0),<br>      child: Column(<br>        mainAxisAlignment: MainAxisAlignment.center,<br>        crossAxisAlignment: CrossAxisAlignment.stretch,<br>        children: [<br>          Text(<br>            &#39;Fashion Week&#39;,<br>            style: TextStyle(<br>              color: Color(0xff8705bf),<br>              fontWeight: FontWeight.<em>bold</em>,<br>              fontSize: 40,<br>            ),<br>          ),<br>          Text(<br>            &#39;2021 Fashion show in paris&#39;,<br>            style: TextStyle(<br>              color: Colors.<em>black87</em>,<br>              fontWeight: FontWeight.<em>w100</em>,<br>              fontSize: 16,<br>            ),<br>          ),<br>          SizedBox(<br>            height: 20,<br>          ),<br>          Container(<br>            child: Padding(<br>              padding: const EdgeInsets.only(top: 10),<br>              child: Row(<br>                children: [<br>                  Text(<br>                    &#39;Explore&#39;,<br>                    style: TextStyle(<br>                      color: Colors.<em>black87</em>,<br>                      fontWeight: FontWeight.<em>bold</em>,<br>                      fontSize: 20,<br>                      height: 1,<br>                    ),<br>                  ),<br>                  SizedBox(<br>                    width: 270,<br>                  ),<br>                  Icon(<br>                    Icons.<em>swap_horiz_rounded</em>,<br>                    color: Colors.<em>black45</em>,<br>                  ),<br>                ],<br>              ),<br>            ),<br>          ),<br>          SizedBox(<br>            height: 20,<br>          ),<br>          Row(<br>            mainAxisAlignment: MainAxisAlignment.spaceBetween,<br>            children: List.generate(<br>              categoryList.length,<br>              (index) =&gt; GestureDetector(<br>                onTap: () =&gt; setState(() {<br>                  selectedIndex = index;<br>                }),<br>                child: Text(<br>                  categoryList[index],<br>                  style: TextStyle(<br>                    fontSize: 16,<br>                    fontWeight: selectedIndex == index<br>                        ? FontWeight.<em>w400<br>                        </em>: FontWeight.<em>w200</em>,<br>                    color: selectedIndex == index<br>                        ? Color(0xff8705bf)<br>                        : Colors.<em>black87</em>,<br>                  ),<br>                ),<br>              ),<br>            ),<br>          ),<br>          SizedBox(<br>            height: 10,<br>          ),<br>          Container(<br>            height: 300,<br>            child: ListView.builder(<br>              scrollDirection: Axis.horizontal,<br>              itemCount: mainColumn.length,<br>              itemBuilder: (BuildContext context, int index) {<br>                return Container(<br>                  height: 250,<br>                  decoration: BoxDecoration(<br>                    borderRadius: BorderRadius.all(<br>                      Radius.circular(25),<br>                    ),<br>                  ),<br>                  constraints: BoxConstraints(<br>                    maxWidth: 200,<br>                  ),<br>                  child: Column(<br>                    children: [<br>                      Expanded(<br>                        child: Padding(<br>                          padding: const EdgeInsets.all(10.0),<br>                          child: ClipRRect(<br>                            borderRadius: BorderRadius.circular(25),<br>                            child: Image.asset(<br>                              &#39;images/&#39; + mainColumn[index].pic,<br>                              fit: BoxFit.contain,<br>                            ),<br>                          ),<br>                        ),<br>                      ),<br>                      SizedBox(<br>                        height: 5,<br>                      ),<br>                      Text(<br>                        mainColumn[index].name,<br>                        style: TextStyle(<br>                          color: Colors.<em>black87</em>,<br>                          fontSize: 16,<br>                          fontWeight: FontWeight.<em>normal</em>,<br>                        ),<br>                      ),<br>                      Text(<br>                        mainColumn[index].place,<br>                        style: TextStyle(<br>                          color: Colors.<em>black87</em>,<br>                          fontSize: 16,<br>                          fontWeight: FontWeight.<em>w100</em>,<br>                        ),<br>                      ),<br>                    ],<br>                  ),<br>                );<br>              },<br>            ),<br>          ),<br>          SizedBox(<br>            height: 10,<br>          ),<br>          Container(<br>            height: 200,<br>            decoration: BoxDecoration(<br>              borderRadius: BorderRadius.all(<br>                Radius.circular(25),<br>              ),<br>            ),<br>            constraints: BoxConstraints(<br>              maxWidth: 100,<br>            ),<br>            child: Padding(<br>              padding: const EdgeInsets.all(10.0),<br>              child: ClipRRect(<br>                borderRadius: BorderRadius.circular(25),<br>                child: Image.asset(<br>                  &#39;images/model2.jpg&#39;,<br>                  fit: BoxFit.fill,<br>                ),<br>              ),<br>            ),<br>          ),<br>        ],<br>      ),<br>    ),<br>  ),<br>),</pre><p>Here is the breakdown of the above code</p><p>List.generate gets the item of the categoryList[]and wrapped with a GestureDetector(). Within the onTap()function, we have setState() with a selectedIndex variable to get the index tapped.</p><p>Next, ListView.builder helps construct a list where children’s (Widgets) are built on demand. However, instead of returning a static widget, it calls a function that can be called multiple times (based on itemCount ) and it’s possible to return different widgets at each call.</p><p>ThescrollDirection: Axis.horizontalallows us to scroll through the list horizontally.</p><p>Lastly, the ClipRRect widget is used to clip its child creating rounded corners rectangle widgets, or circular widgets.</p><p><em>In the next article, we will create the authentication features using firebase.</em></p><p>The Source code will be shared in the next article.</p><p>Thanks for reading ❤</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/0*jGRllsTCENbQqmo7" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec26dec8e4cb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/my-welcome-back-to-flutter-app-work-1-ec26dec8e4cb">My Welcome back to Flutter App work#1</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Interface the Picamera module with Raspberry Pi using python]]></title>
            <link>https://medium.com/geekculture/how-to-interface-the-picamera-module-with-raspberry-pi-using-python-1570e499cc?source=rss-3fe9ca633e2a------2</link>
            <guid isPermaLink="false">https://medium.com/p/1570e499cc</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[raspberry-pi-camera]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[raspberry-pi-3]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Maria Elijah]]></dc:creator>
            <pubDate>Sat, 17 Jul 2021 06:08:47 GMT</pubDate>
            <atom:updated>2021-07-18T03:13:58.476Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Hey guys! Here is another series on Raspberry pi. In the article, we will learn how to install the camera module, take a picture, and send the picture as a mail. Less I forget, you can find other interesting articles on Raspberry Pi <a href="https://medium.com/geekculture/detecting-motions-using-pir-motion-sensor-with-raspberry-pi-98f88f9d5ffe">here</a>.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BY4NN4I0O6DgfoSP.jpg" /><figcaption>image from <a href="https://projects.raspberrypi.org/en/projects/getting-started-with-picamera">projects.raspberrypi.org</a></figcaption></figure><p>Before we head on to the practical part, let’s brush on this powerful component of the Raspberry Pi — Pi Camera module.</p><p>The Pi Camera module takes pictures and high-definition videos. It has two versions which are the <strong>standard</strong> and <strong>NoIR versions</strong>.</p><ul><li><a href="https://www.raspberrypi.org/products/camera-module-v2/"><strong>The standard version</strong></a> takes pictures in normal light.</li><li><a href="https://www.raspberrypi.org/products/pi-noir-camera-v2/"><strong>The NoIR version</strong></a> doesn’t have an infrared filter. It’s used together with an infrared light source to take pictures in the dark.</li></ul><p>The Raspberry Pi Board has CSI (Camera Serial Interface) interface used to attach the PiCamera module.</p><p>This Pi Camera module can attach to the Raspberry Pi’s CSI port using a 15-pin ribbon cable.</p><p>For further reading on the Pi Camera Module, do check the <a href="https://projects.raspberrypi.org/en/projects/getting-started-with-picamera">docs</a>.</p><p>Let’s head over to set up the components.</p><h4>Hardware needed:</h4><ol><li>Pi Camera module</li><li>Raspberry Pi 3 Model B+</li><li>a 5V 2A micro USB power adapter.</li></ol><h4><strong>Software needed:</strong></h4><ol><li>PuTTy</li><li>Raspbian OS</li></ol><p>Note: <strong>Make sure the Raspberry Pi is turned off.</strong></p><p><strong>Step 1:</strong> Installing the Camera module</p><ul><li>On the Raspberry Pi, locate the Camera module port between the audio port and the HDMI port. If you’re using Raspberry Pi B, it is between the Ethernet port and the HDMI port.</li><li>Insert the Camera module ribbon cable by gently pulling up the edges of the camera module port’s plastic chip. When inserting the cable, make sure the blue side is faced to the Ethernet port, and the silver side is facing the HDMI port.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*YMpHubQQPYVAQnjV.jpg" /><figcaption>image from electronicwings.com</figcaption></figure><ul><li>Then, push down the plastic chip into place.</li><li>Power on the Raspberry Pi.</li></ul><p><strong>Step 2:</strong> Connecting the Camera module.</p><ul><li>SSH to the Raspberry PI using its <strong>IP</strong> address and port<strong> 22</strong></li><li>Enter the <strong>Username</strong> and <strong>password</strong></li><li>Upgrade and Update the Pi. It’s a good practice to always update and upgrade the pi each time we use it. Enter sudo apt-get updateand sudo apt-get upgrade.</li><li>On the terminal, run sudo raspi-config.</li><li>Click on the Interface option.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*mD-17F5Y2EefRVi5CLpx2A.png" /><figcaption>image depicting raspberry pi software configuration</figcaption></figure><ul><li>Click on camera, then enable the camera interface.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*t2aJa0fJ6TLXet9Mg33DlQ.png" /><figcaption>image depicting Picamera configuration</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*WTbubq2zTPqZ7ZNxOrxyJQ.png" /><figcaption>Picamera configuring</figcaption></figure><ul><li>Reboot the Raspberry Pi</li></ul><blockquote>Let’s take a still picture to be sure it working properly.</blockquote><p>On the command-line (SSH), run raspistill -o Desktop/pic.jpg</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*9dgFxtbEkMRXXDoqNCCY-g.png" /></figure><p>The command raspistill is for taking still pictures. Since we are running the code from the terminal, we can’t view the image captured. But we can use some software like VNC to view Raspberry’s desktop or send the file via command-line to your PC.</p><p>Here, we’ll use VNC to view the picture taken.</p><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_SRZ_AkwuiClC8WUQ9ztOw.png" /><figcaption>using VNC to display raspberry’s desktop</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0gsA0DnWfCTHCCJyVa4ZZA.png" /><figcaption>image captured using Picamera module</figcaption></figure><p>First, install the Picamera library on the Raspbian OS. Else, we’ll get an Import error: ‘no module named PiCamera’.</p><pre>sudo apt-get install python-picamera python3-picamera</pre><p>Now, let’s write a python code that captures an image and sends a mail attaching the picture.</p><p><strong>Step 3:</strong> Python code</p><ul><li>Create a python file send_image.py</li><li>Run sudo nano send_image.py</li><li>Enter the following codes</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/49ad7111ee5c202e8306603d9e62838a/href">https://medium.com/media/49ad7111ee5c202e8306603d9e62838a/href</a></iframe><p>Code Explanation:</p><p>First, we import the Python picamera library, which allows us to control the Camera Module. The sleep library is used to add delays before the camera captures the image. Then, import smtp(Simple Mail Transfer Protocol) is an SMTP client session object used to send e-mail between mail servers.</p><p>Next, the camera preview opens for five seconds, and then a still picture is captured.</p><p>Up next, we attach the file with the necessary details.</p><p>Finally, we send the mail usingsession.sendmail(sender_address,receiver_address, text)</p><ul><li>Now, run python3 send_image.py</li></ul><p><strong>let’s check out the result-</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F26n7937SwZkal2Oju%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fpray-praying-prayer-26n7937SwZkal2Oju&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2F26n7937SwZkal2Oju%2Fgiphy.gif%3Fcid%3D790b7611f7f3da0aa1d6ee7a1b3791405e47a3d8fc01df84%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="245" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b9e2cd007b1467a91484073c6df09ab/href">https://medium.com/media/5b9e2cd007b1467a91484073c6df09ab/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*HJasQHs0FuzUXm5JArVivg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*OpmFhIKWrKrmBZFzRBqHhA.jpeg" /><figcaption>image depicting mail sent from the raspberry pi</figcaption></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FqqQHsZ7WtSNjlmsUqO%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fabcnetwork-qqQHsZ7WtSNjlmsUqO&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2FqqQHsZ7WtSNjlmsUqO%2Fgiphy-downsized-large.gif%3Fcid%3D790b7611c0190abb7f28d906cc8d5c823a11615778a6dc63%26rid%3Dgiphy-downsized-large.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d58abc135c60b45543a1a3667ea5fb1/href">https://medium.com/media/0d58abc135c60b45543a1a3667ea5fb1/href</a></iframe><p>Note: you must never save the file as picamera.py.</p><p>Check the codes <a href="https://github.com/funmi-cod/Picamera">here</a>.</p><p>Still, want more projects on Raspberry pi? Watch out for my next article. Or better still, follow 😊so you can get a notification for my articles.</p><p>❤ ❤ Thanks for reading this article. ❤❤</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FQ6yaVGg7fY8ql6FxeP%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fthank-you-thanks-thankyou-Q6yaVGg7fY8ql6FxeP&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2FQ6yaVGg7fY8ql6FxeP%2Fgiphy.gif%3Fcid%3D790b761183561c589c59e440dfef44fff7659ea79879f22a%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/de1e91e5d0a8f1fd3a68393b8b3fd5d2/href">https://medium.com/media/de1e91e5d0a8f1fd3a68393b8b3fd5d2/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1570e499cc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/how-to-interface-the-picamera-module-with-raspberry-pi-using-python-1570e499cc">How to Interface the Picamera module with Raspberry Pi using python</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Detecting motions using PIR motion sensor with Raspberry PI]]></title>
            <link>https://medium.com/geekculture/detecting-motions-using-pir-motion-sensor-with-raspberry-pi-98f88f9d5ffe?source=rss-3fe9ca633e2a------2</link>
            <guid isPermaLink="false">https://medium.com/p/98f88f9d5ffe</guid>
            <category><![CDATA[gmail]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pir-motion-sensor]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[pir-motion-sensor-module]]></category>
            <dc:creator><![CDATA[Maria Elijah]]></dc:creator>
            <pubDate>Mon, 05 Jul 2021 00:02:20 GMT</pubDate>
            <atom:updated>2021-08-22T06:14:38.857Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Wow! welcome back to my fourth series on Raspberry Pi. If you haven’t read the previous ones, feel free to <a href="https://medium.com/geekculture/how-to-connect-to-the-raspberry-pi-using-mobile-hotspot-2362a6b02efc">check</a>. I kinda linked each article at the end of every write-up.</blockquote><p>This article will build a simple motion detection using PIR (Passive InfraRed) sensor with Raspberry Pi. PIR sensor is used to sense the movement of people, animals, or other objects. Basically, any object that emits infrared heat. Objects with a temperature above absolute zero emit heat energy in the form of radiation. Usually, this radiation isn’t visible to the human eye because it radiates at infrared wavelengths, but it can be detected by electronic devices such as PIR sensors designed for such a purpose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/0*-pOiAY7iXvSML7qM.jpg" /><figcaption><a href="https://image.made-in-china.com/202f0j00gqBRrtwGYIkK/High-Quality-Hc-Sr501-Adjust-Infrared-PIR-Motion-Sensor-Detector-Module-for-Raspberry-Pi-or-Arduino.jpg">image from image.made-in-china.com</a></figcaption></figure><h4>Practical Explanation:</h4><p>When a motion is detected, one of the LEDs turns on, and the other if no motion is detected. Also, a mail is sent if a motion is detected.</p><h4>Hardware needed:</h4><ol><li>LEDs</li><li>220 Ohms Resistors</li><li>Jumper wires</li><li>PIR motion sensor</li><li>Breadboard</li><li>Raspberry Pi 3 Model B+</li><li>a 5V 2A micro USB power adapter.</li></ol><p>Here is a brief explanation of the PIR motion sensor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/0*YSNQb5fPrNaU-OOI.jpg" /><figcaption>Image from ifuturetech.org</figcaption></figure><p><strong>PIR motion sensor:</strong> PIR stands for Passive Infrared, which consists of an infrared detector, fresnel lens, and supporting detection circuitry. the lens can detect anything that emits infrared heat such as humans, animals. The heat is picked up by the motion sensor.</p><p>A PIR motion sensor has two potentiometers that are used for setting the <strong>delay time</strong> and <strong>sensitivity</strong>.</p><ul><li>The delay time adjustment is used to set how long the output should remain high after detecting motion; it can range from 5 seconds to 5 minutes</li><li>The sensitivity adjustment is used to set the detection range, which can be anywhere from 3 to 7 meters.</li></ul><p>A PIR motion sensor has three pins for connection which are for power(VCC), signal(Output), and ground(GND).</p><p>PIR motion sensors are small, inexpensive, low-power, easy to use, and don’t wear out. For that reason, they are commonly found in appliances and gadgets used in homes or businesses.</p><p><strong>Software needed:</strong></p><ol><li>PuTTy</li><li>Raspbian OS</li></ol><p>let’s head on to the practical part.</p><p><strong>Step 1: </strong>Setting up the circuit</p><p>So I assume that you have successfully done some basic projects. if not, feel free to check my previous article<strong> </strong><a href="https://medium.com/geekculture/how-to-blink-led-using-raspberry-pi-8351b06348d7"><strong>here</strong></a></p><p><strong>Connecting LEDs and Resistors</strong></p><ul><li>Connect the LEDs (red and yellow respectively) to the breadboard.</li><li>Choose the negative one and using the resistor, connect it up to GND (<strong>pin 39</strong>)</li><li>Connect the other end to GPIO (pin 20 and 19) respectively</li></ul><p><strong>Connecting PIR motion sensor</strong></p><ul><li>Connect VCC pin to the 5v of Raspberry’s GPIO</li><li>Connect GND pin to the GND of Raspberry’s GPIO.</li><li>Connect Output pin to GPIO pin 4.</li></ul><p>we should have a connection like this. if not, please feel free to use the picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SDqbf_F0RpPujCcVNA6wfQ.jpeg" /></figure><p><strong>Step 2</strong>: python code</p><ul><li>SSH to the Raspberry PI using its <strong>IP</strong> address and port<strong> 22</strong></li><li>Enter the <strong>Username</strong> and <strong>password</strong></li><li>Upgrade and Update the Pi. It’s a good practice to always update and upgrade the pi each time we use it. Enter <strong>sudo apt-get update</strong> and <strong>sudo apt-get upgrade</strong></li><li>Create a new python file <strong>sudo nano detect_motion.py</strong></li><li>Enter the following codes</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/79b5e54ec81c551dd57479782fc81a16/href">https://medium.com/media/79b5e54ec81c551dd57479782fc81a16/href</a></iframe><ul><li>Run the python file in the terminal using ‘<strong>python3 detect_motion.py</strong>’</li></ul><p><strong>Result:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*80D22X19dAaDGocOl7P05Q.png" /></figure><p>One more step to go!</p><p>let’s add the following python codes to send a mail when a motion is detected</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/347e452b6c5be9452e18222f54afa9c2/href">https://medium.com/media/347e452b6c5be9452e18222f54afa9c2/href</a></iframe><p>Now, our codes should look like this</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e02f504731c4e48a15a2f4414e11af84/href">https://medium.com/media/e02f504731c4e48a15a2f4414e11af84/href</a></iframe><ul><li>Finally, run the python file in the terminal using <strong>python3 detect_motion.py</strong></li></ul><p><strong>let’s check out the result-</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F26n7937SwZkal2Oju%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fpray-praying-prayer-26n7937SwZkal2Oju&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2F26n7937SwZkal2Oju%2Fgiphy.gif%3Fcid%3D790b7611f7f3da0aa1d6ee7a1b3791405e47a3d8fc01df84%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="245" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b9e2cd007b1467a91484073c6df09ab/href">https://medium.com/media/5b9e2cd007b1467a91484073c6df09ab/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*6ASSVA-DqxZWl4fLwGJzEQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*J8_mowVeUgzBiwgbmQg3qA.jpeg" /></figure><p>Note: Make sure the PIR motion sensor is connected properly.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FSfYTJuxdAbsVW%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FSfYTJuxdAbsVW&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2FSfYTJuxdAbsVW%2F200.gif%3Fcid%3D790b76115c54d6015604d9e69f541be0634737861363e080%26rid%3D200.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="346" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd49a76af990be7a5c81883ec5514c97/href">https://medium.com/media/dd49a76af990be7a5c81883ec5514c97/href</a></iframe><p>Check the full codes <a href="https://github.com/funmi-cod/motionSensor"><strong>here</strong></a>.</p><p>There is another interesting module of the Raspberry Pi that I will be sharing in my next article —<strong> </strong><a href="https://medium.com/geekculture/how-to-interface-the-picamera-module-with-raspberry-pi-using-python-1570e499cc"><strong>Pi Camera</strong></a>🙂!</p><p>Thank you for staying till the end.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98f88f9d5ffe" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/detecting-motions-using-pir-motion-sensor-with-raspberry-pi-98f88f9d5ffe">Detecting motions using PIR motion sensor with Raspberry PI</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to connect to the Raspberry Pi using Mobile Hotspot]]></title>
            <link>https://medium.com/geekculture/how-to-connect-to-the-raspberry-pi-using-mobile-hotspot-2362a6b02efc?source=rss-3fe9ca633e2a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2362a6b02efc</guid>
            <category><![CDATA[mobile-hotspot]]></category>
            <category><![CDATA[raspberry-pi-3]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <dc:creator><![CDATA[Maria Elijah]]></dc:creator>
            <pubDate>Wed, 23 Jun 2021 01:02:12 GMT</pubDate>
            <atom:updated>2021-11-01T13:29:19.078Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/552/0*s73c1ZSwGap2u8UG.png" /></figure><blockquote>Welcome back to another article. In my previous <a href="https://medium.com/geekculture/how-to-blink-led-using-raspberry-pi-8351b06348d7">article</a>, I said setting up a Router each time to connect to the Raspberry Pi isn’t cool. So I decided to put up a new article that will be much easier to execute and more convenient on the go. In this method, you only need your PC to cast Pi screen and a power bank to power on the Pi each time you need it. No need for internet and router. But this method will only work with newer version of Raspberry Pi because they have the Wi-Fi chip build in and we will be using the WI-Fi only. however, you can use older versions of Pi with the help of a WiFi dongle.</blockquote><p>Let’s start on with setting up the mobile hotspot.</p><h4>Step 1</h4><ul><li>Open your mobile settings. Turn on Mobile Hotspot. No need to activate mobile data or wifi</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*cjhxx3H-gwfeBWnOFDhtWQ.jpeg" /></figure><ul><li>Note the name and password of your Hotspot</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*xXxEAP0vUdExwj67_LsmIA.jpeg" /></figure><ul><li>keep the Hotspot on.</li></ul><h4>Step2:</h4><ul><li>Login to your Raspberry Pi. This was the IP address we got when we used the Router in the previous article.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/0*eZ5Hhas8FL819kjw.png" /></figure><ul><li>Enter the Username and Password which are ‘<strong>pi</strong> and <strong>raspberry’ </strong>respectively by default.</li><li>Run the command “sudo apt update” and “sudo apt upgrade”. It’s a good practice to upgrade and update the Raspbian OS after booting.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/0*0-S9jf0U3KT57DQv.png" /></figure><h4>Step 3:</h4><p>Set up the Wi-Fi Settings in Raspberry Pi.</p><ul><li>Run this command “ iwlist wlan0 scan “ and press enter. It will list down the available wifi networks around with their <strong>SSID</strong> and other details.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*OtKWxb5tMcnVrRNc0O2vug.png" /></figure><p>You should find your hotspot name. if it’s not listed, reboot the Raspberry Pi and run the code again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*giUd-UKgQp5XX_lR4MwWbw.png" /></figure><p>We can see the name of my Hotspot “FYDE”</p><p>Now, let’s type in the <strong>SSID</strong> and <strong>PSK </strong>which are the hotspot name and password respectively.</p><ul><li>Run “sudo raspi-config”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*OVfpN-PK2tvl4AYqILgaXQ.png" /></figure><ul><li>Navigate to s<strong>ystem options</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*0CMNU1zAj5PErEMkyxSLuQ.png" /></figure><ul><li>Then click on <strong>wireless LAN</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*lKTE2NWELp1Wl0Ut7OQEcQ.png" /></figure><ul><li>Enter the <strong>SSID</strong> and <strong>PSK</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*y3R1KPga6kBGHwjBa4o7rg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*g3_zsUEcbionAE9zhJrjlQ.png" /></figure><p>Next, shutdown the Raspberry Pi</p><p><strong>Step4:</strong></p><p>Now, let’s find the IP address provided by the Mobile hotspot</p><ul><li>Turn on the Raspberry Pi and make sure that the mobile hot spot is turn on.</li><li>Check the connect devices. There will be a new user with the name “<strong>raspberrypi”</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*bRgMs3N1uWjyxSMj9H0bmg.jpeg" /></figure><ul><li>Click on “<strong>raspberryPi</strong>” to get the IP address but this will be different from the previous one.</li></ul><p>Note: Most of the mobile will directly show the IP address. If the IP address doesn’t show up, then login to Putty from PC, type “ifconfig”</p><p><strong>Step5:</strong></p><p>Finally, let’s connect with this new IP address to be sure it’s all set properly.</p><ul><li>Reboot the Raspberry Pi. SSH into the Pi using the new IP address</li><li>Enter the Username and Password which are <strong>pi</strong> and <strong>raspberry </strong>respectively.</li></ul><p>Done!</p><p>Easy, right?</p><p>You see that we didn’t enable mobile data. So when next we want to work on the Raspberry Pi we need just the Pi, a power bank, PC and obviously your mobile.</p><p>Note: Make sure your Mobile Hotspot is turned on before you power on the Raspberry Pi.</p><p>If you’re curious about trying out the new IP address, well so am I😊. Check my next article where we’ll use a <a href="https://medium.com/geekculture/detecting-motions-using-pir-motion-sensor-with-raspberry-pi-98f88f9d5ffe">PIR Motion Sensor to detect motion</a>. See you there!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2362a6b02efc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/how-to-connect-to-the-raspberry-pi-using-mobile-hotspot-2362a6b02efc">How to connect to the Raspberry Pi using Mobile Hotspot</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Blink Led using Raspberry Pi]]></title>
            <link>https://medium.com/geekculture/how-to-blink-led-using-raspberry-pi-8351b06348d7?source=rss-3fe9ca633e2a------2</link>
            <guid isPermaLink="false">https://medium.com/p/8351b06348d7</guid>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[raspberry-pi-3]]></category>
            <category><![CDATA[led]]></category>
            <category><![CDATA[python3]]></category>
            <dc:creator><![CDATA[Maria Elijah]]></dc:creator>
            <pubDate>Fri, 04 Jun 2021 12:37:06 GMT</pubDate>
            <atom:updated>2021-07-03T02:46:15.750Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>This article will guide through on how to blink LED(Light-emitting diodes) using Raspberry Pi and how to use the GPIO(General-purpose input/output) pins on it. At this point, If you haven’t installed the Raspbian OS, read my previous article on the installation of Raspbian OS <a href="https://elijahmaria04.medium.com/getting-started-with-raspberry-pi-and-installing-raspberry-pi-os-f20cbee4c008">here</a>.</blockquote><p>Before we dive into the practical aspect, let’s brush up on one special component of the Raspberry Pi — GPIO</p><ul><li>GPIO known as General-purpose input/output pins is a powerful feature of the Raspberry Pi. These pins can be used to provide signals to components and also read signals from a component. for instance, Pin 1,2 supplies power(3.3V and 5v respectively). The function of the GPIO pin is customizable and can be controlled using several programming languages and tools. For further reading on GPIO pins, check <a href="https://www.raspberrypi.org/documentation/usage/gpio/">here</a>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SYGn1CwfdaGEOLrn.png" /><figcaption>GPIO Pins</figcaption></figure><p>GPIO pins can be damaged easily so be careful when using and use 3.3 V logic.</p><blockquote>Let’s start right on!</blockquote><p><strong>Hardware needed:</strong></p><ol><li>LED</li><li>220 Ohms Resistor</li><li>Jumper wires</li><li>Breadboard</li><li>Raspberry Pi 3 Model B+</li><li>Ethernet cable</li><li>Router</li><li>a 5V 2A micro USB power adapter.</li></ol><p><strong>Software needed:</strong></p><ol><li>PuTTy</li></ol><p><strong>First, enable ssh connection</strong></p><p>i. Slot the MicroSD card into Card Reader and connect to the PC.</p><p>ii. Add the “ssh” file to the MicroSD card Root. Create ssh file name (without any extension) onto the boot partition of the MicroSD card</p><p>iii. safely remove the MicroSD Card. Now SSH is enabled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*kHRE8GuxkyZfAvBEnk7o5w.png" /></figure><p>iv. slot in the MicroSD Card to the appropriate slot on the Raspberry Pi.</p><p><strong>Up next, Download and install </strong><a href="https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html"><strong>Putty</strong></a><strong> on the PC</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*3JCtr-cRhE1t5L3-WR1urQ.png" /><figcaption>PuTTy</figcaption></figure><p>PuTTY is an SSH and Telnet client, free and open-source software for the Windows platform. It is used to remotely access another computer.</p><p><strong>Getting the Raspberry Pi’s IP address</strong></p><p>We need the IP address to connect to the Raspberry Pi.</p><ul><li>Connect one end of the ethernet cable to the Raspberry Pi and the other end to the Router.</li><li>Connect the PC to the Router</li><li>Go to the Router’s DHCP table, copy the IP address of the Raspberry Pi</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*omWNkry7urdAkjJbflLnwA.png" /></figure><p><strong>Setting up Components</strong></p><p>Connect the LEDs, resistors, Jumper wires using Breadboard and the GPIO pins on the Raspberry Pi.</p><p>At this point, the Raspberry Pi should be off as it is safer when connecting components.</p><p>Step 1: Connect the LEDs (red and yellow respectively) to the breadboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*RXrB2l6b-X2Id9pdtQg5wA.png" /><figcaption>LED image from <a href="https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Fwww.energysavinglighting.org%2Fthe-history-of-led-lighting%2F&amp;psig=AOvVaw3SbKMyj32zNzjnePs4mBxU&amp;ust=1622806124865000&amp;source=images&amp;cd=vfe&amp;ved=0CAMQjB1qFwoTCKDrjdet-_ACFQAAAAAdAAAAABAS">energy-saving lighting</a></figcaption></figure><blockquote>The first thing I noticed about LED was the edges. It has a curved edge and a flat edge. the curved side of the LED is positive while the flat side is negative. Bet we’ve got a sharper eye than I did back then 😀and notice that a LED has a long and short leg which are positive and negative respectively.</blockquote><p>Step 2: Choose the negative one and using the resistor, connect it up to GND (<strong>pin 39</strong>).</p><p>Step 3: Connect the other end to GPIO (pin 20 and 19) respectively. Feel free to use the picture as a reference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*_qvC1yVHC51t9aJbQkjPxw.jpeg" /><figcaption>An image depicting the connection</figcaption></figure><p>We can use different GPIO pins for our connection but make sure to follow all the rules.</p><p><strong>Up next, power on the Raspberry Pi.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LwFce6Pg_3WzoSSAgHu8yw.jpeg" /></figure><p>Note: if the LED comes on automatically, it means that there is something wrong with the connection.</p><p><strong>Setting up the Raspberry Pi</strong></p><ul><li>Launch PuTTy, paste the Raspberry Pi’s IP address that we copied earlier on. The default port is 22</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*p_sPPeLcallrJQUS0Dys9A.png" /></figure><ul><li>Enter the Username and Password which are ‘<strong>pi</strong> and <strong>raspberry’ </strong>respectively by default.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*agEqBOExmwNJlGgSCSF8fQ.png" /></figure><ul><li>Upgrade and Update the Pi. It’s a good practice to always update and upgrade the pi each time we use it. Enter “sudo apt-get update” and “sudo apt-get upgrade”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*SybTI8kt-aUXz2RKOeKvEA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*xxiJ8_uthFTcATh0PEpGgg.png" /></figure><p><strong>Controlling the LEDs using Python code</strong></p><ul><li>Enter “sudo apt-get install python3” to install python.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*xw9Rfa3OCNcZIuyaZCyLQw.png" /></figure><ul><li>Install <strong>gpiozero </strong>library.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*aR-tEIiINkowxqu8Shg3lg.png" /></figure><ul><li>Create a file ‘<strong>gzero.py</strong>’.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*nYHtEHsJx5uLQrHKoELQQQ.png" /></figure><ul><li>Write the following codes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*c2-btDA81JF92xPMBEKmLg.png" /></figure><p><strong>LEDBoard </strong>is used<strong> </strong>when we have more than one <strong>LED</strong>. A collection of LEDs can be accessed using <strong>LEDBoard</strong>. If it’s a <strong>LED</strong>, we’ll import <strong>“LED”</strong> instead of <strong>“LEDBoard”</strong>.</p><p>Save the file and go back to the console.</p><p>To run the program, just write “<strong><em>python3 file-name.py”.</em></strong></p><p>NOTE: use the correct number of GPIO pin you’re connected to.</p><p>As long as the code keeps running, the LED turns on/off. Enter Ctrl + C to stop the python program</p><p><strong>Conclusion</strong></p><p>Make sure to connect the components correctly and use the correct number of the GPIO pin in your code.</p><p>Refresher time. Remember when we needed the IP address of the PI, we used a Router. This way isn’t pretty cool. Each time we need to connect to the Raspberry Pi, we have to set up a Router to get the IP address. How about using our mobile hotspot to connect? In my next article, we will learn <a href="https://medium.com/geekculture/how-to-connect-to-the-raspberry-pi-using-mobile-hotspot-2362a6b02efc">how to connect to the Raspberry Pi using Mobile Hotspot</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8351b06348d7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/how-to-blink-led-using-raspberry-pi-8351b06348d7">How to Blink Led using Raspberry Pi</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with Raspberry Pi and Installing Raspberry Pi OS]]></title>
            <link>https://medium.com/geekculture/getting-started-with-raspberry-pi-and-installing-raspberry-pi-os-f20cbee4c008?source=rss-3fe9ca633e2a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f20cbee4c008</guid>
            <category><![CDATA[rasberry-pi-3]]></category>
            <category><![CDATA[raspbian]]></category>
            <category><![CDATA[raspbian-os]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <dc:creator><![CDATA[Maria Elijah]]></dc:creator>
            <pubDate>Mon, 31 May 2021 23:20:18 GMT</pubDate>
            <atom:updated>2021-06-07T04:15:45.127Z</atom:updated>
            <content:encoded><![CDATA[<p>At a point in one’s life, you’ll want to try something new.</p><blockquote>It was on a Saturday morning. I was doing stuff on the internet and I came across the tiny, card-like-shaped computer (Raspberry Pi). I began to do research. I got to see powerful projects you can achieve with this “small but might” computer. The following week I got my first “not expensive” computer.</blockquote><p>That’s how my journey with Raspberry Pi began. Awesome😊</p><p>In this article, you will learn how to install Raspberry Pi OS on Raspberry Pi. No need to worry if this is your first time. This will set you on the right foot to developing amazing projects (DIY) with the Raspberry Pi.</p><p>What is Raspberry Pi?</p><figure><img alt="A raspberry Pi 3 B+" src="https://cdn-images-1.medium.com/max/523/1*vM-59nDg3Ao6TAekocifag.png" /></figure><p>Raspberry Pi is a series of single-board computers developed by the Raspberry Pi Foundation in the UK. It was developed to encourage people to get into programming and create easier access to computing education</p><p>Raspberry Pi is a tiny affordable computer that runs Linux. It provides inbuilt components such as GPIO (General Purpose Input and Output) pins, HDMI port, Ethernet port, audio port, CSI camera port, MicroSD slot, etc. which allows users to connect their physical devices and create fun, practical projects.</p><p>Since the release of Pi 1 Model B in 2012, subsequent improvement has led to many generations of the Raspberry Pi varying from Pi 1 to Pi 4 and even Pi 400 which was released in November 2020.</p><p>Alright. Let’s get started on the Raspberry Pi</p><p>Hardware needed:</p><p>1. Raspberry Pi 3 Model B+</p><p>2. Card Reader</p><p>3. MicroSD card 16G</p><p>4. PC</p><p>Software needed:</p><p>1. Raspberry Pi OS Lite ( this is the operating system of Raspberry Pi which is also called Raspbian OS)</p><p>2. Etcher (this will help flash the Raspbian image on the SD card)</p><p><strong>STEP 1</strong></p><p>Launch your browser and download <a href="https://www.raspberrypi.org/software/operating-systems/"><strong>Raspbian OS</strong></a><strong> Lite</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*4cVVpRnci5ABFZUTWzT4rg.png" /><figcaption>Raspbian OS</figcaption></figure><p><strong>STEP 2</strong></p><p>Download and install <a href="https://www.balena.io/etcher/"><strong>Etcher</strong></a> on your PC</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*OVyyNpCKLumNaGStumupLA.png" /><figcaption>Etcher for Flashing</figcaption></figure><p><strong>STEP 3</strong></p><p>I. Insert the MicroSD card into the Card Reader. Then, slot the Card Reader into the appropriate port on your PC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*srRXetrHYDDldjWVJEPhew.png" /><figcaption>A Card Reader and MicroSD Card</figcaption></figure><p>II. Launch Etcher to flash the Raspbian OS image into the SD card</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*iVkpTMR5J2GtyFdo4PSUrw.png" /><figcaption>interface for Etcher</figcaption></figure><p>III. Select the Raspbian OS image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*OT8mLVpJ55bsYe7G7o_Guw.png" /></figure><p>IV. click on select target to select MicroSD card</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*V72cRIXuCSYmEkd1Hto_VQ.png" /></figure><p>V. click the Flash button to write the image into the SD card</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*GKIazWVjbV5KMGEAZafWEw.png" /></figure><p>VI. Wait till all the processes are completed and it reads ‘Flash Completed’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*QBBrEeBchF4MUHpFtlvuMg.png" /></figure><p>Finally, remove the Card Reader from the PC port and detach the MicroSD Card from the Card Reader. Then, slot in the MicroSD Card into the Raspberry Pi SD Card slot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*UaJetSxqs9k0lXGoG3c5IA.png" /><figcaption>a Raspberry Pi 3 B+ with an inserted MicroSD Card</figcaption></figure><p><strong>Conclusion</strong></p><p>I try as much as possible to break it down for better understanding. I remember when I got started, it took me a whole day to install the Raspbian OS, but with these steps, you are good to go.</p><p>Now that you have installed the Raspbian OS into the Raspberry Pi, you can start developing projects. In my next article, we will be creating our first project “<a href="https://elijahmaria04.medium.com/how-to-blink-led-using-raspberry-pi-8351b06348d7"><strong>How to Blink Led using Raspberry Pi</strong></a>”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f20cbee4c008" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/getting-started-with-raspberry-pi-and-installing-raspberry-pi-os-f20cbee4c008">Getting Started with Raspberry Pi and Installing Raspberry Pi OS</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>