Skip to content

Commit

Permalink
Fix and cleanup implicit animations codelab (#9201)
Browse files Browse the repository at this point in the history
Essentially this PR is focused on improving the clarity of the steps
which are diff based, matching starting and ending runnable samples to
the steps, removing unnecessary code, and completing some cleanup of the
examples and the surrounding text.

**Detailed list of changes:**

- Sets up code excerpts for the starting and complete example code which
were mismatched with the actual steps/instructions. Then updates them to
match.
- Adds missing type specifiers and simplifies variable declarations.
- Adjusts trailing commas and formatting in opacity sample for easier to
read diffs.
- Removes extra folders/steps that are not currently used.
- Adds missing type specifiers and simplifies variable declarations.
- Moves away from inline ignores since the diff tooling doesn't remove
them, making the diffs more confusing and the line numbers inconsistent
between steps. Ignoring in the analysis options file allows for
consistent line numbers.
- Changes text of button from "change" to "Change" to match
instructions.
- Fixes a few instructions in the codelab's text.
- Removes the embedded survey.
- Adds a README to the example directory explaining its setup.

Closes #6929
  • Loading branch information
parlough authored Aug 7, 2023
1 parent a75d4cb commit 932c2eb
Show file tree
Hide file tree
Showing 24 changed files with 169 additions and 589 deletions.
20 changes: 20 additions & 0 deletions examples/animation/implicit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Implicit animations codelab examples

The code samples within this folder are used
within the [Implicit animations codelab][].

- `container1` -> `container5` are used for the
steps of "Shape-shifting effect" portion.
- `container1` is also used for the runnable starter sample and
`container5` for the complete sample.
- `container6` is an extra step that showcases specifying a
non-default animation curve.
- `opacity1` -> `opacity5` are used for the
steps of "Fade-in text effect" portion.
- `opacity1` is also used for the runnable starter sample and
`opacity5` for the complete sample.
- The severity of `missing_required_argument` is ignored manually
in the [`analysis_options.yaml`](analysis_options.yaml) file since the
diffing infrastructure currently can't handle the `ignore` for it.

[Implicit animations codelab]: https://docs.flutter.dev/codelabs/implicit-animations
5 changes: 5 additions & 0 deletions examples/animation/implicit/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
# overrides for individual lints.

include: ../../analysis_options.yaml

analyzer:
errors:
# Ignored since ignore_for_files can't be hidden in diff excerpts yet
missing_required_argument: ignore
72 changes: 0 additions & 72 deletions examples/animation/implicit/container0/lib/main.dart

This file was deleted.

4 changes: 2 additions & 2 deletions examples/animation/implicit/container1/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
late double margin;

@override
initState() {
void initState() {
super.initState();
color = randomColor();
borderRadius = randomBorderRadius();
Expand All @@ -56,7 +56,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
),
),
ElevatedButton(
child: const Text('change'),
child: const Text('Change'),
onPressed: () => {},
),
],
Expand Down
96 changes: 0 additions & 96 deletions examples/animation/implicit/container10/lib/main.dart

This file was deleted.

6 changes: 2 additions & 4 deletions examples/animation/implicit/container2/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file.

// ignore_for_file: missing_required_argument

import 'dart:math';

import 'package:flutter/material.dart';
Expand Down Expand Up @@ -33,7 +31,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
late double margin;

@override
initState() {
void initState() {
super.initState();
color = randomColor();
borderRadius = randomBorderRadius();
Expand All @@ -58,7 +56,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
),
),
ElevatedButton(
child: const Text('change'),
child: const Text('Change'),
onPressed: () => {},
),
],
Expand Down
6 changes: 2 additions & 4 deletions examples/animation/implicit/container3/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file.

// ignore_for_file: missing_required_argument

import 'dart:math';

import 'package:flutter/material.dart';
Expand Down Expand Up @@ -33,7 +31,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
late double margin;

@override
initState() {
void initState() {
super.initState();
color = randomColor();
borderRadius = randomBorderRadius();
Expand Down Expand Up @@ -66,7 +64,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
),
),
ElevatedButton(
child: const Text('change'),
child: const Text('Change'),
onPressed: () => {},
),
],
Expand Down
6 changes: 2 additions & 4 deletions examples/animation/implicit/container4/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file.

// ignore_for_file: missing_required_argument

import 'dart:math';

import 'package:flutter/material.dart';
Expand Down Expand Up @@ -33,7 +31,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
late double margin;

@override
initState() {
void initState() {
super.initState();
color = randomColor();
borderRadius = randomBorderRadius();
Expand Down Expand Up @@ -66,7 +64,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
),
),
ElevatedButton(
child: const Text('change'),
child: const Text('Change'),
onPressed: () => change(),
),
],
Expand Down
4 changes: 2 additions & 2 deletions examples/animation/implicit/container5/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
late double margin;

@override
initState() {
void initState() {
super.initState();
color = randomColor();
borderRadius = randomBorderRadius();
Expand Down Expand Up @@ -67,7 +67,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
),
),
ElevatedButton(
child: const Text('change'),
child: const Text('Change'),
onPressed: () => change(),
),
],
Expand Down
4 changes: 2 additions & 2 deletions examples/animation/implicit/container6/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
late double margin;

@override
initState() {
void initState() {
super.initState();
color = randomColor();
borderRadius = randomBorderRadius();
Expand Down Expand Up @@ -68,7 +68,7 @@ class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
),
),
ElevatedButton(
child: const Text('change'),
child: const Text('Change'),
onPressed: () => change(),
),
],
Expand Down
Loading

0 comments on commit 932c2eb

Please sign in to comment.