text stringlengths 1 474 |
|---|
icon: _isDrawerOpen() || _isDrawerOpening() |
? const Icon( |
Icons.clear, |
color: Colors.black, |
) |
: const Icon( |
Icons.menu, |
color: Colors.black, |
), |
); |
}, |
), |
], |
); |
} |
Widget _buildContent() { |
// Put page content here. |
return const SizedBox(); |
} |
Widget _buildDrawer() { |
return AnimatedBuilder( |
animation: _drawerSlideController, |
builder: (context, child) { |
return FractionalTranslation( |
translation: Offset(1.0 - _drawerSlideController.value, 0.0), |
child: _isDrawerClosed() ? const SizedBox() : const Menu(), |
); |
}, |
); |
} |
} |
class Menu extends StatefulWidget { |
const Menu({super.key}); |
@override |
State<Menu> createState() => _MenuState(); |
} |
class _MenuState extends State<Menu> with SingleTickerProviderStateMixin { |
static const _menuTitles = [ |
'Declarative style', |
'Premade widgets', |
'Stateful hot reload', |
'Native performance', |
'Great community', |
]; |
static const _initialDelayTime = Duration(milliseconds: 50); |
static const _itemSlideTime = Duration(milliseconds: 250); |
static const _staggerTime = Duration(milliseconds: 50); |
static const _buttonDelayTime = Duration(milliseconds: 150); |
static const _buttonTime = Duration(milliseconds: 500); |
final _animationDuration = _initialDelayTime + |
(_staggerTime * _menuTitles.length) + |
_buttonDelayTime + |
_buttonTime; |
late AnimationController _staggeredController; |
final List<Interval> _itemSlideIntervals = []; |
late Interval _buttonInterval; |
@override |
void initState() { |
super.initState(); |
_createAnimationIntervals(); |
_staggeredController = AnimationController( |
vsync: this, |
duration: _animationDuration, |
)..forward(); |
} |
void _createAnimationIntervals() { |
for (var i = 0; i < _menuTitles.length; ++i) { |
final startTime = _initialDelayTime + (_staggerTime * i); |
final endTime = startTime + _itemSlideTime; |
_itemSlideIntervals.add( |
Interval( |
startTime.inMilliseconds / _animationDuration.inMilliseconds, |
endTime.inMilliseconds / _animationDuration.inMilliseconds, |
), |
); |
} |
final buttonStartTime = |
Duration(milliseconds: (_menuTitles.length * 50)) + _buttonDelayTime; |
final buttonEndTime = buttonStartTime + _buttonTime; |
_buttonInterval = Interval( |
buttonStartTime.inMilliseconds / _animationDuration.inMilliseconds, |
buttonEndTime.inMilliseconds / _animationDuration.inMilliseconds, |
); |
} |
@override |
void dispose() { |
_staggeredController.dispose(); |
super.dispose(); |
} |
@override |
Widget build(BuildContext context) { |
return Container( |
color: Colors.white, |
child: Stack( |
fit: StackFit.expand, |
children: [ |
_buildFlutterLogo(), |
_buildContent(), |
], |
), |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.