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

Extracted Widget Lacks Access to error Variable, Causing Undefined Name Error #59787

Open
stephane-archer opened this issue Dec 21, 2024 · 0 comments
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.

Comments

@stephane-archer
Copy link

stephane-archer commented Dec 21, 2024

      error: (error, stackTrace) => Center(
        child: Text(
          'Error: $error',
          style: const TextStyle(color: CupertinoColors.systemRed),
        ),
      ),

extract the widget on the Center widget

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

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Text(
        'Error: $error',
        style: const TextStyle(color: CupertinoColors.systemRed),
      ),
    );
  }
}

Undefined name 'error'. Try correcting the name to one that is defined, or defining the name.

expected code:

class FavoriteFoldersErrorWidget extends StatelessWidget {
  final Object error;
  const FavoriteFoldersErrorWidget({
    required this.error,
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Text(
        'Error: $error',
        style: const TextStyle(color: CupertinoColors.systemRed),
      ),
    );
  }
}
@stephane-archer stephane-archer added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
Projects
None yet
Development

No branches or pull requests

1 participant