-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple widgets used the same GlobalKey #62
Comments
Hi, thanks for opening up an issue. Could you tell me which version of scribble you are on? I can't reproduce this on the latest version. Also, is it possible, that you are using the same |
Hi, We are not using multiple scribble widgets but screen orientations happen when building widget. Sharing sample code.
|
Any solution for this ? @timcreatedit I'm also getting this same error. |
@kushal2021 @anaghvj I still can't reproduce. Could you share a minimal example, ideally without any 3rd party dependencies? |
This is the example I'm running now: When switching orientation, everything works fine, no exceptions in the console. import 'package:flutter/material.dart';
import 'package:scribble/scribble.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Scribble',
theme: ThemeData.from(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.purple)),
home: const SignatureView(),
);
}
}
class SignatureView extends StatefulWidget {
const SignatureView({super.key});
@override
State<StatefulWidget> createState() => _SignatureViewState();
}
class _SignatureViewState extends State<SignatureView> {
late ScribbleNotifier notifier;
@override
void initState() {
notifier = ScribbleNotifier();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: SafeArea(
child: Column(
children: [
Text(MediaQuery.of(context).orientation.toString()),
SizedBox(
width:
MediaQuery.of(context).orientation == Orientation.portrait
? MediaQuery.of(context).size.height - 120
: MediaQuery.of(context).size.width - 20,
height:
MediaQuery.of(context).orientation == Orientation.portrait
? MediaQuery.of(context).size.width - 120
: MediaQuery.of(context).size.height - 120,
child: AspectRatio(
aspectRatio: 16 / 9,
child: Container(
clipBehavior: Clip.hardEdge,
decoration: ShapeDecoration(
shape: RoundedRectangleBorder(
side: BorderSide(width: 1, color: Colors.red),
borderRadius: BorderRadius.circular(12),
),
),
child: Scribble(
notifier: notifier,
drawPen: true,
),
),
),
),
],
),
),
),
);
}
}
|
I am not facing this error with minimal code, I am only facing this error with my project's code. I'm implementing same functionality like instagram story create where user can select multiple images and can draw on particular images. If you want then we can connect and trace the issue. |
Getting GlobalKey Error
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:
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:
The text was updated successfully, but these errors were encountered: