Name : Sanskar Kumar
Register no : 24MCA1066
Mobile App Development Lab
Session : 11 , 12 and 13
File format :
Lib → models →category.dart
enum ProjectCategory{
ai(
title : "Artificial Intelligence",
description : "Cutting edge research on AI and Ml",
image: "ai_img.jpeg"
),
cyberSecurity(
title : "Cyber Security",
description : "Research on recent trends in cyber security",
image : "cyber.jpeg"
),
robotics(
title : "Robotics",
description : "Research based on AI and robotics",
image : "robotics.jpg"
),
wn(
title : "Wireless Networking",
description : "Research based on wireless network and communication",
image : "wireless.jpeg"
);
const ProjectCategory({
required this.title,
required this.description,
required this.image
});
final String title;
final String description;
final String image;
}
Lib → models → project.dart
import 'package:research_app/models/category.dart';
import 'package:research_app/models/stats.dart';
import 'package:research_app/skill.dart';
class Project with Stats{
Project({
required this.id,
required this.title,
required this.description,
required this.category,
});
final Set<Skill>skills = {};
final ProjectCategory category;
final String id;
final String title;
final String description;
bool _isFeatured = false;
bool get isFeatured => _isFeatured;
void toggleisFeatured(){
_isFeatured = !_isFeatured;
}
void updateSkill(Skill skill){
skills.clear();
skills.add(skill);
}
static List<Project> projects = [
Project(id : '1',title: 'Image Recognition',description: "Recognise Number
Plates",category: ProjectCategory.ai),
Project(id: '2', title: 'Cyber Security', description: 'Securing Servers',
category: ProjectCategory.cyberSecurity),
Project(id: '3', title: "Wireless Networking", description:"Wirelessly
connecting devices", category: ProjectCategory.wn),
Project(id: '4', title: "Robotics", description: "Autonomous UAV", category:
ProjectCategory.robotics),
];
static int get length => projects.length;
}
Lib → models → stats.dart
mixin Stats{
int _citiation = 10;
int _download = 10;
int _view = 10;
int _collaboration = 10;
Map<String,int> get statsAsMap =>{
"citiation" : _citiation,
"download" : _download,
"view" : _view,
"collaboration":_collaboration
};
List<Map<String,String>>get statsAsFormattedList => [
{'title':'citiation','value':_citiation.toString()},
{'title':'download','value':_download.toString()},
{'title':'view','value':_collaboration.toString()},
];
void increaseStat(String stat){
if(stat == 'citiation'){
_citiation ++;
}
if(stat == 'download'){
_download ++;
}
if(stat == 'view'){
_view ++;
}
if(stat == 'collaboration'){
_collaboration ++;
}
}
void decreaseStat(String stat){
if(stat == 'citiation' && _citiation > 0){
_citiation--;
}
if(stat == 'download' && _download > 0){
_download--;
}
if(stat == 'view' && _view > 0){
_view --;
}
if(stat == 'collaboration' && _collaboration > 0){
_collaboration--;
}
}
}
Lib → screens → home → home.dart
import 'package:flutter/material.dart';
import 'package:research_app/models/project.dart';
import 'package:research_app/screens/home/project_card.dart';
import 'package:research_app/shared/shared_button.dart';
import 'package:research_app/shared/shared_text.dart';
class Home extends StatefulWidget{
const Home({super.key});
@override
State<Home>createState()=>_HomeState();
}
class _HomeState extends State<Home>{
@override
Widget build(BuildContext context){
return Scaffold(
appBar: AppBar(
title: StyledTitle('My projects'),
centerTitle: true,
) ,
body:Container(
padding: EdgeInsets.all(16),
child: Column(
children: [
Expanded(
child: ListView.builder(
itemCount: Project.projects.length,
itemBuilder: (_,index){
return ProjectCard(Project.projects[index]
);
},
),
),
StyledButton(onPressed: (){}, child: StyledHeading("Create New")),
],
),
)
);
}
}
Lib → screens → home → project_card.dart
import 'package:flutter/material.dart';
import 'package:research_app/models/project.dart';
import 'package:research_app/shared/shared_text.dart';
import 'package:research_app/theme.dart';
class ProjectCard extends StatelessWidget{
const ProjectCard(this.project,{super.key});
final Project project;
@override
Widget build(BuildContext context){
return Card(
child:Padding(
padding: EdgeInsets.symmetric(horizontal: 24,vertical: 16),
child:Row(
children:[
Image.asset(
'assets/img/category/${project.category.image}',
width : 80,
),
SizedBox(width : 20),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
StyledHeading(project.title),
StyledText(project.category.title),
],
),
Expanded(child:SizedBox()),
IconButton(
onPressed:(){},
icon: Icon(
Icons.arrow_forward,
color: AppColors.textColor,
),
),
],
),
),
);
}
}
Lib → shared →shared_button.dart
import 'package:flutter/material.dart';
import 'package:research_app/theme.dart';
class StyledButton extends StatelessWidget{
const StyledButton({super.key,required this.onPressed,required this.child});
final Function() onPressed;
final Widget child;
@override
Widget build(BuildContext context){
return TextButton(
onPressed:onPressed,
child :Container(
padding:EdgeInsets.symmetric(vertical:10,horizontal: 20),
decoration: BoxDecoration(
gradient: LinearGradient(colors :
[AppColors.primaryColor,AppColors.primaryAccent],
begin:Alignment.topCenter,
end:Alignment.bottomCenter
),
borderRadius: BorderRadius.all(Radius.circular(10))
),
child:child,
)
);
}
}
Lib → shared → shared_text.dart
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class StyledText extends StatelessWidget{
const StyledText(this.text,{super.key});
final String text;
@override
Widget build(BuildContext context){
return Text(
text,
style:
GoogleFonts.kanit(textStyle:Theme.of(context).textTheme.bodyMedium),
);
}
}
class StyledHeading extends StatelessWidget{
const StyledHeading(this.text,{super.key});
final String text;
@override
Widget build(BuildContext context){
return Text(
text.toUpperCase(),
style:GoogleFonts.kanit(textStyle:Theme.of(context).textTheme.headlineMediu
m),
);
}
}
class StyledTitle extends StatelessWidget{
const StyledTitle(this.text,{super.key});
final String text;
@override
Widget build(BuildContext context){
return Text(
text.toUpperCase(),
style:GoogleFonts.kanit(textStyle:Theme.of(context).textTheme.titleMedium),
);
}
}
Lib → main.dart
import 'package:flutter/material.dart';
import 'package:research_app/screens/home/home.dart';
import 'package:research_app/theme.dart';
void main() {
runApp(MaterialApp(
theme: primaryTheme,
home: const Home(),
));
}
Lib→ skill.dart
import 'package:research_app/models/category.dart';
class Skill {
final String id;
final String name;
final String image;
final ProjectCategory projectCategory;
Skill(
{required this.id,
required this.name,
required this.image,
required this.projectCategory});
final List<Skill> allSkill = [
Skill(
id: '1',
name: 'Machine Learning Algorithms',
image: 'Machine_Learning_Algorithms.jpg',
projectCategory: ProjectCategory.ai),
Skill(
id: '2',
name: 'Data Processing',
image: 'Data_Processing.jpg',
projectCategory: ProjectCategory.ai),
Skill(
id: '3',
name: 'Neural Network',
image: 'Neural_Network.jpg',
projectCategory: ProjectCategory.ai),
Skill(
id: '4',
name: 'NLP',
image: 'nlp.jpg',
projectCategory: ProjectCategory.ai),
Skill(
id: '5',
name: 'Penetration Testing',
image: 'Penetration_Testing.jpg',
projectCategory: ProjectCategory.cyberSecurity),
Skill(
id: '6',
name: 'Cryptography',
image: 'Cryptography.jpg',
projectCategory: ProjectCategory.cyberSecurity),
Skill(
id: '7',
name: 'Incident Response',
image: 'Incident_Response.jpg',
projectCategory: ProjectCategory.cyberSecurity),
Skill(
id: '8',
name: 'Network Security',
image: 'ns.jpg',
projectCategory: ProjectCategory.cyberSecurity),
Skill(
id: '9',
name: 'Network Protocols',
image: 'netp.jpg',
projectCategory: ProjectCategory.wn),
Skill(
id: '10',
name: 'Routing & Switching',
image: 'rs.jpg',
projectCategory: ProjectCategory.wn),
Skill(
id: '11',
name: 'Signal Processing',
image: 'sp.jpg',
projectCategory: ProjectCategory.wn),
Skill(
id: '12',
name: 'Network Simulation',
image: 'nets.jpg',
projectCategory: ProjectCategory.wn),
Skill(
id: '13',
name: 'Robotic Motion Planning',
image: 'rmp.jpg',
projectCategory: ProjectCategory.robotics),
Skill(
id: '14',
name: 'Computer Vision',
image: 'cv.jpg',
projectCategory: ProjectCategory.robotics),
Skill(
id: '15',
name: 'Embedded Systems',
image: 'es.jpg',
projectCategory: ProjectCategory.robotics),
Skill(
id: '16',
name: 'Control Systems',
image: 'cs.jpg',
projectCategory: ProjectCategory.robotics),
];
}
Lib→ theme.dart
import 'package:flutter/material.dart';
class AppColors{
static Color primaryColor = const Color.fromRGBO(162,29,19,1);
static Color primaryAccent = const Color.fromRGBO(120, 14, 14, 1);
static Color secondaryColor = const Color.fromRGBO(45,45,45,1);
static Color secondaryAccent = const Color.fromRGBO(35,35,35,1);
static Color titleColor = const Color.fromRGBO(200,200,200,1);
static Color textColor = const Color.fromRGBO(150,150,150,1);
static Color successColor = const Color.fromRGBO(9,149,110,1);
static Color highlightColor = const Color.fromRGBO(212,172,13,1);
}
ThemeData primaryTheme = ThemeData(colorScheme:
ColorScheme.fromSeed(seedColor:AppColors.primaryColor),
scaffoldBackgroundColor: AppColors.secondaryAccent,
appBarTheme: AppBarTheme(
backgroundColor: AppColors.secondaryColor,
foregroundColor: AppColors.textColor,
surfaceTintColor: Colors.transparent,
centerTitle: true
),
textTheme:TextTheme(
bodyMedium: TextStyle(
color:AppColors.textColor,
fontSize: 16,
fontWeight : FontWeight.bold,
letterSpacing: 1,
),
headlineMedium: TextStyle(
color:AppColors.titleColor,
fontSize: 20,
fontWeight : FontWeight.bold,
letterSpacing: 1,
),
titleMedium: TextStyle(
color:AppColors.titleColor,
fontSize: 24,
fontWeight : FontWeight.bold,
letterSpacing: 2,
),
)
);
Output: