simc / auto_size_text

Flutter widget that automatically resizes text to fit perfectly within its bounds.
https://pub.dev/packages/auto_size_text
MIT License
2.06k stars 241 forks source link

AutoSizeText cannot be properly tested in Integration tests #27

Closed vishaldhudum closed 5 years ago

vishaldhudum commented 5 years ago

Is your feature request related to a problem? Please describe. AutoSizeText has a key, but using the key we cannot get text in Integration test. As await driver.getText(finder) can get text from a Text type widget and not from custom widget which is not a subtype of text.

Though we can do await driver.waitFor(find.text("text")); but this is not appropriate as a page can have multiple places with same text and it is best to find text using a key finder.

Describe the solution you'd like Passing a separate key parameter in AutoSizeText widget for the Text widget defined inside AutoSizeText library can let us find the text from the key for Text widget.

Version

Error:

DriverError: Error in Flutter application: Uncaught extension error while executing get_text: type 'AutoSizeText' is not a subtype of type 'Text'
  #0      FlutterDriverExtension._getText (package:flutter_driver/src/extension/extension.dart:446:16)
  <asynchronous suspension>
  #1      FlutterDriverExtension.call (package:flutter_driver/src/extension/extension.dart:188:53)
  <asynchronous suspension>
  #2      BindingBase.registerServiceExtension.<anonymous closure> (package:flutter/src/foundation/binding.dart:512:32)
  <asynchronous suspension>
  #3      _runExtension (dart:developer-patch/developer.dart:84:23)

  Original error: null
  Original stack trace:
  null
simc commented 5 years ago

Would a textKey which is being passed to the actual Text widget solve your problem?

vishaldhudum commented 5 years ago

Yes it will.

simc commented 5 years ago

Okay, I'll implement that asap. You can also create a pull request if you need it faster 👍

vishaldhudum commented 5 years ago

I have updated and used as local library. I see you have already updated the code. Please update here once you release it. Thanks

simc commented 5 years ago

Before I can publish it, I want to create a few more tests. I'll close this issue once the new version is live.

simc commented 5 years ago

I just published a new version: https://pub.dev/packages/auto_size_text/versions/2.1.0