Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.41 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. class OverlayDialogPage extends ModalRoute<void> {
  4. @override
  5. Duration get transitionDuration => Duration(milliseconds: 100);
  6.  
  7. @override
  8. bool get opaque => false;
  9.  
  10. @override
  11. bool get barrierDismissible => false;
  12.  
  13. @override
  14. Color get barrierColor => Colors.black.withOpacity(0.5);
  15.  
  16. @override
  17. String get barrierLabel => null;
  18.  
  19. @override
  20. bool get maintainState => true;
  21.  
  22. @override
  23. Widget buildPage(
  24. BuildContext context,
  25. Animation<double> animation,
  26. Animation<double> secondaryAnimation,
  27. ) {
  28. return Material(
  29. type: MaterialType.transparency,
  30. child: SafeArea(
  31. child: _buildOverlayContent(context),
  32. ),
  33. );
  34. }
  35.  
  36. Widget _buildOverlayContent(BuildContext context) {
  37. return Center(
  38. child: dialogContent(context),
  39. );
  40. }
  41.  
  42. @override
  43. Widget buildTransitions(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
  44. return FadeTransition(
  45. opacity: animation,
  46. child: ScaleTransition(
  47. scale: animation,
  48. child: child,
  49. ),
  50. );
  51. }
  52.  
  53. // ダイアログ
  54. Widget dialogContent(BuildContext context) {
  55. return Stack(
  56. children: <Widget>[
  57. Padding(
  58. padding: const EdgeInsets.all(32.0),
  59. child: Container(
  60. padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 32.0),
  61. decoration: new BoxDecoration(
  62. color: Colors.white,
  63. shape: BoxShape.rectangle,
  64. borderRadius: BorderRadius.circular(16),
  65. boxShadow: [
  66. BoxShadow(
  67. color: Colors.black26,
  68. blurRadius: 10.0,
  69. offset: const Offset(0.0, 10.0),
  70. ),
  71. ],
  72. ),
  73. child: Column(
  74. mainAxisSize: MainAxisSize.min,
  75. children: <Widget>[
  76. Text(
  77. "Text Widget",
  78. style: TextStyle(
  79. fontSize: 18.0,
  80. fontWeight: FontWeight.w700,
  81. color: Colors.blue[800],
  82. ),
  83. ),
  84. SizedBox(height: 8.0),
  85. Text(
  86. "Text Widget",
  87. style: TextStyle(
  88. fontSize: 24.0,
  89. fontWeight: FontWeight.bold,
  90. ),
  91. ),
  92. SizedBox(height: 16.0),
  93. Container(
  94. height: 130.0,
  95. child: Placeholder(),
  96. ),
  97. SizedBox(height: 16.0),
  98. Container(
  99. height: 130.0,
  100. child: Placeholder(),
  101. ),
  102. SizedBox(height: 16.0),
  103. Align(
  104. alignment: Alignment.bottomCenter,
  105. child: Container(
  106. height: 50.0,
  107. width: double.infinity,
  108. child: RaisedButton(
  109. onPressed: () {
  110. Navigator.of(context).pop(); // To close the dialog
  111. },
  112. shape: RoundedRectangleBorder(
  113. borderRadius: BorderRadius.all(Radius.circular(30.0)),
  114. ),
  115. color: Colors.blue[800],
  116. child: Text(
  117. "次へ",
  118. style: TextStyle(
  119. color: Colors.white,
  120. fontWeight: FontWeight.bold,
  121. fontSize: 18.0,
  122. ),
  123. ),
  124. ),
  125. ),
  126. ),
  127. ],
  128. ),
  129. ),
  130. ),
  131. Positioned(
  132. bottom: 0,
  133. right: -30,
  134. child: IgnorePointer(
  135. child: FlutterLogo(
  136. size: 150,
  137. colors: Colors.orange,
  138. ),
  139. ),
  140. ),
  141. Positioned(
  142. top: 0,
  143. bottom: 0,
  144. left: -30,
  145. child: IgnorePointer(
  146. child: FlutterLogo(
  147. size: 150,
  148. ),
  149. ),
  150. ),
  151. Positioned(
  152. top: -10,
  153. right: 0,
  154. left: 0,
  155. child: IgnorePointer(
  156. child: FlutterLogo(
  157. size: 150,
  158. colors: Colors.purple,
  159. ),
  160. ),
  161. ),
  162. ],
  163. );
  164. }
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement