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

TextInput can try to make a child into a parent of itself #23

Closed
tvolkert opened this issue Aug 13, 2021 · 2 comments
Closed

TextInput can try to make a child into a parent of itself #23

tvolkert opened this issue Aug 13, 2021 · 2 comments

Comments

@tvolkert
Copy link
Owner

cace425 introduced the a bug in TextInput that manifests as the following exception:

Tried to make a child into a parent of itself.
'package:flutter/src/widgets/focus_manager.dart':
Failed assertion: line 1041 pos 12: 'child != this'
@tvolkert
Copy link
Owner Author

Reproducible with the following test:

import 'dart:ui' as ui;

import 'package:chicago/chicago.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  Widget wrap(Widget child) {
    return Localizations(
      locale: Locale('en', 'US'),
      delegates: [
        DefaultWidgetsLocalizations.delegate,
        DefaultMaterialLocalizations.delegate,
      ],
      child: MediaQuery(
        data: MediaQueryData.fromWindow(ui.window),
        child: Directionality(
          textDirection: TextDirection.ltr,
          child: Material(
            child: Navigator(
              onGenerateRoute: (RouteSettings settings) {
                return MaterialPageRoute<void>(
                  settings: settings,
                  builder: (BuildContext context) => child,
                );
              },
            ),
          ),
        ),
      ),
    );
  }

  testWidgets('Can render a TextInput with an onKeyEvent handler', (WidgetTester tester) async {
    await tester.pumpWidget(wrap(
      TextInput(onKeyEvent: (RawKeyEvent event) {}),
    ));
    expect(find.byType(TextInput), findsOneWidget);
  });
}

tvolkert added a commit that referenced this issue Aug 13, 2021
@tvolkert
Copy link
Owner Author

As of 43f302e, the aforementioned test is checked in, and fails at Tot

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

1 participant