Last active
January 18, 2023 18:06
-
-
Save Vatsal596/0bbbbaa21f9e288c7ba4eb594eb342c8 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
//Enter Marks | |
import 'package:flutter/cupertino.dart'; | |
import 'package:flutter/material.dart'; | |
import 'dart:math'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
TextEditingController textbox =new TextEditingController(); | |
List<int> arrtextbox =[]; | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home:Scaffold( | |
appBar: AppBar(title: Text("text box"),), | |
body: Column( | |
children: [ | |
Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: TextField( | |
controller: textbox, | |
decoration: InputDecoration( | |
labelText: "Enter Marks", | |
), | |
), | |
), | |
Padding( | |
padding: const EdgeInsets.all(20.0), | |
child: ElevatedButton(onPressed: () { | |
int marks=int.parse(textbox.text); | |
arrtextbox.add(marks); | |
print(arrtextbox); | |
}, child:Text("Save")), | |
), | |
Padding( | |
padding: const EdgeInsets.all(10.0), | |
child: ElevatedButton(onPressed: () { | |
print(arrtextbox.reduce((max))); | |
}, child:Text("Max")), | |
) | |
], | |
), | |
), | |
); | |
} | |
} | |
// Login | |
import 'package:flutter/material.dart'; | |
void main(){ | |
runApp(MaterialApp( | |
home: MyApp(), | |
)); | |
} | |
class MyApp extends StatelessWidget { | |
MyApp({Key? key}) : super(key: key); | |
TextEditingController txtUserName = new TextEditingController(); | |
TextEditingController txtPwd = new TextEditingController(); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(title: Text("Login")), | |
body: Column( | |
crossAxisAlignment: CrossAxisAlignment.center, | |
children: [ | |
CircleAvatar( | |
backgroundImage: AssetImage("one.jpeg"), | |
radius: 50, | |
backgroundColor: Colors.red, | |
), | |
TextField( | |
controller: txtUserName, | |
decoration: InputDecoration( | |
icon: Icon(Icons.verified_user), | |
hintText: "Username", | |
labelText: "Enter Username"), | |
), | |
TextField( | |
controller: txtPwd, | |
decoration: InputDecoration( | |
icon: Icon(Icons.verified_sharp), | |
hintText: "Password", | |
labelText: "Enter password", | |
), | |
), | |
Container( | |
margin: EdgeInsets.all(20.8), | |
child: ElevatedButton(onPressed: () {}, child: Text("Login")) | |
) | |
], | |
), | |
floatingActionButton: FloatingActionButton(onPressed: () { | |
print(txtUserName.text); | |
},), | |
); | |
} | |
} | |
//Prime Number | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MaterialApp( | |
home: MyFirstApp(), | |
)); | |
} | |
class MyFirstApp extends StatelessWidget { | |
const MyFirstApp({super.key}); | |
void printMyName() { | |
print("Vatsal Bhatiya"); | |
} | |
void printPrimeNos() { | |
for (int no = 1; no <=10; no++) { | |
int totalFactors = 0; | |
for (int cntr = 1; cntr <= no; cntr++) { | |
if(no % cntr == 0) { | |
totalFactors = totalFactors + 1; | |
} | |
} | |
if (totalFactors == 2) { | |
print("$no is prime"); | |
} else { | |
print("$no is not prime"); | |
} | |
} | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: Center( | |
child: ElevatedButton.icon( | |
onPressed: () => printMyName(), | |
label: Text("Call"), | |
icon: Icon(Icons.add_call), | |
), | |
), | |
floatingActionButton: FloatingActionButton( | |
onPressed: () => printPrimeNos(), | |
child: Icon( | |
Icons.clear, | |
color: Colors.red, | |
), | |
), | |
appBar: AppBar(title: Text("Prime No")), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment