global_key_factory.dart 344 B

123456789101112131415
  1. import 'package:flutter/material.dart';
  2. /*
  3. * 全局的Key管理,可以用于默认页面或Widgert标识
  4. */
  5. class GlobalKeyFactory {
  6. static BigInt _counter = BigInt.zero;
  7. static GlobalKey createGlobalKey() {
  8. final key = GlobalKey(debugLabel: 'global_key_${_counter.toString()}');
  9. _counter += BigInt.one;
  10. return key;
  11. }
  12. }