Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does flutter_hooks throw an error if I don't use SearchController?

Tags:

flutter

First I hooked up hooks_riverpod which didn't recognize useEffect, then I hooked up flutter_hooks and it threw an error: Method not found: 'SearchController'.

Error: .../Pub/Cache/hosted/pub.dev/flutter_hooks-0.20.0/lib/src/search_controller.dart:21:22: Error: Method not found: 'SearchController'. final controller = SearchController();

import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:riverpod_firebase_register_crud_app/ui/utils/lables.dart';

import '../root.dart';

class SplashPage extends HookWidget {
  const SplashPage({super.key});

  static const String route = '/splash';

  void startController() async {
    await Future.delayed(const Duration(seconds: 1));
  }

  @override
  Widget build(BuildContext context) {
    useEffect(() {
      startController();
      if (Navigator.canPop(context)) {
        Navigator.pushNamedAndRemoveUntil(
          context,
          Root.route,
          (route) => false,
        );
      }
      return null; // Returning null to indicate no cleanup is needed
    }, const []);

    return Scaffold(
      backgroundColor: Theme.of(context).colorScheme.primaryContainer,
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const Icon(
              Icons.favorite,
              size: 80,
            ),
            const SizedBox(
              height: 24,
            ),
            Text(
              Labels.appName,
              style: Theme.of(context).textTheme.headlineLarge!.copyWith(
                  color: Theme.of(context).colorScheme.onPrimaryContainer),
            ),
          ],
        ),
      ),
    );
  }
}
like image 811
Nasimi Gun Avatar asked Nov 01 '25 23:11

Nasimi Gun


2 Answers

To temporarily work around this issue, you can comment out search_controller.dart in flutter_hooks>lib>src>hooks.dart

like image 115
Nasimi Gun Avatar answered Nov 03 '25 12:11

Nasimi Gun


Not the best solution though Downgrade works

Use this for now: flutter_hooks: ^0.18.6

like image 39
Fredrick Avatar answered Nov 03 '25 12:11

Fredrick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!