Interested in setting up a mentioning system in your social networking app?

Here's a short thread on how I've implemented one in #Flutter.

I've included code snippets, important packages, and some tasty tech tips. Check it --> 🧵

#appdevelopment #cs
First, you'll want to make sure that each username is formatted correctly.

For implementing "mentions" like Twitter, your usernames cannot have spaces.

This lets you tag users in posts by typing the at-sign and then the name. Examples: @NoboxApp, @ParaSightApp, @BigIdeaski
In #Flutter you can prevent spaces using the FilteringTextInputFormatter and setting the maxLines property to 1.

This maxLines setting prevents new line characters.

@carbon_app TextFormField(   focusNode:...
Next, you'll need to make sure that each username is unique.

If not, you won't be able to accurately mention users and the concept of a digital #identity starts to crumble.

You can check the uniqueness by running a quick @Firebase query and checking if a document exists.
Something as simple as this should do.

I typically run this query when the user submits their changes but if you want to be ambitious, you can check the availability as they type.

Beware of over-querying. A debouncing method is smart here.

@carbon_app        QuerySnapshot existi...
Now for the fun part!

Once your users are created, you can use the detectable_text_field package to highlight strings starting with @.

This package has DetectableTextField and DetectableText widgets so you can show mentions everywhere.

pub.dev/packages/detec…
To implement the "write" side of it, create a DetectableTextField and set the detectionRegExp to one that includes AtSigns.

- hashTagAtSignUrlRegExp
- atSignRegExp
- AtSignUrlRegExp
- hashTagAtSignRegExp

The output is just what you would expect. Image
On the "read" side, it's just as simple.

Create a DetectableText widget with one of the above detectionRegExps.

You can add interactivity by setting the onTap property. Note that you'll need to distinguish hashtags from mentions.

@carbon_app DetectableText(   text: pos...
If you found this useful, subscribe to my #Flutter newsletter (Flutter Fast, Flutter Far) on my profile page.

I'll be sending out one letter each week on Flutter dev, feature implementation, and coding efficiency!

Thanks!

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Joe Muller

Joe Muller Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Mullr33

30 Sep
One thing you need to consider when designing your #Firestore database is how much data you'll need to build each document reference.

This will be important if you ever add notifications to your #flutter app since the notification should bring the user to a relevant screen.
For example, say you have the following collections:

Users -> Posts -> Comments

And you want to notify a user about a comment on their own post. In this case, the notification will only need the post ID and the comment ID since we can infer the user ID.
But what if you wanted to notify a user about a reply to their comment on someone else's post?

You'd need to send all 3 IDs so your app can resolve the destination.

Alternatively, you could flatten the database so that users, posts, and comments are top-level.
Read 4 tweets
26 Mar
A thread on how I managed to encrypt and store a video using #Flutter

Scroll for links, code snippets, and my general thought process...
Recording and saving videos locally isn't too difficult.

Dependencies:
- camera
- path_provider

#flutter #android #s21 #video #coding

Below is the code for getting a file reference:

Created with @carbon_app   /// One call to get a file reference, set temp = false to
Encryption on the other hand is a foreign language to me. From my research, I learned that each user needs an #AsymmetricKeyPair that can be used to #encrypt and #decrypt data.

To generate these, I used the rsa_encrypt package.

pub.dev/packages/rsa_e…
Read 19 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(