title: Can't get variable in another class - Flutter
body: <p>Tell me, I need to get a <code>hash</code> variable in a <code>cubit</code> file which is in <code>block_info_page</code>. I need this variable to make an API request to <code>block_repository</code> that uses the <code>hash_block</code> variable. Is it possible to implement this? Thanks in advance.</p>
  <p><strong>cubit</strong></p>
  <pre><code>class BlockinfoCubit extends Cubit&lt;BlockInfoState&gt; {
    final BlockInfoRepository _blockInfoRepository;
  
    BlockinfoCubit(this._blockInfoRepository) : super(BlockInfoInitialState());
  
    void getBlockInfo() async {
      emit(BlockInfoLoadingState());
      try {
        final hash_block = ; 
        final blocksInfo = await _blockInfoRepository.getBlockInfo(hash_block);
        emit(BlockInfoLoadedState(blocksInfo));
      } catch (e) {
        emit(BlockInfoErrorState(e.toString()));
      }
    }
  }
  </code></pre>
  <p><strong>block_info_page</strong></p>
  <pre><code>class BlockInfoPage extends StatelessWidget {
    final String hash;
    const BlockInfoPage({Key? key, required this.hash}) : super(key: key);
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.white,
          title: Image.asset(
            'assets/images/logo.png',
            height: 35,
          ),
          centerTitle: false,
        ),
        body: Center(child: Text(hash)),
      );
    }
  }
  </code></pre>
  <p><strong>block_repository</strong></p>
  <pre><code>class BlockInfoRepository {
    Future&lt;List&lt;BlockInfoModel&gt;&gt; getBlockInfo(hash_block) async {
      final response = await http
          .get(Uri.parse('https://blockchain.../$hash_block'));
  
      if (response.hashCode == 200) {
        final blockInfo = json.decode(response.body);
  
        return blockInfo
            .map&lt;BlockInfoModel&gt;((json) =&gt; BlockInfoModel.fromJson(json))
            .toList();
      } else {
        throw Exception('Failed to load block-info');
      }
    }
  }
  </code></pre>
  <p><strong>block_page</strong></p>
  <pre><code>TextButton(
                                onPressed: () =&gt; Navigator.push(
                                    context,
                                    MaterialPageRoute(
                                        builder: (context) =&gt; BlockInfoPage(
                                            hash: blocksData[index].hash))),
  </code></pre>