0% found this document useful (0 votes)
49 views7 pages

Flutter Car Parking System Code

The document contains a Flutter application for a car parking system, allowing users to input vehicle numbers and select vehicle types (Car or Bike). It manages a list of parked vehicles, tracks the total number of parked vehicles and earnings, and provides options to filter and park out vehicles. The application uses a stateful widget to handle user interactions and updates the UI accordingly.

Uploaded by

M Tech Solutions
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views7 pages

Flutter Car Parking System Code

The document contains a Flutter application for a car parking system, allowing users to input vehicle numbers and select vehicle types (Car or Bike). It manages a list of parked vehicles, tracks the total number of parked vehicles and earnings, and provides options to filter and park out vehicles. The application uses a stateful widget to handle user interactions and updates the UI accordingly.

Uploaded by

M Tech Solutions
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

import 'dart:ffi';

import 'package:flutter/[Link]';
import 'package:studentregistration/MidTermTask/Screens/Vec
[Link]';

class Parkin extends StatefulWidget {


const Parkin({[Link]});

@override
State<Parkin> createState() => _ParkinState();
}

class _ParkinState extends State<Parkin> {


TextEditingController Numbercontroller = TextEditingContr
oller();
int b1 = 1;
String? Type;
int? parkcount = 0, Earning = 0;

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Car Parking System"),
backgroundColor: [Link],
),
body: Padding(
padding: [Link](10),
child: Column(
children: [
Container(
width: 300,
height: 60,
child: TextFormField(
controller: Numbercontroller,

Untitled 1
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'VehicleNumber',
labelText: 'VehicleNumber'),
),
),
Row(
children: [
Radio(
value: "Car",
groupValue: Type,
onChanged: (String? val) {
setState(() {
Type = val;
});
}),
Text('Car'),
SizedBox(
width: 10,
),
Radio(
value: "Bike",
groupValue: Type,
onChanged: (String? val) {
setState(() {
Type = val;
});
}),
Text('Bike'),
SizedBox(
width: 50,
),
Container(
height: 50,
width: 100,
child: ElevatedButton(
onPressed: () {
setState(() {

Untitled 2
parkcount = parkcount! + 1;
vechicle v1 = vechicle(
Number: [Link]
t,
Status: 1,
Type: Type);
vechile_list.add(v1);
Filter =
vechile_list.where((e) => e.S
tatus == 1).toList();
});
},
child: Text("Park in"),
),
)
],
),
SizedBox(
height: 5,
),
Row(
children: [
Container(
height: 30,
width: 70,
color: b1 == 1 ? [Link] : Colors.g
rey,
child: ElevatedButton(
onPressed: () {
setState(() {
b1 = 1;
Filter =
vechile_list.where((e) => e.S
tatus == 1).toList();
print(Filter);
});
},
child: Text("All"),

Untitled 3
),
),
SizedBox(
width: 5,
),
Container(
height: 30,
width: 70,
color: b1 == 2 ? [Link] : Colors.g
rey,
child: ElevatedButton(
onPressed: () {
setState(() {
b1 = 2;
Filter = vechile_list
.where((e) => [Link] == 1 &
& [Link] == "Car")
.toList();
});
},
child: Text("Car"),
),
),
SizedBox(
width: 5,
),
Container(
height: 30,
width: 75,
color: b1 == 3 ? [Link] : Colors.g
rey,
child: ElevatedButton(
onPressed: () {
setState(() {
b1 = 3;
Filter = vechile_list
.where((e) => [Link] == 1 &
& [Link] == "Bike")

Untitled 4
.toList();
});
},
child: Text("Bike"),
),
),
SizedBox(
width: 5,
),
Container(
height: 30,
width: 120,
color: b1 == 4 ? [Link] : Colors.g
rey,
child: ElevatedButton(
onPressed: () {
setState(() {
b1 = 4;
Filter = parkout_list;
});
},
child: Text("Park out"),
),
),
],
),
SizedBox(
height: 10,
),
Row(
children: [
Text("Total Park is : ${parkcount}"),
SizedBox(
width: 100,
),
Text("Total Earning is : ${Earning}"),
],
),

Untitled 5
Container(
child: Expanded(
child: Container(
child: [Link](
itemCount: [Link],
itemBuilder: (context, index) {
vechicle sobj = Filter[index];
return ListTile(
onTap: () {},
title: Text('Bike Number : ${sob
[Link]}'),
subtitle: Text('Type : ${[Link]
e}'),
trailing: b1 != 4 ? Parkout(sobj)
: Text(""));
}),
)))
],
),
));
}

ElevatedButton Parkout(vechicle sobj) {


return ElevatedButton(
onPressed: () {
setState(() {
vechile_list.remove(sobj);
parkout_list.add(sobj);
Filter = vechile_list.where((e) => [Link] ==
1).toList();
Earning = Earning! + 30;
parkcount = parkcount! - 1;
});
},
child: Text("parkOut"),
);
}
}

Untitled 6
class vechicle {
String? Number;
String? Type;
int? Status;

vechicle({required [Link], required [Link], req


uired [Link]});
}

List<vechicle> vechile_list = [];


List<vechicle> park_list = [];
List<vechicle> parkout_list = [];
List<vechicle> Filter = vechile_list.where((e) => [Link]
== 1).toList();

Untitled 7

You might also like