Flutterando / slidy

CLI package manager and template for Flutter
https://pub.dev/packages/slidy
Apache License 2.0
803 stars 101 forks source link

Flutter/Dart - Player de vídeo não funciona fica por trás da tela, nem lista de imagem ou vídeo #225

Closed LukeGMs closed 3 years ago

LukeGMs commented 3 years ago

Infelizmente não consigo fazer com que o vídeo fique armazenado dentro de um pequeno espaço somente para exibi-lo para conferir! Peço até desculpas se for algo muito bobo, mas sou iniciante em flutter, neste mesmo código não consegui adicionar uma lista de imagens conforme fosse capturada ou selecionada na galeria e além disto, é esse problema com o player de vídeo! Alguém pode incentivar este iniciante a continuar a programar? Estou com esse problema a dias!

Meu codigo:

import 'dart:ffi';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:image_picker/image_picker.dart';
import 'package:ouvidoria_mvl/confirmacao.dart';
import 'package:video_player/video_player.dart';

class Anonimo extends StatefulWidget {
  @override
  _AnonimoState createState() => _AnonimoState();
}

class _AnonimoState extends State<Anonimo> {
  File _imagem;
  File _imagemGaleria;
  File _video;
  VideoPlayerController _videoPlayerController;
  final picker = ImagePicker();

 void ImageVideo(ImageSource imagesource) async 
{
     _video = await ImagePicker.pickVideo(source: imagesource);

    if (_video == null) return null;
    _video = File(_video.path);

    _videoPlayerController = VideoPlayerController.file(_video)
      ..initialize().then((value) {
        setState(() {});
        _videoPlayerController.play();
      });
  }

  void ImagemCamera(ImageSource imageSource) async {
    _imagem = await ImagePicker.pickImage(source: imageSource);
    setState(() {
      _imagem = _imagem;
    });
  }
   void ImagemGaleria(ImageSource imageSource) async {
    _imagemGaleria = await ImagePicker.pickImage(source: imageSource);
    setState(() {
      _imagemGaleria = _imagemGaleria;
    });
  }

  void blockgiro() {
    SystemChrome.setPreferredOrientations(
        [DeviceOrientation.portraitDown, DeviceOrientation.portraitUp]);
  }

  TextEditingController _textProblemAn = TextEditingController();
  TextEditingController _textLocalAn = TextEditingController();

  final _formKey = GlobalKey<FormState>();

  @override
  Widget build(BuildContext context) {
    Color hexToColor(String code) {
      return Color(int.parse(code.substring(1, 7), radix: 16) + 0xFF000000);
    }

    return MaterialApp(
        debugShowCheckedModeBanner: false,
        title: "Ouvidoria Móvel",
        home: Material(
            child: Stack(children: <Widget>[
          Image.asset(
            "Assets/image/bn_anonimo.jpg",
            fit: BoxFit.cover,
            height: 1000,
          ),Form(key:_formKey, child:
          Container(
              padding: const EdgeInsets.all(30.0),
              color: Colors.transparent,
              child: Container(
                  child: Center(
                child: SingleChildScrollView(
                    child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                      Padding(padding: EdgeInsets.only(top: 50.0)),
                      SizedBox(
                        width: 200,
                        height: 150,
                        child: Image.asset(
                          'Assets/image/anonimo.png',
                          height: 10,
                          width: 10,
                          alignment: Alignment.center,
                        ),
                      ),
                      Text(
                        'Você esta no modo anônimo',
                        style: TextStyle(
                            color: Colors.white70,
                            fontSize: 25.0,
                            fontWeight: FontWeight.bold),
                      ),
                      Padding(padding: EdgeInsets.only(top: 50.0)),
                      //Inicio dos campos de texto
                      Padding(
                          padding: EdgeInsets.only(top: 10.0, bottom: 10.0)),
                      AnimatedContainer(
                        duration: Duration(microseconds: 1000),
                        curve: Curves.fastLinearToSlowEaseIn,
                        margin: EdgeInsets.only(bottom: 2, top: 2, right: 2),
                        decoration: BoxDecoration(
                          boxShadow: [
                            BoxShadow(
                                blurRadius: 2,
                                color: Colors.white,
                                offset: Offset(1, 1))
                          ],
                          borderRadius: BorderRadius.circular(30),
                        ),
                        child: TextFormField(
                          controller: _textLocalAn,
                          decoration: InputDecoration(
                            labelText: "Titulo da situação",
                            fillColor: Colors.white,
                            border: OutlineInputBorder(
                              borderRadius: BorderRadius.circular(25.0),
                              borderSide: BorderSide(),
                            ),
                            //fillColor: Colors.green
                          ),
                          validator: (val) {
                            if (val.length == 0) {
                              return "Não entendi, digitou algo";
                            } else {
                              return null;
                            }
                          },
                          keyboardType: TextInputType.streetAddress,
                          style: TextStyle(
                            fontFamily: "Poppins",
                          ),
                        ),
                      ),
                      //FINAL DO CAMPO DE ENDEREÇO
                      Padding(
                          padding: EdgeInsets.only(top: 10.0, bottom: 5.0)),
                      AnimatedContainer(
                        duration: Duration(microseconds: 1000),
                        curve: Curves.fastLinearToSlowEaseIn,
                        margin: EdgeInsets.only(bottom: 2, top: 2, right: 2),
                        decoration: BoxDecoration(
                          boxShadow: [
                            BoxShadow(
                                blurRadius: 2,
                                color: Colors.white,
                                offset: Offset(1, 1))
                          ],
                          borderRadius: BorderRadius.circular(30),
                        ),
                        child: TextFormField(
                          controller: _textProblemAn,
                          maxLines: 5,
                          decoration: InputDecoration(
                            labelText: "Detalhe da situação visualizada",
                            fillColor: Colors.white,
                            border: OutlineInputBorder(
                              borderRadius: BorderRadius.circular(25.0),
                              borderSide: BorderSide(),
                            ),
                            //fillColor: Colors.green
                          ),
                          validator: (val) {
                            if (val.length == 0) {
                              return "Não entendi, digitou algo";
                            } else {
                              return null;
                            }
                          },
                          keyboardType: TextInputType.text,
                          style: TextStyle(
                            fontFamily: "Poppins",
                          ),
                        ),
                      ),
                      Padding(
                          padding: EdgeInsets.only(top: .2, bottom: 2.0)),Container(margin: EdgeInsets.all(20),child:
                      AnimatedContainer(
                          duration: Duration(microseconds: 1000),
                          curve: Curves.fastLinearToSlowEaseIn,
                          margin: EdgeInsets.only(bottom: 2, top: 2, right: 2),
                          decoration: BoxDecoration(
                            boxShadow: [
                              BoxShadow(
                                  blurRadius: 2,
                                  color: Colors.transparent,
                                  offset: Offset(1, 1))
                            ],
                            borderRadius: BorderRadius.circular(30),
                          ),
                          child: _imagem != null
                              ? Image.file(_imagem)
                              : Center(
                                  child: Text(
                                    '',
                                    style: TextStyle(color: Colors.white),
                                  ),
                                ))),
                                Container(margin: EdgeInsets.all(20),child:
                      AnimatedContainer(
                          duration: Duration(microseconds: 1000),
                          curve: Curves.fastLinearToSlowEaseIn,
                          margin: EdgeInsets.only(bottom: 2, top: 2, right: 2),
                          decoration: BoxDecoration(
                            boxShadow: [
                              BoxShadow(
                                  blurRadius: 2,
                                  color: Colors.transparent,
                                  offset: Offset(1, 1))
                            ],
                            borderRadius: BorderRadius.circular(30),
                          ),
                          child: _video != null
                              ? Image.file(_video)
                              : Center(
                                  child: Text(
                                    '',
                                    style: TextStyle(color: Colors.white),
                                  ),
                                ))),
                                Container(margin: EdgeInsets.all(10),child:
                                AnimatedContainer(
                          duration: Duration(microseconds: 1000),
                          curve: Curves.fastLinearToSlowEaseIn,
                          margin: EdgeInsets.only(bottom: 2, top: 2, right: 2),
                          decoration: BoxDecoration(
                            boxShadow: [
                              BoxShadow(
                                  blurRadius: 2,
                                  color: Colors.transparent,
                                  offset: Offset(1, 1))
                            ],
                            borderRadius: BorderRadius.circular(30),
                          ),
                          child: _imagemGaleria != null
                              ? Image.file(_imagemGaleria)
                              : Center(
                                  child: Text(
                                    '',
                                    style: TextStyle(color: Colors.white),
                                  ),
                                ))),
                      Padding(
                        padding: EdgeInsets.only(bottom: 0, top: 0, left: 10, right: 10)),
                         Row(
                          mainAxisAlignment: MainAxisAlignment.end,
                          children: [
                            IconButton(
                                icon: Icon(
                                  Icons.camera_alt,
                                  color: Colors.teal,
                                  size: 35,
                                ),
                                onPressed: () {
                                  ImagemCamera(ImageSource.camera);
                                }),
                                Padding(padding: EdgeInsets.only(left: 10, right: 10)),
                                IconButton(
                                icon: Icon(
                                  Icons.image_rounded,
                                  color: Colors.teal,
                                  size: 35,
                                ),
                                onPressed: () {
                                  ImagemGaleria(ImageSource.gallery);
                                }),
                                 Padding(padding: EdgeInsets.only(left: 10, right: 10)),
                                IconButton(
                                icon: Icon(
                                  Icons.videocam,
                                  color: Colors.teal,
                                  size: 35,
                                ),
                                onPressed: () {
                                  ImageVideo(ImageSource.camera);
                                }),
                          ],
                        ),
                      Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: <Widget>[
                            Container(
                              margin: EdgeInsets.only(bottom: 20),
                              child: RaisedButton(
                                  color: Colors.red,
                                  splashColor: Colors.blue,
                                  child: Text(
                                    "Enviar",
                                    style: TextStyle(
                                        fontSize: 20,
                                        fontWeight: FontWeight.bold,
                                        color: Colors.white),
                                  ),
                                  onPressed: () {
                                    BoxDecoration(
                                      borderRadius: BorderRadius.circular(50),
                                      color: Colors.redAccent,
                                      boxShadow: [
                                        BoxShadow(
                                            color: Colors.red,
                                            blurRadius: 50,
                                            offset: Offset(
                                              10,
                                              0,
                                            ))
                                      ],
                                    );
                                    Navigator.push(
                                        context,
                                        MaterialPageRoute(
                                            builder: (context) =>
                                                PaginadeBoasVindasAN(
                                                    _textLocalAn.text,
                                                    _textProblemAn.text,
                                                    _imagem)));
                                  }),
                            )
                          ]),
                    ])),
              )))
    )])));

  }
}
Ascenio commented 3 years ago

Como o seu issue não tem a ver diretamente com slidy provavelmente você não terá suporte aqui. Tenta entrar no grupo da Flutterando no Telegram ou no Discord, pode ser que alguém te ajude.