Advertisement
Guest User

example flutter

a guest
Jan 2nd, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 4.15 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() => runApp(MyApp());
  4.  
  5. class MyApp extends StatelessWidget {
  6.   @override
  7.   Widget build(BuildContext context) {
  8.     return MaterialApp(
  9.       title: 'Flutter Demo',
  10.       theme: ThemeData(
  11.         primarySwatch: Colors.blue,
  12.       ),
  13.       home: MyHomePage(title: 'Flutter Demo Home Page'),
  14.     );
  15.   }
  16. }
  17.  
  18. class MyHomePage extends StatefulWidget {
  19.   MyHomePage({Key key, this.title}) : super(key: key);
  20.  
  21.   final String title;
  22.  
  23.   @override
  24.   _MyHomePageState createState() => _MyHomePageState();
  25. }
  26.  
  27. class _MyHomePageState extends State<MyHomePage> {
  28.  
  29.   Page progressDialog = Page.getProgressDialog();
  30.  
  31.   @override
  32.   Widget build(BuildContext context) {
  33.     return Scaffold(
  34.       appBar: AppBar(
  35.         title: Text(widget.title),
  36.       ),
  37.       body: Stack(
  38.         children: <Widget>[
  39.           Center(
  40.             child: Column(
  41.               mainAxisAlignment: MainAxisAlignment.center,
  42.               children: <Widget>[
  43.                 RaisedButton(
  44.                   onPressed: (){
  45.                     progressDialog.showProgress();
  46.                   },
  47.                   child: Text('Show dialog'),
  48.                 )
  49.               ],
  50.             ),
  51.           ),
  52.           progressDialog,
  53.         ],  
  54.       ),
  55.     );
  56.   }
  57. }
  58.  
  59.  
  60. //---------------------------------------
  61. class Page extends StatefulWidget {
  62.  
  63.   PageState seguimientoDialogState;
  64.  
  65.   @override
  66.   createState() => seguimientoDialogState = new PageState();
  67.  
  68.   void showProgress() {
  69.     seguimientoDialogState.showProgress();
  70.   }
  71.   static Widget getProgressDialog() {
  72.     return new Page();
  73.   }
  74. }
  75.  
  76. class PageState extends State <Page> {
  77.  
  78.   bool _opacity = false;
  79.  
  80.   @override
  81.   void initState() {
  82.     super.initState();
  83.   }
  84.  
  85.   @override
  86.   Widget build(BuildContext context) {
  87.     return new Container(
  88.       child: !_opacity
  89.         ? null
  90.         : new Opacity(
  91.           opacity: _opacity ? 1.0 : 0.0,
  92.           child: new Container(
  93.             color: Colors.black54,
  94.             child: new Stack(
  95.               children: <Widget>[
  96.                 new Center(
  97.                   child: Stack(
  98.                     children: <Widget>[
  99.                       Padding(
  100.                         padding: EdgeInsets.all(4.0),
  101.                         child: Card(
  102.                           shape: RoundedRectangleBorder(
  103.                             borderRadius: BorderRadius.circular(10.0),
  104.                           ),
  105.                           child: Container(
  106.                             width: MediaQuery.of(context).size.width-50.0,
  107.                             height: MediaQuery.of(context).size.height-100.0,
  108.                             padding: EdgeInsets.all(10.0),
  109.                             child: Column(
  110.                               crossAxisAlignment: CrossAxisAlignment.center,
  111.                               children: <Widget>[
  112.                                 Padding(
  113.                                   padding: EdgeInsets.all(5.0),
  114.                                   child: Container(
  115.                                     child: Text('test'),
  116.                                     color: Colors.green[100],
  117.                                   )
  118.                                 ),
  119.                               ],
  120.                             ),
  121.                           ),
  122.                         ),
  123.                       ),
  124.                       Positioned(
  125.                         top: .0,
  126.                         right: .0,
  127.                         child: InkWell(
  128.                           //child: Image.asset('assets/close_alt.png',width: 25.0,),
  129.                           child: Icon(Icons.close, color:Colors.black, size: 25.0),
  130.                           onTap: () {
  131.                             setState(() {
  132.                               _opacity=false;
  133.                             });
  134.                           },
  135.                         ),
  136.                       )
  137.                     ],
  138.                   ),
  139.                 ),
  140.               ],
  141.             ),
  142.           ),
  143.         )
  144.     );
  145.   }
  146.   void showProgress() {
  147.     setState(() {
  148.       _opacity = true;
  149.     });
  150.   }
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement