0
useEffect((){
   StoreProvider.of<AppState>(context).dispatch(getBalanceThunk());
},[]);


return Scaffold(
  appBar: AppBar(
    title: Text('ola'),
  ),
  body: Center(child:  StoreConnector<AppState, BalanceState>(
    converter: (store) =>store.state.balanceState,
    builder: (context, state) {
      return Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          if (state.loading)Column(
            children: [
              CircularProgressIndicator(),
              SizedBox(height: 30,)
            ],
          ),
          Text(state.message),
        ],
      );
    },
  ),),
);

但是这段代码会抛出一个错误:

Cannot listen to inherited widgets inside HookState.initState. Use HookState.build instead
'package:flutter_hooks/src/framework.dart':

我已经搜索了很多次,但找不到任何答案。请帮助我摆脱这个问题。提前致谢。

4

0 回答 0