Skip to content

Instantly share code, notes, and snippets.

@masashi-sutou
Last active May 21, 2019 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masashi-sutou/5807334b4ac814b15c2c43e92012808a to your computer and use it in GitHub Desktop.
Save masashi-sutou/5807334b4ac814b15c2c43e92012808a to your computer and use it in GitHub Desktop.
Flutter Tokyo Meetup #9 で発表したときのサンプルコード
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatelessWidget {
final String title;
const MyHomePage({this.title});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(title)),
body: Center(
child: RaisedButton(
child: Text('リッチなポップアップ'),
onPressed: () {
_showRichPopup(context);
},
),
),
);
}
void _showRichPopup(BuildContext context) {
showGeneralDialog(
context: context,
barrierLabel: 'Dismiss',
barrierColor: Colors.black.withOpacity(0.5),
barrierDismissible: false,
transitionDuration: const Duration(milliseconds: 200),
transitionBuilder: (_, animation, __, child) {
return ScaleTransition(
alignment: Alignment.center,
scale: animation,
child: child,
);
},
pageBuilder: (context, _, __) {
final size = MediaQuery.of(context).size;
return Center(
child: SizedBox(
height: size.height * 0.7,
width: size.width * 0.8,
child: Card(
elevation: 8,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(12),
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Icon(
Icons.image,
size: 200,
),
Text(
'Rich Popup Screen 😁',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black,
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Text(
'Lorem ipsum dolor sit amet, consectetur adipisicing 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. ',
textAlign: TextAlign.left,
maxLines: 5,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Colors.grey,
fontSize: 18,
),
),
),
FlatButton(
onPressed: () {
Navigator.pop(context);
},
color: Colors.blue,
shape: StadiumBorder(),
child: Text(
'OK',
style: TextStyle(color: Colors.white),
),
)
],
),
),
),
);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment