Skip to content
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

"Duplicate GlobalKey detected in widget tree" when used with flutter_html #89

Open
MikesDevCorner opened this issue Jul 15, 2023 · 3 comments

Comments

@MikesDevCorner
Copy link

Steps to recreate:

import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:liquid_swipe/liquid_swipe.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: Scaffold(
        appBar: AppBar(
          backgroundColor: Theme.of(context).colorScheme.inversePrimary,
          title: const Text('Test Title'),
        ),
        body: LiquidSwipe(
          pages: [
            Container(
              color: Colors.purple,
              width: double.infinity,
              height: double.infinity,
              child: const Center(
                child: Text('Test'),
              ),
            ),
            Container(
              color: Colors.amber,
              width: double.infinity,
              height: double.infinity,
              child: Center(
                child: Html(
                  data: '<div class="center">TEST ABC</div>',
                  style: {
                    ".center": Style(
                      textAlign: TextAlign.center,
                    ),
                  },
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}

Look at this example and tap or drag on the rendered html, the following exception occurs:

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:
- [GlobalKey#25af9]
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:
- Html(state: _HtmlState#279ad)
A GlobalKey can only be specified on one widget at a time in the widget tree.

Would be very cool if these two widgets work together :)
Thanks, M

@github-actions
Copy link

Hey, Thanks for creating the first issue. I will respond in a day or two. If doesn't, feel free to ping me.

@MikesDevCorner
Copy link
Author

@iamSahdeep hi, ping 🔔☺️

@iamSahdeep
Copy link
Owner

Hi @MikesDevCorner Let me get on it this weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants