Updated the TextButton image button example artwork (#144583)
Updated the "smiley" TextButton example with new images from Nancy Hu @google. I also made the example a little more complicated, per the new artwork: now it displays a different image while the button's action pretends to run for a second. https://github.com/flutter/flutter/assets/1377460/b631a484-4b4f-4e01-ad52-a877fb46ef72
This commit is contained in:
@@ -54,9 +54,25 @@ void main() {
|
||||
await tester.tap(find.widgetWithText(TextButton, 'TextButton #8'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byType(TextButton).last); // Smiley image button
|
||||
final Finder smileyButton = find.byType(TextButton).last;
|
||||
await tester.tap(smileyButton); // Smiley image button
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
String smileyButtonImageUrl() {
|
||||
final AnimatedContainer container = tester.widget<AnimatedContainer>(
|
||||
find.descendant(of: smileyButton, matching: find.byType(AnimatedContainer)),
|
||||
);
|
||||
final BoxDecoration decoration = container.decoration! as BoxDecoration;
|
||||
final NetworkImage image = decoration.image!.image as NetworkImage;
|
||||
return image.url;
|
||||
}
|
||||
// The smiley button's onPressed method changes the button image
|
||||
// for one second to simulate a long action running. The button's
|
||||
// image changes while the action is running.
|
||||
expect(smileyButtonImageUrl().endsWith('text_button_nhu_end.png'), isTrue);
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
expect(smileyButtonImageUrl().endsWith('text_button_nhu_default.png'), isTrue);
|
||||
|
||||
await tester.tap(find.byType(Switch).at(0)); // Dark Mode Switch
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user