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

Add test for animated_size.0.dart API example. #147828

Merged

Conversation

ksokolovskyi
Copy link
Contributor

This PR contributes to #130459

Description

  • Updates examples/api/lib/widgets/animated_size/animated_size.0.dart API example by using SizedBox to size the surrounding of the FlutterLogo while setting the constant FlutterLogo size. This was done because FlutterLogo already has size animation under the hood, and the main goal of this example is to show AnimatedSize usage
  • Adds test for examples/api/lib/widgets/animated_size/animated_size.0.dart

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels May 4, 2024
Copy link
Contributor

@bleroux bleroux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great test!
One minor comment related to formatting and one question.

@ksokolovskyi ksokolovskyi force-pushed the add-animated-size-example-test branch from f239240 to 607567a Compare May 8, 2024 19:03
@ksokolovskyi ksokolovskyi requested a review from bleroux May 8, 2024 19:05
_large = !_large;
});
}
bool _isSelected = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice simplification!

Comment on lines +64 to +69
child: SizedBox.square(
dimension: _isSelected ? 250.0 : 100.0,
child: const Center(
child: FlutterLogo(size: 75.0),
),
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to not animate the FlutterLogo the way it was done before? I think the visual effect made sense and the sample will be a little easier to understand when removing the SizedBox.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bleroux
This was done because FlutterLogo already has size animation under the hood, and the main goal of the example is to show AnimatedSize usage. You can try the following code sample to verify that FlutterLogo animates without the usage of AnimatedSize.

Code sample
// 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';

/// Flutter code sample for [AnimatedSize].

void main() => runApp(const AnimatedSizeExampleApp());

class AnimatedSizeExampleApp extends StatelessWidget {
  const AnimatedSizeExampleApp({super.key});

  static const Duration duration = Duration(seconds: 1);
  static const Curve curve = Curves.easeIn;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('AnimatedSize Sample')),
        body: const Center(
          child: AnimatedSizeExample(
            duration: duration,
            curve: curve,
          ),
        ),
      ),
    );
  }
}

class AnimatedSizeExample extends StatefulWidget {
  const AnimatedSizeExample({
    required this.duration,
    required this.curve,
    super.key,
  });

  final Duration duration;

  final Curve curve;

  @override
  State<AnimatedSizeExample> createState() => _AnimatedSizeExampleState();
}

class _AnimatedSizeExampleState extends State<AnimatedSizeExample> {
  bool _isSelected = false;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        setState(() {
          _isSelected = !_isSelected;
        });
      },
      child: Center(
        child: ColoredBox(
          color: Colors.amberAccent,
          child: FlutterLogo(
            size: _isSelected ? 250.0 : 100.0,
          ),
        ),
      ),
    );
  }
}

Copy link
Contributor

@bleroux bleroux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

@TahaTesser TahaTesser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@TahaTesser TahaTesser added the autosubmit Merge PR when tree becomes green via auto submit App label May 10, 2024
@ksokolovskyi
Copy link
Contributor Author

@bleroux @TahaTesser thanks for the review!

@auto-submit auto-submit bot merged commit 65e8c61 into flutter:master May 10, 2024
137 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 11, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 11, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request May 11, 2024
flutter/flutter@2bfb1b0...2aa05c1

2024-05-11 [email protected] Roll Flutter Engine from fad88cb16d03 to 558a81dd8b08 (3 revisions) (flutter/flutter#148163)
2024-05-11 [email protected] Roll Flutter Engine from ba8e0d3e2f23 to fad88cb16d03 (9 revisions) (flutter/flutter#148156)
2024-05-11 [email protected] Add test for scaffold.1.dart (flutter/flutter#147966)
2024-05-10 [email protected] Fix `MaterialStateBorderSide` lerp in the `Checkbox` and chips (flutter/flutter#148124)
2024-05-10 [email protected] Docs on TextField disposed by a scrollable (flutter/flutter#148149)
2024-05-10 [email protected] Roll Flutter Engine from d4f705ccb695 to ba8e0d3e2f23 (8 revisions) (flutter/flutter#148147)
2024-05-10 [email protected] Roll pub packages (flutter/flutter#148148)
2024-05-10 [email protected] Add `clipBehavior` to `DialogTheme` (flutter/flutter#147635)
2024-05-10 [email protected] bump cupertino_icons to 1.08 (flutter/flutter#146806)
2024-05-10 [email protected] Add test for animated_size.0.dart API example. (flutter/flutter#147828)
2024-05-10 [email protected] Fix `DropdownMenu` keyboard navigation (flutter/flutter#147294)
2024-05-10 [email protected] Add test for draggable.0.dart API example. (flutter/flutter#147941)
2024-05-10 [email protected] Update TESTOWNERS (flutter/flutter#148108)
2024-05-10 [email protected] Add tests for stream_builder.0.dart API example. (flutter/flutter#147832)
2024-05-10 [email protected] Roll Flutter Engine from 1ccd0c308b3a to d4f705ccb695 (2 revisions) (flutter/flutter#148142)
2024-05-10 [email protected] Roll Packages from 8de142d to 6c4482a (8 revisions) (flutter/flutter#148079)
2024-05-10 [email protected] Roll Flutter Engine from c0917b14fc36 to 1ccd0c308b3a (10 revisions) (flutter/flutter#148137)
2024-05-10 [email protected] `if` chains â�� `switch` expressions (flutter/flutter#147793)
2024-05-10 49699333+dependabot[bot]@users.noreply.github.com Bump ossf/scorecard-action from 2.3.1 to 2.3.3 (flutter/flutter#148091)
2024-05-10 [email protected] Reland "Implement computeDryBaseline for `RenderWrap` (#146260)" (flutter/flutter#148086)
2024-05-10 [email protected] Update dependabot reviewers (flutter/flutter#148101)
2024-05-10 [email protected] Roll Flutter Engine from 6e722ae213bd to c0917b14fc36 (1 revision) (flutter/flutter#148084)
2024-05-09 [email protected] Don't pin package:macros (flutter/flutter#148087)
2024-05-09 [email protected] Remove hidden dependencies on the default LocalPlatform (flutter/flutter#147342)
2024-05-09 [email protected] Getting rid of containers (flutter/flutter#147432)
2024-05-09 [email protected] Roll Flutter Engine from c0fd3386d018 to 6e722ae213bd (2 revisions) (flutter/flutter#148070)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants