Skip to content
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

Use curly_braces_in_flow_control_structures for material #104499

Merged
merged 4 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ class AnimatedIcon extends StatelessWidget {
final TextDirection textDirection = this.textDirection ?? Directionality.of(context);
final double iconOpacity = iconTheme.opacity!;
Color iconColor = color ?? iconTheme.color!;
if (iconOpacity != 1.0)
if (iconOpacity != 1.0) {
iconColor = iconColor.withOpacity(iconColor.opacity * iconOpacity);
}
return Semantics(
label: semanticLabel,
child: CustomPaint(
Expand Down Expand Up @@ -162,8 +163,9 @@ class _AnimatedIconPainter extends CustomPainter {
canvas.scale(scale, scale);

final double clampedProgress = clampDouble(progress.value, 0.0, 1.0);
for (final _PathFrames path in paths)
for (final _PathFrames path in paths) {
path.paint(canvas, color, uiPathFactory, clampedProgress);
}
}


Expand Down Expand Up @@ -203,8 +205,9 @@ class _PathFrames {
..style = PaintingStyle.fill
..color = color.withOpacity(color.opacity * opacity);
final ui.Path path = uiPathFactory();
for (final _PathCommand command in commands)
for (final _PathCommand command in commands) {
command.apply(path, progress);
}
canvas.drawPath(path, paint);
}
}
Expand Down Expand Up @@ -291,8 +294,9 @@ class _PathClose extends _PathCommand {
T _interpolate<T>(List<T> values, double progress, _Interpolator<T> interpolator) {
assert(progress <= 1.0);
assert(progress >= 0.0);
if (values.length == 1)
if (values.length == 1) {
return values[0];
}
final double targetIdx = lerpDouble(0, values.length -1, progress)!;
final int lowIdx = targetIdx.floor();
final int highIdx = targetIdx.ceil();
Expand Down
3 changes: 2 additions & 1 deletion packages/flutter/lib/src/material/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1000,8 +1000,9 @@ class _MaterialAppState extends State<MaterialApp> {
result = Focus(
canRequestFocus: false,
onKey: (FocusNode node, RawKeyEvent event) {
if (event is! RawKeyDownEvent || event.logicalKey != LogicalKeyboardKey.escape)
if (event is! RawKeyDownEvent || event.logicalKey != LogicalKeyboardKey.escape) {
return KeyEventResult.ignored;
}
return Tooltip.dismissAllToolTips() ? KeyEventResult.handled : KeyEventResult.ignored;
},
child: result,
Expand Down
21 changes: 14 additions & 7 deletions packages/flutter/lib/src/material/app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -803,11 +803,13 @@ class _AppBarState extends State<AppBar> {
@override
void didChangeDependencies() {
super.didChangeDependencies();
if (_scrollNotificationObserver != null)
if (_scrollNotificationObserver != null) {
_scrollNotificationObserver!.removeListener(_handleScrollNotification);
}
_scrollNotificationObserver = ScrollNotificationObserver.of(context);
if (_scrollNotificationObserver != null)
if (_scrollNotificationObserver != null) {
_scrollNotificationObserver!.addListener(_handleScrollNotification);
}
}

@override
Expand Down Expand Up @@ -949,10 +951,12 @@ class _AppBarState extends State<AppBar> {

if (widget.toolbarOpacity != 1.0) {
final double opacity = const Interval(0.25, 1.0, curve: Curves.fastOutSlowIn).transform(widget.toolbarOpacity);
if (titleTextStyle?.color != null)
if (titleTextStyle?.color != null) {
titleTextStyle = titleTextStyle!.copyWith(color: titleTextStyle.color!.withOpacity(opacity));
if (toolbarTextStyle?.color != null)
}
if (toolbarTextStyle?.color != null) {
toolbarTextStyle = toolbarTextStyle!.copyWith(color: toolbarTextStyle.color!.withOpacity(opacity));
}
overallIconTheme = overallIconTheme.copyWith(
opacity: opacity * (overallIconTheme.opacity ?? 1.0),
);
Expand All @@ -971,8 +975,9 @@ class _AppBarState extends State<AppBar> {
tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip,
);
} else {
if (!hasEndDrawer && canPop)
if (!hasEndDrawer && canPop) {
leading = useCloseButton ? const CloseButton() : const BackButton();
}
}
}
if (leading != null) {
Expand Down Expand Up @@ -2048,10 +2053,12 @@ class _SliverAppBarState extends State<SliverAppBar> with TickerProviderStateMix
@override
void didUpdateWidget(SliverAppBar oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.snap != oldWidget.snap || widget.floating != oldWidget.floating)
if (widget.snap != oldWidget.snap || widget.floating != oldWidget.floating) {
_updateSnapConfiguration();
if (widget.stretch != oldWidget.stretch)
}
if (widget.stretch != oldWidget.stretch) {
_updateStretchConfiguration();
}
}

@override
Expand Down
6 changes: 4 additions & 2 deletions packages/flutter/lib/src/material/app_bar_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,12 @@ class AppBarTheme with Diagnosticable {

@override
bool operator ==(Object other) {
if (identical(this, other))
if (identical(this, other)) {
return true;
if (other.runtimeType != runtimeType)
}
if (other.runtimeType != runtimeType) {
return false;
}
return other is AppBarTheme
&& other.brightness == brightness
&& other.backgroundColor == backgroundColor
Expand Down
72 changes: 48 additions & 24 deletions packages/flutter/lib/src/material/arc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,25 @@ class MaterialPointArcTween extends Tween<Offset> {
/// The center of the circular arc, null if [begin] and [end] are horizontally or
/// vertically aligned, or if either is null.
Offset? get center {
if (begin == null || end == null)
if (begin == null || end == null) {
return null;
if (_dirty)
}
if (_dirty) {
_initialize();
}
return _center;
}
Offset? _center;

/// The radius of the circular arc, null if [begin] and [end] are horizontally or
/// vertically aligned, or if either is null.
double? get radius {
if (begin == null || end == null)
if (begin == null || end == null) {
return null;
if (_dirty)
}
if (_dirty) {
_initialize();
}
return _radius;
}
double? _radius;
Expand All @@ -117,10 +121,12 @@ class MaterialPointArcTween extends Tween<Offset> {
/// This will be null if [begin] and [end] are horizontally or vertically
/// aligned, or if either is null.
double? get beginAngle {
if (begin == null || end == null)
if (begin == null || end == null) {
return null;
if (_dirty)
}
if (_dirty) {
_initialize();
}
return _beginAngle;
}
double? _beginAngle;
Expand All @@ -131,10 +137,12 @@ class MaterialPointArcTween extends Tween<Offset> {
/// This will be null if [begin] and [end] are horizontally or vertically
/// aligned, or if either is null.
double? get endAngle {
if (begin == null || end == null)
if (begin == null || end == null) {
return null;
if (_dirty)
}
if (_dirty) {
_initialize();
}
return _beginAngle;
}
double? _endAngle;
Expand All @@ -157,14 +165,18 @@ class MaterialPointArcTween extends Tween<Offset> {

@override
Offset lerp(double t) {
if (_dirty)
if (_dirty) {
_initialize();
if (t == 0.0)
}
if (t == 0.0) {
return begin!;
if (t == 1.0)
}
if (t == 1.0) {
return end!;
if (_beginAngle == null || _endAngle == null)
}
if (_beginAngle == null || _endAngle == null) {
return Offset.lerp(begin, end, t)!;
}
final double angle = lerpDouble(_beginAngle, _endAngle, t)!;
final double x = math.cos(angle) * _radius!;
final double y = math.sin(angle) * _radius!;
Expand Down Expand Up @@ -279,21 +291,25 @@ class MaterialRectArcTween extends RectTween {
/// The path of the corresponding [begin], [end] rectangle corners that lead
/// the animation.
MaterialPointArcTween? get beginArc {
if (begin == null)
if (begin == null) {
return null;
if (_dirty)
}
if (_dirty) {
_initialize();
}
return _beginArc;
}
late MaterialPointArcTween _beginArc;

/// The path of the corresponding [begin], [end] rectangle corners that trail
/// the animation.
MaterialPointArcTween? get endArc {
if (end == null)
if (end == null) {
return null;
if (_dirty)
}
if (_dirty) {
_initialize();
}
return _endArc;
}
late MaterialPointArcTween _endArc;
Expand All @@ -316,12 +332,15 @@ class MaterialRectArcTween extends RectTween {

@override
Rect lerp(double t) {
if (_dirty)
if (_dirty) {
_initialize();
if (t == 0.0)
}
if (t == 0.0) {
return begin!;
if (t == 1.0)
}
if (t == 1.0) {
return end!;
}
return Rect.fromPoints(_beginArc.lerp(t), _endArc.lerp(t));
}

Expand Down Expand Up @@ -373,10 +392,12 @@ class MaterialRectCenterArcTween extends RectTween {
/// If [begin] and [end] are non-null, returns a tween that interpolates along
/// a circular arc between [begin]'s [Rect.center] and [end]'s [Rect.center].
MaterialPointArcTween? get centerArc {
if (begin == null || end == null)
if (begin == null || end == null) {
return null;
if (_dirty)
}
if (_dirty) {
_initialize();
}
return _centerArc;
}
late MaterialPointArcTween _centerArc;
Expand All @@ -399,12 +420,15 @@ class MaterialRectCenterArcTween extends RectTween {

@override
Rect lerp(double t) {
if (_dirty)
if (_dirty) {
_initialize();
if (t == 0.0)
}
if (t == 0.0) {
return begin!;
if (t == 1.0)
}
if (t == 1.0) {
return end!;
}
final Offset center = _centerArc.lerp(t);
final double width = lerpDouble(begin!.width, end!.width, t)!;
final double height = lerpDouble(begin!.height, end!.height, t)!;
Expand Down
3 changes: 2 additions & 1 deletion packages/flutter/lib/src/material/banner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,9 @@ class _MaterialBannerState extends State<MaterialBanner> {
);

// This provides a static banner for backwards compatibility.
if (widget.animation == null)
if (widget.animation == null) {
return materialBanner;
}

materialBanner = SafeArea(
child: materialBanner,
Expand Down
6 changes: 4 additions & 2 deletions packages/flutter/lib/src/material/banner_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@ class MaterialBannerThemeData with Diagnosticable {

@override
bool operator ==(Object other) {
if (identical(this, other))
if (identical(this, other)) {
return true;
if (other.runtimeType != runtimeType)
}
if (other.runtimeType != runtimeType) {
return false;
}
return other is MaterialBannerThemeData
&& other.backgroundColor == backgroundColor
&& other.contentTextStyle == contentTextStyle
Expand Down
3 changes: 2 additions & 1 deletion packages/flutter/lib/src/material/bottom_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,9 @@ class _BottomAppBarClipper extends CustomClipper<Path> {
// Material widget.
double get bottomNavigationBarTop {
final double? bottomNavigationBarTop = geometry.value.bottomNavigationBarTop;
if (bottomNavigationBarTop != null)
if (bottomNavigationBarTop != null) {
return bottomNavigationBarTop;
}
final RenderBox? box = materialKey.currentContext?.findRenderObject() as RenderBox?;
return box?.localToGlobal(Offset.zero).dy ?? 0;
}
Expand Down
6 changes: 4 additions & 2 deletions packages/flutter/lib/src/material/bottom_app_bar_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ class BottomAppBarTheme with Diagnosticable {

@override
bool operator ==(Object other) {
if (identical(this, other))
if (identical(this, other)) {
return true;
if (other.runtimeType != runtimeType)
}
if (other.runtimeType != runtimeType) {
return false;
}
return other is BottomAppBarTheme
&& other.color == color
&& other.elevation == elevation
Expand Down