Skip to content

[Add2App] No constructor 'Text.' with matching arguments declared in class 'Text'. #109602

Open

Description

@zerryzarax

I'm using flutter module in my existing iOS app. While making changes Text, I use hot reload to see the output. It was working bad, Whether I use an emulator or iphone.(only way it work fine,it‘s using ’flutter run‘ directly rather than using xcode run) its giving me the exception like this:

======== Exception caught by widgets library =======================================================
The following NoSuchMethodError was thrown building ContainerMain(dirty, state: _ContainerMain#f0c96):
No constructor 'Text.' with matching arguments declared in class 'Text'.
Receiver: Text
Tried calling: new Text.()
Found: new Text.(String, {Key? key, TextStyle? style, StrutStyle? strutStyle, TextAlign? textAlign, TextDirection? textDirection, Locale? locale, bool? softWrap, TextOverflow? overflow, double? textScaleFactor, int? maxLines, String? semanticsLabel, TextWidthBasis? textWidthBasis, TextHeightBehavior? textHeightBehavior}) => Text

example code:

void main() {
  runZonedGuarded<Future<Null>>(() async {
    runApp(ContainerMain(inApp: true, appType: global.AppType.xxxxx,));

    }, (dynamic error, StackTrace stackTrace) async {
      if (kReleaseMode) {
        reportError(error, stackTrace);
      }
  });
}
class _ContainerMain extends State<ContainerMain> {
  bool? inApp;

  _ContainerMain({bool inApp = true}) {
    this.inApp = inApp;
  }

  @override
  void initState() {

    if (!this.inApp!) {
      super.initState();
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      // builder: Hybrid.init(),
      home: Container(alignment: Alignment.center, child: Text("tetetet2"), color: Colors.yellow,),
    );
  }
}

evironment:
1、flutter
[✓] Flutter (Channel stable, 3.0.3, on macOS 12.5 21G72 darwin-x64, locale
zh-Hans-CN)
• Flutter version 3.0.3 at /Users/xxxxx/Documents/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 676cefa (8 weeks ago), 2022-06-22 11:34:49 -0700
• Engine revision ffe7b86a1e
• Dart version 2.17.5
• DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version
32.1.0-rc1)
• Android SDK at /Users/xxxxx/Library/Android/sdk
• Platform android-32, build-tools 32.1.0-rc1
• Java binary at: /Applications/Android
Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.

[✓] Android Studio (version 2021.2)
• Android Studio at /Applications/Android Studio.app/Contents
• 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
11.0.12+0-b1504.28-7817840)
in flutter module

Activity

  1. added
    in triagePresently being triaged by the triage team
    on Aug 16, 2022
  2. huycozy commented on Aug 16, 2022

    @huycozy
    Member

    Hi @zerryzarax
    From the logs:

    Receiver: Text
    Tried calling: new Text.()

    It looks like it's caused by a syntax error. It should be Text() rather than Text.().
    So, try correcting it to see if the issue is still reproducible. Thanks!

  3. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 16, 2022
  4. zerryzarax commented on Aug 17, 2022

    @zerryzarax
    Author

    hi @huycozy
    If it is like you said, the direct build should report an error, but the direct build can run normally, and the interface looks normal. And I use 'flutter attach' in the direct build mode of xcode, and then I just change 'Text("tetetet")' to 'Text("tetetet2"), and then use android studio to save the file to trigger hot reload. As a result, the above error was triggered. I suspect there is something wrong in xcode_backend.dart. Is it inconsistent with the code that android studio directly triggers flutter run?
    thank you for your reply

  5. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 17, 2022
  6. zerryzarax commented on Aug 18, 2022

    @zerryzarax
    Author

    At present, I have found a temporary adaptation solution:

    1. Must use 'FlutterEngineGroup'
    2. App needs to support hot restart mode
    3. When saving a file in android studio to trigger hot reload, although an error will be reported, only one hot restart is required, so that hot reload can also be used normally.
  7. exaby73 commented on Aug 18, 2022

    @exaby73
    Member

    Hello @zerryzarax. Thank you for the information. Can you provide a minimal, reproducible example in the form of a public repository so that we can investigate this issue?

  8. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 18, 2022
  9. zerryzarax commented on Aug 21, 2022

    @zerryzarax
    Author

    Hello @zerryzarax. Thank you for the information. Can you provide a minimal, reproducible example in the form of a public repository so that we can investigate this issue?

    hi @exaby73 ,there is a bug demo,https://github.com/zerryzarax/flutter-3.0.3-bug-test-demo

  10. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 21, 2022
  11. exaby73 commented on Aug 22, 2022

    @exaby73
    Member

    @zerryzarax I am unable to run the project you have provided. Could you provide some steps to run the project which has caused you to get this error?

  12. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 22, 2022
  13. zerryzarax commented on Aug 22, 2022

    @zerryzarax
    Author

    @exaby73
    The following are the steps to run the project:

    1. Download the bug demo source code
    2. Use android studio to open the path/to/flutter_bug_demo/dart_demo directory
    3. Use the "flutter pub get" command in the terminal of android studio until the successful prompt appears
    4. On the computer terminal "cd path/to/XcodeFlutterEngineGroupDemo", then "pod install". If cocospod is not installed, you need to install it
    5. Use xcode to open XcodeFlutterEngineGroupDemo.xcworkspace in the XcodeFlutterEngineGroupDemo directory, and run the simulator directly
    6. Click the program "打开flutter页面", you can see the flutter debug prompt
    7. The dart_demo project of android studio, "flutter attach" program running in the emulator
    8. When the attach is successful, you can modify the Text("testtest2") to Text("testtest3") in the container.dart file under the dart_demo project, and then save the changes to trigger hot reload, so that you can see the error.
  14. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 22, 2022
  15. huycozy commented on Aug 23, 2022

    @huycozy
    Member

    Hi @zerryzarax, thanks for providing very detailed steps to reproduce.

    Demo (screenshot)
    Logs
    ➜  dart_demo git:(main) flutter attach
    Multiple devices found:
    iPhone (mobile)    • d9a94afe2b649fef56ba0bfeb052f0f2a7dae95e • ios • iOS 15.5 19F77
    iPhone 13 (mobile) • 2526BC1A-435D-4B08-B99C-44B928F2517B     • ios • com.apple.CoreSimulator.SimRuntime.iOS-15-4 (simulator)
    [1]: iPhone (d9a94afe2b649fef56ba0bfeb052f0f2a7dae95e)
    [2]: iPhone 13 (2526BC1A-435D-4B08-B99C-44B928F2517B)
    Please choose one (To quit, press "q/Q"): 2
    Syncing files to device iPhone 13...                                8.1s
    
    Flutter run key commands.
    r Hot reload. 🔥🔥🔥
    R Hot restart.
    h List all available interactive commands.
    d Detach (terminate "flutter run" but leave application running).
    c Clear the screen
    q Quit (terminate the application on the device).
    
    💪 Running with sound null safety 💪
    
    An Observatory debugger and profiler on iPhone 13 is available at: http://127.0.0.1:53510/QmQvQYXYoMY=/
    The Flutter DevTools debugger and profiler on iPhone 13 is available at: http://127.0.0.1:9100?uri=http://127.0.0.1:53510/QmQvQYXYoMY=/
    
    
    ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
    The following NoSuchMethodError was thrown building ContainerMain(dirty, state:
    _ContainerMain#a57e2):
    No constructor 'Text.' with matching arguments declared in class 'Text'.
    Receiver: Text
    Tried calling: new Text.()
    Found: new Text.(String, {Key? key, TextStyle? style, StrutStyle? strutStyle, TextAlign? textAlign,
    TextDirection? textDirection, Locale? locale, bool? softWrap, TextOverflow? overflow, double?
    textScaleFactor, int? maxLines, String? semanticsLabel, TextWidthBasis? textWidthBasis,
    TextHeightBehavior? textHeightBehavior}) => Text
    
    Widget creation tracking is currently disabled. Enabling it enables improved error messages. It can
    be enabled by passing `--track-widget-creation` to `flutter run` or `flutter test`.
    
    When the exception was thrown, this was the stack:
    #0      NoSuchMethodError._throwNew (dart:core-patch/errors_patch.dart:216:5)
    #1      _ContainerMain.build (package:dart_demo/container.dart)
    #2      StatefulElement.build (package:flutter/src/widgets/framework.dart:4919:27)
    #3      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4806:15)
    #4      StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4977:11)
    #5      Element.rebuild (package:flutter/src/widgets/framework.dart:4529:5)
    #6      BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2659:19)
    #7      WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:891:21)
    #8      RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:370:5)
    #9      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1146:15)
    #10     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1083:9)
    #11     SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:864:7)
    (elided 4 frames from class _RawReceivePortImpl, class _Timer, and dart:async-patch)
    
    ════════════════════════════════════════════════════════════════════════════════════════════════════
    Performing hot reload...                                                
    Reloaded 1 of 586 libraries in 426ms.
    flutter doctor -v
    [✓] Flutter (Channel stable, 3.0.5, on macOS 12.2.1 21D62 darwin-x64, locale en-VN)
        • Flutter version 3.0.5 at /Users/huynq/Documents/GitHub/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision f1875d570e (9 hours ago), 2022-07-13 11:24:16 -0700
        • Engine revision e85ea0e79c
        • Dart version 2.17.6
        • DevTools version 2.12.2
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /Users/huynq/Library/Android/sdk
        • Platform android-33, build-tools 31.0.0
        • ANDROID_HOME = /Users/huynq/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 13.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2021.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • 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 11.0.12+0-b1504.28-7817840)
    
    [✓] IntelliJ IDEA Community Edition (version 2020.3.3)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • 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
    
    [✓] IntelliJ IDEA Community Edition (version 2022.1.1)
        • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app
        • 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
    
    [✓] VS Code (version 1.69.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.44.0
    
    [✓] Connected device (3 available)
        • SM T225 (mobile) • R9JT3004VRJ • android-arm64  • Android 11 (API 30)
        • macOS (desktop)  • macos       • darwin-x64     • macOS 12.2.1 21D62 darwin-x64
        • Chrome (web)     • chrome      • web-javascript • Google Chrome 103.0.5060.114
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    
    [✓] Flutter (Channel master, 3.1.0-0.0.pre.2428, on macOS 12.5 21G72 darwin-x64, locale en-EE)
        • Flutter version 3.1.0-0.0.pre.2428 on channel master at /Users/huynq/Documents/GitHub/flutter_master
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 328545e5af (40 minutes ago), 2022-08-22 22:31:06 -0400
        • Engine revision ca48808d06
        • Dart version 2.19.0 (build 2.19.0-124.0.dev)
        • DevTools version 2.16.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /Users/huynq/Library/Android/sdk
        • Platform android-33, build-tools 31.0.0
        • ANDROID_HOME = /Users/huynq/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 13.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 13E113
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2021.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • 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 11.0.12+0-b1504.28-7817840)
    
    [✓] IntelliJ IDEA Community Edition (version 2020.3.3)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • 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
    
    [✓] IntelliJ IDEA Community Edition (version 2022.1.1)
        • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app
        • 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
    
    [✓] VS Code (version 1.70.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.46.0
    
    [✓] Connected device (3 available)
        • iPhone 13 (mobile) • 2526BC1A-435D-4B08-B99C-44B928F2517B • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-4 (simulator)
        • macOS (desktop)    • macos                                • darwin-x64     • macOS 12.5 21G72 darwin-x64
        • Chrome (web)       • chrome                               • web-javascript • Google Chrome 104.0.5112.101
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    
  16. 3 remaining items

  17. added
    a: existing-appsIntegration with existing apps via the add-to-app flow
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Aug 23, 2022
  18. changed the title [-]flutter 3.0.3, No constructor 'Text.' with matching arguments declared in class 'Text'.[/-] [+][Add2App] No constructor 'Text.' with matching arguments declared in class 'Text'.[/+] on Aug 23, 2022
  19. added
    P2Important issues not at the top of the work list
    on Aug 23, 2022
  20. jmagman commented on Aug 23, 2022

    @jmagman
    Member

    Not sure why the String arg isn't being passed through to the constructor, I can see arguments and argumentNames is nil when NoSuchMethodError is thrown.

      // The compiler emits a call to _throwNew when it cannot resolve a static
      // method at compile time. The receiver is actually the literal class of the
      // unresolved method.
      @pragma("vm:entry-point", "call")
      static void _throwNew(
          Object receiver,
          String memberName,
          int invocationType,
          int typeArgumentsLength,
          Object? typeArguments,
          List? arguments,
          List? argumentNames) {
        throw new NoSuchMethodError._withType(receiver, memberName, invocationType,
            typeArgumentsLength, typeArguments, arguments, argumentNames);
      }

    This doesn't reproduce from the Flutter module, just from the embedded add-to-app case.
    @rmacnak-google do you know what's going on here? https://dart-review.googlesource.com/c/sdk/+/143541

  21. a-siva commented on Sep 15, 2023

    @a-siva
    Contributor

    //cc @rmacnak-google a hot reload issue, though not sure why it should be an iOS only problem.

  22. afradahsan commented on Nov 16, 2023

    @afradahsan

    //cc @rmacnak-google a hot reload issue, though not sure why it should be an iOS only problem.

    I'm facing the issue on my android device.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: existing-appsIntegration with existing apps via the add-to-app flowc: crashStack traces logged to the consoledependency: dartDart team may need to help usfound in release: 3.0Found to occur in 3.0found in release: 3.1Found to occur in 3.1has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions