This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Widget build(BuildContext context) { | |
return new Scaffold( | |
appBar: new AppBar( | |
title: new Text(widget.title), | |
), | |
body: new Center( | |
child: new Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
new Text( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Widget build(BuildContext context) => | |
Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
), | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
Text( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:math'; | |
import 'package:flutter/material.dart'; | |
import 'package:meta/meta.dart'; | |
void main() { | |
runApp(new AppContainer()); | |
} | |
class AppContextData { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Widget buildStackActions(BuildContext context, SlidableDelegateContext ctx) { | |
return new Positioned.fill( | |
child: new LayoutBuilder(builder: (context, constraints) { | |
final state = ctx.state; | |
final count = state.actionCount; | |
final bool showActions = ctx.showActions; | |
final Animation<double> actionsMoveAnimation = | |
state.actionsMoveAnimation; | |
final double actionExtent = | |
ctx.getMaxExtent(constraints) * state.widget.actionExtentRatio; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class SlidableStackDelegate extends SlidableDelegate { | |
const SlidableStackDelegate({ | |
double fastThreshold, | |
}) : super(fastThreshold: fastThreshold); | |
@override | |
Widget buildActions(BuildContext context, SlidableDelegateContext ctx) { | |
final animation = new Tween( | |
begin: Offset.zero, | |
end: ctx.createOffset(ctx.state.totalActionsExtent * ctx.state.dragSign), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final double actionExtent = | |
ctx.getMaxExtent(constraints) * state.widget.actionExtentRatio; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final animations = Iterable.generate(count).map((index) { | |
return new Tween( | |
begin: -actionExtent, | |
end: (count - index - 1) * actionExtent, | |
).animate(actionsMoveAnimation); | |
}).toList(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For the main actions we have to reverse the order if we want the last item at the bottom of the stack. | |
int displayIndex = showActions ? count - index - 1 : index; | |
return ctx.createPositioned( | |
position: animations[index].value, | |
extent: actionExtent, | |
child: actionDelegate.build(context, displayIndex, | |
actionsMoveAnimation, SlidableRenderingMode.slide), | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SlidableDrawerDelegateAnimation({ | |
Key key, | |
this.controller, | |
}) : dxPositions = <Animation<Offset>>[ | |
Tween<Offset>( | |
begin: Offset(-1.0, 0.0), | |
end: Offset(1.0, 0.0), | |
).animate( | |
CurvedAnimation( | |
parent: controller, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SlidableDrawerDelegateDemo extends StatefulWidget { | |
@override | |
_SlidableDrawerDelegateDemoState createState() => | |
new _SlidableDrawerDelegateDemoState(); | |
} | |
class _SlidableDrawerDelegateDemoState extends State<SlidableDrawerDelegateDemo> | |
with TickerProviderStateMixin { | |
AnimationController _controller; |
OlderNewer