mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

This auto-formats all *.dart files in the repository outside of the `engine` subdirectory and enforces that these files stay formatted with a presubmit check. **Reviewers:** Please carefully review all the commits except for the one titled "formatted". The "formatted" commit was auto-generated by running `dev/tools/format.sh -a -f`. The other commits were hand-crafted to prepare the repo for the formatting change. I recommend reviewing the commits one-by-one via the "Commits" tab and avoiding Github's "Files changed" tab as it will likely slow down your browser because of the size of this PR. --------- Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
108 lines
2.8 KiB
Dart
108 lines
2.8 KiB
Dart
// 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';
|
|
|
|
class AnimatedIconsTestApp extends StatelessWidget {
|
|
const AnimatedIconsTestApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return const MaterialApp(title: 'Animated Icons Test', home: Scaffold(body: IconsList()));
|
|
}
|
|
}
|
|
|
|
class IconsList extends StatelessWidget {
|
|
const IconsList({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListView(
|
|
children: samples.map<IconSampleRow>((IconSample s) => IconSampleRow(s)).toList(),
|
|
);
|
|
}
|
|
}
|
|
|
|
class IconSampleRow extends StatefulWidget {
|
|
const IconSampleRow(this.sample, {super.key});
|
|
|
|
final IconSample sample;
|
|
|
|
@override
|
|
State createState() => IconSampleRowState();
|
|
}
|
|
|
|
class IconSampleRowState extends State<IconSampleRow> with SingleTickerProviderStateMixin {
|
|
late final AnimationController progress = AnimationController(
|
|
vsync: this,
|
|
duration: const Duration(milliseconds: 300),
|
|
);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListTile(
|
|
leading: InkWell(
|
|
onTap: () {
|
|
progress.forward(from: 0.0);
|
|
},
|
|
child: AnimatedIcon(icon: widget.sample.icon, progress: progress, color: Colors.lightBlue),
|
|
),
|
|
title: Text(widget.sample.description),
|
|
subtitle: Slider(
|
|
value: progress.value,
|
|
onChanged: (double v) {
|
|
progress.animateTo(v, duration: Duration.zero);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
progress.addListener(_handleChange);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
progress.removeListener(_handleChange);
|
|
super.dispose();
|
|
}
|
|
|
|
void _handleChange() {
|
|
setState(() {});
|
|
}
|
|
}
|
|
|
|
const List<IconSample> samples = <IconSample>[
|
|
IconSample(AnimatedIcons.arrow_menu, 'arrow_menu'),
|
|
IconSample(AnimatedIcons.menu_arrow, 'menu_arrow'),
|
|
|
|
IconSample(AnimatedIcons.close_menu, 'close_menu'),
|
|
IconSample(AnimatedIcons.menu_close, 'menu_close'),
|
|
|
|
IconSample(AnimatedIcons.home_menu, 'home_menu'),
|
|
IconSample(AnimatedIcons.menu_home, 'menu_home'),
|
|
|
|
IconSample(AnimatedIcons.play_pause, 'play_pause'),
|
|
IconSample(AnimatedIcons.pause_play, 'pause_play'),
|
|
|
|
IconSample(AnimatedIcons.list_view, 'list_view'),
|
|
IconSample(AnimatedIcons.view_list, 'view_list'),
|
|
|
|
IconSample(AnimatedIcons.add_event, 'add_event'),
|
|
IconSample(AnimatedIcons.event_add, 'event_add'),
|
|
|
|
IconSample(AnimatedIcons.ellipsis_search, 'ellipsis_search'),
|
|
IconSample(AnimatedIcons.search_ellipsis, 'search_ellipsis'),
|
|
];
|
|
|
|
class IconSample {
|
|
const IconSample(this.icon, this.description);
|
|
final AnimatedIconData icon;
|
|
final String description;
|
|
}
|
|
|
|
void main() => runApp(const AnimatedIconsTestApp());
|