Skip to content

Instantly share code, notes, and snippets.

@kumar-aakash86
Created January 28, 2022 15:22
Show Gist options
  • Save kumar-aakash86/aa4d246deb397375cc43f767318c18e5 to your computer and use it in GitHub Desktop.
Save kumar-aakash86/aa4d246deb397375cc43f767318c18e5 to your computer and use it in GitHub Desktop.
Flutter Animated Dialog
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/gestures.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(home: TexspanTap());
}
}
class TexspanTap extends StatefulWidget {
@override
_TexspanTapState createState() => _TexspanTapState();
}
class _TexspanTapState extends State<TexspanTap> {
bool _visible = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: SafeArea(
child: Column(
children: [
TextButton(
child: Text("Show"),
onPressed: () async {
_showDialog(context);
print('started');
await Future.delayed(const Duration(milliseconds: 2000), () {
print('completed');
Navigator.pop(context);
});
},
),
],
),
),
);
}
_showDialog(BuildContext context) {
return showGeneralDialog(barrierColor: Colors.black.withOpacity(0.5),
transitionBuilder: (context, a1, a2, widget) {
return Transform.scale(
scale: a1.value,
child: Opacity(
opacity: a1.value,
child: AlertDialog(
shape: OutlineInputBorder(
borderRadius: BorderRadius.circular(16.0)),
title: Text('Hello!!'),
content: Text('How are you?'),
),
),
);
},
transitionDuration: Duration(milliseconds: 500),
barrierDismissible: true,
barrierLabel: '',
context: context,
pageBuilder: (context, animation1, animation2) {
return Container();
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment