Multiple widgets used the same GlobalKey

前端 未结 4 1975
清歌不尽
清歌不尽 2020-12-07 01:05

I\'m using Flutter. I have a simple app with 3 tabs. There is a RefreshIndicator in each tab with a ListView. The rows are built in another method. This is the code:

4条回答
  •  甜味超标
    2020-12-07 01:51

    Same as @babernethy above, you can have

    import 'package:flutter/widgets.dart';
    
    class JosKeys {
      static final josKeys1 = const Key('__JosKey1__');
      static final josKeys2 = const Key('__JosKey2__');
    }
    

    then do this on one of your Global Keys, make sure to have a different JosKeys.josKeys{number} for each global key

    GlobalKey _globalKey = JosKeys.josKeys1;
    

提交回复
热议问题