forked from flutter/packages
-
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.
Fix DecoratedSliver sample code to reflect the description (#148621)
### Demo screenshot ![Screenshot 2024-05-19 at 05 42 35](https://github.com/flutter/flutter/assets/104349824/6b4aec1f-32ab-496e-ab20-458c2051055d) ### Related issue - Fixes flutter/flutter#145935 - Add test for `examples/api/test/widgets/sliver/decorated_sliver.0_test.dart` as a part of flutter/flutter#130459.
- Loading branch information
Showing
3 changed files
with
131 additions
and
10 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
74 changes: 74 additions & 0 deletions
74
examples/api/test/widgets/sliver/decorated_sliver.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,74 @@ | ||
// 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/widgets/sliver/decorated_sliver.0.dart' as example; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
testWidgets('Verify the texts are displayed', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
const example.SliverDecorationExampleApp(), | ||
); | ||
|
||
final Finder moonText = find.text('A moon on a night sky'); | ||
expect(moonText, findsOneWidget); | ||
|
||
final Finder blueSkyText = find.text('A blue sky'); | ||
expect(blueSkyText, findsOneWidget); | ||
}); | ||
|
||
testWidgets('Verify the sliver with key `radial-gradient` has a RadialGradient', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
const example.SliverDecorationExampleApp(), | ||
); | ||
|
||
final DecoratedSliver radialDecoratedSliver = tester.widget<DecoratedSliver>( | ||
find.byKey(const ValueKey<String>('radial-gradient')), | ||
); | ||
expect( | ||
radialDecoratedSliver.decoration, | ||
const BoxDecoration( | ||
gradient: RadialGradient( | ||
center: Alignment(-0.5, -0.6), | ||
radius: 0.15, | ||
colors: <Color>[ | ||
Color(0xFFEEEEEE), | ||
Color(0xFF111133), | ||
], | ||
stops: <double>[0.4, 0.8], | ||
), | ||
), | ||
); | ||
}); | ||
|
||
testWidgets('Verify that the sliver with key `linear-gradient` has a LinearGradient', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
const example.SliverDecorationExampleApp(), | ||
); | ||
|
||
final DecoratedSliver linearDecoratedSliver = tester.widget<DecoratedSliver>( | ||
find.byKey(const ValueKey<String>('linear-gradient')), | ||
); | ||
expect( | ||
linearDecoratedSliver.decoration, | ||
const BoxDecoration( | ||
gradient: LinearGradient( | ||
begin: Alignment.topCenter, | ||
end: Alignment.bottomCenter, | ||
colors: <Color>[ | ||
Color(0xFF111133), | ||
Color(0xFF1A237E), | ||
Color(0xFF283593), | ||
Color(0xFF3949AB), | ||
Color(0xFF3F51B5), | ||
Color(0xFF1976D2), | ||
Color(0xFF1E88E5), | ||
Color(0xFF42A5F5), | ||
], | ||
), | ||
), | ||
); | ||
}); | ||
} |