Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Web]: Hot restart throws Assertion Failure using nested MaterialApp on latest stable and master. #83864

@chitoadinugraha

Description

@chitoadinugraha

Steps to Reproduce

  1. run this code
import 'package:flutter/material.dart';

void main() {
  runApp(ParentApp());
}

class ParentApp extends StatelessWidget {
  const ParentApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      darkTheme: ThemeData(brightness: Brightness.dark),
      themeMode: ThemeMode.dark,
      home: Scaffold(
        appBar: AppBar(
          title: Text('Parent Material'),
        ),
        body: Center(
            child: Container(width: 300, height: 400, child: ChildApp())),
        endDrawer: Drawer(child: Text('Drawer Content x')),
      ),
    );
  }
}

class ChildApp extends StatelessWidget {
  const ChildApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(brightness: Brightness.light),
      themeMode: ThemeMode.light,
      home: Scaffold(
        appBar: AppBar(
          title: Text('Child Material'),
        ),
        body: Builder(builder: (context) {
          return Center(
            child: ElevatedButton(
              onPressed: () {
                Scaffold.of(context).openDrawer();
              },
              child: Text('show drawer'),
            ),
          );
        }),
        drawer: ChildDrawerTest(),
      ),
    );
  }
}

class ChildDrawerTest extends StatelessWidget {
  const ChildDrawerTest({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Drawer(
      child: Text('Drawer '),
    );
  }
}

  1. Run using chrome
  2. Change something
  3. Hot reload stuck

Expected results: Hot reload working on save

Actual results: Hot reload stuck

Logs
[   +1 ms] Error: Assertion failed: org-dartlang-sdk:///flutter_web_sdk/lib/_engine/engine/navigation/history.dart:284:14        
           _userProvidedRouteName != null
           is not true
               at Object.throw_ [as throw] (http://localhost:51909/dart_sdk.js:5041:11)
               at Object.assertFailed (http://localhost:51909/dart_sdk.js:4980:15)
               at _engine.SingleEntryBrowserHistory.new.onPopState (http://localhost:51909/dart_sdk.js:141776:59)
flutter analyze
Analyzing test_multimaterial...                                         
No issues found! (ran in 1.1s)
 flutter doctor -v
[√] Flutter (Channel stable, 2.2.1, on Microsoft Windows [Version 10.0.19042.985], locale en-US)
    • Flutter version 2.2.1 at C:\flutter
    • Framework revision 02c026b03c (6 days ago), 2021-05-27 12:24:44 -0700
    • Engine revision 0fdb562ac8
    • Dart version 2.13.1

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3) 
    • Android SDK at C:\Users\Chito\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java       
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 4.1.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.56.2)
    • VS Code at C:\Users\Chito\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.22.0

[√] Connected device (3 available)
    • sdk gphone x86 arm (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • Chrome (web)                • chrome        • web-javascript • Google Chrome 90.0.4430.212
    • Edge (web)                  • edge          • web-javascript • Microsoft Edge 91.0.864.37

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: error messageError messages from the Flutter frameworkengineflutter/engine related. See also e: labels.f: material designflutter/packages/flutter/material repository.found in release: 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versiont: hot reloadReloading code during "flutter run"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions