avatarY.L. Wolfe

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

6856

Abstract

edFileExtension = selectedFileName.split(‘.’).last; <span class="hljs-keyword">if</span>(allowedFormats != <span class="hljs-literal">null</span> || allowedFormats.isNotEmpty) { <span class="hljs-keyword">if</span>(!allowedFormats.contains(‘selectedFileExtension’)) { print(selectedFileName); message = ‘<span class="hljs-type">Selected</span> file format { selectedFileExtension } isn\’ allowed’; <span class="hljs-keyword">return</span> <span class="hljs-type">FilePickerWrapperFailedResult</span>(errorMessage: message,code: <span class="hljs-number">0</span>); } }

<span class="hljs-keyword">if</span> ( maxFileSizeAllowed < file.lengthSync() / <span class="hljs-number">1024</span>) { message = ‘<span class="hljs-type">File</span> size exceed, maximum file size allowed($maxFileSizeAllowed kB)’; <span class="hljs-keyword">return</span> <span class="hljs-type">FilePickerWrapperFailedResult</span>(errorMessage: message,code: <span class="hljs-number">0</span>); } <span class="hljs-keyword">return</span> <span class="hljs-type">FilePickerWrapperSuccessResult</span>(code: <span class="hljs-number">1</span>,filePath: file.path, fileName: selectedFileName); } }

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">FilePickerWrapperResult</span> </span>{ int code; <span class="hljs-comment">// 1 means success result, 0 means failed or error result </span> }

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">FilePickerWrapperSuccessResult</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">FilePickerWrapperResult</span> </span>{ <span class="hljs-type">FilePickerWrapperSuccessResult</span>({<span class="hljs-meta">@required</span> <span class="hljs-keyword">this</span>.filePath, <span class="hljs-meta">@required</span> <span class="hljs-keyword">this</span>.fileName, <span class="hljs-meta">@required</span> int code}) { <span class="hljs-keyword">this</span>.code = code; } <span class="hljs-type">String</span> filePath; <span class="hljs-type">String</span> fileName; }

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">FilePickerWrapperFailedResult</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">FilePickerWrapperResult</span> </span>{ <span class="hljs-type">FilePickerWrapperFailedResult</span>({<span class="hljs-meta">@required</span> <span class="hljs-keyword">this</span>.errorMessage, <span class="hljs-meta">@required</span> int code}) { <span class="hljs-keyword">this</span>.code = code; } <span class="hljs-type">String</span> errorMessage; }</pre></div><p id="bb4a">In this helper class, we added functionality to select the image from the gallery app on the device. Now create a new file and name it <b>image_picker_wrapper.dart.</b></p><h1 id="c228">Enabling image selection</h1><p id="d038">Add the following code to this file:</p><div id="ef30"><pre>import ‘dart:io’; import ‘package:facerecognition/supporting_files/file_picker_wrapper.dart’; import ‘package:flutter/cupertino.dart’; import ‘package:flutter/material.dart’; import ‘package:image_picker/image_picker.dart’;

typedef ImagePickerResult = <span class="hljs-keyword">void</span> <span class="hljs-title function_ invoke__">Function</span>(FilePickerWrapperResult result);

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ImagePickerWrapper</span> </span>{ <span class="hljs-title function_ invoke__">ImagePickerWrapper</span>({ @required ImagePickerResult imagePickerResult, <span class="hljs-keyword">double</span> maxFileSizeAllowed = <span class="hljs-number">2024</span> //size in kb }) { this._imagePickerResult = imagePickerResult; this._maxFileSizeAllowed = maxFileSizeAllowed; } ImagePickerResult _imagePickerResult; <span class="hljs-keyword">double</span> _maxFileSizeAllowed;

<span class="hljs-keyword">void</span> <span class="hljs-title function_ invoke__">openImagePickerActionSheet</span>({@required BuildContext buildContext}) { <span class="hljs-keyword">if</span>(buildContext == <span class="hljs-literal">null</span>) { <span class="hljs-keyword">print</span>(‘build content can’’\’t be <span class="hljs-keyword">empty</span>’); <span class="hljs-keyword">return</span>; } <span class="hljs-keyword">if</span> (Platform.isIOS) { <span class="hljs-title function_ invoke__">_actionSheet</span>(buildContext); } <span class="hljs-keyword">else</span> { <span class="hljs-title function_ invoke__">_androidBottomSheet</span>(buildContext); } }

<span class="hljs-comment">//For ios </span> <span class="hljs-keyword">void</span> <span class="hljs-title function_ invoke__">_actionSheet</span>(BuildContext context) { _containerForSheet<String>( context: context, child: <span class="hljs-title function_ invoke__">CupertinoActionSheet</span>( <span class="hljs-attr">title</span>: <span class="hljs-title function_ invoke__">Text</span>(‘’), <span class="hljs-attr">message</span>: <span class="hljs-title function_ invoke__">Text</span>(‘’), <span class="hljs-attr">actions</span>: <Widget>[ <span class="hljs-title function_ invoke__">CupertinoActionSheetAction</span>( <span class="hljs-attr">child</span>: <span class="hljs-title function_ invoke__">Text</span>(‘Camera’), <span class="hljs-attr">onPressed</span>: () { <span class="hljs-title function_ invoke__">_openCamera</span>(ImageSource.camera); }, ), <span class="hljs-title function_ invoke__">CupertinoActionSheetAction</span>( <span class="hljs-attr">child</span>: <span class="hljs-title function_ invoke__">Text</span>(‘Gallery’), <span class="hljs-attr">onPressed</span>: () async { <span class="hljs-title function_ invoke__">_openFileExplorer</span>(); }, ), ], cancelButton: <span class="hljs-title function_ invoke__">CupertinoActionSheetAction</span>( <span class="hljs-attr">child</span>: <span class="hljs-title function_ invoke__">Text</span>(‘Cancel’), <span class="hljs-attr">isDefaultAction</span>: <span class="hljs-literal">true</span>, <span class="hljs-attr">onPressed</span>: () { Navigator.<span class="hljs-title function_ invoke__">pop</span>(context, ‘Cancel’); }, ))); }

<span class="hljs-keyword">void</span> _containerForSheet<T>({BuildContext context, Widget child}) { showCupertinoModalPopup<T>( context: context, builder: (BuildContext context) => child, ).then<<span class="hljs-keyword">void</span>>((T value) { }); }

<span class="hljs-comment">//For Android </span> <span class="hljs-keyword">void</span> <span class="hljs-title function_ invoke__">_androidBottomSheet</span>(BuildContext context) { show

Options

ModalBottomSheet<<span class="hljs-keyword">void</span>>( context: context, builder: (BuildContext context) { <span class="hljs-keyword">return</span> <span class="hljs-title function_ invoke__">Container</span>( <span class="hljs-attr">margin</span>: <span class="hljs-keyword">const</span> EdgeInsets.<span class="hljs-title function_ invoke__">only</span>(<span class="hljs-attr">left</span>: <span class="hljs-number">20.0</span>, <span class="hljs-attr">right</span>: <span class="hljs-number">20.0</span>), <span class="hljs-attr">child</span>: <span class="hljs-title function_ invoke__">Wrap</span>( <span class="hljs-attr">children</span>: <Widget>[ <span class="hljs-title function_ invoke__">ListTile</span>( <span class="hljs-attr">leading</span>: <span class="hljs-title function_ invoke__">Icon</span>(Icons.camera), <span class="hljs-attr">title</span>: <span class="hljs-title function_ invoke__">Text</span>(‘Camera’), <span class="hljs-attr">onTap</span>: () { <span class="hljs-title function_ invoke__">_openCamera</span>(ImageSource.camera); }), <span class="hljs-title function_ invoke__">ListTile</span>( <span class="hljs-attr">leading</span>: <span class="hljs-keyword">const</span> <span class="hljs-title function_ invoke__">Icon</span>(Icons.landscape), <span class="hljs-attr">title</span>: <span class="hljs-title function_ invoke__">Text</span>(‘Gallery’), <span class="hljs-attr">onTap</span>: () { // <span class="hljs-title function_ invoke__">_openFileExplorer</span>(); <span class="hljs-title function_ invoke__">_openCamera</span>(ImageSource.gallery); }, ), ], ), ); }); }

Future<<span class="hljs-keyword">void</span>> <span class="hljs-title function_ invoke__">_openCamera</span>(ImageSource source) async { File imageSelected = await ImagePicker.<span class="hljs-title function_ invoke__">pickImage</span>( <span class="hljs-attr">source</span>: source, <span class="hljs-attr">maxHeight</span>: <span class="hljs-number">400</span>, <span class="hljs-attr">maxWidth</span>: <span class="hljs-number">400</span>); <span class="hljs-keyword">if</span> (imageSelected != <span class="hljs-literal">null</span>) { <span class="hljs-keyword">final</span> String fileName = imageSelected.path.<span class="hljs-title function_ invoke__">split</span>(‘/’).last; <span class="hljs-keyword">if</span> ( _maxFileSizeAllowed < imageSelected.<span class="hljs-title function_ invoke__">lengthSync</span>() / <span class="hljs-number">1024</span>) { String message = ‘File size exceed, maximum file size <span class="hljs-title function_ invoke__">allowed</span>(<span class="hljs-variable">$_maxFileSizeAllowed</span> kB)’; <span class="hljs-title function_ invoke__">_imagePickerResult</span>(<span class="hljs-title function_ invoke__">FilePickerWrapperFailedResult</span>(<span class="hljs-attr">errorMessage</span>: message,<span class="hljs-attr">code</span>: <span class="hljs-number">0</span>)); } <span class="hljs-title function_ invoke__">_imagePickerResult</span>(<span class="hljs-title function_ invoke__">FilePickerWrapperSuccessResult</span>(<span class="hljs-attr">code</span>: <span class="hljs-number">1</span>,<span class="hljs-attr">filePath</span>: imageSelected.path, <span class="hljs-attr">fileName</span>: fileName)); } <span class="hljs-keyword">else</span> { <span class="hljs-title function_ invoke__">_imagePickerResult</span>(<span class="hljs-title function_ invoke__">FilePickerWrapperFailedResult</span>(<span class="hljs-attr">errorMessage</span>: ‘Failed to get the image’,<span class="hljs-attr">code</span>: <span class="hljs-number">0</span>)); } }

Future<<span class="hljs-keyword">void</span>> <span class="hljs-title function_ invoke__">_openFileExplorer</span>() async { <span class="hljs-keyword">final</span> FilePickerWrapperResult wrapperResult = await <span class="hljs-title function_ invoke__">FilePickerWrapper</span>() .<span class="hljs-title function_ invoke__">openFileExplorer</span>( <span class="hljs-attr">maxFileSizeAllowed</span>: <span class="hljs-number">2048</span>, <span class="hljs-attr">fileFormatsAllowed</span>: [‘jpeg’, ‘png’, ‘jpg’]); <span class="hljs-title function_ invoke__">_imagePickerResult</span>(wrapperResult); } }</pre></div><p id="f671">This helper class will provide the functionality to pick an image from the device’s gallery app or take a new one using the device’s camera. The alerts style will be as per the platform (i.e., on iOS, it will be shown in Cupertino style, and, on the Android platform, it will be displayed using Material style).</p><p id="4867">In this blog, we have examined the steps needed to create a UI in Flutter to allow users to pick images from their phones for use with Amazon Rekognition.</p><p id="2179">Next, we design a UI to allow the user to pick images and implement the functionality to pick image/s either from the camera or mobile storage. In the next part of this blog, we will focus on:</p><ul><li>Initiating the action of comparison.</li><li>Convert the raw result into a model.</li><li>Display the result of the comparison.</li></ul><p id="9c29">Read the next part of the blog on implementing facial recognition where we cover these topics:</p><div id="eb9f" class="link-block"> <a href="https://readmedium.com/implementing-facial-recognition-in-flutter-apps-1e99a23ac9c4"> <div> <div> <h2>Implementing Facial Recognition in Flutter Apps</h2> <div><h3>Read our blog to learn how to implement Facial Recognition in Flutter Apps using Amazon Rekognition.</h3></div> <div><p>DLT Labs on medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*aGrAV7khLCz6_oKQmAG29w.png)"></div> </div> </div> </a> </div><p id="ca73"><i>Amazon Rekognition is the intellectual property of Amazon Inc. Flutter is a trademark of Google LLC.</i></p><p id="e5a4"><i>Author — Suhail Shabir, DLT Labs</i></p><p id="0f4a"><b>About the Author: </b><i>Suhail </i>is an application development professional who has worked on different platforms and technologies. He has completed his Bachelors in Computer Application from Kashmir University.</p><p id="e3ea">Disclaimer: This article was originally published on the DLT Labs Blog page: <a href="https://www.dltlabs.com/blog/enabling-facial-recognition-in-flutterapps-764220">https://www.dltlabs.com/blog/enabling-facial-recognition-in-flutterapps-764220</a></p><figure id="2629"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*0Rjo1bW8T-fHbjiq.png"><figcaption></figcaption></figure></article></body>

Is Being Single Sexier Than We Thought?

It can be fun, freeing, and hot as hell — and I know from experience

Photo by Ryan Moreno on Unsplash

I’ve always felt troubled by our culture’s perspective on being a single woman. If you’re young and having lots of sex with lots of people, it’s sometimes viewed as cool and edgy — but maybe slightly pathetic under certain circumstances (like if you can’t wrangle a date for your best friend’s wedding or dragged your mascara-streaked face home at 4 in the morning, after a night of passion).

Once you’re over 35, people don’t find it so cool and edgy anymore — slightly pathetic turns into fully pathetic, and after 40, it’s just plain apathetic. No one cares that much about your love life anymore. You’re labeled a hopeless cause.

It’s hard to keep from internalizing these messages. I remember feeling so much pressure to marry by the time I was 24 — the age my mother was when she got married. It seemed like something to which I was supposed to aspire.

When that didn’t happen, and I took a year to explore my career, education, and sexuality in Santa Fe at the age of 25, I decided to embrace my singleness. Sex and the City was in its third season, giving us a whole new way to view “the single gal.” I threw caution to the wind (a little too much, if I’m being honest) and allowed myself to express my sexuality with any partner who caught my interest.

It was a time of paradox, however, the pleasure balanced out with shame and pain. My conservative friends condemned my behavior and refused to listen to me vent when my musician partner treated me badly or when my younger lover told me he couldn’t see me anymore because he’d been cheating on his girlfriend back home. And honestly, I often left encounters with these men feeling used up and discarded.

If you’re young and having lots of sex with lots of people, it’s sometimes viewed as cool and edgy — but maybe slightly pathetic under certain circumstances…

I wasn’t very good at being single. I didn’t take good care of myself, I didn’t choose the right partners, and I prioritized the pursuit of my sexual pleasure over the realization of it. (Trust me, there’s an important distinction there.)

By the time I returned home, to my old life, I no longer found being single to be as fun or independent as Sex and the City made it look.

I found myself single once again at the end of my thirties and am still single today. It was devastating, at first. I thought I was too old to find love again, that my chances of becoming a mother were dashed, and basically, that the world was going to end in a burning cloud of fire.

But over the years, I started to enjoy it more and more. I loved the freedom of being able to scope out potential lovers, even when nothing came of it. It felt so freeing to know that I could date — or fuck — anyone I wanted, after feeling so trapped during the last few years of my previous relationship.

I loved doing whatever I wanted, whenever I wanted. I didn’t have to check with a partner about dinner dates with friends, appointments, holiday parties, or anything else.

And strangely, I came to love one of the most challenging things about being single: Making it on my own.

I’d always wanted to be an independent woman, but deep down, after watching my mother rely on men her whole life to support her, I think I feared I would have the same fate. Though I always paid my way with my last partner, it wasn’t a challenge, thanks to splitting the expenses in half. But living alone and being able to pay all my bills seemed like a pipe dream to me, especially in my region’s bloated housing market and with the nonprofit salary I was making at the time.

But you know what? I did it. I pinched pennies for years, pursued every opportunity that came my way, took classes, networked, and worked my fingers to the bone until I was able to buy my own house.

That’s right. I bought a fucking house all by myself. And nothing has ever felt so good.

I loved doing whatever I wanted, whenever I wanted.

Over time, I’ve stopped feeling so defined by our culture’s perspectives and judgments about single women. I don’t see a pathetic person when I look in the mirror — I see a woman who is making her way in the world.

My grandmothers relied on their fathers and husbands for money. My mother relied on her father and husband for money. And while there’s nothing wrong with deciding with your partner to be a stay at home mother and rely on a man’s income, I’m proud that I make my own money and that I have a career that I enjoy.

That makes me feel powerful.

It also makes me feel powerful that I’m doing things most of my female contemporaries have never done before — because they never had to. For instance, I’ve learned how to take apart the drain stopper in my bathtub, how to operate power tools, how to build a compost bin (from scratch, with actual lumber), how to winterize my house, how to mow the lawn, and yes, how to remove unwanted insects from my house even when I’m deathly afraid of them. These are all tasks that my friends brag that their husbands perform for them.

I feel like I should be the one bragging that I’m my own husband…and a damn good one.

I try to embrace my singleness as much as I can — I might not be on my own forever, after all, so I want to enjoy every second of this.

  • I sleep in the middle of my bed — because I can. I go to bed late when I want and sleep when I want.
  • I listen to music loudly when I’m cleaning the house.
  • I am creating a garden of my dreams because I can do whatever I want with my yard.
  • I make myself french toast now and then on a Sunday morning and eat it curled up on my couch. (And I don’t have to share.)
  • I invite friends over whenever I want — even the friends whom I rarely got to see because my ex didn’t like them.
  • I go on last-minute outings.
  • I wear busty blouses on occasion that would have caused arguments with my former partner who didn’t like me to show off my body in public.
  • I take the occasional midday nap.
  • I have solo fun whenever I damn well want to.
  • I decorate my house with wreaths, candles, and dried flowers and don’t have to listen to anyone complain that it’s “too girly.”

I feel like I should be the one bragging that I’m my own husband…and a damn good one.

Don’t get me wrong. Sometimes, it’s hard being single. I get tired of fixing everything myself. I feel overwhelmed on occasion. I want to cry when it snows three feet at a time and I can barely keep my sidewalks and driveway shoveled.

And of course, that’s saying nothing of the loneliness that can hit me. Or the longing to be cuddled and touched. Or just wanting to get greased up and crazy in the bedroom.

The days that I need that and can’t have it are very difficult.

But it was also difficult to be in a relationship. It was hard to have to constantly compromise. I often felt trapped. And I was just as lonely then as I get now.

The hard days pass. Maybe after a week. Maybe after a month. But eventually, they pass.

Then I make myself some french toast and kick back on the sofa and I remember how lucky I am. Lucky to be the kind of single woman I had dreamed of being at 25.

This is the kind of woman I want my nieces to see and admire. I want being single to be just another awesome option that a woman can take. I don’t want them to feel like they have to be in a relationship just to avoid the stigma that comes with being single.

I want them to see that yes, single can be sexy. Single can be exciting. Single can be cool.

I want them to look at me and see a wild wolf who does whatever she wants, who pursues pleasure with abandon — and has it fulfilled.

Though I hope to see our culture experienced a major shift in the way it perceives single women, I’m not going to hold my breath. I’ve got french toast to make, a drain to unclog, and a mortgage payment to mail.

And I’m gonna kick ass at all of that, all by myself, and look hot doing it. Or at least pretend that I look hot. After all, there’s no one here to claim otherwise.

© Yael Wolfe 2019

If you like my work and want to stay updated, click here to subscribe to my newsletter.

Love
Women
Relationships
Culture
Self Love
Recommended from ReadMedium