首先我连接了hooks_riverpod
,它不能识别useEffect
,然后我连接了flutter_hooks
,它抛出了一个错误:未找到方法:'SearchController'.
错误:.../Pub/Cache/hosted/pub.dev/flutter_hooks-0.20.0/lib/src/search_controller.dart:21:22:错误:未找到方法:'SearchController'. int n = getString();
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),
),
],
),
),
);
}
}
字符串
1条答案
按热度按时间wj8zmpe11#
不是最好的解决方案,但降级工作
现在使用这个:flutter_hooks:0.18.6