bouncing_draggable_dialog 1.0.2 bouncing_draggable_dialog: ^1.0.2 copied to clipboard
Flutter package to implement an animated Bouncing Draggable Dialog.
import 'package:flutter/material.dart';
import 'package:bouncing_draggable_dialog/bouncing_draggable_dialog.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: HomePageScreen(),
);
}
}
class HomePageScreen extends StatefulWidget {
const HomePageScreen({Key? key}) : super(key: key);
@override
State<HomePageScreen> createState() => _HomePageScreenState();
}
class _HomePageScreenState extends State<HomePageScreen> {
Widget content() {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Breaking News!',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w700,
fontSize: 20,
),
),
SizedBox(
height: 8.0,
),
Divider(
color: Colors.black,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.normal,
fontSize: 12,
),
textAlign: TextAlign.center,
),
),
Padding(
padding: const EdgeInsets.only(right: 24.0, top: 8.0, bottom: 8.0),
child: Container(
alignment: Alignment.bottomRight,
child: GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: Text(
'Close',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 14,
),
),
),
),
),
],
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Builder(builder: (context) {
return Center(
child: GestureDetector(
onTap: () {
showDialog(
context: context,
builder: (BuildContext context) {
return BouncingDraggableDialog(
width: 400,
height: 200,
content: content(),
);
});
},
child: Text('Open dialog')));
}),
);
}
}