@@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [Flow].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [Flow].
|
||||
|
||||
void main() => runApp(const FlowApp());
|
||||
|
||||
class FlowApp extends StatelessWidget {
|
||||
@@ -31,8 +31,7 @@ class FlowMenu extends StatefulWidget {
|
||||
State<FlowMenu> createState() => _FlowMenuState();
|
||||
}
|
||||
|
||||
class _FlowMenuState extends State<FlowMenu>
|
||||
with SingleTickerProviderStateMixin {
|
||||
class _FlowMenuState extends State<FlowMenu> with SingleTickerProviderStateMixin {
|
||||
late AnimationController menuAnimation;
|
||||
IconData lastTapped = Icons.notifications;
|
||||
final List<IconData> menuItems = <IconData>[
|
||||
@@ -59,8 +58,7 @@ class _FlowMenuState extends State<FlowMenu>
|
||||
}
|
||||
|
||||
Widget flowMenuItem(IconData icon) {
|
||||
final double buttonDiameter =
|
||||
MediaQuery.of(context).size.width / menuItems.length;
|
||||
final double buttonDiameter = MediaQuery.of(context).size.width / menuItems.length;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: RawMaterialButton(
|
||||
@@ -70,9 +68,7 @@ class _FlowMenuState extends State<FlowMenu>
|
||||
constraints: BoxConstraints.tight(Size(buttonDiameter, buttonDiameter)),
|
||||
onPressed: () {
|
||||
_updateMenu(icon);
|
||||
menuAnimation.status == AnimationStatus.completed
|
||||
? menuAnimation.reverse()
|
||||
: menuAnimation.forward();
|
||||
menuAnimation.status == AnimationStatus.completed ? menuAnimation.reverse() : menuAnimation.forward();
|
||||
},
|
||||
child: Icon(
|
||||
icon,
|
||||
@@ -87,15 +83,13 @@ class _FlowMenuState extends State<FlowMenu>
|
||||
Widget build(BuildContext context) {
|
||||
return Flow(
|
||||
delegate: FlowMenuDelegate(menuAnimation: menuAnimation),
|
||||
children:
|
||||
menuItems.map<Widget>((IconData icon) => flowMenuItem(icon)).toList(),
|
||||
children: menuItems.map<Widget>((IconData icon) => flowMenuItem(icon)).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FlowMenuDelegate extends FlowDelegate {
|
||||
FlowMenuDelegate({required this.menuAnimation})
|
||||
: super(repaint: menuAnimation);
|
||||
FlowMenuDelegate({required this.menuAnimation}) : super(repaint: menuAnimation);
|
||||
|
||||
final Animation<double> menuAnimation;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user