Qries

Subscribe Us

Advertisement

Video Player App

Video Player App with Register & Login form:



main.dart

import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:video/home.dart';
import 'package:video/register.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
String email, password;

@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: LoginPage(),
);
}
}

class LoginPage extends StatefulWidget {
LoginPage({Key key}) : super(key: key);

@override
_LoginPageState createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
@override
// final _auth = FirebaseAuth.instance;
// bool showProgress = false;
String emails, passwords;

final GlobalKey<FormState> _loginFormKey = GlobalKey<FormState>();
TextEditingController email;
TextEditingController password;

@override
initState() {
email = new TextEditingController();
password = new TextEditingController();
super.initState();
// Firebase.initializeApp().whenComplete(() {
// print("completed");
// setState(() {});
// });
}

String pwdValidator(String value) {
if (value.length < 8) {
return 'Password must be longer than 8 characters';
} else {
return null;
}
}

@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Container(
color: Colors.white,
child: new ListView(
children: <Widget>[
Column(
children: <Widget>[
new Container(
height: 200.0,
color: Colors.white,
child: new Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 1.0),
child:
new Stack(fit: StackFit.loose, children: <Widget>[
Padding(
padding: EdgeInsets.only(
top: 90.0,
),

///Circle Avtar
child: new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new CircleAvatar(
backgroundColor: Colors.red,
radius: 50.0,
child: new Icon(
Icons.person,
size: 90,
color: Colors.white,
),
)
],
)),
]),
)
],
),
),
Form(
key: _loginFormKey,
child: new Container(
color: Color(0xffFFFFFF),
child: Padding(
padding: EdgeInsets.only(bottom: 25.0),
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
///Login lable
Padding(
padding: EdgeInsets.only(
left: 25.0, right: 25.0, bottom: 20, top: 20.0),
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
new Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new Text(
'Login',
style: TextStyle(
fontSize: 28.0,
fontWeight: FontWeight.bold),
),
],
),
],
),
),

///Email ID
Padding(
padding: EdgeInsets.only(
left: 25.0, right: 25.0, top: 20.0),
child: new Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
new Flexible(
child: new TextFormField(
decoration: InputDecoration(
prefixIcon: Icon(Icons.email),
contentPadding: EdgeInsets.fromLTRB(
20.0, 15.0, 20.0, 15.0),
hintText: "Enter Email ID",
border: OutlineInputBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(25),
topLeft: Radius.circular(10),
),
),
),
controller: email,
keyboardType: TextInputType.emailAddress,
validator: (value) {
if (value.isEmpty) {
return 'Please enter a Email address';
}
if (!value.contains('@')) {
return 'Email is invalid, must contain @';
}
if (!value.contains('.')) {
return 'Email is invalid, must contain .';
}
return null;
},
),
),
],
),
),

///Password
Padding(
padding: EdgeInsets.only(
left: 25.0, right: 25.0, top: 20.0),
child: new Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
new Flexible(
child: new TextFormField(
decoration: InputDecoration(
prefixIcon: Icon(Icons.vpn_key),
contentPadding: EdgeInsets.fromLTRB(
20.0, 15.0, 20.0, 15.0),
hintText: "Password",
border: OutlineInputBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(25),
topLeft: Radius.circular(10),
),
),
),
controller: password,
obscureText: true,
validator: (value) {
if (value.isEmpty) {
return 'Please enter a Password';
}
if (value.length < 8) {
return 'Password must be longer than 8 characters';
}
return null;
},
),
),
],
),
),

///Login Button
Padding(
padding: EdgeInsets.only(
left: 35.0, right: 35.0, top: 45.0),
child: new Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Expanded(
child: Padding(
padding: EdgeInsets.only(
right: 5.0,
left: 5.0,
),
child: Container(
height: 50,
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(16.0),
),
),
child: Text("Login",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 26,
color: Colors.white,
fontWeight: FontWeight.bold)),
color: Colors.red,
textColor: Colors.white,
onPressed: () {
if (_loginFormKey.currentState
.validate()) {
return showGeneralDialog(
context: context,
barrierDismissible: true,
transitionDuration:
Duration(milliseconds: 500),
barrierLabel:
MaterialLocalizations.of(
context)
.dialogLabel,
barrierColor:
Colors.black.withOpacity(0.5),
pageBuilder: (context, _, __) {
return Column(
mainAxisAlignment:
MainAxisAlignment.start,
children: <Widget>[
Container(
width:
MediaQuery.of(context)
.size
.width,
color: Colors.white,
child: Card(
color: Colors
.grey.shade300,
child: ListView(
shrinkWrap: true,
children: <Widget>[
Container(
color: Colors.grey
.shade300,
child: ListTile(
trailing:
RaisedButton
.icon(
color: Colors
.yellow,
onPressed:
() {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) =>
Home()));
},
icon: Icon(
Icons
.move_to_inbox,
color: Colors
.black,
),
label: Text(
"OK",
style: TextStyle(
color: Colors
.black),
),
),
leading: Text(
"Thanks!",
style:
TextStyle(
fontSize:
20,
),
),
),
),
],
),
),
),
],
);
},
transitionBuilder: (context,
animation,
secondaryAnimation,
child) {
return SlideTransition(
position: CurvedAnimation(
parent: animation,
curve: Curves.easeInOutSine,
).drive(Tween<Offset>(
begin: Offset(0, -1.0),
end: Offset.zero,
)),
child: child,
);
},
);

// Navigator.pushReplacement(context,
// MaterialPageRoute(builder: (context) => Home()));
}
},
),
),
),
flex: 2,
),
],
),
),
SizedBox(
height: 10,
),
Center(child: Text("Don't have an account yet?")),
Center(
child: FlatButton(
child: Text(
"Register here!",
style: TextStyle(
fontSize: 20,
),
),
// onPressed: () async {
// setState(() {
// showProgress = true;
// });

// try {
// final newUser =
// await _auth.signInWithEmailAndPassword(
// email: emails, password: passwords);

// print(newUser.toString());
// } catch (e) {}
// },

onPressed: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => Register()));
},
),
)
],
),
),
),
)
],
),
],
),
),
);
}
}

register.dart

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:video/home.dart';
import 'package:video/main.dart';

class Register extends StatefulWidget {
Register({Key key}) : super(key: key);

@override
_RegisterState createState() => _RegisterState();
}

class _RegisterState extends State<Register> {
// final _auth = FirebaseAuth.instance;
// bool showProgress = false;
String emails, passwords;

final GlobalKey<FormState> _loginFormKey = GlobalKey<FormState>();
TextEditingController email;
TextEditingController password;
TextEditingController firstname;
TextEditingController lastname;
TextEditingController confpassword;
TextEditingController mobileno;

@override
initState() {
email = new TextEditingController();
password = new TextEditingController();
firstname = new TextEditingController();
lastname = new TextEditingController();
confpassword = new TextEditingController();
mobileno = new TextEditingController();

super.initState();
}

@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Container(
color: Colors.white,
child: new ListView(
children: <Widget>[
Column(
children: <Widget>[
new Container(
color: Colors.white,
child: new Column(
children: <Widget>[
///Circular Avtar
Padding(
padding: EdgeInsets.only(top: 1.0),
child:
new Stack(fit: StackFit.loose, children: <Widget>[
Padding(
padding: EdgeInsets.only(
top: 20.0,
),
child: new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new CircleAvatar(
backgroundColor: Colors.red,
radius: 50.0,
child: new Icon(
Icons.person,
size: 90,
color: Colors.white,
),
)
],
)),
]),
)
],
),
),
Form(
key: _loginFormKey,
child: new Container(
color: Color(0xffFFFFFF),

///Register title
child: Padding(
padding: EdgeInsets.only(bottom: 25.0),
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Padding(
padding: EdgeInsets.only(
left: 25.0, right: 25.0, bottom: 20, top: 10.0),
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
new Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new Text(
'Register',
style: TextStyle(
fontSize: 28.0,
fontWeight: FontWeight.bold),
),
],
),
],
),
),

///First Name
Padding(
padding: EdgeInsets.only(
left: 25.0, right: 25.0, top: 10.0),
child: new Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
new Flexible(
child: new TextFormField(
decoration: InputDecoration(
prefixIcon: Icon(Icons.person),
contentPadding: EdgeInsets.fromLTRB(
20.0, 15.0, 20.0, 15.0),
hintText: "First Name",
border: OutlineInputBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(25),
topLeft: Radius.circular(10),
),
),
),
controller: firstname,
keyboardType: TextInputType.name,
validator: (value) {
if (value.isEmpty) {
return 'Please enter a First Name';
}
return null;
},
),
),
],
),
),

