Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
Flood Prediction
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Intelligent Tank Management System
Flood Prediction
Commits
52fd1ea9
Commit
52fd1ea9
authored
Apr 27, 2022
by
Mohamed Naseef
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
main.dart
parent
e15088b4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
268 additions
and
0 deletions
+268
-0
main.dart
main.dart
+268
-0
No files found.
main.dart
0 → 100644
View file @
52fd1ea9
import
'dart:io'
;
import
'package:dropdownfield/dropdownfield.dart'
;
import
'package:flutter/material.dart'
;
import
'package:image_picker/image_picker.dart'
;
import
'package:http/http.dart'
as
http
;
import
'AjouterVoiture.dart'
;
import
'package:searchfield/searchfield.dart'
;
void
main
(
)
{
runApp
(
const
MyApp
());
}
class
MyApp
extends
StatelessWidget
{
const
MyApp
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
title:
'Flutter Demo'
,
theme:
ThemeData
(
primarySwatch:
Colors
.
blue
,
),
debugShowCheckedModeBanner:
false
,
home:
AllPersonData
(),
);
}
}
class
DemoUploadImage
extends
StatefulWidget
{
@override
_DemoUploadImage
createState
()
=>
_DemoUploadImage
();
}
class
_DemoUploadImage
extends
State
<
DemoUploadImage
>
{
File
?
_image
;
final
picker
=
ImagePicker
();
TextEditingController
marqueController
=
TextEditingController
();
TextEditingController
modelController
=
TextEditingController
();
TextEditingController
vitesseController
=
TextEditingController
();
TextEditingController
placeController
=
TextEditingController
();
TextEditingController
prixController
=
TextEditingController
();
TextEditingController
couleurController
=
TextEditingController
();
TextEditingController
disponibleController
=
TextEditingController
();
TextEditingController
CodeController
=
TextEditingController
();
bool
editMode
=
false
;
Future
choiceImage
()
async
{
var
pickedImage
=
await
picker
.
getImage
(
source
:
ImageSource
.
gallery
);
setState
(()
{
_image
=
File
(
pickedImage
!.
path
);
});
}
Future
upload
()
async
{
final
uri
=
Uri
.
parse
(
"http://192.168.43.245/location/upload.php"
);
var
request
=
http
.
MultipartRequest
(
'POST'
,
uri
);
request
.
fields
[
'marque'
]
=
marqueController
.
text
;
request
.
fields
[
'Modele'
]
=
modelController
.
text
;
request
.
fields
[
'vitesses'
]
=
vitesseController
.
text
;
request
.
fields
[
'nbr_places'
]
=
placeController
.
text
;
request
.
fields
[
'Prix'
]
=
prixController
.
text
;
request
.
fields
[
'Couleur'
]
=
couleurController
.
text
;
request
.
fields
[
'Disponibilite'
]
=
'DISPONIBLE'
;
request
.
fields
[
'Code'
]
=
CodeController
.
text
;
var
pic
=
await
http
.
MultipartFile
.
fromPath
(
"image"
,
_image
!.
path
);
request
.
files
.
add
(
pic
);
var
response
=
await
request
.
send
();
if
(
response
.
statusCode
==
200
)
{
print
(
'Image Uploaded'
);
}
else
{
print
(
'Image Not Uploaded'
);
}
}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
backgroundColor:
Colors
.
purple
.
shade900
,
title:
Center
(
child:
Text
(
'AJOUTER'
)),
),
body:
SingleChildScrollView
(
child:
Column
(
children:
<
Widget
>[
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
TextFormField
(
controller:
marqueController
,
decoration:
InputDecoration
(
labelText:
'Marque'
,
contentPadding:
EdgeInsets
.
fromLTRB
(
20
,
15
,
20
,
15
),
border:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
circular
(
20
),
),
),
),
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
TextFormField
(
controller:
modelController
,
decoration:
InputDecoration
(
labelText:
'Modele'
,
contentPadding:
EdgeInsets
.
fromLTRB
(
20
,
15
,
20
,
15
),
border:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
circular
(
20
),
),
),
),
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
TextFormField
(
controller:
placeController
,
decoration:
InputDecoration
(
labelText:
'Nomber Place'
,
contentPadding:
EdgeInsets
.
fromLTRB
(
20
,
15
,
20
,
15
),
border:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
circular
(
20
),
),
),
),
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
TextFormField
(
controller:
prixController
,
decoration:
InputDecoration
(
labelText:
'Prix'
,
contentPadding:
EdgeInsets
.
fromLTRB
(
20
,
15
,
20
,
15
),
border:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
circular
(
20
),
),
),
),
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
TextFormField
(
controller:
CodeController
,
decoration:
InputDecoration
(
labelText:
'Code Voiture'
,
contentPadding:
EdgeInsets
.
fromLTRB
(
20
,
15
,
20
,
15
),
border:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
circular
(
20
),
),
),
),
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
DropDownField
(
controller:
vitesseController
,
hintText:
"Type de Moteur"
,
enabled:
true
,
items:
moteur
,
onValueChanged:
(
value
)
{
setState
(()
{
selectMoteur
=
value
;
});
},
),
// SearchField(
// hint: "Type de Moteur",
// controller: vitesseController,
// suggestions: [
// 'Gasoil',
// 'Essence',
// 'Hybride',
// ],
// ),
),
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
DropDownField
(
controller:
couleurController
,
hintText:
"Couleurs"
,
enabled:
true
,
items:
couleurs
,
onValueChanged:
(
value
)
{
setState
(()
{
selectCouleur
=
value
;
});
},
),
// SearchField(
// hint: "Couleur",
// controller: couleurController,
// suggestions: [
// 'Noir',
// 'Rouge',
// 'Jaune',
// 'Blanc',
// 'Bleu',
// 'Gris',
// 'Violet',
// 'Orange',
// 'Vert',
// ],
// ),
),
// Padding(
// padding: const EdgeInsets.all(8.0),
// child: TextField(
// controller: disponibleController,
// decoration: InputDecoration(labelText: 'Disponibilite'),
// ),
// ),
IconButton
(
icon:
Icon
(
Icons
.
image
),
onPressed:
()
{
choiceImage
();
},
),
Container
(
child:
_image
==
null
?
Text
(
'Aucune Image Selectionnee'
)
:
Image
.
file
(
_image
!),
),
SizedBox
(
height:
10
,
),
RaisedButton
(
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
10
)),
disabledColor:
Colors
.
purple
.
shade900
,
child:
Text
(
'Ajoute'
),
onPressed:
()
{
upload
();
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
AllPersonData
(),
),
);
},
)
],
),
));
}
}
String
selectCouleur
=
""
;
String
selectMoteur
=
""
;
List
<
String
>
couleurs
=
[
'Noir'
,
'Blanc'
,
'Jaune'
,
'Vert'
,
'Bleu'
,
'Rouge'
,
'Gris'
,
'Brun'
,
'Orange'
,
'Violet'
];
List
<
String
>
moteur
=
[
'Gasoil'
,
'Essence'
,
'Hybride'
,
];
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment