Flutter hooks – useMemoized() | A brief overview

useMemoized :

In this site we will be working with the utilization of caching idea in flutter apps employing flutter hooks, when just about every there is any advanced item than we can cache it and use it for afterwards use.

This system of caching is realized by useMemoized which will improved app effectiveness and pace.Also we make use of flutter hooks to strengthen app’s effectiveness.

The work of useMemoized is to make cache of the intricate objects and use them when necessary as like the output is very same everytime so we have to have to waste time in processing.

In this case in point we have consider a time period and have been ready for a particular time to make the get the job done performed as a uncomplicated example so that you can fully grasp how the processing is delayed for sometime in authentic scenario’s.




pubspec.yaml :

Include flutter hooks dependency to pubspec file so that we can help cache using useMemoized.Make positive you add the most up-to-date version of plugin.

    sdk: flutter

  flutter_hooks: ^.18.3


major.dart :

Let’s get begun with our void principal the place we specify the class utilizing operate app these types of that our system starts here and goes on.

Listed here we are hoping to cache the fetchData perform and use it many times keeping away from the delay we confront.

import 'package:flutter/material.dart'
import 'package:flutter_hooks/flutter_hooks.dart'

void main()

class MyApp extends StatelessWidget 
  const MyApp(Essential? important) : tremendous(key: key)

  Widget develop(BuildContext context) 
    return MaterialApp(
      house: Scaffold(
        appBar: AppBar(
          title: Text("flutter Hooks"),
        human body: Hook()

class Hook extends HookWidget {
  const Hook(Essential? important) : super(critical: vital)

  Widget make(BuildContext context) 

    last depend = useState()

    Potential fetchData() async
      await Future.delayed(Period(seconds: 1))
      return "Hello there Earth $count.benefit"

    last potential = useMemoized(fetchData, [])
    final snapshot = useFuture(long term)

    return Center(
      kid: snapshot.hasData ? Textual content("$snapshot.knowledge")
          : CircularProgressIndicator(),


If you have any queries in this principle of useMemoized permit us know in the comment segment beneath.Do like and share us if you like this tutorial for much more exciting updates coming up.


Next Post

Can We Really Count On Facebook?

This week, Facebook/MetaZuck broke DTC Twitter and despatched media prospective buyers scrambling just about everywhere when it randomly shut off best-accomplishing advertisement strategies at 7:30pm Pacific. At the very least they waited till several media prospective buyers ended up on their way again from their lunch breaks. Not all accounts […]
Can We Really Count On Facebook?

You May Like