flutter_eval icon indicating copy to clipboard operation
flutter_eval copied to clipboard

Compile error when using Navigator.push in patch

Open tusharsainx opened this issue 11 months ago • 0 comments

Flutter version: 3.22.3 dart_eval: 0.7.10 flutter_eval: 0.7.6 Below is the patch I am trying to compile

import 'package:eval_annotation/eval_annotation.dart';
import 'package:flutter/material.dart';
import 'package:testingpatch/page_changer/page1.dart';
import 'package:testingpatch/page_changer/page2.dart';

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('My Home Page')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const Text('Remote data fetched successfully!!'),
            ElevatedButton(
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (context) => const Page1(),
                  ),
                );
              },
              child: const Text('Go to Page 1'),
            ),
            ElevatedButton(
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (context) => const Page2(),
                  ),
                );
              },
              child: const Text('Go to Page 2'),
            ),
            const SizedBox(height: 20),
          ],
        ),
      ),
    );
  }
}

@RuntimeOverride('#myHomePage')
Widget myHomePageUpdate(BuildContext context) {
  return const MyHomePage();
}

CompileError: Cannot find static method Navigator.push at unknown (file package:testingpatch/testingpatch.dart) #0 resolveStaticMethod (package:dart_eval/src/eval/compiler/expression/method_invocation.dart:393:3) #1 _invokeWithTarget (package:dart_eval/src/eval/compiler/expression/method_invocation.dart:256:12) #2 compileMethodInvocation (package:dart_eval/src/eval/compiler/expression/method_invocation.dart:55:12) #3 compileExpression (package:dart_eval/src/eval/compiler/expression/expression.dart:38:12) #4 compileExpressionAndDiscardResult (package:dart_eval/src/eval/compiler/expression/expression.dart:106:12) #5 compileStatement (package:dart_eval/src/eval/compiler/statement/statement.dart:26:15) #6 compileBlock (package:dart_eval/src/eval/compiler/statement/block.dart:19:20) #7 compileFunctionExpression (package:dart_eval/src/eval/compiler/expression/function.dart:92:14) #8 compileExpression (package:dart_eval/src/eval/compiler/expression/expression.dart:54:12) #9 compileArgumentListWithBridge (package:dart_eval/src/eval/compiler/helpers/argument_list.dart:369:18) #10 compileMethodInvocation (package:dart_eval/src/eval/compiler/expression/method_invocation.dart:130:22) #11 compileExpression (package:dart_eval/src/eval/compiler/expression/expression.dart:38:12) #12 compileListElement (package:dart_eval/src/eval/compiler/collection/list.dart:137:19) #13 compileListLiteral (package:dart_eval/src/eval/compiler/collection/list.dart:56:24) #14 parseLiteral (package:dart_eval/src/eval/compiler/expression/literal.dart:43:12) #15 compileExpression (package:dart_eval/src/eval/compiler/expression/expression.dart:32:12) #16 compileArgumentListWithBridge (package:dart_eval/src/eval/compiler/helpers/argument_list.dart:369:18) #17 compileMethodInvocation (package:dart_eval/src/eval/compiler/expression/method_invocation.dart:130:22) #18 compileExpression (package:dart_eval/src/eval/compiler/expression/expression.dart:38:12) #19 compileArgumentListWithBridge (package:dart_eval/src/eval/compiler/helpers/argument_list.dart:369:18) #20 compileMethodInvocation (package:dart_eval/src/eval/compiler/expression/method_invocation.dart:130:22) #21 compileExpression (package:dart_eval/src/eval/compiler/expression/expression.dart:38:12) #22 compileArgumentListWithBridge (package:dart_eval/src/eval/compiler/helpers/argument_list.dart:369:18) #23 compileMethodInvocation (package:dart_eval/src/eval/compiler/expression/method_invocation.dart:130:22) #24 compileExpression (package:dart_eval/src/eval/compiler/expression/expression.dart:38:12) #25 compileReturn (package:dart_eval/src/eval/compiler/statement/return.dart:24:9) #26 compileStatement (package:dart_eval/src/eval/compiler/statement/statement.dart:32:12) #27 compileBlock (package:dart_eval/src/eval/compiler/statement/block.dart:19:20) #28 compileMethodDeclaration (package:dart_eval/src/eval/compiler/declaration/method.dart:56:14) #29 compileDeclaration (package:dart_eval/src/eval/compiler/declaration/declaration.dart:21:12) #30 compileClassDeclaration (package:dart_eval/src/eval/compiler/declaration/class.dart:47:5) #31 compileDeclaration (package:dart_eval/src/eval/compiler/declaration/declaration.dart:17:5) #32 Compiler.compileSources.. (package:dart_eval/src/eval/compiler/compiler.dart:492:11) #33 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633:13) #34 Compiler.compileSources. (package:dart_eval/src/eval/compiler/compiler.dart:481:15) #35 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633:13) #36 Compiler.compileSources (package:dart_eval/src/eval/compiler/compiler.dart:477:32) #37 Compiler.compile (package:dart_eval/src/eval/compiler/compiler.dart:163:12) #38 cliCompile (package:dart_eval/src/eval/cli/compile.dart:126:34) #39 main (file:///Users/tushar.saini/.pub-cache/hosted/pub.dev/dart_eval-0.7.10/bin/dart_eval.dart:71:5) #40 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:295:33) #41 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

@ethanblake4 and team, any help would be appreciated.

tusharsainx avatar Feb 12 '25 10:02 tusharsainx