Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- void main() => runApp(MyApp());
- class MyApp extends StatelessWidget {
- // 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: MyHomePage(),
- );
- }
- }
- class MyHomePage extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: Center(
- child: RaisedButton(
- color: Color(0xFF1BC0C5),
- shape:
- RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
- child: SizedBox(
- width: 100,
- height: 50,
- child: Center(
- child: Text("Click Me"),
- ),
- ),
- onPressed: () {
- showDialog(
- context: context,
- builder: (BuildContext context) => CustomDialog(
- title: "Success",
- description:
- "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
- buttonText: "Okay",
- ),
- );
- },
- ),
- ),
- );
- }
- }
- class CustomDialog extends StatelessWidget {
- final String title, description, buttonText;
- final Image image;
- CustomDialog({
- @required this.title,
- @required this.description,
- @required this.buttonText,
- this.image,
- });
- @override
- Widget build(BuildContext context) {
- return Dialog(
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(16),
- ),
- elevation: 0.0,
- backgroundColor: Colors.transparent,
- child: dialogContent(context),
- );
- }
- dialogContent(BuildContext context) {
- return Stack(
- children: <Widget>[
- Container(
- padding: EdgeInsets.only(
- top: 100,
- bottom: 16,
- left: 16,
- right: 16,
- ),
- margin: EdgeInsets.only(top: 16),
- decoration: new BoxDecoration(
- color: Colors.white,
- shape: BoxShape.rectangle,
- borderRadius: BorderRadius.circular(16),
- boxShadow: [
- BoxShadow(
- color: Colors.black26,
- blurRadius: 10.0,
- offset: const Offset(0.0, 10.0),
- ),
- ],
- ),
- child: Column(
- mainAxisSize: MainAxisSize.min, // To make the card compact
- children: <Widget>[
- Text(
- title,
- style: TextStyle(
- fontSize: 24.0,
- fontWeight: FontWeight.w700,
- ),
- ),
- SizedBox(height: 16.0),
- Text(
- description,
- textAlign: TextAlign.center,
- style: TextStyle(
- fontSize: 16.0,
- ),
- ),
- SizedBox(height: 24.0),
- Align(
- alignment: Alignment.bottomRight,
- child: FlatButton(
- onPressed: () {
- Navigator.of(context).pop(); // To close the dialog
- },
- child: Text(buttonText),
- ),
- ),
- ],
- ),
- ),
- Positioned(
- top: 0,
- left: 16,
- right: 16,
- child: CircleAvatar(
- backgroundColor: Colors.blueAccent,
- radius: 50,
- backgroundImage: AssetImage('assets/XLpr.gif'),
- ),
- ),
- ],
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement