text stringlengths 1 372 |
|---|
playing all of the animations at the same time can be |
overwhelming. playing the animations one after the other |
can take too long. a better option is to stagger the animations. |
each animation begins at a different time, |
but the animations overlap to create a shorter duration. |
in this recipe, you build a drawer menu with animated |
content that is staggered and has a button that pops |
in at the bottom. |
the following animation shows the app’s behavior: |
<topic_end> |
<topic_start> |
create the menu without animations |
the drawer menu displays a list of titles, |
followed by a get started button at |
the bottom of the menu. |
define a stateful widget called menu |
that displays the list and button |
in static locations. |
<code_start> |
class menu extends StatefulWidget { |
const menu({super.key}); |
@override |
State<Menu> createState() => _MenuState(); |
} |
class _MenuState extends State<Menu> { |
static const _menuTitles = [ |
'declarative style', |
'premade widgets', |
'stateful hot reload', |
'native performance', |
'great community', |
]; |
@override |
widget build(BuildContext context) { |
return container( |
color: colors.white, |
child: stack( |
fit: StackFit.expand, |
children: [ |
_buildFlutterLogo(), |
_buildContent(), |
], |
), |
); |
} |
widget _buildFlutterLogo() { |
// TODO: we'll implement this later. |
return container(); |
} |
widget _buildContent() { |
return column( |
crossAxisAlignment: CrossAxisAlignment.start, |
children: [ |
const SizedBox(height: 16), |
..._buildlistitems(), |
const spacer(), |
_buildGetStartedButton(), |
], |
); |
} |
List<Widget> _buildListItems() { |
final listItems = <widget>[]; |
for (var i = 0; i < _menuTitles.length; ++i) { |
listItems.add( |
padding( |
padding: const EdgeInsets.symmetric(horizontal: 36, vertical: 16), |
child: text( |
_menuTitles[i], |
textAlign: TextAlign.left, |
style: const TextStyle( |
fontSize: 24, |
fontWeight: FontWeight.w500, |
), |
), |
), |
); |
} |
return listItems; |
} |
widget _buildGetStartedButton() { |
return SizedBox( |
width: double.infinity, |
child: padding( |
padding: const EdgeInsets.all(24), |
child: ElevatedButton( |
style: ElevatedButton.styleFrom( |
shape: const StadiumBorder(), |
backgroundColor: colors.blue, |
padding: const EdgeInsets.symmetric(horizontal: 48, vertical: 14), |
), |
onPressed: () {}, |
child: const text( |
'get started', |
style: TextStyle( |
color: colors.white, |
fontSize: 22, |
), |
), |
), |
), |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.