-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Refactor StrokeAlign to allow double values. #108339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
f974e4e
Refactor StrokeAlign to allow any value.
bernaferrari d5af3c9
Greg Patch
bernaferrari 0bb6bd5
Patch fixes.
bernaferrari 75bb18d
Make dimensions non-negative.
bernaferrari 3f8e9cb
Add multiple StrokeAlign.
bernaferrari 045c152
Revert "Add multiple StrokeAlign."
bernaferrari 4a20d21
Small fixes.
bernaferrari 39bfb55
Fix StarBorder.
bernaferrari 6e0175f
Remove StrokeAlign. Most painful commit in a while.
bernaferrari ccef943
Fix typo.
bernaferrari d63482b
Refactor sample.
bernaferrari d562415
Rename strokeOffset -> halfStrokeOffset
bernaferrari 7e97fd0
Imprrove documentation.
bernaferrari 97a396d
Fix doc.
bernaferrari aba0366
Fix BoxDecoration with borderRadius.
bernaferrari 30b917f
Re-add StrokeAlign class. It is back. For now.
bernaferrari d1f571e
Fix PR comments.
bernaferrari acb25ac
Fix analyzer.
bernaferrari 1cad490
Rename description
bernaferrari e2e877d
Add "for example".
bernaferrari 172ab57
Fix typo.
bernaferrari 8106006
Bring back BorderSide.strokeAlignInside.
bernaferrari 7aa2408
Fix test
bernaferrari 40f96e5
Fix PR comments.
bernaferrari c6f42aa
Fix redundant import.
bernaferrari 4eda7a3
Fix test (ops).
bernaferrari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,204 @@ | ||
| // 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. | ||
|
|
||
| /// Flutter code sample for [BorderSide]. | ||
|
|
||
| import 'package:flutter/material.dart'; | ||
|
|
||
| void main() => runApp(const BorderSideApp()); | ||
|
|
||
| class BorderSideApp extends StatelessWidget { | ||
| const BorderSideApp({super.key}); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return const MaterialApp(home: BorderSideExample()); | ||
| } | ||
| } | ||
|
|
||
| class BorderSideExample extends StatefulWidget { | ||
| const BorderSideExample({super.key}); | ||
|
|
||
| @override | ||
| State<BorderSideExample> createState() => _BorderSideExampleState(); | ||
| } | ||
|
|
||
| class _BorderSideExampleState extends State<BorderSideExample> | ||
| with TickerProviderStateMixin { | ||
| late final AnimationController animation; | ||
|
|
||
| @override | ||
| void initState() { | ||
| super.initState(); | ||
| animation = | ||
| AnimationController(vsync: this, duration: const Duration(seconds: 1)); | ||
| animation.repeat(reverse: true); | ||
| animation.addListener(_markDirty); | ||
| } | ||
|
|
||
| @override | ||
| void dispose() { | ||
| animation.dispose(); | ||
| super.dispose(); | ||
| } | ||
|
|
||
| void _markDirty() { | ||
| setState(() {}); | ||
| } | ||
|
|
||
| static const double borderWidth = 10; | ||
| static const double cornerRadius = 10; | ||
| static const Color borderColor = Color(0x8000b4fc); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Material( | ||
| child: Center( | ||
| child: Column( | ||
| mainAxisAlignment: MainAxisAlignment.spaceAround, | ||
| children: <Widget>[ | ||
| TestBox( | ||
| shape: StadiumBorder( | ||
| side: BorderSide( | ||
| color: borderColor, | ||
| width: borderWidth, | ||
| strokeAlign: (animation.value * 2) - 1, | ||
| ), | ||
| ), | ||
| ), | ||
| Row( | ||
| mainAxisAlignment: MainAxisAlignment.spaceAround, | ||
| children: <Widget>[ | ||
| TestBox( | ||
| shape: CircleBorder( | ||
| side: BorderSide( | ||
| color: borderColor, | ||
| width: borderWidth, | ||
| strokeAlign: (animation.value * 2) - 1, | ||
| ), | ||
| ), | ||
| ), | ||
| TestBox( | ||
| shape: OvalBorder( | ||
| side: BorderSide( | ||
| color: borderColor, | ||
| width: borderWidth, | ||
| strokeAlign: (animation.value * 2) - 1, | ||
| ), | ||
| ), | ||
| ), | ||
| ], | ||
| ), | ||
| Row( | ||
| mainAxisAlignment: MainAxisAlignment.spaceAround, | ||
| children: <Widget>[ | ||
| TestBox( | ||
| shape: BeveledRectangleBorder( | ||
| side: BorderSide( | ||
| color: borderColor, | ||
| width: borderWidth, | ||
| strokeAlign: (animation.value * 2) - 1, | ||
| ), | ||
| ), | ||
| ), | ||
| TestBox( | ||
| shape: BeveledRectangleBorder( | ||
| borderRadius: BorderRadius.circular(cornerRadius), | ||
| side: BorderSide( | ||
| color: borderColor, | ||
| width: borderWidth, | ||
| strokeAlign: (animation.value * 2) - 1, | ||
| ), | ||
| ), | ||
| ), | ||
| ], | ||
| ), | ||
| Row( | ||
| mainAxisAlignment: MainAxisAlignment.spaceAround, | ||
| children: <Widget>[ | ||
| TestBox( | ||
| shape: RoundedRectangleBorder( | ||
| side: BorderSide( | ||
| color: borderColor, | ||
| width: borderWidth, | ||
| strokeAlign: (animation.value * 2) - 1, | ||
| ), | ||
| ), | ||
| ), | ||
| TestBox( | ||
| shape: RoundedRectangleBorder( | ||
| borderRadius: BorderRadius.circular(cornerRadius), | ||
| side: BorderSide( | ||
| color: borderColor, | ||
| width: borderWidth, | ||
| strokeAlign: (animation.value * 2) - 1, | ||
| ), | ||
| ), | ||
| ), | ||
| ], | ||
| ), | ||
| Row( | ||
| mainAxisAlignment: MainAxisAlignment.spaceAround, | ||
| children: <Widget>[ | ||
| TestBox( | ||
| shape: StarBorder( | ||
| side: BorderSide( | ||
| color: borderColor, | ||
| width: borderWidth, | ||
| strokeAlign: (animation.value * 2) - 1, | ||
| ), | ||
| ), | ||
| ), | ||
| TestBox( | ||
| shape: StarBorder( | ||
| pointRounding: 1, | ||
| innerRadiusRatio: 0.5, | ||
| points: 8, | ||
| side: BorderSide( | ||
| color: borderColor, | ||
| width: borderWidth, | ||
| strokeAlign: (animation.value * 2) - 1, | ||
| ), | ||
| ), | ||
| ), | ||
| TestBox( | ||
| shape: StarBorder.polygon( | ||
| sides: 6, | ||
| pointRounding: 0.5, | ||
| side: BorderSide( | ||
| color: borderColor, | ||
| width: borderWidth, | ||
| strokeAlign: (animation.value * 2) - 1, | ||
| ), | ||
| ), | ||
| ), | ||
| ], | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class TestBox extends StatelessWidget { | ||
| const TestBox({ | ||
| super.key, | ||
| required this.shape, | ||
| }); | ||
|
|
||
| final ShapeBorder shape; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Container( | ||
| width: 100, | ||
| height: 50, | ||
| decoration: ShapeDecoration( | ||
| color: const Color(0xff012677), | ||
| shape: shape, | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or 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,21 @@ | ||
| // 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/painting/borders/border_side.0.dart' | ||
| as example; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
|
|
||
| void main() { | ||
| testWidgets('Finds the expected TestBox', (WidgetTester tester) async { | ||
| await tester.pumpWidget( | ||
| const MaterialApp( | ||
| home: example.BorderSideExample(), | ||
| ), | ||
| ); | ||
|
|
||
| expect(find.byType(example.BorderSideExample), findsOneWidget); | ||
| expect(find.byType(example.TestBox), findsNWidgets(10)); | ||
| }); | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.