nslogx / flutter_easyloading

✨A clean and lightweight loading/toast widget for Flutter, easy to use without context, support iOS、Android and Web

Home Page:https://pub.dev/packages/flutter_easyloading

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Duplicate GlobalKey detected in widget tree

wangjunjx8868 opened this issue · comments

Describe the bug

void addHour(String hour,int index) async{
    Map<String, dynamic>? formData = {
      "id": "1"
    };
    await EasyLoading.show(status: 'Loading...', maskType: EasyLoadingMaskType.black);
    String url="http://www.1111.com";
    Map<String, dynamic>? headers={"Content-type":"application/x-www-form-urlencoded"};
    RequestClient requestClient = RequestClient();
    await requestClient.post(url,data: formData,headers: headers,onError: (e){
      EasyLoading.dismiss();
      EasyLoading.showError(e.message!);
      return e.code==0;
    },onSuccess: (res){
      EasyLoading.dismiss();
      if(res.code==0)
      {
        EasyLoading.showSuccess("ok!");
      }
      else
      {
        EasyLoading.showError(res.message!);
      }
    });
  }

提示错误
Duplicate GlobalKey detected in widget tree.

The following GlobalKey was specified multiple times in the widget tree. This will lead to parts of the widget tree being truncated unexpectedly, because the second time a key is seen, the previous instance is moved to the new location. The key was:

  • [LabeledGlobalKey#59426]
    This was determined by noticing that after the widget with the above global key was moved out of its previous parent, that previous parent never updated during this frame, meaning that it either did not update at all or updated before the widget was moved, in either case implying that it still thinks that it should have a child with that global key.
    The specific parent that did not update after having one or more children forcibly removed due to GlobalKey reparenting is:
  • _EffectiveTickerMode(effective mode: enabled)
    A GlobalKey can only be specified on one widget at a time in the widget tree.
    When the exception was thrown, this was the stack:
    #0 BuildOwner.finalizeTree. (package:flutter/src/widgets/framework.dart:3083:15)
    #1 BuildOwner.finalizeTree (package:flutter/src/widgets/framework.dart:3108:8)
    #2 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:866:19)
    #3 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:381:5)
    #4 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1289:15)
    #5 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1218:9)
    #6 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1076:5)
    #7 _invoke (dart:ui/hooks.dart:145:13)
    #8 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:338:5)
    #9 _drawFrame (dart:ui/hooks.dart:112:31)
    Flutter/Dart info
    please run flutter doctor then put it here.

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.7.9, on Microsoft Windows [版本 10.0.19045.2846], locale zh-CN)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Enterprise 2022 17.5.3)
[√] Android Studio (version 2022.1)
[√] Connected device (3 available)
[√] HTTP Host Availability

Thanks for taking the time to open an issue. I will have a look and answer as soon as possible.