title: Flutter HookWidget unlimited reloading build method
body: <p>In our application which implemented with <code>Riverpod</code> Library and <code>HookWidget</code> we have a unlimited reloading <code>build</code> method and it doesn't finished,</p>
  <p>we have this problem only on <code>release</code> not <code>debug</code> mode and I'm don't whats the problem on <code>release</code> mode that cause having unlimited reloading <code>build</code> and we don't get any error or warning in <code>logcat</code></p>
  <p>our implemented <code>HookWidget</code>:</p>
  <pre class="lang-dart prettyprint-override"><code>class Home extends HookWidget {
    @override
    Widget build(BuildContext context) {
      useProvider(articleProvider.notifier).getPosts();
  
      return Directionality(
        textDirection: TextDirection.rtl,
        child: Scaffold(
          body: ProviderListener&lt;NetworkRequestState&lt;Article&gt;&gt;(
            provider: articleProvider,
            onChange: (BuildContext context,
                NetworkRequestState&lt;Article&gt;? postListener) {
              postListener?.when(
                  idle: () {},
                  success: (value) {},
                  error: (error, stackTrace) {
                    //...
                  },
                  loading: () {
                    //...
                  });
            },
            child: Container(
                child: useProvider(articleProvider).when(
              idle: () {
                return const SizedBox();
              },
              loading: () =&gt; const SpinKitHourGlass(
                color: DefaultColors.$darkBlue,
                size: 45.0,
              ),
              success: (value) {
                final Article article = value as Article;
                final List&lt;Posts&gt; posts = article.posts;
                return ListView.separated(
                  //...
                );
              },
              error: (error, stackTrace) {
                return Container(
                  width: double.infinity,
                  height: double.infinity,
                  child: Column(
                    children: [
                      //...
                      ),
                    ],
                  ),
                );
              },
            )),
          ),
        ),
      );
    }
  }
  </code></pre>
  <p>and the <code>Riverpod</code> repository:</p>
  <pre class="lang-dart prettyprint-override"><code>final getPostProvider = Provider((ref) =&gt; PostRepository(ref.read));
  final articleProvider =
      StateNotifierProvider&lt;ArticleNotifier, NetworkRequestState&lt;Article&gt;&gt;(
    (ref) =&gt; ArticleNotifier(
      ref.watch(getPostProvider),
    ),
  );
  
  class PostRepository {
    final Reader _reader;
  
    PostRepository(this._reader);
  
    Future&lt;Article&gt; requestGetPosts() async {
      try {
        const r = RetryOptions(maxAttempts: 3);
        final response = await r.retry(
          () =&gt; _reader(dioProvider)
              .get(Server.$posts,
                  options: Options(
                    headers: {'Content-Type': 'application/json'},
                  ))
              .timeout(const Duration(seconds: 30)),
          retryIf: (e) =&gt; e is SocketException || e is TimeoutException,
        );
  
        return Article.fromJson(response.data as Map&lt;String, dynamic&gt;);
      } on DioError catch (e) {
        throw e.error as Object;
      }
    }
  }
  
  class ArticleNotifier extends RequestStateNotifier&lt;Article&gt; {
    final PostRepository _postRepository;
  
    ArticleNotifier(this._postRepository);
  
    Future&lt;NetworkRequestState&lt;Article&gt;&gt; getPosts() =&gt;
        makeRequest(() =&gt;_postRepository.requestGetPosts());
  }
  </code></pre>