- Не происходит переход к следующему экрану, когда функция sendAlert вызывается при нажатии кнопки.
- Я пробовал различные методы для постоянной проверки BPM, прослушивая его значение, а затем вызывая функцию sendAlert, если условие BPM>95 выполнено. Но ничего не работает
Мой код:
import 'package:firebase_database/firebase_database.dart';
import 'package:firebase_database/ui/firebase_animated_list.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:geocoding/geocoding.dart';
import 'package:geolocator/geolocator.dart';
import 'package:intl/intl.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:pregathi/buttons/main_button.dart';
import 'package:pregathi/const/constants.dart';
import 'package:pregathi/db/db_services.dart';
import 'package:pregathi/model/contacts.dart';
import 'package:pregathi/model/emergency_message.dart';
import 'package:pregathi/navigators.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:background_sms/background_sms.dart';
class InstaShareBottomSheet extends StatefulWidget {
const InstaShareBottomSheet({super.key});
@override
State createState() => _InstaShareBottomSheetState();
}
class _InstaShareBottomSheetState extends State {
final ref = FirebaseDatabase(
databaseURL:
"...")
.ref('sensors');
final User? user = FirebaseAuth.instance.currentUser;
sendAlert() async {
//...
navigateToWifeEmergency(context);
//...
}
@override
Widget build(BuildContext context) {
return Container(
height: MediaQuery.of(context).size.height / 1.4,
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30),
),
),
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
"Send current location immediately to your emergency contacts and nearby volunteers..",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 24),
),
const SizedBox(
height: 10,
),
Container(
height: MediaQuery.of(context).size.height / 11,
child: FirebaseAnimatedList(
query: ref,
itemBuilder: (context, snapshot, animation, index) {
return Column(
children: [
Text('BPM: ${snapshot.child('BPM').value.toString()}'),
Text(
'S-Value: ${snapshot.child('Svalue').value.toString()}'),
],
);
},
),
),
Padding(
padding: const EdgeInsets.only(top: 20.0),
child: MainButton(
title: "Send Alert",
onPressed: () => sendAlert(),
),
),
],
),
),
);
}
}
...
navigateToWifeEmergency(BuildContext context) {
Routemaster.of(context).push('/wife-emergency');
}
...
'/wife-emergency': (_) => MaterialPage(child: WifeEmergencyScreen()),
Подробнее здесь: https://stackoverflow.com/questions/783 ... e-database