forked from flutter/plugins
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DropdownButton
: Update selectedItemBuilder
example to show case i…
…tem alignment and update DropdownButton examples (#102748)
- Loading branch information
1 parent
cd6b2a3
commit 9489b64
Showing
6 changed files
with
173 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
examples/api/test/material/dropdown/dropdown_button.0_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2014 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_api_samples/material/dropdown/dropdown_button.0.dart' as example; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
testWidgets('Select an item from DropdownButton', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
const MaterialApp( | ||
home: Scaffold( | ||
body: example.DropdownButtonApp(), | ||
), | ||
), | ||
); | ||
|
||
expect(find.text('One'), findsOneWidget); | ||
|
||
await tester.tap(find.text('One')); | ||
await tester.pumpAndSettle(); | ||
await tester.tap(find.text('Two').last); | ||
await tester.pumpAndSettle(); | ||
expect(find.text('Two'), findsOneWidget); | ||
}); | ||
} |
27 changes: 27 additions & 0 deletions
27
examples/api/test/material/dropdown/dropdown_button.selected_item_builder.0_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2014 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_api_samples/material/dropdown/dropdown_button.selected_item_builder.0.dart' as example; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
testWidgets('Select an item from DropdownButton', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
const MaterialApp( | ||
home: Scaffold( | ||
body: example.DropdownButtonApp(), | ||
), | ||
), | ||
); | ||
|
||
expect(find.text('NYC'), findsOneWidget); | ||
|
||
await tester.tap(find.text('NYC')); | ||
await tester.pumpAndSettle(); | ||
await tester.tap(find.text('San Francisco').last); | ||
await tester.pumpAndSettle(); | ||
expect(find.text('SF'), findsOneWidget); | ||
}); | ||
} |
28 changes: 28 additions & 0 deletions
28
examples/api/test/material/dropdown/dropdown_button.style.0_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2014 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_api_samples/material/dropdown/dropdown_button.style.0.dart' as example; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
testWidgets('Select an item from DropdownButton', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
const MaterialApp( | ||
home: Scaffold( | ||
body: example.DropdownButtonApp(), | ||
), | ||
), | ||
); | ||
|
||
expect(find.text('One'), findsNWidgets(4)); | ||
|
||
await tester.tap(find.text('One').first); | ||
await tester.pumpAndSettle(); | ||
expect(find.text('Two'), findsOneWidget); | ||
await tester.tap(find.text('Two')); | ||
await tester.pumpAndSettle(); | ||
expect(find.text('Two'), findsNWidgets(4)); | ||
}); | ||
} |