-
Notifications
You must be signed in to change notification settings - Fork 30.5k
[Material Cross Imports] Clean up Material Divider usages #187300
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||
| // 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/widgets.dart'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /// Flutter code sample for [FontFeature]. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -11,27 +11,65 @@ void main() => runApp(const ExampleApp()); | |||||||||||||||||||||||||||||||||||||||||||||
| class ExampleApp extends StatelessWidget { | ||||||||||||||||||||||||||||||||||||||||||||||
| const ExampleApp({super.key}); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| static PageRoute<T> _pageRouteBuilder<T>( | ||||||||||||||||||||||||||||||||||||||||||||||
| RouteSettings settings, | ||||||||||||||||||||||||||||||||||||||||||||||
| WidgetBuilder builder, | ||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| return PageRouteBuilder<T>( | ||||||||||||||||||||||||||||||||||||||||||||||
| settings: settings, | ||||||||||||||||||||||||||||||||||||||||||||||
| pageBuilder: | ||||||||||||||||||||||||||||||||||||||||||||||
| ( | ||||||||||||||||||||||||||||||||||||||||||||||
| BuildContext context, | ||||||||||||||||||||||||||||||||||||||||||||||
| Animation<double> animation, | ||||||||||||||||||||||||||||||||||||||||||||||
| Animation<double> secondaryAnimation, | ||||||||||||||||||||||||||||||||||||||||||||||
| ) => builder(context), | ||||||||||||||||||||||||||||||||||||||||||||||
| transitionsBuilder: | ||||||||||||||||||||||||||||||||||||||||||||||
| ( | ||||||||||||||||||||||||||||||||||||||||||||||
| BuildContext context, | ||||||||||||||||||||||||||||||||||||||||||||||
| Animation<double> animation, | ||||||||||||||||||||||||||||||||||||||||||||||
| Animation<double> secondaryAnimation, | ||||||||||||||||||||||||||||||||||||||||||||||
| Widget child, | ||||||||||||||||||||||||||||||||||||||||||||||
| ) => child, | ||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| @override | ||||||||||||||||||||||||||||||||||||||||||||||
| Widget build(BuildContext context) { | ||||||||||||||||||||||||||||||||||||||||||||||
| return const MaterialApp(home: ExampleWidget()); | ||||||||||||||||||||||||||||||||||||||||||||||
| return WidgetsApp( | ||||||||||||||||||||||||||||||||||||||||||||||
| color: const Color(0xFFFFFFFF), | ||||||||||||||||||||||||||||||||||||||||||||||
| home: ExampleWidget(), | ||||||||||||||||||||||||||||||||||||||||||||||
| pageRouteBuilder: _pageRouteBuilder, | ||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| final TextStyle titleStyle = TextStyle( | ||||||||||||||||||||||||||||||||||||||||||||||
| const TextStyle titleStyle = TextStyle( | ||||||||||||||||||||||||||||||||||||||||||||||
| fontSize: 18, | ||||||||||||||||||||||||||||||||||||||||||||||
| fontFeatures: const <FontFeature>[FontFeature.enable('smcp')], | ||||||||||||||||||||||||||||||||||||||||||||||
| color: Colors.blueGrey[600], | ||||||||||||||||||||||||||||||||||||||||||||||
| fontFeatures: <FontFeature>[FontFeature.enable('smcp')], | ||||||||||||||||||||||||||||||||||||||||||||||
| color: Color(0xFF0000FF), | ||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| class ExampleWidget extends StatelessWidget { | ||||||||||||||||||||||||||||||||||||||||||||||
| const ExampleWidget({super.key}); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Widget buildDivider() { | ||||||||||||||||||||||||||||||||||||||||||||||
| return Padding( | ||||||||||||||||||||||||||||||||||||||||||||||
| padding: const EdgeInsets.all(4), | ||||||||||||||||||||||||||||||||||||||||||||||
| child: Container( | ||||||||||||||||||||||||||||||||||||||||||||||
| color: const Color(0xFF000000), | ||||||||||||||||||||||||||||||||||||||||||||||
| height: 4, | ||||||||||||||||||||||||||||||||||||||||||||||
| width: double.infinity, | ||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+55
to
+64
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Suggested change
References
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| @override | ||||||||||||||||||||||||||||||||||||||||||||||
| Widget build(BuildContext context) { | ||||||||||||||||||||||||||||||||||||||||||||||
| // The Cardo, Milonga and Raleway Dots fonts can be downloaded from Google | ||||||||||||||||||||||||||||||||||||||||||||||
| // Fonts (https://www.google.com/fonts). | ||||||||||||||||||||||||||||||||||||||||||||||
| return Scaffold( | ||||||||||||||||||||||||||||||||||||||||||||||
| body: Center( | ||||||||||||||||||||||||||||||||||||||||||||||
| return Directionality( | ||||||||||||||||||||||||||||||||||||||||||||||
| textDirection: TextDirection.ltr, | ||||||||||||||||||||||||||||||||||||||||||||||
| child: Center( | ||||||||||||||||||||||||||||||||||||||||||||||
| child: Column( | ||||||||||||||||||||||||||||||||||||||||||||||
| mainAxisAlignment: .center, | ||||||||||||||||||||||||||||||||||||||||||||||
| children: <Widget>[ | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -55,7 +93,7 @@ class ExampleWidget extends StatelessWidget { | |||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||
| const Spacer(), | ||||||||||||||||||||||||||||||||||||||||||||||
| const Divider(), | ||||||||||||||||||||||||||||||||||||||||||||||
| buildDivider(), | ||||||||||||||||||||||||||||||||||||||||||||||
| const Spacer(), | ||||||||||||||||||||||||||||||||||||||||||||||
| Text( | ||||||||||||||||||||||||||||||||||||||||||||||
| 'fractions look better with a custom ligature:', | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -70,7 +108,7 @@ class ExampleWidget extends StatelessWidget { | |||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||
| const Spacer(), | ||||||||||||||||||||||||||||||||||||||||||||||
| const Divider(), | ||||||||||||||||||||||||||||||||||||||||||||||
| buildDivider(), | ||||||||||||||||||||||||||||||||||||||||||||||
| const Spacer(), | ||||||||||||||||||||||||||||||||||||||||||||||
| Text('multiple stylistic sets in one font:', style: titleStyle), | ||||||||||||||||||||||||||||||||||||||||||||||
| const Text( | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -73,8 +73,14 @@ class _ScrollNotificationDemoState extends State<ScrollNotificationDemo> { | |||||||||||||||||||||||||||||||||||||
| child: Text('Item $index'), | ||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||
| separatorBuilder: (_, _) => | ||||||||||||||||||||||||||||||||||||||
| const Divider(indent: 20, endIndent: 20, thickness: 2), | ||||||||||||||||||||||||||||||||||||||
| separatorBuilder: (_, _) => Padding( | ||||||||||||||||||||||||||||||||||||||
| padding: const EdgeInsets.all(4), | ||||||||||||||||||||||||||||||||||||||
| child: Container( | ||||||||||||||||||||||||||||||||||||||
| color: const Color(0xFF000000), | ||||||||||||||||||||||||||||||||||||||
| height: 4, | ||||||||||||||||||||||||||||||||||||||
| width: double.infinity, | ||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+76
to
+83
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Suggested change
References
|
||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,17 @@ class MyApp extends StatefulWidget { | |||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| class _MyAppState extends State<MyApp> { | ||||||||||||||||||||||||||||||||||||||||||||||
| Widget buildDivider() { | ||||||||||||||||||||||||||||||||||||||||||||||
| return Padding( | ||||||||||||||||||||||||||||||||||||||||||||||
| padding: const EdgeInsets.all(4), | ||||||||||||||||||||||||||||||||||||||||||||||
| child: Container( | ||||||||||||||||||||||||||||||||||||||||||||||
| color: const Color(0xFF000000), | ||||||||||||||||||||||||||||||||||||||||||||||
| height: 4, | ||||||||||||||||||||||||||||||||||||||||||||||
| width: double.infinity, | ||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+18
to
+27
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Suggested change
References
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| @override | ||||||||||||||||||||||||||||||||||||||||||||||
| Widget build(BuildContext context) { | ||||||||||||||||||||||||||||||||||||||||||||||
| final TextStyle? bodyStyle = Theme.of(context).textTheme.bodyLarge; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -46,15 +57,15 @@ class _MyAppState extends State<MyApp> { | |||||||||||||||||||||||||||||||||||||||||||||
| const Text( | ||||||||||||||||||||||||||||||||||||||||||||||
| 'The identifier property in Semantics widget is used for UI testing with tools that work by querying the native accessibility, like UIAutomator, XCUITest, or Appium. It can be matched with CommonFinders.bySemanticsIdentifier.', | ||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||
| const Divider(), | ||||||||||||||||||||||||||||||||||||||||||||||
| buildDivider(), | ||||||||||||||||||||||||||||||||||||||||||||||
| Text('Text Example:', style: bodyStyle), | ||||||||||||||||||||||||||||||||||||||||||||||
| const Text( | ||||||||||||||||||||||||||||||||||||||||||||||
| 'This text has a custom label and an identifier. In Android, the label is used as the content-desc, and the identifier is used as the resource-id.', | ||||||||||||||||||||||||||||||||||||||||||||||
| semanticsLabel: 'This is a custom label', | ||||||||||||||||||||||||||||||||||||||||||||||
| semanticsIdentifier: | ||||||||||||||||||||||||||||||||||||||||||||||
| 'This is a custom identifier that only the automation tools are able to see', | ||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||
| const Divider(), | ||||||||||||||||||||||||||||||||||||||||||||||
| buildDivider(), | ||||||||||||||||||||||||||||||||||||||||||||||
| Text('Text.rich Example:', style: bodyStyle), | ||||||||||||||||||||||||||||||||||||||||||||||
| Text.rich( | ||||||||||||||||||||||||||||||||||||||||||||||
| TextSpan( | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -80,7 +91,7 @@ class _MyAppState extends State<MyApp> { | |||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||
| const Divider(), | ||||||||||||||||||||||||||||||||||||||||||||||
| buildDivider(), | ||||||||||||||||||||||||||||||||||||||||||||||
| Text('Multi-tenant Example:', style: bodyStyle), | ||||||||||||||||||||||||||||||||||||||||||||||
| const SizedBox(height: 16), | ||||||||||||||||||||||||||||||||||||||||||||||
| Column( | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,13 +2,13 @@ | |
| // 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/widgets.dart'; | ||
| import 'package:flutter_api_samples/ui/text/font_feature.0.dart' as example; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
|
|
||
| void main() { | ||
| testWidgets('shows font features', (WidgetTester tester) async { | ||
| await tester.pumpWidget(const MaterialApp(home: example.ExampleWidget())); | ||
| await tester.pumpWidget(example.ExampleWidget()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| expect(find.byType(Text), findsNWidgets(9)); | ||
| expect( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,9 +91,9 @@ class _WindowSettingsEditorState extends State<_WindowSettingsEditor> { | |
| child: ListView( | ||
| children: [ | ||
| _buildRegularEditor(), | ||
| const Divider(), | ||
| _buildDivider(), | ||
| _buildDialogEditor(), | ||
| const Divider(), | ||
| _buildDivider(), | ||
| _buildTooltipEditor(), | ||
| ], | ||
| ), | ||
|
|
@@ -359,6 +359,13 @@ class _WindowSettingsEditorState extends State<_WindowSettingsEditor> { | |
| ); | ||
| } | ||
|
|
||
| Widget _buildDivider() { | ||
| return Padding( | ||
| padding: const EdgeInsets.all(4), | ||
| child: Container(color: const Color(0xFF000000), height: 4, width: double.infinity), | ||
| ); | ||
| } | ||
|
Comment on lines
+362
to
+367
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using Widget _buildDivider() {
return const Padding(
padding: EdgeInsets.all(4),
child: SizedBox(
height: 4,
width: double.infinity,
child: ColoredBox(color: Color(0xFF000000)),
),
);
}References
|
||
|
|
||
| void _updateRegularSize() { | ||
| widget.settings.regularSize = Size( | ||
| double.tryParse(_regularWidthController.text) ?? widget.settings.regularSize.width, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -579,7 +579,14 @@ void main() { | |||||||||||||||||||||||||||||||||
| ListTile(title: Text('Item a-$i')), | ||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||
| const Divider(thickness: 5), | ||||||||||||||||||||||||||||||||||
| Padding( | ||||||||||||||||||||||||||||||||||
| padding: const EdgeInsets.all(4), | ||||||||||||||||||||||||||||||||||
| child: Container( | ||||||||||||||||||||||||||||||||||
| color: const Color(0xFF000000), | ||||||||||||||||||||||||||||||||||
| height: 5, | ||||||||||||||||||||||||||||||||||
| width: double.infinity, | ||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+582
to
+589
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Suggested change
References
|
||||||||||||||||||||||||||||||||||
| Expanded( | ||||||||||||||||||||||||||||||||||
| child: ListView.builder( | ||||||||||||||||||||||||||||||||||
| key: const Key('listView-b'), | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since
ExampleWidgethas aconstconstructor, it should be instantiated withconsthere to avoid unnecessary rebuilds and improve performance.