question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

debugger seems to auto hot reload after hot restart

See original GitHub issue

Describe the bug

Run the follow simple code:

import 'package:flutter/material.dart';

class TestWidgetLifeCycle extends StatefulWidget {
  TestWidgetLifeCycle({Key key}) : super(key: key);

  @override
  _TestWidgetLifeCycleState createState() => _TestWidgetLifeCycleState();
}

class _TestWidgetLifeCycleState extends State<TestWidgetLifeCycle> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Widget Life Cycle'),
      ),
      body: Column(
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: [
              ElevatedButton(
                onPressed: () {
                  setState(() {});
                },
                child: Text('setState'),
              )
            ],
          ),
          _TestStatefulWidgetLifeCycle(),
        ],
      ),
    );
  }
}

class _TestStatefulWidgetLifeCycle extends StatefulWidget {
  _TestStatefulWidgetLifeCycle({Key key}) : super(key: key) {
    print('[#${identityHashCode(this)}][stateful widget] call constructor!');
  }

  @override
  StatefulElement createElement() {
    print('[#${identityHashCode(this)}][stateful widget] call createElement!');
    return super.createElement();
  }

  @override
  __TestStatefulWidgetLifeCycleState createState() {
    print('[#${identityHashCode(this)}][stateful widget] call create state!');
    return __TestStatefulWidgetLifeCycleState();
  }
}

class __TestStatefulWidgetLifeCycleState
    extends State<_TestStatefulWidgetLifeCycle> {
  @override
  void initState() {
    super.initState();
    print('[#${identityHashCode(this)}][stateful widget state] init state!');
  }

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    print(
        '[#${identityHashCode(this)}][stateful widget state] call didChangeDependencies!');
  }

  @override
  void didUpdateWidget(covariant _TestStatefulWidgetLifeCycle oldWidget) {
    super.didUpdateWidget(oldWidget);
    print(
        '[#${identityHashCode(this)}][stateful widget state] call didUpdateWidget!');
  }

  @override
  void dispose() {
    print('[#${identityHashCode(this)}][stateful widget state] dispose!');
    super.dispose();
  }

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

The Stateful Widget seems to be updated caused by run command hot reload:

image

If I run hot reload, result in:

image

Versions (please complete the following information):

  • VS Code version: 1.55.0-insider (Universal)
  • Dart extension version: v3.20.1
  • Dart/Flutter SDK version: Flutter 2.0.3, Dart 2.12.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
DanTupcommented, Apr 13, 2021

I’m not sure what changed to fix it, but glad it seems to be resolved. If it comes back, please let me know. Thanks!

0reactions
tjx666commented, Apr 13, 2021

This seems to be fixed in latest extension.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Write and debug code by using Hot Reload - Visual Studio ...
Open a project based on a supported application type. · Make sure that Enable native code debugging is disabled in the debugger settings...
Read more >
Hot reload - Flutter documentation
Only Flutter apps in debug mode can be hot reloaded or hot restarted. Modify one of the Dart files in your project. Most...
Read more >
Debug sessions often terminate during a hot restart after ...
Describe the bug Hot reload works flawlessly on 1.65.2 but upgrading to 1.66 cause frequent disconnection of debugger after few seconds.
Read more >
VSCode hot reload for Flutter does not work - Stack Overflow
To solve the issue first close the running debugging session using Shift+f5. Then click debug from the menu bar. Click Start without debugging....
Read more >
Edit running code with Hot Reload - JetBrains Rider
Hot Reload, also known as Edit & Continue. Learn how to make changes while running and debugging without restarting the session.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found