-
Notifications
You must be signed in to change notification settings - Fork 52
Description
Getting GlobalKey Error
Multiple widgets used the same GlobalKey.
════════ Exception caught by widgets library ═══════════════════════════════════
Multiple widgets used the same GlobalKey.
════════════════════════════════════════════════════════════════════════════════
`The following assertion was thrown while finalizing the widget tree:
Multiple widgets used the same GlobalKey.
The key [GlobalKey#beb1f] was used by multiple widgets. The parents of those widgets were:
- CustomPaint(renderObject: RenderCustomPaint#830c9 NEEDS-PAINT)
- CustomPaint(renderObject: RenderCustomPaint#e5d2c NEEDS-PAINT)
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:
#6 BuildOwner.finalizeTree. (package:flutter/src/widgets/framework.dart:3177:11)
framework.dart:3177
#7 BuildOwner.finalizeTree (package:flutter/src/widgets/framework.dart:3259:8)
framework.dart:3259
#8 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:992:19)
binding.dart:992
#9 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:448:5)
binding.dart:448
#10 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1386:15)
binding.dart:1386
#11 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1311:9)
binding.dart:1311
#12 SchedulerBinding.scheduleWarmUpFrame. (package:flutter/src/scheduler/binding.dart:1034:7)
binding.dart:1034
#16 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
isolate_patch.dart:184
(elided 3 frames from class _Timer and dart:async-patch)`
How to reproduce:
SizedBox(
width: MediaQuery.of(context).orientation == Orientation.portrait ? MediaQuery.of(context).size.height - 120 : MediaQuery.of(context).size.width - 120,
height: MediaQuery.of(context).orientation == Orientation.portrait ? MediaQuery.of(context).size.width - 120 : MediaQuery.of(context).size.height - 140,
child: AspectRatio(
aspectRatio: 16 / 9,
child: Card(
clipBehavior: Clip.hardEdge,
surfaceTintColor: EmintColors.emerald,
elevation: 0.2,
child: Scribble(
notifier: notifier,
drawPen: true,
),
),
),
),