text stringlengths 1 372 |
|---|
), |
), |
), |
), |
); |
} |
<code_end> |
congratulations! |
you have an animated menu where the appearance of each |
list item is staggered, followed by a bottom button that |
pops into place. |
<topic_end> |
<topic_start> |
interactive example |
<code_start> |
import 'package:flutter/material.dart'; |
void main() { |
runApp( |
const MaterialApp( |
home: ExampleStaggeredAnimations(), |
debugShowCheckedModeBanner: false, |
), |
); |
} |
class ExampleStaggeredAnimations extends StatefulWidget { |
const ExampleStaggeredAnimations({ |
super.key, |
}); |
@override |
State<ExampleStaggeredAnimations> createState() => |
_ExampleStaggeredAnimationsState(); |
} |
class _ExampleStaggeredAnimationsState extends State<ExampleStaggeredAnimations> |
with SingleTickerProviderStateMixin { |
late AnimationController _drawerSlideController; |
@override |
void initState() { |
super.initState(); |
_drawerSlideController = AnimationController( |
vsync: this, |
duration: const duration(milliseconds: 150), |
); |
} |
@override |
void dispose() { |
_drawerSlideController.dispose(); |
super.dispose(); |
} |
bool _isDrawerOpen() { |
return _drawerSlideController.value == 1.0; |
} |
bool _isDrawerOpening() { |
return _drawerSlideController.status == AnimationStatus.forward; |
} |
bool _isDrawerClosed() { |
return _drawerSlideController.value == 0.0; |
} |
void _toggleDrawer() { |
if (_isdraweropen() || _isDrawerOpening()) { |
_drawerSlideController.reverse(); |
} else { |
_drawerSlideController.forward(); |
} |
} |
@override |
widget build(BuildContext context) { |
return scaffold( |
backgroundColor: colors.white, |
appBar: _buildAppBar(), |
body: stack( |
children: [ |
_buildContent(), |
_buildDrawer(), |
], |
), |
); |
} |
PreferredSizeWidget _buildAppBar() { |
return AppBar( |
title: const text( |
'flutter menu', |
style: TextStyle( |
color: colors.black, |
), |
), |
backgroundColor: colors.transparent, |
elevation: 0.0, |
automaticallyImplyLeading: false, |
actions: [ |
AnimatedBuilder( |
animation: _drawerSlideController, |
builder: (context, child) { |
return IconButton( |
onPressed: _toggleDrawer, |
icon: _isDrawerOpen() || _isDrawerOpening() |
? const icon( |
icons.clear, |
color: colors.black, |
) |
: const icon( |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.