Last active
July 1, 2020 10:55
-
-
Save MartinJLee/0992a986ad641ef5b4f477fb1ce69249 to your computer and use it in GitHub Desktop.
animations package OpenContainer
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:async'; | |
import 'package:flutter/material.dart'; | |
import 'package:animations/animations.dart'; | |
void main() async { | |
runApp( | |
MaterialApp( | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: Container( | |
color: Colors.black54, | |
child: Align( | |
alignment: Alignment.bottomCenter, | |
child: OpenContainer( | |
closedBuilder: (BuildContext context, void Function() action) { | |
return RaisedButton( | |
child: Text('Open Content'), | |
onPressed: action, | |
); | |
}, | |
openBuilder: (_, __) { | |
return NextScreen( | |
deleted: true, | |
); | |
}, | |
), | |
), | |
), | |
), | |
), | |
); | |
} | |
class NextScreen extends StatelessWidget { | |
final bool deleted; | |
const NextScreen({Key key, this.deleted}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Builder(builder: (context) { | |
if (deleted) { | |
Timer( | |
Duration.zero, | |
() => showDialog( | |
context: context, | |
builder: (_) => AlertDialog( | |
title: Text('Content Deleted'), | |
actions: <Widget>[FlatButton(child: Text('Ok'), onPressed: () => Navigator.pop(context))], | |
))); | |
} | |
return Scaffold( | |
appBar: AppBar(), | |
body: Container( | |
color: Colors.white, | |
child: Center(child: Text('Content')), | |
), | |
); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment