Last active
April 11, 2023 05:43
-
-
Save Vatsal596/d761b5d99816efe374ec7d5b9a82615f to your computer and use it in GitHub Desktop.
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
import 'dart:ui'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter_application_1/percentage.dart'; | |
void main() { | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Set-1', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: const MyHomePage(title: 'SET-1'), | |
debugShowCheckedModeBanner: false, | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
const MyHomePage({super.key, required this.title}); | |
final String title; | |
@override | |
State<MyHomePage> createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
int _counter = 0; | |
TextEditingController UserName = TextEditingController(); | |
TextEditingController Email = TextEditingController(); | |
TextEditingController PassWord = TextEditingController(); | |
TextEditingController ConfirmPassword = TextEditingController(); | |
bool _validateUser = false; | |
bool _validateEmail = false; | |
bool _validatePass = false; | |
bool _validateConfpass = false; | |
void _incrementCounter() { | |
setState(() { | |
_counter++; | |
}); | |
} | |
String? get _errorText { | |
final text = UserName.value.text; | |
if (text.isEmpty) { | |
return 'Can\'t be empty'; | |
} | |
return null; | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
), | |
body: Center( | |
child: Container( | |
width: 500, | |
height: 700, | |
decoration: BoxDecoration( | |
color: Colors.blueAccent, | |
boxShadow: [ | |
BoxShadow(color: Colors.black54, spreadRadius: 3), | |
], | |
borderRadius: BorderRadius.circular(10)), | |
child: Column( | |
children: [ | |
SizedBox( | |
height: 80, | |
), | |
Container( | |
width: 120, | |
height: 120, | |
decoration: BoxDecoration( | |
borderRadius: BorderRadius.circular(50), | |
color: Colors.white38, | |
image: DecorationImage( | |
fit: BoxFit.cover, | |
image: NetworkImage( | |
"https://cdn.pixabay.com/photo/2021/03/02/17/26/pixel-6063246_1280.png"))), | |
), | |
SizedBox( | |
height: 20, | |
), | |
Row( | |
children: [ | |
SizedBox( | |
width: 10, | |
), | |
Text( | |
"UserName:- ", | |
style: TextStyle(color: Colors.white, fontSize: 18), | |
), | |
SizedBox( | |
width: 10, | |
), | |
Expanded( | |
child: TextField( | |
controller: UserName, | |
decoration: InputDecoration( | |
errorText: | |
_validateUser ? 'Value Can\'t Be Empty' : null, | |
enabledBorder: const OutlineInputBorder( | |
borderSide: const BorderSide( | |
color: Colors.grey, width: 0.0), | |
), | |
fillColor: Colors.white, | |
border: OutlineInputBorder(), | |
hintText: 'Enter Your Username', | |
hintStyle: TextStyle(color: Colors.white)), | |
style: TextStyle(color: Colors.white), | |
), | |
), | |
SizedBox( | |
width: 20, | |
) | |
], | |
), | |
SizedBox( | |
height: 15, | |
), | |
Row( | |
children: [ | |
SizedBox( | |
width: 10, | |
), | |
Text( | |
"Email:- ", | |
style: TextStyle(color: Colors.white, fontSize: 18), | |
), | |
SizedBox( | |
width: 10, | |
), | |
Expanded( | |
child: TextField( | |
controller: Email, | |
decoration: InputDecoration( | |
enabledBorder: const OutlineInputBorder( | |
borderSide: const BorderSide( | |
color: Colors.grey, width: 0.0), | |
), | |
fillColor: Colors.white, | |
border: OutlineInputBorder(), | |
hintText: 'Enter Your Email', | |
hintStyle: TextStyle(color: Colors.white), | |
errorText: | |
_validateEmail ? 'Value Can\'t Be Empty' : null), | |
style: TextStyle(color: Colors.white), | |
), | |
), | |
SizedBox( | |
width: 20, | |
) | |
], | |
), | |
SizedBox( | |
height: 15, | |
), | |
Row( | |
children: [ | |
SizedBox( | |
width: 10, | |
), | |
Text( | |
"Password:- ", | |
style: TextStyle(color: Colors.white, fontSize: 18), | |
), | |
SizedBox( | |
width: 10, | |
), | |
Expanded( | |
child: TextField( | |
controller: PassWord, | |
decoration: InputDecoration( | |
enabledBorder: const OutlineInputBorder( | |
borderSide: const BorderSide( | |
color: Colors.grey, width: 0.0), | |
), | |
fillColor: Colors.white, | |
border: OutlineInputBorder(), | |
hintText: 'Enter Your Password', | |
hintStyle: TextStyle(color: Colors.white), | |
errorText: | |
_validatePass ? 'Value Can\'t Be Empty' : null), | |
style: TextStyle(color: Colors.white), | |
), | |
), | |
SizedBox( | |
width: 20, | |
) | |
], | |
), | |
SizedBox( | |
height: 15, | |
), | |
Row( | |
children: [ | |
SizedBox( | |
width: 10, | |
), | |
Text( | |
"Confirm Password:- ", | |
style: TextStyle(color: Colors.white, fontSize: 18), | |
), | |
SizedBox( | |
width: 10, | |
), | |
Expanded( | |
child: TextField( | |
controller: ConfirmPassword, | |
cursorColor: Colors.white, | |
decoration: InputDecoration( | |
enabledBorder: const OutlineInputBorder( | |
borderSide: const BorderSide( | |
color: Colors.grey, width: 0.0), | |
), | |
fillColor: Colors.white, | |
border: OutlineInputBorder(), | |
hintText: 'Confirm your password', | |
hintStyle: TextStyle(color: Colors.white), | |
errorText: _validateConfpass | |
? 'Value Can\'t Be Empty' | |
: null), | |
style: TextStyle(color: Colors.white), | |
), | |
), | |
SizedBox( | |
width: 20, | |
) | |
], | |
), | |
SizedBox( | |
height: 30, | |
), | |
ElevatedButton( | |
onPressed: () { | |
setState(() { | |
UserName.text.isEmpty | |
? _validateUser = true | |
: _validateUser = false; | |
Email.text.isEmpty | |
? _validateEmail = true | |
: _validateEmail = false; | |
PassWord.text.isEmpty | |
? _validatePass = true | |
: _validatePass = false; | |
}); | |
if (PassWord.value.text == ConfirmPassword.value.text && | |
ConfirmPassword.text.isNotEmpty) { | |
setState(() { | |
_validateConfpass = false; | |
}); | |
} else { | |
setState(() { | |
_validateConfpass = true; | |
}); | |
} | |
}, | |
child: Text( | |
"Sign Up", | |
style: TextStyle( | |
fontWeight: FontWeight.w800, color: Colors.blueAccent), | |
), | |
style: ElevatedButton.styleFrom( | |
backgroundColor: Colors.white, | |
fixedSize: const Size(120, 50), | |
shape: RoundedRectangleBorder( | |
borderRadius: BorderRadius.circular(50))), | |
) | |
], | |
), | |
), | |
), | |
floatingActionButton: FloatingActionButton( | |
onPressed: () { | |
Navigator.push( | |
context, | |
MaterialPageRoute(builder: (context) => const Percent()), | |
); | |
}, | |
tooltip: 'Next Page', | |
child: const Icon(Icons.navigate_next_rounded), | |
), | |
); | |
} | |
} |
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
import 'package:flutter/material.dart'; | |
import 'package:flutter/src/widgets/container.dart'; | |
import 'package:flutter/src/widgets/framework.dart'; | |
class Percent extends StatefulWidget { | |
const Percent({super.key}); | |
@override | |
State<Percent> createState() => _PercentState(); | |
} | |
class _PercentState extends State<Percent> { | |
TextEditingController marks = TextEditingController(); | |
TextEditingController name = TextEditingController(); | |
double maxi = -10000; | |
double mini = 100000; | |
List student = []; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("Max/Min Percentage"), | |
), | |
body: Row( | |
children: [ | |
SizedBox( | |
width: 90, | |
), | |
Center( | |
child: Container( | |
width: 500, | |
height: 600, | |
decoration: BoxDecoration( | |
color: Colors.blueAccent, | |
boxShadow: [ | |
BoxShadow(color: Colors.black54, spreadRadius: 3), | |
], | |
borderRadius: BorderRadius.circular(10)), | |
child: Column( | |
children: [ | |
SizedBox( | |
height: 100, | |
), | |
Row( | |
children: [ | |
SizedBox( | |
width: 20, | |
), | |
Text("Enter Name:- ", | |
style: TextStyle(color: Colors.white, fontSize: 18)), | |
SizedBox( | |
width: 20, | |
), | |
Expanded( | |
child: TextField( | |
controller: name, | |
cursorColor: Colors.white, | |
decoration: InputDecoration( | |
enabledBorder: const OutlineInputBorder( | |
borderSide: const BorderSide( | |
color: Colors.grey, width: 0.0), | |
), | |
fillColor: Colors.white, | |
border: OutlineInputBorder(), | |
hintText: 'Enter Name', | |
hintStyle: TextStyle(color: Colors.white), | |
), | |
style: TextStyle(color: Colors.white), | |
), | |
), | |
SizedBox( | |
width: 20, | |
) | |
], | |
), | |
SizedBox( | |
height: 10, | |
), | |
Row( | |
children: [ | |
SizedBox( | |
width: 20, | |
), | |
Text("Enter Marks:- ", | |
style: TextStyle(color: Colors.white, fontSize: 18)), | |
SizedBox( | |
width: 20, | |
), | |
Expanded( | |
child: TextField( | |
controller: marks, | |
cursorColor: Colors.white, | |
decoration: InputDecoration( | |
enabledBorder: const OutlineInputBorder( | |
borderSide: const BorderSide( | |
color: Colors.grey, width: 0.0), | |
), | |
fillColor: Colors.white, | |
border: OutlineInputBorder(), | |
hintText: 'Enter Marks', | |
hintStyle: TextStyle(color: Colors.white), | |
), | |
style: TextStyle(color: Colors.white), | |
), | |
), | |
SizedBox( | |
width: 20, | |
) | |
], | |
), | |
SizedBox( | |
height: 20, | |
), | |
ElevatedButton( | |
onPressed: () { | |
setState(() { | |
student.add({ | |
'Name': name.value.text, | |
'Marks': double.parse(marks.text.toString()) | |
}); | |
}); | |
print(student); | |
}, | |
child: Text( | |
"Add Marks", | |
style: TextStyle( | |
fontWeight: FontWeight.w800, | |
color: Colors.blueAccent), | |
), | |
style: ElevatedButton.styleFrom( | |
backgroundColor: Colors.white, | |
fixedSize: const Size(120, 50), | |
shape: RoundedRectangleBorder( | |
borderRadius: BorderRadius.circular(50))), | |
), | |
SizedBox( | |
height: 10, | |
), | |
Row( | |
children: [ | |
ElevatedButton( | |
onPressed: () { | |
setState(() { | |
for (int i = 0; i < student.length; i++) { | |
if (maxi < student[i]['Marks']) { | |
maxi = student[i]['Marks']; | |
} | |
} | |
}); | |
print(student); | |
}, | |
child: Text( | |
"Get Max", | |
style: TextStyle( | |
fontWeight: FontWeight.w800, | |
color: Colors.blueAccent), | |
), | |
style: ElevatedButton.styleFrom( | |
backgroundColor: Colors.white, | |
fixedSize: const Size(120, 50), | |
shape: RoundedRectangleBorder( | |
borderRadius: BorderRadius.circular(50))), | |
), | |
SizedBox( | |
width: 20, | |
), | |
Text(maxi < 0 ? "0" : maxi.toString(), | |
style: TextStyle(color: Colors.white, fontSize: 20)) | |
], | |
), | |
SizedBox( | |
height: 10, | |
), | |
Row( | |
children: [ | |
ElevatedButton( | |
onPressed: () { | |
setState(() { | |
for (int i = 0; i < student.length; i++) { | |
if (mini > student[i]['Marks']) { | |
mini = student[i]['Marks']; | |
} | |
} | |
}); | |
print(student); | |
}, | |
child: Text( | |
"Get Min", | |
style: TextStyle( | |
fontWeight: FontWeight.w800, | |
color: Colors.blueAccent), | |
), | |
style: ElevatedButton.styleFrom( | |
backgroundColor: Colors.white, | |
fixedSize: const Size(120, 50), | |
shape: RoundedRectangleBorder( | |
borderRadius: BorderRadius.circular(50))), | |
), | |
SizedBox( | |
width: 20, | |
), | |
Text(mini == 100000 ? "0" : mini.toString(), | |
style: TextStyle(color: Colors.white, fontSize: 20)) | |
], | |
) | |
], | |
), | |
), | |
), | |
SizedBox( | |
width: 50, | |
), | |
Container( | |
width: 500, | |
height: 600, | |
decoration: BoxDecoration( | |
color: Colors.blueAccent, | |
boxShadow: [ | |
BoxShadow(color: Colors.black54, spreadRadius: 3), | |
], | |
borderRadius: BorderRadius.circular(10)), | |
child: Column( | |
children: [ | |
Expanded( | |
child: ListView.builder( | |
itemCount: student.length, | |
itemBuilder: (context, index) { | |
return ListTile( | |
title: Text( | |
student[index]['Name'].toString(), | |
style: TextStyle(color: Colors.white, fontSize: 20), | |
), | |
trailing: Text(student[index]['Marks'].toString(), | |
style: | |
TextStyle(color: Colors.white, fontSize: 20)), | |
); | |
}, | |
), | |
), | |
], | |
), | |
) | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment