Created
November 22, 2021 08:20
-
-
Save gabrielgatu/83d5e0d8a842c91b26595916af2de9a6 to your computer and use it in GitHub Desktop.
Flutter2Start - Dialog #flutter2start
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ignore_for_file: use_key_in_widget_constructors, prefer_const_constructors, prefer_const_literals_to_create_immutables | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(App()); | |
} | |
class App extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: HomePage(), | |
); | |
} | |
} | |
class HomePage extends StatelessWidget { | |
final TextEditingController emailController = TextEditingController(); | |
void showEmailDialog(BuildContext context) { | |
showDialog( | |
context: context, | |
builder: (context) => Dialog( | |
backgroundColor: Colors.white, | |
child: Container( | |
padding: EdgeInsets.all(16), | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
mainAxisSize: MainAxisSize.min, | |
children: [ | |
Text( | |
"Componi la tua email", | |
style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold), | |
), | |
SizedBox(height: 5), | |
Divider(), | |
TextField( | |
controller: emailController, | |
minLines: 3, | |
maxLines: 10, | |
decoration: InputDecoration( | |
hintText: "Il tuo messaggio", | |
border: InputBorder.none, | |
), | |
), | |
Divider(), | |
SizedBox( | |
width: double.infinity, | |
child: ElevatedButton( | |
onPressed: () { | |
final emailComposed = emailController.text.trim(); | |
print(emailComposed); | |
Navigator.pop(context); | |
}, | |
style: ButtonStyle( | |
backgroundColor: MaterialStateProperty.all( | |
Colors.red.shade100, | |
), | |
foregroundColor: MaterialStateProperty.all( | |
Colors.red.shade900, | |
), | |
), | |
child: Text("Spedici email"), | |
), | |
), | |
], | |
), | |
), | |
)); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("Flutter2Start"), | |
centerTitle: true, | |
), | |
body: Center( | |
child: Text("Empty."), | |
), | |
floatingActionButton: FloatingActionButton.extended( | |
backgroundColor: Colors.red.shade100, | |
foregroundColor: Colors.red.shade900, | |
splashColor: Colors.red.shade200, | |
icon: Icon(Icons.add), | |
label: Text("Email"), | |
onPressed: () => showEmailDialog(context), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment