0% found this document useful (0 votes)
37 views4 pages

Add Income Page for Finance App

The document is a Flutter Dart code for an 'Add Income' page in a finance application. It includes a dropdown for selecting income sources, a text field for entering the income amount, and buttons to save the data or go back to the homepage. The code also handles HTTP requests to add the balance to a database and updates the UI accordingly.

Uploaded by

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

Add Income Page for Finance App

The document is a Flutter Dart code for an 'Add Income' page in a finance application. It includes a dropdown for selecting income sources, a text field for entering the income amount, and buttons to save the data or go back to the homepage. The code also handles HTTP requests to add the balance to a database and updates the UI accordingly.

Uploaded by

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

import 'dart:convert';

import 'package:http/[Link]' as http;


import 'package:flutter/[Link]';
import 'package:flutter/[Link]';
import '[Link]';
import '[Link]';
import '[Link]';

class AddIncomePage extends StatefulWidget {


const AddIncomePage({[Link]});

@override
State<AddIncomePage> createState() => _AddIncomePageState();
}

class _AddIncomePageState extends State<AddIncomePage> {

//PARA SA DROPDOWN LIST TO PAR YUNG MAGSESELECT KA, PARANG NAKA LIST MUNA TAS
MAUUNA SA BLANK, NASA OPTION DIN YUNG BLANK TIGNAN MO NALANG SA BABA
String selectedOptionIncome = '';

TextEditingController add_salary = TextEditingController();

Future<void> addbalance() async{

final uri = link + "add_balance.php";


Map<String, dynamic> userbalance =
{
'balancename' : selectedOptionIncome,
'balancevalue' : add_salary.text,
'userid' : [Link]()
};

final response = await [Link]([Link](uri), body: userbalance);


print([Link]);

@override

Widget build(BuildContext context) {


return Scaffold(
appBar: AppBar(
title:
Text('My Finance App'),
),

drawer: Drawer(
width: 0,
),

//DESIGN ULET MARAMI


body: Padding(
padding: const [Link](top: 3),
child: Container(
decoration: BoxDecoration(
border: [Link](
color: [Link], // Set your desired border color
width: 2.0,
// Set the border width
),
color: [Link],
// Set the color inside the border
),
child: Padding(
padding: const [Link](left: 20,right: 20),
child: Column(
children: [
SizedBox(height: 40,),

//BASTA DIALOG PARANG ALERT DIALOG STYLE WIDGET PARA DI LUMAYO


DESIGN SA KANINA
ClipRRect(
borderRadius: [Link](30.0),
child: Container(
decoration: BoxDecoration(
border: [Link](
color: [Link],
width: 2.0,
),
color: [Link],
),
height: 370.0,
width: 400.0,
padding: [Link](20.0),
child: Column(
crossAxisAlignment: [Link],
children: <Widget>[
//TITLE LANG TO SA TAAS
Text('INCOME', style: TextStyle(fontWeight:
[Link], fontSize: 20)),
SizedBox(height: 20),

//TEXT LANG TO BAGO PUMILI


Text('Source of Income',style: TextStyle(fontWeight:
[Link]),),

Container(
decoration: BoxDecoration(
borderRadius: [Link](10.0), // Adjust
the radius as needed
border: [Link](
color: [Link], // Set the border color
width: 3.0, // Set the border width
),
),

//DROPDOWN SELECT OPTION PIPILI NA KUNG ANO I ADD


child: DropdownButton<String>(
hint: Text('Select an option'),
// Hint text before selecting an option
value: selectedOptionIncome,
onChanged: (String? newValue){
setState(() {
selectedOptionIncome = newValue!;
});
},

//ETO PWEDE MAGLAGAY OPTION


items: ['','Savings', 'Salary', 'Others',]
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
underline: Container()
),
),
SizedBox(height: 20),

//TATAWGIN YOUNG SELECTED OPTION SA TAAS KUNG ANO SINELECT


MO
Text('You Select to Add: $selectedOptionIncome'),

SizedBox(height: 20),
Text('Income Amount',style: TextStyle(fontWeight:
[Link]),),

//ETO YUNG SA ENTER AMOUNT MA DESIGN LANG KAYA MAHABA


Padding(
padding: const [Link](right: 60,top: 8),
child: Container(
decoration: BoxDecoration(
borderRadius: [Link](10.0), // Adjust
the radius as needed
border: [Link](
color: [Link], // Set the border color
width: 3.0, // Set the border width
),
),

//ETO SA TEXTFIELD NUMBERS LANG PWEDE INPUT AMOUNT


child: TextFormField(
controller: add_salary,
keyboardType: [Link],
inputFormatters: <TextInputFormatter>[
[Link]
], // Only numbers can be entered
decoration: InputDecoration(
border: [Link],
// Remove default border
contentPadding: [Link](horizontal:
10.0),
//HINT TEXT PARANG LABELTEXT LANG
hintText: 'Enter Amount in ₱',
),
),
),
),
SizedBox(height: 20),
// Add your text field for numbers here
SizedBox(height: 20),
Row(
mainAxisAlignment: [Link],
children: [
ElevatedButton(
onPressed: () async{
// Handle the button press
await addbalance();
add_salary.text = "";
[Link](context,
MaterialPageRoute(builder: (context) => Homepage()));
add_salary.text = "";

},

//ETO PAR LAGAY MO NALANG PAG NAG SAVE MA SAVE YUNG


DATA SA DATABASE
child: Text('Save',style: TextStyle(color:
[Link]),),
style: [Link](
backgroundColor: [Link],
),
),
SizedBox(width: 20),
TextButton(
onPressed: () {
// Handle the button press
[Link](context, MaterialPageRoute(builder:
(context) => Homepage())); // Close the dialog
},

//GO BACK , BABALIK LANG SA HOMEPAGE


child: Text('Go Back',style: TextStyle(color:
[Link]),),
style: [Link](backgroundColor:
[Link]),
),
],
),
],
),
),
),

],
),
),
),
),
);
}
}

You might also like