///Last Name
Padding(
padding: EdgeInsets.only(
left: 25.0, right: 25.0, top: 10.0),
child: new Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
new Flexible(
child: new TextFormField(
decoration: InputDecoration(
prefixIcon: Icon(Icons.person_outline),
contentPadding: EdgeInsets.fromLTRB(
20.0, 15.0, 20.0, 15.0),
hintText: "Last Name",
border: OutlineInputBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(25),
topLeft: Radius.circular(10),
),
),
),
controller: lastname,
keyboardType: TextInputType.name,
validator: (value) {
if (value.isEmpty) {
return 'Please enter a Last Name';
}
return null;
},
),
),
],
),
),

///Email ID
Padding(
padding: EdgeInsets.only(
left: 25.0, right: 25.0, top: 10.0),
child: new Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
new Flexible(
child: new TextFormField(
decoration: InputDecoration(
prefixIcon: Icon(Icons.email),
contentPadding: EdgeInsets.fromLTRB(
20.0, 15.0, 20.0, 15.0),
hintText: "Enter Email ID",
border: OutlineInputBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(25),
topLeft: Radius.circular(10),
),
),
),
controller: email,
keyboardType: TextInputType.emailAddress,
validator: (value) {
if (value.isEmpty) {
return 'Please enter a Email address';
}
if (!value.contains('@')) {
return 'Email is invalid, must contain @';
}
if (!value.contains('.')) {
return 'Email is invalid, must contain .';
}
return null;
},
),
),
],
),
),

///Password
Padding(
padding: EdgeInsets.only(
left: 25.0, right: 25.0, top: 10.0),
child: new Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
new Flexible(
child: new TextFormField(
decoration: InputDecoration(
prefixIcon: Icon(Icons.vpn_key),
contentPadding: EdgeInsets.fromLTRB(
20.0, 15.0, 20.0, 15.0),
hintText: "Password",
border: OutlineInputBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(25),
topLeft: Radius.circular(10),
),
),
),
controller: password,
obscureText: true,
validator: (value) {
if (value.isEmpty) {
return 'Please enter a Password';
}
if (value.length < 8) {
return 'Password must be longer than 8 characters';
}
return null;
},
),
),
],
),
),

///Conforme Password
Padding(
padding: EdgeInsets.only(
left: 25.0, right: 25.0, top: 10.0),
child: new Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
new Flexible(
child: new TextFormField(
decoration: InputDecoration(
prefixIcon: Icon(Icons.lock_outline),
contentPadding: EdgeInsets.fromLTRB(
20.0, 15.0, 20.0, 15.0),
hintText: "Conforme Password",
border: OutlineInputBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(25),
topLeft: Radius.circular(10),
),
),
),
controller: confpassword,
obscureText: true,
validator: (value) {
if (value.isEmpty) {
return 'Please enter a Conforme Password';
}
if (password.value !=
confpassword.value) {
return 'Conforme Password not match';
}
return null;
},
),
),
],
),
),

///Mobile No.
Padding(
padding: EdgeInsets.only(
left: 25.0, right: 25.0, top: 10.0),
child: new Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
new Flexible(
child: new TextFormField(
decoration: InputDecoration(
prefixIcon: Icon(Icons.call),
contentPadding: EdgeInsets.fromLTRB(
20.0, 15.0, 20.0, 15.0),
hintText: "mobile no.",
border: OutlineInputBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(25),
topLeft: Radius.circular(10),
),
),
),
controller: mobileno,
obscureText: true,
validator: (value) {
if (value.isEmpty) {
return 'Please enter a Password';
}
return null;
},
),
),
],
),
),

///Register Button
Padding(
padding: EdgeInsets.only(
left: 35.0, right: 35.0, top: 20.0),
child: new Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Expanded(
child: Padding(
padding: EdgeInsets.only(
right: 5.0,
left: 5.0,
),
child: Container(
height: 50,
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(16.0),
),
),
child: Text(
"Register",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 26,
color: Colors.white,
fontWeight: FontWeight.bold),
),
color: Colors.red,
textColor: Colors.white,
onPressed: () {
if (_loginFormKey.currentState
.validate()) {
return showGeneralDialog(
context: context,
barrierDismissible: true,
transitionDuration:
Duration(milliseconds: 500),
barrierLabel:
MaterialLocalizations.of(
context)
.dialogLabel,
barrierColor:
Colors.black.withOpacity(0.5),
pageBuilder: (context, _, __) {
return Column(
mainAxisAlignment:
MainAxisAlignment.start,
children: <Widget>[
Container(
width:
MediaQuery.of(context)
.size
.width,
color: Colors.white,
child: Card(
color: Colors
.grey.shade300,
child: ListView(
shrinkWrap: true,
children: <Widget>[
Container(
color: Colors.grey
.shade300,
child: ListTile(
trailing:
RaisedButton
.icon(
color: Colors
.yellow,
// onPressed:
// () async {
// setState(
// () {
// showProgress =
// true;
// });
// try {
// final newuser = await _auth.createUserWithEmailAndPassword(
// email:
// emails,
// password:
// passwords);

// if (newuser !=
// null) {
// Navigator
// .push(
// context,
// MaterialPageRoute(
// builder: (context) => Home()),
// );

// setState(
// () {
// showProgress =
// false;
// });
// }
// } catch (e) {}
// },

onPressed:
() {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) =>
Home()));
},
icon: Icon(
Icons
.move_to_inbox,
color: Colors
.black,
),
label: Text(
"OK",
style: TextStyle(
color: Colors
.black),
),
),
leading: Text(
"Thanks!",
style:
TextStyle(
fontSize:
20,
),
),
),
),
],
),
),
),
],
);
},
transitionBuilder: (context,
animation,
secondaryAnimation,
child) {
return SlideTransition(
position: CurvedAnimation(
parent: animation,
curve: Curves.easeInOutSine,
).drive(Tween<Offset>(
begin: Offset(0, -1.0),
end: Offset.zero,
)),
child: child,
);
},
);
}
},
),
),
),
flex: 2,
),
],
),
),
SizedBox(
height: 3,
),
Center(
child: FlatButton(
child: Text(
"Login here!",
style: TextStyle(
fontSize: 20,
),
),
onPressed: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => LoginPage()));
},
),
)
],
),
),
),
)
],
),
],
),
),
);
}
}

home.dart

import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
import 'package:video/managevideo.dart';

class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blueGrey,
appBar: AppBar(
title: Text("Video Player"),
backgroundColor: Colors.pink,
),
body: ListView(
children: <Widget>[
Card(
child: Column(
children: [
Text(
"Flutter Top 5 Packages",
style: TextStyle(
fontSize: 20,
),
),
ChewieListItem(
videoPlayerController: VideoPlayerController.asset(
'videos/v1.mp4',
),
looping: true,
),
],
),
),

Card(
child: Column(
children: [
Text(
"Flutter Hover - 3D Effect",
style: TextStyle(
fontSize: 20,
),
),
ChewieListItem(
videoPlayerController: VideoPlayerController.asset(
'videos/v3.mp4',
),
looping: true,
),
],
),
),

// ChewieListItem(
// videoPlayerController: VideoPlayerController.network(
// 'https://drive.google.com/file/d/1JGTEF75nirI5gmAmdhXn_S7z9tVY-lJV/view?usp=sharing.mp4',
// ),
// ),

// ChewieListItem(
// // This URL doesn't exist - will display an error
// videoPlayerController: VideoPlayerController.network(
// 'http://events.maherlibrary.in',
// ),
// ),
],
),
);
}
}

managevideo.dart

import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
import 'package:chewie/chewie.dart';

class ChewieListItem extends StatefulWidget {
final VideoPlayerController videoPlayerController;
final bool looping;

ChewieListItem({
@required this.videoPlayerController,
this.looping,
Key key,
}) : super(key: key);

@override
_ChewieListItemState createState() => _ChewieListItemState();
}

class _ChewieListItemState extends State<ChewieListItem> {
ChewieController _chewieController;

@override
void initState() {
super.initState();
_chewieController = ChewieController(
videoPlayerController: widget.videoPlayerController,
aspectRatio: 16 / 9,
autoInitialize: true,
looping: widget.looping,
errorBuilder: (context, errorMessage) {
return Center(
child: Text(
errorMessage,
style: TextStyle(color: Colors.white),
),
);
},
);
}

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Chewie(
controller: _chewieController,
),
);
}

@override
void dispose() {
super.dispose();
widget.videoPlayerController.dispose();
_chewieController.dispose();
}
}

Post a Comment

0 Comments