rrousselGit / flutter_hooks

React hooks for Flutter. Hooks are a new kind of object that manages a Widget life-cycles. They are used to increase code sharing between widgets and as a complete replacement for StatefulWidget.
MIT License
3.07k stars 175 forks source link

Issue with debugging variable values in Flutter widgets created using flutter_hooks in VS Code #359

Closed fangkyi03 closed 1 year ago

fangkyi03 commented 1 year ago

Problem Description: I encountered an issue while debugging in VS Code. I created a Flutter widget using the flutter_hooks library. However, when I try to inspect the values of variables, VS Code shows an error message: : . This problem does not occur when I create widgets without using flutter_hooks.

Reproducible Code:

import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';

class MyWidget extends HookWidget {
  @override
  Widget build(BuildContext context) {
    final count = useState(0);

    return Scaffold(
      appBar: AppBar(
        title: Text('My Widget'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text('Count: ${count.value}'),
            ElevatedButton(
              onPressed: () => count.value++,
              child: Text('Increment'),
            ),
          ],
        ),
      ),
    );
  }
}

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Hooks Debug Issue',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyWidget(),
    );
  }
}

Please help me resolve this issue. Thank you!

fangkyi03 commented 1 year ago
image

Flutter 3.10.3 • channel stable • https://github.com/flutter/flutter.git Framework • revision f92f44110e (4 周前) • 2023-06-01 18:17:33 -0500 Engine • revision 2a3401c9bb Tools • Dart 3.0.3 • DevTools 2.23.1 mac m1 13.4.1 (22F82)

rrousselGit commented 1 year ago

This isn't really a flutter_hooks issue.

I'd suggest making an issue on the devtool or sdk repo instead.

fangkyi03 commented 1 year ago

However, flutter_hooks only have this problem again and it hasn't happened in previous versions. I haven't had this problem since 2.0 to 3.0. I recently upgraded to 3.10 and upgraded the hooks at the same time so it's completely unusable