Commit 31f902a3 authored by senith sulara's avatar senith sulara

update report

parent 26303dbd
import 'package:auditoryflutter/cameraTwo.dart';
import 'package:camera/camera.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:tflite/tflite.dart';
import 'components/custom_page_route.dart';
import 'main.dart';
import 'screens/report.dart';
class Camerapage extends StatefulWidget {
const Camerapage({Key? key}) : super(key: key);
......@@ -15,12 +21,19 @@ class _CamerapageState extends State<Camerapage> {
CameraImage? cameraImage;
CameraController? cameraController;
String output = '';
int dett = 0;
int undett = 0;
String detect = '';
@override
void initState() {
super.initState();
loadCamera();
loadmodel();
// Future.delayed(Duration(milliseconds: 1000), () {
// });
}
loadCamera() {
......@@ -56,6 +69,13 @@ class _CamerapageState extends State<Camerapage> {
predictions!.forEach((element) {
setState(() {
output = element['label'];
for (var i = 0; i < 10; i++) {
if (output == "detected") {
dett++;
} else {
undett++;
}
}
});
});
}
......@@ -66,6 +86,62 @@ class _CamerapageState extends State<Camerapage> {
model: "assets/model.tflite", labels: "assets/labels.txt");
}
_saveTask() {
double pres = (dett / (dett + undett)) * 100;
String pres2 = pres.toStringAsFixed(2);
FirebaseFirestore.instance.collection("results").add({
"userid": 101,
"ear": "Left",
"detected": dett,
"undetected": undett,
"percentage": pres
});
Fluttertoast.showToast(
msg: "Data Saved",
toastLength: Toast.LENGTH_SHORT,
timeInSecForIosWeb: 1,
textColor: Colors.white,
fontSize: 16.0);
}
showAlertDialog(BuildContext context) {
// set up the buttons
Widget remindButton = TextButton(
child: Text("Save Data"),
onPressed: () => _saveTask(),
);
Widget cancelButton = TextButton(
child: Text("Cancel"),
onPressed: () {
Navigator.of(context).pop();
},
);
Widget launchButton = TextButton(
child: Text("Next"),
onPressed: () => Navigator.of(context).push(CustomPageRoute(
child: CameraTwopage(), direction: AxisDirection.right)),
);
// set up the AlertDialog
AlertDialog alert = AlertDialog(
title: Text("Notice"),
content: Text("Save Test Results and click Next"),
actions: [
cancelButton,
remindButton,
launchButton,
],
);
// show the dialog
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
......@@ -75,7 +151,7 @@ class _CamerapageState extends State<Camerapage> {
title: const Padding(
padding: EdgeInsets.only(top: 10.0),
child: Text(
"Check Babies Ears",
"Check Babies Left Ear",
style: TextStyle(
fontSize: 20.0, color: Color.fromARGB(215, 255, 255, 255)),
),
......@@ -100,7 +176,18 @@ class _CamerapageState extends State<Camerapage> {
Text(
output,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
)
),
// for (var i = 0; i < 10; i++) ...[],
// if (output == "detected") ...[],
FloatingActionButton.extended(
onPressed: () {
showAlertDialog(context);
},
// Navigator.of(context).push(CustomPageRoute(
// child: ReportPage(), direction: AxisDirection.right)),
icon: Icon(Icons.save),
label: Text("Get Result"),
),
]),
);
}
......
import 'package:auditoryflutter/cameraTwo.dart';
import 'package:camera/camera.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:tflite/tflite.dart';
import 'components/custom_page_route.dart';
import 'main.dart';
import 'screens/report.dart';
class CameraTwopage extends StatefulWidget {
const CameraTwopage({Key? key}) : super(key: key);
@override
_CameraTwopageState createState() => _CameraTwopageState();
}
class _CameraTwopageState extends State<CameraTwopage> {
CameraImage? cameraImage;
CameraController? cameraController;
String output = '';
int dett = 0;
int undett = 0;
String detect = '';
@override
void initState() {
super.initState();
loadCamera();
loadmodel();
// Future.delayed(Duration(milliseconds: 1000), () {
// });
}
loadCamera() {
cameraController = CameraController(cameras![0], ResolutionPreset.high);
cameraController!.initialize().then((value) {
if (!mounted) {
return;
} else {
setState(() {
cameraController!.startImageStream((imageStream) {
cameraImage = imageStream;
runModel();
});
});
}
});
}
runModel() async {
if (cameraImage != null) {
var predictions = await Tflite.runModelOnFrame(
bytesList: cameraImage!.planes.map((plane) {
return plane.bytes;
}).toList(),
imageHeight: cameraImage!.height,
imageWidth: cameraImage!.width,
imageMean: 127.5,
imageStd: 127.5,
rotation: 90,
numResults: 2,
threshold: 0.1,
asynch: true);
predictions!.forEach((element) {
setState(() {
output = element['label'];
for (var i = 0; i < 10; i++) {
if (output == "detected") {
dett++;
} else {
undett++;
}
}
});
});
}
}
loadmodel() async {
await Tflite.loadModel(
model: "assets/model.tflite", labels: "assets/labels.txt");
}
_saveTask() {
double pres = (dett / (dett + undett)) * 100;
String pres2 = pres.toStringAsFixed(2);
FirebaseFirestore.instance.collection("results").add({
"userid": 101,
"ear": "Right",
"detected": dett,
"undetected": undett,
"percentage": pres
});
Fluttertoast.showToast(
msg: "Data Saved",
toastLength: Toast.LENGTH_SHORT,
timeInSecForIosWeb: 1,
textColor: Colors.white,
fontSize: 16.0);
}
showAlertDialog(BuildContext context) {
// set up the buttons
Widget remindButton = TextButton(
child: Text("Save Data"),
onPressed: () => _saveTask(),
);
Widget cancelButton = TextButton(
child: Text("Cancel"),
onPressed: () {
Navigator.of(context).pop();
},
);
Widget launchButton = TextButton(
child: Text("Next"),
onPressed: () => Navigator.of(context).push(
CustomPageRoute(child: ReportPage(), direction: AxisDirection.right)),
);
// set up the AlertDialog
AlertDialog alert = AlertDialog(
title: Text("Notice"),
content: Text("Save Test Results and click Next"),
actions: [
cancelButton,
remindButton,
launchButton,
],
);
// show the dialog
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: Color.fromARGB(255, 7, 218, 77),
title: const Padding(
padding: EdgeInsets.only(top: 10.0),
child: Text(
"Check Babies Right Ear",
style: TextStyle(
fontSize: 20.0, color: Color.fromARGB(215, 255, 255, 255)),
),
),
iconTheme:
const IconThemeData(color: Color.fromARGB(255, 247, 213, 255)),
),
body: Column(children: [
Padding(
padding: EdgeInsets.all(20),
child: Container(
height: MediaQuery.of(context).size.height * 0.7,
width: MediaQuery.of(context).size.width,
child: !cameraController!.value.isInitialized
? Container()
: AspectRatio(
aspectRatio: cameraController!.value.aspectRatio,
child: CameraPreview(cameraController!),
),
),
),
Text(
output,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
),
// for (var i = 0; i < 10; i++) ...[],
// if (output == "detected") ...[],
FloatingActionButton.extended(
onPressed: () {
showAlertDialog(context);
},
// Navigator.of(context).push(CustomPageRoute(
// child: ReportPage(), direction: AxisDirection.right)),
icon: Icon(Icons.save),
label: Text("Get Result"),
),
]),
);
}
}
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
class ThemeHelper{
InputDecoration textInputDecoration([String lableText="", String hintText = ""]){
return InputDecoration(
labelText: lableText,
hintText: hintText,
fillColor: Colors.white,
filled: true,
contentPadding: EdgeInsets.fromLTRB(20, 10, 20, 10),
focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(100.0), borderSide: BorderSide(color: Colors.grey)),
enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(100.0), borderSide: BorderSide(color: Colors.grey.shade400)),
errorBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(100.0), borderSide: BorderSide(color: Colors.red, width: 2.0)),
focusedErrorBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(100.0), borderSide: BorderSide(color: Colors.red, width: 2.0)),
);
}
BoxDecoration inputBoxDecorationShaddow() {
return BoxDecoration(boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 20,
offset: const Offset(0, 5),
)
]);
}
BoxDecoration buttonBoxDecoration(BuildContext context, [String color1 = "", String color2 = ""]) {
Color c1 = Theme.of(context).primaryColor;
Color c2 = Theme.of(context).accentColor;
if (color1.isEmpty == false) {
c1 = HexColor(color1);
}
if (color2.isEmpty == false) {
c2 = HexColor(color2);
}
return BoxDecoration(
boxShadow: [
BoxShadow(color: Colors.black26, offset: Offset(0, 4), blurRadius: 5.0)
],
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
stops: [0.0, 1.0],
colors: [
c1,
c2,
],
),
color: Colors.deepPurple.shade300,
borderRadius: BorderRadius.circular(30),
);
}
ButtonStyle buttonStyle() {
return ButtonStyle(
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
),
),
minimumSize: MaterialStateProperty.all(Size(50, 50)),
backgroundColor: MaterialStateProperty.all(Colors.transparent),
shadowColor: MaterialStateProperty.all(Colors.transparent),
);
}
AlertDialog alartDialog(String title, String content, BuildContext context) {
return AlertDialog(
title: Text(title),
content: Text(content),
actions: [
TextButton(
child: Text(
"OK",
style: TextStyle(color: Colors.white),
),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.black38)),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
}
}
class LoginFormStyle{
}
\ No newline at end of file
List musicList = [
{
'title': "Slow Motion",
'singer': "Lexin Music",
'url': "https://cdn.pixabay.com/audio/2022/10/05/audio_1c7fba0237.mp3",
'coverUrl':
"https://cdn.pixabay.com/audio/2022/10/05/19-48-58-986_200x200.jpg",
},
{
'title': "Sweet Love",
'singer': "DayFox",
'url': "https://cdn.pixabay.com/audio/2022/10/02/audio_8f97a56643.mp3",
'coverUrl':
"https://cdn.pixabay.com/audio/2022/10/02/06-29-09-949_200x200.jpg",
},
{
'title': "Something is Going On",
'singer': "Godmode",
'url': "https://cdn.pixabay.com/audio/2022/09/18/audio_5658d27863.mp3",
'title': "500 Hz Pure Tone",
'singer': "35 db",
'url':
"https://res.cloudinary.com/dz3ljnlvy/video/upload/v1668108542/500_Hz_Test_Tone_c03ly3.mp3",
'coverUrl':
"https://cdn.pixabay.com/audio/2022/09/18/16-52-08-594_200x200.jpg",
"https://res.cloudinary.com/dz3ljnlvy/image/upload/v1668108693/maxresdefault_tgdpgu.jpg",
},
{
'title': "Mandaram Kathawe",
'singer': "Anushka Udana",
'title': "1000 Hz Pure Tone",
'singer': "35 db",
'url':
"https://res.cloudinary.com/dz3ljnlvy/video/upload/v1665170166/Mandaaram_dwlob0.mp3",
"https://res.cloudinary.com/dz3ljnlvy/video/upload/v1668108542/1000_Hz_Test_Tone_g1cfnk.mp3",
'coverUrl':
"https://res.cloudinary.com/dz3ljnlvy/image/upload/v1665170207/mandaram_t4sfa6.jpg",
"https://res.cloudinary.com/dz3ljnlvy/image/upload/v1668108693/maxresdefault_1_bk6flc.jpg",
},
{
'title': "Blessed(Main)",
'singer': "Daddy s Music",
'url': "https://cdn.pixabay.com/audio/2022/09/22/audio_14e9964c5f.mp3",
'title': "2000 Hz Pure Tone",
'singer': "35 db",
'url':
"https://res.cloudinary.com/dz3ljnlvy/video/upload/v1668108543/2000_Hz_Test_Tone_ywxvex.mp3",
'coverUrl':
"https://cdn.pixabay.com/audio/2022/09/24/09-19-03-222_200x200.jpeg",
"https://res.cloudinary.com/dz3ljnlvy/image/upload/v1668108693/maxresdefault_2_bt8tkr.jpg",
},
{
'title': "madiRFAN - Both of Us",
'singer': "MADiRFAN",
'url': "https://cdn.pixabay.com/audio/2022/01/12/audio_45cacdef8f.mp3",
'title': "3000 Hz Pure Tone",
'singer': "35 db",
'url':
"https://res.cloudinary.com/dz3ljnlvy/video/upload/v1668108803/3000_Hz_Test_Tone_scteai.mp3",
'coverUrl':
"https://cdn.pixabay.com/audio/2022/03/15/07-26-27-958_200x200.jpg",
"https://res.cloudinary.com/dz3ljnlvy/image/upload/v1668108693/maxresdefault_3_xmjkac.jpg",
},
{
'title': "Relaxing Light",
'singer': "AudioCoffee",
'url': "https://cdn.pixabay.com/audio/2022/08/08/audio_0627597b4f.mp3",
'title': "4000 Hz Pure Tone",
'singer': "35 db",
'url':
"https://res.cloudinary.com/dz3ljnlvy/video/upload/v1668108542/4000_Hz_Test_Tone_sgwjlk.mp3",
'coverUrl':
"https://cdn.pixabay.com/audio/2022/08/08/09-06-17-761_200x200.jpg",
"https://res.cloudinary.com/dz3ljnlvy/image/upload/v1668108693/maxresdefault_4_gxx5xw.jpg",
},
];
import 'package:auditoryflutter/screens/CheckEars.dart';
import 'package:auditoryflutter/screens/homeMain.dart';
import 'package:auditoryflutter/screens/howto.dart';
import 'package:auditoryflutter/screens/map.dart';
import 'package:auditoryflutter/screens/report.dart';
import 'package:auditoryflutter/screens/soundLibrary.dart';
import 'package:flutter/material.dart';
......@@ -53,15 +54,20 @@ class NevigationDrawer extends StatelessWidget {
onClicked: () => selectedItem(context, 3)),
const SizedBox(height: 16),
buildMenuItem(
text: 'How to Use',
icon: Icons.question_answer,
text: 'Hospitals',
icon: Icons.local_hospital,
onClicked: () => selectedItem(context, 4)),
const SizedBox(height: 16),
const Divider(color: Colors.white70),
buildMenuItem(
text: 'Guidence',
icon: Icons.question_answer,
onClicked: () => selectedItem(context, 5)),
const SizedBox(height: 16),
buildMenuItem(
text: 'Logout',
icon: Icons.logout,
onClicked: () => selectedItem(context, 5)),
onClicked: () => selectedItem(context, 6)),
const SizedBox(height: 24),
],
),
......@@ -142,6 +148,10 @@ void selectedItem(BuildContext context, int i) {
CustomPageRoute(child: ReportPage(), direction: AxisDirection.left));
break;
case 4:
Navigator.of(context).push(CustomPageRoute(
child: CurrentLocationScreen(), direction: AxisDirection.left));
break;
case 5:
Navigator.of(context).push(CustomPageRoute(
child: HowToUsePage(), direction: AxisDirection.left));
break;
......
import 'package:auditoryflutter/screens/splash.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:camera/camera.dart';
import 'camera.dart';
......@@ -7,6 +8,7 @@ List<CameraDescription>? cameras;
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
cameras = await availableCameras();
runApp(new MyApp());
}
......
import 'dart:ui';
class GeoPoint {
/// Create [GeoPoint] instance.
const GeoPoint(this.latitude, this.longitude)
: assert(latitude >= -90 && latitude <= 90),
assert(longitude >= -180 && longitude <= 180);
final double latitude; // ignore: public_member_api_docs
final double longitude; // ignore: public_member_api_docs
@override
bool operator ==(dynamic o) =>
o is GeoPoint && o.latitude == latitude && o.longitude == longitude;
@override
int get hashCode => hashValues(latitude, longitude);
}
class Nearby {
String? businessStatus;
Geometry? geometry;
String? icon;
String? iconBackgroundColor;
String? iconMaskBaseUri;
String? name;
String? placeId;
PlusCode? plusCode;
int? rating;
String? reference;
String? scope;
List<String>? types;
int? userRatingsTotal;
String? vicinity;
Nearby(
{this.businessStatus,
this.geometry,
this.icon,
this.iconBackgroundColor,
this.iconMaskBaseUri,
this.name,
this.placeId,
this.plusCode,
this.rating,
this.reference,
this.scope,
this.types,
this.userRatingsTotal,
this.vicinity});
Nearby.fromJson(Map<String, dynamic> json) {
businessStatus = json['business_status'];
geometry = json['geometry'] != null
? new Geometry.fromJson(json['geometry'])
: null;
icon = json['icon'];
iconBackgroundColor = json['icon_background_color'];
iconMaskBaseUri = json['icon_mask_base_uri'];
name = json['name'];
placeId = json['place_id'];
plusCode = json['plus_code'] != null
? new PlusCode.fromJson(json['plus_code'])
: null;
rating = json['rating'];
reference = json['reference'];
scope = json['scope'];
types = json['types'].cast<String>();
userRatingsTotal = json['user_ratings_total'];
vicinity = json['vicinity'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['business_status'] = this.businessStatus;
if (this.geometry != null) {
data['geometry'] = this.geometry!.toJson();
}
data['icon'] = this.icon;
data['icon_background_color'] = this.iconBackgroundColor;
data['icon_mask_base_uri'] = this.iconMaskBaseUri;
data['name'] = this.name;
data['place_id'] = this.placeId;
if (this.plusCode != null) {
data['plus_code'] = this.plusCode!.toJson();
}
data['rating'] = this.rating;
data['reference'] = this.reference;
data['scope'] = this.scope;
data['types'] = this.types;
data['user_ratings_total'] = this.userRatingsTotal;
data['vicinity'] = this.vicinity;
return data;
}
}
class Geometry {
Location? location;
Viewport? viewport;
Geometry({this.location, this.viewport});
Geometry.fromJson(Map<String, dynamic> json) {
location = json['location'] != null
? new Location.fromJson(json['location'])
: null;
viewport = json['viewport'] != null
? new Viewport.fromJson(json['viewport'])
: null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.location != null) {
data['location'] = this.location!.toJson();
}
if (this.viewport != null) {
data['viewport'] = this.viewport!.toJson();
}
return data;
}
}
class Location {
double? lat;
double? lng;
Location({this.lat, this.lng});
Location.fromJson(Map<String, dynamic> json) {
lat = json['lat'];
lng = json['lng'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['lat'] = this.lat;
data['lng'] = this.lng;
return data;
}
}
class Viewport {
Location? northeast;
Location? southwest;
Viewport({this.northeast, this.southwest});
Viewport.fromJson(Map<String, dynamic> json) {
northeast = json['northeast'] != null
? new Location.fromJson(json['northeast'])
: null;
southwest = json['southwest'] != null
? new Location.fromJson(json['southwest'])
: null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.northeast != null) {
data['northeast'] = this.northeast!.toJson();
}
if (this.southwest != null) {
data['southwest'] = this.southwest!.toJson();
}
return data;
}
}
class PlusCode {
String? compoundCode;
String? globalCode;
PlusCode({this.compoundCode, this.globalCode});
PlusCode.fromJson(Map<String, dynamic> json) {
compoundCode = json['compound_code'];
globalCode = json['global_code'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['compound_code'] = this.compoundCode;
data['global_code'] = this.globalCode;
return data;
}
}
import 'package:auditoryflutter/camera.dart';
import 'package:auditoryflutter/screens/CheckEars.dart';
import 'package:auditoryflutter/screens/howto.dart';
import 'package:auditoryflutter/screens/map.dart';
import 'package:auditoryflutter/screens/report.dart';
import 'package:auditoryflutter/screens/soundLibrary.dart';
import 'package:flutter/material.dart';
......@@ -40,7 +41,7 @@ class Home extends StatelessWidget {
),
body: Container(
decoration: const BoxDecoration(
color: Color.fromARGB(255, 93, 237, 153),
color: Color.fromARGB(255, 240, 240, 240),
// image: DecorationImage(
// image: AssetImage('assets/images/background2.jpg'),
// fit: BoxFit.cover),
......@@ -199,7 +200,7 @@ class Home extends StatelessWidget {
splashColor: Colors.black45,
onTap: () => Navigator.of(context).push(
CustomPageRoute(
child: HowToUsePage(),
child: CurrentLocationScreen(),
direction: AxisDirection.right)),
child: Container(
decoration: BoxDecoration(
......@@ -215,14 +216,14 @@ class Home extends StatelessWidget {
children: [
Ink.image(
image: AssetImage(
'assets/images/que.png'),
'assets/images/hosp.png'),
height: 150,
width: 150,
fit: BoxFit.cover,
),
const SizedBox(height: 7),
const Text(
'How To use',
'Hospitals',
style: TextStyle(
fontSize: 22,
color: Colors.white),
......
......@@ -12,34 +12,17 @@ class HowToUsePage extends StatefulWidget {
class _HowToUsePageState extends State<HowToUsePage> {
@override
Widget build(BuildContext context) {
Widget aboutUsSection = SizedBox(
child: Column(
children: const [
Padding(
padding: EdgeInsets.only(top: 10),
child: Text(
"We will not use your personal data for any purpose.",
style: TextStyle(
fontFamily: 'Roboto',
fontSize: 50,
color: Color.fromARGB(253, 255, 208, 208)),
textAlign: TextAlign.center,
)),
],
),
);
return Scaffold(
drawer: NevigationDrawer(),
appBar: PreferredSize(
preferredSize: const Size.fromHeight(60),
child: AppBar(
centerTitle: true,
backgroundColor: const Color.fromARGB(255, 135, 63, 243),
backgroundColor: const Color.fromARGB(255, 7, 218, 77),
title: const Padding(
padding: EdgeInsets.only(top: 10.0),
child: Text(
"Terms and Conditions",
"Guidence",
style: TextStyle(
fontSize: 20.0, color: Color.fromARGB(215, 255, 255, 255)),
),
......@@ -49,12 +32,91 @@ class _HowToUsePageState extends State<HowToUsePage> {
),
),
body: Container(
decoration: const BoxDecoration(
color: Color.fromARGB(255, 235, 237, 206),
// image: DecorationImage(
// image: AssetImage('assets/images/background2.jpg'),
// fit: BoxFit.cover),
),
height: double.maxFinite,
width: double.maxFinite,
padding: const EdgeInsets.only(top: 50),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [aboutUsSection],
padding: const EdgeInsets.only(top: 30),
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Step 1: You Need to Go to the Sound Library and select tone and play it",
style: TextStyle(fontSize: 20.0)),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Step 2: Warrning Please adjust the volume before placeing ear phone to babies ear",
style: TextStyle(
fontSize: 20.0,
color: Color.fromARGB(214, 230, 10, 10))),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Step 3: Place a one ear phone to babies Left Ear only",
style: TextStyle(fontSize: 20.0),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Step 4: Go back and open Check Ears",
style: TextStyle(fontSize: 20.0)),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Step 5: Give permission for camera and audio",
style: TextStyle(fontSize: 20.0)),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Step 6: Place your camera to the babies face and collect data",
style: TextStyle(fontSize: 20.0)),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Step 7: Now select the Get Result button and select Save Data",
style: TextStyle(fontSize: 20.0)),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Step 8: Select Next ",
style: TextStyle(fontSize: 20.0)),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Step 9: Place a one ear phone to babies Right Ear only",
style: TextStyle(fontSize: 20.0)),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Step 10: Now Continue from Step 7 ",
style: TextStyle(
fontSize: 20.0,
color: Color.fromARGB(213, 10, 230, 43))),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Step 11: You Can view Test Results from Report",
style: TextStyle(
fontSize: 20.0,
color: Color.fromARGB(212, 10, 80, 230))),
),
],
),
),
),
);
......
import 'package:auditoryflutter/screens/homeMain.dart';
import 'package:auditoryflutter/screens/register.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import '../common/theme_helper.dart';
import '../components/custom_page_route.dart';
import 'widgets/header_widget.dart';
class LoginPage extends StatefulWidget {
static const String routeName = '/signInscreen';
const LoginPage({Key? key}) : super(key: key);
@override
_LoginPageState createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
final _signInFormKey = GlobalKey<FormState>();
final TextEditingController _emailController = TextEditingController();
final TextEditingController _passwordController = TextEditingController();
double _headerHeight = 250;
Key _formKey = GlobalKey<FormState>();
@override
void dispose() {
super.dispose();
_emailController.dispose();
_passwordController.dispose();
}
// void signUpUser() {
// authService.signUpUser(
// context: context,
// email: _emailController.text,
// password: _passwordController.text,
// name: _nameController.text,
// );
// }
void signInUser() {
// authService.signInUser(
// context: context,
// email: _emailController.text,
// password: _passwordController.text,
// );
Navigator.push(context, MaterialPageRoute(builder: (context) => Home()));
Fluttertoast.showToast(
msg: "Login Success",
toastLength: Toast.LENGTH_SHORT,
timeInSecForIosWeb: 1,
textColor: Colors.white,
fontSize: 16.0);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Column(
children: [
Container(
height: _headerHeight,
child: HeaderWidget(_headerHeight, true,
Icons.login_rounded), //let's create a common header widget
),
SafeArea(
child: Container(
padding: EdgeInsets.fromLTRB(20, 10, 20, 10),
margin: EdgeInsets.fromLTRB(
20, 10, 20, 10), // This will be the login form
child: Column(
children: [
Text(
'Welcome',
style: TextStyle(
fontSize: 60, fontWeight: FontWeight.bold),
),
Text(
'Signin into your account',
style: TextStyle(color: Colors.grey),
),
SizedBox(height: 30.0),
Form(
key: _signInFormKey,
child: Column(
children: [
Container(
child: TextField(
controller: _emailController,
decoration: ThemeHelper().textInputDecoration(
'Email', 'Enter your email'),
),
decoration:
ThemeHelper().inputBoxDecorationShaddow(),
),
SizedBox(height: 30.0),
Container(
child: TextField(
controller: _passwordController,
obscureText: true,
decoration: ThemeHelper().textInputDecoration(
'Password', 'Enter your password'),
),
decoration:
ThemeHelper().inputBoxDecorationShaddow(),
),
SizedBox(height: 15.0),
Container(
margin: EdgeInsets.fromLTRB(10, 0, 10, 20),
alignment: Alignment.topRight,
child: GestureDetector(
onTap: () {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) =>
// ForgotPasswordPage()),
// );
},
child: Text(
"Forgot your password?",
style: TextStyle(
color: Colors.grey,
),
),
),
),
Container(
decoration:
ThemeHelper().buttonBoxDecoration(context),
child: ElevatedButton(
style: ThemeHelper().buttonStyle(),
child: Padding(
padding:
EdgeInsets.fromLTRB(40, 10, 40, 10),
child: Text(
'Sign In'.toUpperCase(),
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.white),
),
),
onPressed: () {
//After successful login we will redirect to profile page. Let's create profile page now
// Navigator.pushReplacement(
// context,
// MaterialPageRoute(
// builder: (context) => Items()));
if (_signInFormKey.currentState!
.validate()) {
signInUser();
}
},
),
),
Container(
margin: EdgeInsets.fromLTRB(10, 20, 10, 20),
//child: Text('Don\'t have an account? Create'),
child: Text.rich(TextSpan(children: [
TextSpan(text: "Don\'t have an account? "),
TextSpan(
text: 'Create',
recognizer: TapGestureRecognizer()
..onTap = () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
RegistrationPage()));
},
style: TextStyle(
fontWeight: FontWeight.bold,
color: Theme.of(context).accentColor),
),
])),
),
],
)),
],
)),
),
],
),
),
);
}
}
// import 'dart:ffi';
// import 'package:flutter/material.dart';
// import 'package:google_maps_flutter/google_maps_flutter.dart';
// import '../components/navigationdrawer.dart';
// class MapPage extends StatefulWidget {
// const MapPage({Key? key}) : super(key: key);
// @override
// State<MapPage> createState() => _MapPageState();
// }
// class _MapPageState extends State<MapPage> {
// static const _initialCameraPosition = CameraPosition(
// target: LatLng(7.8731, 80.7718),
// zoom: 11.5,
// );
// GoogleMapController? _googleMapController;
// @override
// void dispose() {
// _googleMapController?.dispose();
// super.dispose();
// }
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// drawer: NevigationDrawer(),
// appBar: PreferredSize(
// preferredSize: const Size.fromHeight(60),
// child: AppBar(
// centerTitle: true,
// backgroundColor: const Color.fromARGB(255, 7, 218, 77),
// title: const Padding(
// padding: EdgeInsets.only(top: 10.0),
// child: Text(
// "Map",
// style: TextStyle(
// fontSize: 20.0, color: Color.fromARGB(215, 255, 255, 255)),
// ),
// ),
// iconTheme:
// const IconThemeData(color: Color.fromARGB(255, 247, 213, 255)),
// ),
// ),
// body: GoogleMap(
// myLocationButtonEnabled: false,
// zoomControlsEnabled: false,
// initialCameraPosition: _initialCameraPosition,
// onMapCreated: (controller) => _googleMapController = controller,
// ),
// floatingActionButton: FloatingActionButton(
// backgroundColor: Colors.white,
// foregroundColor: Colors.black,
// onPressed: () => _googleMapController?.animateCamera(
// CameraUpdate.newCameraPosition(_initialCameraPosition),
// ),
// child: const Icon(Icons.center_focus_strong),
// ),
// );
// }
// }
import 'package:auditoryflutter/services/nearby_location_api.dart';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:auditoryflutter/models/nearby.dart';
import 'package:auditoryflutter/models/geoPoint.dart';
class CurrentLocationScreen extends StatefulWidget {
const CurrentLocationScreen({Key? key}) : super(key: key);
@override
_CurrentLocationScreenState createState() => _CurrentLocationScreenState();
}
class _CurrentLocationScreenState extends State<CurrentLocationScreen> {
late GoogleMapController googleMapController;
static const CameraPosition initialCameraPosition = CameraPosition(
target: LatLng(37.42796133580664, -122.085749655962), zoom: 14);
Set<Marker> markers = {};
List<Nearby> nearbyLocations = <Nearby>[];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Nearby Hospitals"),
centerTitle: true,
backgroundColor: const Color.fromARGB(255, 7, 218, 77),
),
body: GoogleMap(
initialCameraPosition: initialCameraPosition,
markers: markers,
zoomControlsEnabled: false,
mapType: MapType.normal,
onMapCreated: (GoogleMapController controller) {
googleMapController = controller;
},
),
floatingActionButton: FloatingActionButton.extended(
onPressed: () async {
Position position = await _determinePosition();
googleMapController.animateCamera(CameraUpdate.newCameraPosition(
CameraPosition(
target: LatLng(position.latitude, position.longitude),
zoom: 14)));
markers.clear();
markers.add(Marker(
markerId: const MarkerId('currentLocation'),
position: LatLng(position.latitude, position.longitude)));
setState(() {});
final List<Nearby> result = await NearcyLocationApi.instance!
.getNearby(radius: 1000, type: 'doctor', keyword: '');
nearbyLocations = result;
},
label: const Text("Current Location"),
icon: const Icon(Icons.location_history),
),
);
}
Future<Position> _determinePosition() async {
bool serviceEnabled;
LocationPermission permission;
serviceEnabled = await Geolocator.isLocationServiceEnabled();
if (!serviceEnabled) {
return Future.error('Location services are disabled');
}
permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission();
if (permission == LocationPermission.denied) {
return Future.error("Location permission denied");
}
}
if (permission == LocationPermission.deniedForever) {
return Future.error('Location permissions are permanently denied');
}
Position position = await Geolocator.getCurrentPosition();
return position;
}
}
This diff is collapsed.
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import '../components/navigationdrawer.dart';
final resultRef = FirebaseFirestore.instance.collection('results');
class ReportPage extends StatefulWidget {
const ReportPage({Key? key}) : super(key: key);
......@@ -10,53 +13,182 @@ class ReportPage extends StatefulWidget {
}
class _ReportPageState extends State<ReportPage> {
// int documentId = 100;
// String output = '';
// String detect = '';
// String ear = '';
// double percentage = 0;
// String pres2 = '';
@override
void initState() {
super.initState();
// getResults();
}
// getResults() {
// resultRef
// .where('userid', isEqualTo: 100)
// .get()
// .then((QuerySnapshot snapshot) {
// snapshot.docs.forEach((DocumentSnapshot doc) {
// ear = doc["ear"];
// percentage = doc["percentage"];
// pres2 = percentage.toStringAsFixed(2);
// print(doc["ear"]);
// print(pres2);
// if (ear == "Right Ear") {
// if (percentage < 50) {
// print("Do ABR or OBE");
// } else {
// print("Left ear is fine");
// }
// }
// if (ear == "Left Ear") {
// if (percentage < 50) {
// print("Do ABR or OBE");
// } else {
// print("Left ear is fine");
// }
// }
// });
// });
// }
@override
Widget build(BuildContext context) {
Widget aboutUsSection = SizedBox(
child: Column(
children: const [
Padding(
padding: EdgeInsets.only(top: 10),
return Scaffold(
drawer: NevigationDrawer(),
appBar: PreferredSize(
preferredSize: const Size.fromHeight(60),
child: AppBar(
centerTitle: true,
backgroundColor: const Color.fromARGB(255, 7, 218, 77),
title: const Padding(
padding: EdgeInsets.only(top: 10.0),
child: Text(
"We will not use your personal data for any purpose.",
"Report",
style: TextStyle(
fontFamily: 'Roboto',
fontSize: 50,
color: Color.fromARGB(253, 255, 208, 208)),
textAlign: TextAlign.center,
)),
],
),
);
return Scaffold(
drawer: NevigationDrawer(),
appBar: PreferredSize(
preferredSize: const Size.fromHeight(60),
child: AppBar(
centerTitle: true,
backgroundColor: const Color.fromARGB(255, 135, 63, 243),
title: const Padding(
padding: EdgeInsets.only(top: 10.0),
child: Text(
"Report",
style: TextStyle(
fontSize: 20.0, color: Color.fromARGB(215, 255, 255, 255)),
fontSize: 20.0, color: Color.fromARGB(215, 255, 255, 255)),
),
),
iconTheme:
const IconThemeData(color: Color.fromARGB(255, 247, 213, 255)),
),
iconTheme:
const IconThemeData(color: Color.fromARGB(255, 247, 213, 255)),
),
),
body: Container(
height: double.maxFinite,
width: double.maxFinite,
padding: const EdgeInsets.only(top: 50),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [aboutUsSection],
),
),
);
body: StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance
.collection('results')
.where('userid', isEqualTo: 101)
.snapshots(),
builder:
(BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (!snapshot.hasData) return Text('Loading...');
return ListView(
children: snapshot.data!.docs.map((DocumentSnapshot document) {
Map<String, dynamic> data =
document.data()! as Map<String, dynamic>;
if (data['ear'] == "Right") {
if (data['percentage'] < 50) {
return Padding(
padding: EdgeInsets.only(
left: 120,
top: 50,
right: 50,
),
child: Text(
"Ear: " +
data['ear'] +
"\n" +
"percentage: " +
data['percentage'].toStringAsFixed(2) +
'\n\n' +
"Do ABR or OBE Test from Hospital",
style: TextStyle(
fontSize: 20.0,
color: Color.fromARGB(213, 243, 23, 23)),
),
);
} else {
return Padding(
padding: EdgeInsets.only(
left: 120,
top: 50,
right: 30,
),
child: Text(
"Ear: " +
data['ear'] +
"\n" +
"percentage: " +
data['percentage'].toStringAsFixed(2) +
'\n\n' +
"Right ear is fine",
style: TextStyle(
fontSize: 20.0,
color: Color.fromARGB(214, 4, 184, 46)),
),
);
}
}
;
if (data['ear'] == "Left") {
if (data['percentage'] < 50) {
return Padding(
padding: EdgeInsets.only(
left: 120,
top: 20,
right: 50,
),
child: Text(
"Ear: " +
data['ear'] +
"\n" +
"percentage: " +
data['percentage'].toStringAsFixed(2) +
'\n\n' +
"Do ABR or OBE Test from Hospital",
style: TextStyle(
fontSize: 20.0,
color: Color.fromARGB(213, 243, 23, 23)),
),
);
} else {
return Padding(
padding: EdgeInsets.only(
left: 120,
top: 20,
right: 30,
),
child: Text(
"Ear: " +
data['ear'] +
"\n" +
"percentage: " +
data['percentage'].toStringAsFixed(2) +
'\n\n' +
"Left ear is fine",
style: TextStyle(
fontSize: 20.0,
color: Color.fromARGB(214, 4, 184, 46)),
),
);
}
}
;
return ListTile(
title: Text("Ear: " +
data['ear'] +
"\n" +
"percentage: " +
data['percentage'].toStringAsFixed(2)),
subtitle: Text(data['percentage'].toString()),
);
}).toList(),
);
},
));
}
}
......@@ -78,6 +78,23 @@ class _SoundPageState extends State<SoundPage> {
),
body: Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(
"-WARNING-",
style: TextStyle(
color: Colors.red,
fontSize: 20.0,
),
),
),
Text(
"- Adjust your volume before testing -",
style: TextStyle(
color: Colors.red,
fontSize: 18.0,
),
),
Expanded(
child: ListView.builder(
itemCount: musicList.length,
......@@ -117,10 +134,10 @@ class _SoundPageState extends State<SoundPage> {
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(
height: 60.0,
width: 60.0,
height: 50.0,
width: 50.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6.0),
borderRadius: BorderRadius.circular(8.0),
image: DecorationImage(
image: NetworkImage(currentCover))),
),
......
......@@ -4,6 +4,8 @@ import '../components/custom_page_route.dart';
import '/screens/homeMain.dart';
import 'package:google_fonts/google_fonts.dart';
import 'login.dart';
class Splash extends StatefulWidget {
const Splash({Key? key}) : super(key: key);
@override
......@@ -32,8 +34,10 @@ class _SplashState extends State<Splash> with SingleTickerProviderStateMixin {
_navigatetohome() async {
await Future.delayed(const Duration(milliseconds: 2500), () {});
Navigator.pushReplacement(context,
CustomPageRoute(child: const Home(), direction: AxisDirection.left));
Navigator.pushReplacement(
context,
CustomPageRoute(
child: const LoginPage(), direction: AxisDirection.left));
}
@override
......
import 'package:flutter/material.dart';
class AccountButton extends StatelessWidget {
final String text;
final VoidCallback onTap;
const AccountButton({
Key? key,
required this.text,
required this.onTap,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Expanded(
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 10),
height: 40,
decoration: BoxDecoration(
border: Border.all(color: Colors.white, width: 0.0),
borderRadius: BorderRadius.circular(50),
color: Colors.white,
),
child: OutlinedButton(
style: ElevatedButton.styleFrom(
primary: Colors.black12.withOpacity(0.03),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
),
),
onPressed: onTap,
child: Text(
text,
style: const TextStyle(
color: Colors.black,
fontWeight: FontWeight.normal,
),
),
),
),
);
}
}
import 'package:flutter/material.dart';
class CustomButton extends StatelessWidget {
final String text;
final VoidCallback onTap;
final Color? color;
const CustomButton({
Key? key,
required this.text,
required this.onTap,
this.color,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return ElevatedButton(
child: Text(
text,
style: TextStyle(
color: color == null ? Colors.white : Colors.black,
),
),
onPressed: onTap,
style: ElevatedButton.styleFrom(
minimumSize: const Size(double.infinity, 50),
primary: color,
),
);
}
}
// This widget will draw header section of all page. Wich you will get with the project source code.
import 'package:flutter/material.dart';
class HeaderWidget extends StatefulWidget {
final double _height;
final bool _showIcon;
final IconData _icon;
const HeaderWidget(this._height, this._showIcon, this._icon, {Key? key})
: super(key: key);
@override
_HeaderWidgetState createState() =>
_HeaderWidgetState(_height, _showIcon, _icon);
}
class _HeaderWidgetState extends State<HeaderWidget> {
double _height;
bool _showIcon;
IconData _icon;
_HeaderWidgetState(this._height, this._showIcon, this._icon);
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
return Container(
child: Stack(
children: [
ClipPath(
child: Container(
decoration: new BoxDecoration(
gradient: new LinearGradient(
colors: [
Theme.of(context).primaryColor.withOpacity(0.4),
Theme.of(context).accentColor.withOpacity(0.4),
],
begin: const FractionalOffset(0.0, 0.0),
end: const FractionalOffset(1.0, 0.0),
stops: [0.0, 1.0],
tileMode: TileMode.clamp),
),
),
clipper: new ShapeClipper([
Offset(width / 5, _height),
Offset(width / 10 * 5, _height - 60),
Offset(width / 5 * 4, _height + 20),
Offset(width, _height - 18)
]),
),
ClipPath(
child: Container(
decoration: new BoxDecoration(
gradient: new LinearGradient(
colors: [
Theme.of(context).primaryColor.withOpacity(0.4),
Theme.of(context).accentColor.withOpacity(0.4),
],
begin: const FractionalOffset(0.0, 0.0),
end: const FractionalOffset(1.0, 0.0),
stops: [0.0, 1.0],
tileMode: TileMode.clamp),
),
),
clipper: new ShapeClipper([
Offset(width / 3, _height + 20),
Offset(width / 10 * 8, _height - 60),
Offset(width / 5 * 4, _height - 60),
Offset(width, _height - 20)
]),
),
ClipPath(
child: Container(
decoration: new BoxDecoration(
gradient: new LinearGradient(
colors: [
Theme.of(context).primaryColor,
Theme.of(context).accentColor,
],
begin: const FractionalOffset(0.0, 0.0),
end: const FractionalOffset(1.0, 0.0),
stops: [0.0, 1.0],
tileMode: TileMode.clamp),
),
),
clipper: new ShapeClipper([
Offset(width / 5, _height),
Offset(width / 2, _height - 40),
Offset(width / 5 * 4, _height - 80),
Offset(width, _height - 20)
]),
),
Visibility(
visible: _showIcon,
child: Container(
height: _height - 40,
child: Center(
child: Container(
margin: EdgeInsets.all(20),
padding: EdgeInsets.only(
left: 5.0,
top: 20.0,
right: 5.0,
bottom: 20.0,
),
decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(20),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(100),
topRight: Radius.circular(100),
bottomLeft: Radius.circular(60),
bottomRight: Radius.circular(60),
),
border: Border.all(width: 5, color: Colors.white),
),
child: Icon(
_icon,
color: Colors.white,
size: 40.0,
),
),
),
),
),
],
),
);
}
}
class ShapeClipper extends CustomClipper<Path> {
List<Offset> _offsets = [];
ShapeClipper(this._offsets);
@override
Path getClip(Size size) {
var path = new Path();
path.lineTo(0.0, size.height - 20);
// path.quadraticBezierTo(size.width/5, size.height, size.width/2, size.height-40);
// path.quadraticBezierTo(size.width/5*4, size.height-80, size.width, size.height-20);
path.quadraticBezierTo(
_offsets[0].dx, _offsets[0].dy, _offsets[1].dx, _offsets[1].dy);
path.quadraticBezierTo(
_offsets[2].dx, _offsets[2].dy, _offsets[3].dx, _offsets[3].dy);
// path.lineTo(size.width, size.height-20);
path.lineTo(size.width, 0.0);
path.close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
import 'package:flutter/material.dart';
class SingleProduct extends StatelessWidget {
final String image;
const SingleProduct({
Key? key,
required this.image,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 5),
child: DecoratedBox(
decoration: BoxDecoration(
border: Border.all(
color: Colors.black12,
width: 1.5,
),
borderRadius: BorderRadius.circular(5),
color: Colors.white,
),
child: Container(
width: 180,
padding: const EdgeInsets.all(10),
child: Image.network(
image,
fit: BoxFit.fitHeight,
width: 180,
),
),
),
);
}
}
import 'package:auditoryflutter/models/geoPoint.dart';
import 'package:auditoryflutter/models/nearby.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
class NearcyLocationApi {
static NearcyLocationApi? _instance;
NearcyLocationApi._();
static NearcyLocationApi? get instance {
if (_instance == null) {
_instance = NearcyLocationApi._();
}
return _instance;
}
Future<List<Nearby>> getNearby(
{GeoPoint? position,
double? radius,
String? type,
String? keyword}) async {
String url =
'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=${position!.latitude},${position.longitude}&radius=$radius&type=$type&keyword=$keyword&key=AIzaSyDl3W5L-KXzVcU3z90JgYylyNw8zL3IY6U';
http.Response response = await http.get(Uri.parse(url));
final values = jsonDecode(response.body);
final List result = values['results'];
print(result);
return result.map((e) => Nearby.fromJson(e)).toList();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment