问题描述
程序员家庭。我是编程新手,我很难将数据从屏幕传输到列表,用户可以在其中查看发送的消息。对不起,这个问题很愚蠢,但我已经在图书馆、视频等中尝试过了。但是我没有找到解决方案,请有人帮我解决这个问题吗?谢谢! (我已经被这个问题困扰了好几天了)。
我的代码:
import 'dart:io';
import 'package:Flutter/services.dart';
import 'package:animated_text_kit/animated_text_kit.dart';
import 'package:Flutter/cupertino.dart';
import 'package:Flutter/material.dart';
import 'package:animated_button/animated_button.dart';
import 'package:giffy_dialog/giffy_dialog.dart';
import 'package:mailer/mailer.dart';
import 'package:mailer/smtp_server/gmail.dart';
import 'package:ouvidoria_mvl/main.dart';
// ignore: must_be_immutable
class PaginadeBoasVindasAN extends StatelessWidget {
String _localAn;
String _problemaAn;
File _imagemAn;
File _imagemgaleriaAn;
PaginadeBoasVindasAN(
this._localAn,this._problemaAn,this._imagemAn,this._imagemgaleriaAn,);
final _formKey = GlobalKey<FormState>();
// Aqui vamos criar o e-mail - smtp
enviarMensagem() async {
String username = '@gmail.com';
String password = '4#';
final smtpServer = gmail(username,password);
// Use the SmtpServer class to configure an SMTP server:
// final smtpServer = SmtpServer('smtp.domain.com');
// See the named arguments of SmtpServer for further configuration
// options.
// Create our message.
final message = Message()
..from = Address('','')
..recipients.add('@gmail.com')
..ccRecipients.addAll(['destCc1@gmail.com','destCc1@gmail.com'])
..bccRecipients.add(Address('destCc1@gmail.com'))
..subject = '$_localAn :: ${DateTime.Now()}'
..text = 'LOCAL DA OCORRÊNCIA: $_localAn,n\ OCORRÊNCIA: $_problemaAn';
if ((_imagemAn != null) && (_imagemAn != ""))
message.attachments.add(FileAttachment(_imagemAn,));
if ((_imagemgaleriaAn!= null) && (_imagemgaleriaAn!= ""))
message.attachments.add(FileAttachment(_imagemgaleriaAn,));
try {
final sendReport = await send(message,smtpServer);
print('Mensagem enviada: ' + sendReport.toString());
} on MailerException catch (e) {
print('Mensagem não enviada.');
for (var p in e.problems) {
print('Problema: ${p.code}: ${p.msg}');
}
}
var connection = PersistentConnection(smtpServer);
await connection.send(message);
await connection.close();
}
// HERE THE APP CONfigURATION IS ENDED
// The Function below blocks the screen rotation,thus allowing the app to stay in vertical mode
void blockgiro() {
SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitDown,DeviceOrientation.portraitUp]);
}
@override
Widget build(BuildContext context) {
blockgiro();
return Stack(children: <Widget>[
Scaffold(
backgroundColor: Colors.white,body: SingleChildScrollView(
padding: EdgeInsets.only(bottom: 20),child: Container(
margin: EdgeInsets.all(10),color: Colors.transparent,child: Column(
crossAxisAlignment: CrossAxisAlignment.center,children: <Widget>[
Container(
margin: EdgeInsets.only(
left: 1,bottom: 10,top: 10,),padding: EdgeInsets.all(10),height: 200,decoration: Boxdecoration(
BoxShadow: [
BoxShadow(
blurRadius: 0,color: Colors.white,offset: Offset(0,0))
],borderRadius: BorderRadius.circular(13),color: Colors.white),child:
Image.asset("Assets/image/enviando-loading.gif")),Column(
mainAxisAlignment: MainAxisAlignment.center,children: [
Container(
padding: EdgeInsets.only(
bottom: 30,right: 1,left: 1,top: 20),Container(
margin: EdgeInsets.only(
left: 1,top: 5,decoration: Boxdecoration(
BoxShadow: [
BoxShadow(
blurRadius: 2,color: Colors.black54,offset: Offset(1,1))
],child: Align(
alignment: Alignment.topLeft,child: SizedBox(
width: 250.0,child: TypewriteranimatedTextKit(
pause: Duration(minutes: 10),speed: Duration(milliseconds: 100),onTap: () {
print("Tap Event");
},text: ['The location is this: $_localAn'],textStyle: TextStyle(
color: Colors.black,fontSize: 20.0,fontFamily: "Agne"),textAlign: TextAlign.start,Container(
margin: EdgeInsets.only(
left: 1,decoration: Boxdecoration(
BoxShadow: [
BoxShadow(
blurRadius: 4,offset: Offset(2,2))
],child: Align(
alignment: Alignment.topLeft,child: SizedBox(
width: 1000.0,child: TypewriteranimatedTextKit(
pause: Duration(minutes: 10),onTap: () {
print("Tap Event");
},text: [
'Its occurrence: $_problemaAn',],textStyle: TextStyle(
color: Colors.black,textAlign: TextAlign.justify,curve: Curves.linear),)),Container(
margin: EdgeInsets.all(10),child: _imagemAn != null
? Image.file(
_imagemAn,fit: BoxFit.scaleDown,)
: Center(
child: Text(
'',style: TextStyle(
color: Colors.black,fontWeight: FontWeight.w400),decoration: Boxdecoration(
BoxShadow: [
BoxShadow(
blurRadius: 1,borderRadius: BorderRadius.circular(30),color: Colors.transparent),child: _imagemgaleriaAn != null
? Image.file(
_imagemgaleriaAn,)
: Center(
child: Text(
'Capture a photo',Row(
mainAxisAlignment: MainAxisAlignment.center,children: [
TypewriteranimatedTextKit(
pause: Duration(minutes: 10),onTap: () {
print("Select below");
},text: [
'Need to edit your message?',textStyle: TextStyle(
fontWeight: FontWeight.w600,color: Colors.lightBlueAccent,textAlign: TextAlign.center,//INICIO DOS BOTOES SIM E NAO
Container(
padding: EdgeInsets.only(bottom: 50),crossAxisAlignment: CrossAxisAlignment.center,children: [
Container(
margin: EdgeInsets.only(
bottom: 2,top: 2,right: 55),alignment: Alignment.centerLeft,child: AnimatedButton(
shape: BoxShape.rectangle,child: Text(
'Edit',style: TextStyle(
fontSize: 15,fontWeight: FontWeight.w500,onpressed: () {
Navigator.pop(context);
},width: 70,height: 40,color: Theme.of(context).primaryColor,shadowDegree: ShadowDegree.dark,enabled: true,//ACIMA SIM,ABAIXO NÃO
Container(
margin: EdgeInsets.only(
bottom: 2,left: 55),alignment: Alignment.centerRight,child: AnimatedButton(
child: const Text(
'Send',style: TextStyle(
fontSize: 19,onpressed: () {
enviarMensagem();
showDialog(
context: context,builder: (_) => AssetGiffyDialog(
image: Image.asset(
'Assets/image/Correta.gif'),title: Text(
'Success',style: TextStyle(
fontSize: 22.0,fontWeight:
FontWeight.w600),description: Text(
'Hi,we received your message',style: TextStyle(),entryAnimation:
EntryAnimation.BottOM_RIGHT,onlyCancelButton: false,onOkButtonpressed: () async {
final result =
await Navigator.push(
context,MaterialPageRoute(
builder: (context) =>
splashScreen()));
},onlyOkButton: true,));
},)
],Container(
padding: EdgeInsets.only(bottom: 50),]))),)
]);
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)