From a3101a1d2d0d139a34e8a3b1d868197044f02c19 Mon Sep 17 00:00:00 2001 From: Muhammad Waleed Amir <51195207+MuhammadWaleedAmir@users.noreply.github.com> Date: Tue, 26 Sep 2023 22:38:06 +0500 Subject: [PATCH] updated to run with latest flutter, dart and package updates --- ios/Runner/AppDelegate.swift | 9 + lib/calc/bmiCalc.dart | 18 +- lib/components/buttonButton.dart | 4 +- lib/components/iconContent.dart | 6 +- lib/components/lineChart1.dart | 621 +++++++++--------- lib/components/lineChart2.dart | 232 +++---- lib/components/lineChart3.dart | 291 ++++---- lib/components/lineChart4.dart | 241 +++---- lib/components/resusableCard.dart | 17 +- lib/db/alarm_databaseProvider.dart | 10 +- lib/db/body_databaseProvider.dart | 10 +- lib/db/bp_databaseProvider.dart | 10 +- lib/db/bs_databaseProvider.dart | 10 +- lib/db/sleep_databaseProvider.dart | 10 +- lib/events/reminderBloc.dart | 13 +- lib/events/reminderEvent.dart | 8 +- lib/localization/appLocalization.dart | 6 +- lib/main.dart | 8 +- lib/models/alarmModel.dart | 18 +- lib/models/bodyModel.dart | 16 +- lib/models/bpDBModel.dart | 18 +- lib/models/bsDBModel.dart | 14 +- lib/models/sleepDBModel.dart | 14 +- lib/request/flutterTencentOCR.dart | 39 +- lib/screens/FunctionScreen/alarmScreen.dart | 61 +- lib/screens/FunctionScreen/bmiScreen.dart | 14 +- lib/screens/FunctionScreen/bpScreen.dart | 8 +- lib/screens/FunctionScreen/bsScreen.dart | 16 +- lib/screens/FunctionScreen/exportPDF.dart | 8 +- .../FunctionScreen/medicineListScreen.dart | 8 +- lib/screens/FunctionScreen/ocrScreen.dart | 10 +- lib/screens/FunctionScreen/sleepScreen.dart | 20 +- lib/screens/ResultScreen/bmiResultScreen.dart | 18 +- lib/screens/ResultScreen/bpResultScreen.dart | 7 +- lib/screens/ResultScreen/bsResultScreen.dart | 6 +- .../ResultScreen/sleepResultScreen.dart | 6 +- lib/screens/historyScreen.dart | 143 ++-- lib/screens/languageView.dart | 2 +- lib/screens/mainScreen.dart | 2 +- lib/screens/reminderScreen.dart | 40 +- pubspec.lock | 508 +++++++++----- pubspec.yaml | 40 +- 42 files changed, 1397 insertions(+), 1163 deletions(-) diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 70693e4..7929ecd 100755 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -7,6 +7,15 @@ import Flutter _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { + + FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { (registry) in + GeneratedPluginRegistrant.register(with: registry) + } + + if #available(iOS 10.0, *) { + UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate + } + GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } diff --git a/lib/calc/bmiCalc.dart b/lib/calc/bmiCalc.dart index 5081cab..3f647a2 100755 --- a/lib/calc/bmiCalc.dart +++ b/lib/calc/bmiCalc.dart @@ -2,20 +2,26 @@ import 'dart:math'; class BMICalculator { - BMICalculator({this.height, this.weight, this.age, this.waist, this.gender}); + BMICalculator({ + required this.height, + required this.weight, + required this.age, + this.waist, + required this.gender, + }); final int height; final double weight; final int age; - final int waist; + final int? waist; final int gender; double _bmi = 0; double _bf = 0; double calculateBMI() { - _bmi = weight / pow(height / 100, 2); - return num.parse(_bmi.toStringAsFixed(1)); + _bmi = (weight / pow(height / 100, 2)); + return double.parse(_bmi.toStringAsFixed(1)); } double calculateBF() { @@ -29,10 +35,10 @@ class BMICalculator { (0.005 * _bmi * _bmi * gender) + (0.00021 * _bmi * _bmi * age); if (_bf > 0) - return num.parse(_bf.toStringAsFixed(1)); + return double.parse(_bf.toStringAsFixed(1)); else return 0; } - // Body fat % = -44.988 + (0.503 * age) + (10.689 * gender) + (3.172 * BMI) - (0.026 * BMI2) + (0.181 * BMI * gender) - (0.02 * BMI * age) - (0.005 * BMI2 * gender) + (0.00021 * BMI2 * age) +// Body fat % = -44.988 + (0.503 * age) + (10.689 * gender) + (3.172 * BMI) - (0.026 * BMI2) + (0.181 * BMI * gender) - (0.02 * BMI * age) - (0.005 * BMI2 * gender) + (0.00021 * BMI2 * age) } diff --git a/lib/components/buttonButton.dart b/lib/components/buttonButton.dart index 29f64c6..855cf7d 100755 --- a/lib/components/buttonButton.dart +++ b/lib/components/buttonButton.dart @@ -3,8 +3,8 @@ import 'package:flutter/material.dart'; import 'package:bp_notepad/components/constants.dart'; class ButtonButton extends StatelessWidget { - ButtonButton({@required this.onTap, @required this.buttonTitle}); - final Function onTap; + ButtonButton({required this.onTap, required this.buttonTitle}); + final VoidCallback onTap; final String buttonTitle; @override Widget build(BuildContext context) { diff --git a/lib/components/iconContent.dart b/lib/components/iconContent.dart index d45b7d7..d75fc27 100755 --- a/lib/components/iconContent.dart +++ b/lib/components/iconContent.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; class IconFont extends StatelessWidget { - IconFont({this.icon, this.lable, this.textStyle,this.colorStyle}); + IconFont({required this.icon, required this.label, required this.textStyle,required this.colorStyle}); final IconData icon; - final String lable; + final String label; final TextStyle textStyle; final Color colorStyle; @@ -21,7 +21,7 @@ class IconFont extends StatelessWidget { const SizedBox( height: 10.0, ), - Text(lable, style: textStyle) + Text(label, style: textStyle) ], ); } diff --git a/lib/components/lineChart1.dart b/lib/components/lineChart1.dart index 8f11c05..f830612 100755 --- a/lib/components/lineChart1.dart +++ b/lib/components/lineChart1.dart @@ -1,5 +1,3 @@ -/* 血压图表小组件 */ - import 'package:bp_notepad/db/bp_databaseProvider.dart'; import 'package:bp_notepad/localization/appLocalization.dart'; import 'package:fl_chart/fl_chart.dart'; @@ -17,29 +15,27 @@ class _BPLineChartState extends State { int segmentedControlGroupValue = 10; - double sbpAvg = 0; //高压平均值 - double dbpAvg = 0; //低压平均值 - double sbpAll = 0; //用于计算平均值的高压总值 - double dbpAll = 0; //用于计算平均值的高压总值 - int max = 120; //用于找出最大的值 - int min = 70; //用于找出最小的值 + double sbpAvg = 0; // Average systolic blood pressure + double dbpAvg = 0; // Average diastolic blood pressure + double sbpAll = 0; // Total systolic blood pressure for calculating average + double dbpAll = 0; // Total diastolic blood pressure for calculating average + int max = 120; // For finding the maximum value + int min = 70; // For finding the minimum value List sbpSpotsData = []; List dbpSpotsData = []; bool showAvg = false; - //获得平均值的点 List getSBPAvgData() { - List avgSBPSpotDatas = []; //一个growable的List必须使用.add进行数据装填 + List avgSBPSpotDatas = []; for (int x = 0; x <= maxx; x++) { avgSBPSpotDatas.add(FlSpot(x.toDouble(), sbpAvg)); } return avgSBPSpotDatas; } - //获得平均值的点 List getDBPAvgData() { - List avgDBPSpotDatas = []; //一个growable的List必须使用.add进行数据装填 + List avgDBPSpotDatas = []; for (int x = 0; x <= maxx; x++) { avgDBPSpotDatas.add(FlSpot(x.toDouble(), dbpAvg)); } @@ -49,256 +45,237 @@ class _BPLineChartState extends State { @override Widget build(BuildContext context) { return AspectRatio( - aspectRatio: 1, - child: FutureBuilder( - future: BpDataBaseProvider.db.getGraphData(), - builder: (context, snapshot) { - if (snapshot.hasData) { - int showLength = 0; - int addLength = 0; - if ((snapshot.data[0].length - segmentedControlGroupValue) > 0) { - showLength = - snapshot.data[0].length - segmentedControlGroupValue; - addLength = segmentedControlGroupValue; - } else { - addLength = snapshot.data[0].length; - } - if (snapshot.data[0].length >= 10) { - sbpSpotsData.clear(); - dbpSpotsData.clear(); - sbpAll = 0; - dbpAll = 0; - for (int x = 0; x < addLength; x++) { - // 获取最大值和最小值 - if (snapshot.data[0][x + showLength] > max) { - max = snapshot.data[0][x + showLength]; - } else if (snapshot.data[1][x + showLength] < min) { - min = snapshot.data[1][x + showLength]; - } - sbpSpotsData.add(FlSpot(x.toDouble(), - snapshot.data[0][x + showLength].toDouble())); - // 加上最近十次的高压 - sbpAll += snapshot.data[0][x + showLength].toDouble(); - dbpSpotsData.add(FlSpot(x.toDouble(), - snapshot.data[1][x + showLength].toDouble())); - // 加上最近十次的低压 - dbpAll += snapshot.data[1][x + showLength].toDouble(); + aspectRatio: 1, + child: FutureBuilder( + future: BpDataBaseProvider.db.getGraphData(), + builder: (context, snapshot) { + if (snapshot.hasData) { + int showLength = 0; + int addLength = 0; + if ((snapshot.data![0].length - segmentedControlGroupValue) > 0) { + showLength = + snapshot.data![0].length - segmentedControlGroupValue; + addLength = segmentedControlGroupValue; + } else { + addLength = snapshot.data![0].length; + } + if (snapshot.data![0].length >= 10) { + sbpSpotsData.clear(); + dbpSpotsData.clear(); + sbpAll = 0; + dbpAll = 0; + for (int x = 0; x < addLength; x++) { + if (snapshot.data![0][x + showLength] > max) { + max = snapshot.data![0][x + showLength]; + } else if (snapshot.data![1][x + showLength] < min) { + min = snapshot.data![1][x + showLength]; } - sbpAvg = sbpAll / addLength; - dbpAvg = dbpAll / addLength; - } else { - if (sbpSpotsData.isEmpty && dbpSpotsData.isEmpty) { - for (int x = 0; x < snapshot.data[0].length; x++) { - //获取最大值和最小值 - if (snapshot.data[0][x] > max) { - max = snapshot.data[0][x]; - } else if (snapshot.data[1][x] < min) { - min = snapshot.data[1][x]; - } - sbpSpotsData.add( - (FlSpot(x.toDouble(), snapshot.data[0][x].toDouble()))); - sbpAll += snapshot.data[0][x].toDouble(); - dbpSpotsData.add( - (FlSpot(x.toDouble(), snapshot.data[1][x].toDouble()))); - dbpAll += snapshot.data[1][x].toDouble(); + sbpSpotsData.add(FlSpot(x.toDouble(), + snapshot.data![0][x + showLength].toDouble())); + sbpAll += snapshot.data![0][x + showLength].toDouble(); + dbpSpotsData.add(FlSpot(x.toDouble(), + snapshot.data![1][x + showLength].toDouble())); + dbpAll += snapshot.data![1][x + showLength].toDouble(); + } + sbpAvg = sbpAll / addLength; + dbpAvg = dbpAll / addLength; + } else { + if (sbpSpotsData.isEmpty && dbpSpotsData.isEmpty) { + for (int x = 0; x < snapshot.data![0].length; x++) { + if (snapshot.data![0][x] > max) { + max = snapshot.data![0][x]; + } else if (snapshot.data![1][x] < min) { + min = snapshot.data![1][x]; } - sbpAvg = sbpAll / snapshot.data[0].length; - dbpAvg = dbpAll / snapshot.data[1].length; + sbpSpotsData.add( + FlSpot(x.toDouble(), snapshot.data![0][x].toDouble())); + sbpAll += snapshot.data![0][x].toDouble(); + dbpSpotsData.add( + FlSpot(x.toDouble(), snapshot.data![1][x].toDouble())); + dbpAll += snapshot.data![1][x].toDouble(); } + sbpAvg = sbpAll / snapshot.data![0].length; + dbpAvg = dbpAll / snapshot.data![1].length; } - return Container( - decoration: const BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(18)), - // gradient: LinearGradient( - // //渐变色 - // colors: [ - // const Color(0xff2c274c), - // const Color(0xff46426c), - // ], - // begin: Alignment.bottomCenter, - // end: Alignment.topCenter, - // ), - color: const Color(0xFF241f48)), - child: Stack( - children: [ - Column( - children: [ - const SizedBox( - height: 10, - ), - CupertinoSlidingSegmentedControl( - thumbColor: const Color(0xFF1d193a), - groupValue: segmentedControlGroupValue, - children: { - 10: Text( - AppLocalization.of(context) - .translate('chart_range_10'), - style: TextStyle( - color: CupertinoColors.systemGrey), - ), - 20: Text( - AppLocalization.of(context) - .translate('chart_range_20'), - style: TextStyle( - color: CupertinoColors.systemGrey), - ), - 30: Text( - AppLocalization.of(context) - .translate('chart_range_30'), - style: TextStyle( - color: CupertinoColors.systemGrey), - ) - }, - onValueChanged: (i) { - setState(() { - segmentedControlGroupValue = i; - }); - }), - const SizedBox( - height: 4, - ), - Text( - AppLocalization.of(context) - .translate('bp_chart_tittle'), - style: TextStyle( - color: const Color(0xFFFFFFFF), - fontSize: 36, - fontWeight: FontWeight.bold, - letterSpacing: 2), - textAlign: TextAlign.center, - ), - const SizedBox( - height: 30, + } + return Container( + decoration: const BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(18)), + color: const Color(0xFF241f48), + ), + child: Stack( + children: [ + Column( + children: [ + const SizedBox( + height: 10, + ), + CupertinoSlidingSegmentedControl( + thumbColor: const Color(0xFF1d193a), + groupValue: segmentedControlGroupValue, + children: { + 10: Text( + AppLocalization.of(context) + .translate('chart_range_10'), + style: TextStyle(color: CupertinoColors.systemGrey), + ), + 20: Text( + AppLocalization.of(context) + .translate('chart_range_20'), + style: TextStyle(color: CupertinoColors.systemGrey), + ), + 30: Text( + AppLocalization.of(context) + .translate('chart_range_30'), + style: TextStyle(color: CupertinoColors.systemGrey), + ) + }, + onValueChanged: (i) { + setState(() { + segmentedControlGroupValue = i as int; + }); + }, + ), + const SizedBox( + height: 4, + ), + Text( + AppLocalization.of(context) + .translate('bp_chart_tittle'), + style: TextStyle( + color: const Color(0xFFFFFFFF), + fontSize: 36, + fontWeight: FontWeight.bold, + letterSpacing: 2, ), - Expanded( - child: Padding( - padding: - const EdgeInsets.only(right: 16.0, left: 6.0), - child: LineChart( - showAvg ? avgData() : mainData(), - swapAnimationDuration: - const Duration(milliseconds: 250), - ), + textAlign: TextAlign.center, + ), + const SizedBox( + height: 30, + ), + Expanded( + child: Padding( + padding: + const EdgeInsets.only(right: 16.0, left: 6.0), + child: LineChart( + showAvg ? avgData() : mainData(), + duration: const Duration(milliseconds: 250), ), ), - Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - SizedBox( - width: 60, - height: 34, - child: TextButton( - onPressed: () { - setState(() { - showAvg = !showAvg; - }); - }, - child: Text( - AppLocalization.of(context) - .translate('bs_chart_subtittle'), - style: TextStyle( - fontSize: 14, - color: showAvg - ? const Color(0xFFFFFFFF) - .withOpacity(0.5) - : const Color(0xFFFFFFFF), - ), + ), + Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + SizedBox( + width: 60, + height: 34, + child: TextButton( + onPressed: () { + setState(() { + showAvg = !showAvg; + }); + }, + child: Text( + AppLocalization.of(context) + .translate('bs_chart_subtittle'), + style: TextStyle( + fontSize: 14, + color: showAvg + ? const Color(0xFFFFFFFF).withOpacity(0.5) + : const Color(0xFFFFFFFF), ), ), ), - ], - ), - ], - ), - ], - ), - ); - } else { - return CupertinoActivityIndicator(); - } - }, - )); + ), + ], + ), + ], + ), + ], + ), + ); + } else { + return CupertinoActivityIndicator(); + } + }, + ), + ); } LineChartData mainData() { - // getSpotData(); return LineChartData( lineTouchData: LineTouchData( touchTooltipData: LineTouchTooltipData( tooltipBgColor: const Color(0XFF607D8B).withOpacity(0.8), ), - touchCallback: (LineTouchResponse touchResponse) {}, + touchCallback: + (FlTouchEvent flTouchEvent, LineTouchResponse? touchResponse) {}, handleBuiltInTouches: true, ), - gridData: FlGridData( - show: false, - ), + gridData: FlGridData(show: false), titlesData: FlTitlesData( - bottomTitles: SideTitles( - showTitles: true, - reservedSize: 22, - getTextStyles: (value) => const TextStyle( - color: const Color(0xB3FFFFFF), - fontWeight: FontWeight.bold, - fontSize: 12, - ), - margin: 10, - getTitles: (value) { - switch (value.toInt()) { - case 0: - return '1'; - case 4: - return '5'; - case 9: - return '10'; - case 14: - return '15'; - case 19: - return '20'; - case 24: - return '25'; - case 29: - return '30'; - } - return ''; - }, - ), - leftTitles: SideTitles( - showTitles: true, - getTextStyles: (value) => const TextStyle( - color: const Color(0xB3FFFFFF), - fontWeight: FontWeight.bold, - fontSize: 14, + bottomTitles: AxisTitles( + // showTitles: true, + // reservedSize: 22, + // getTextStyles: (value) => const TextStyle( + // color: const Color(0xB3FFFFFF), + // fontWeight: FontWeight.bold, + // fontSize: 12, + // ), + sideTitles: SideTitles( + showTitles: true, + getTitlesWidget: (value, titleMeta) { + switch (value.toInt()) { + case 0: + return Text('1'); + case 4: + return Text('5'); + case 9: + return Text('10'); + case 14: + return Text('15'); + case 19: + return Text('20'); + case 24: + return Text('25'); + case 29: + return Text('30'); + } + return Text(''); + }, + ), ), - getTitles: (value) { - switch (value.toInt()) { - case 40: - return '40'; - case 60: - return '60'; - case 80: - return '80'; - case 100: - return '100'; - case 120: - return '120'; - case 140: - return '140'; - case 160: - return '160'; - case 180: - return '180'; - case 200: - return '200'; - case 220: - return '220'; - } - return ''; - }, - margin: 8, - reservedSize: 30, - ), - ), + leftTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: true, + getTitlesWidget: (value, t) { + switch (value.toInt()) { + case 40: + return Text('40'); + case 60: + return Text('60'); + case 80: + return Text('80'); + case 100: + return Text('100'); + case 120: + return Text('120'); + case 140: + return Text('140'); + case 160: + return Text('160'); + case 180: + return Text('180'); + case 200: + return Text('200'); + case 220: + return Text('220'); + } + return Text(''); + }, + reservedSize: 30, + ), + )), borderData: FlBorderData( show: true, border: const Border( @@ -325,43 +302,48 @@ class _BPLineChartState extends State { ); } - //血压记录主界面的绘图线条颜色 List linesBarData1() { final LineChartBarData lineChartBarData1 = LineChartBarData( spots: sbpSpotsData, isCurved: true, curveSmoothness: 0, - colors: [ - const Color(0xffaa4cfc), - const Color(0xffFF1493), - ], + gradient: LinearGradient( + colors: [ + const Color(0xffaa4cfc), + const Color(0xffFF1493), + ], + ), barWidth: 3, isStrokeCapRound: true, dotData: FlDotData( show: true, ), - belowBarData: BarAreaData(show: true, colors: [ - const Color(0xffaa4cfc).withOpacity(0.3), - const Color(0xffFF1493).withOpacity(0.2), - ]), + belowBarData: BarAreaData( + show: true, + gradient: LinearGradient(colors: [ + const Color(0xffaa4cfc).withOpacity(0.3), + const Color(0xffFF1493).withOpacity(0.2), + ])), ); final LineChartBarData lineChartBarData2 = LineChartBarData( spots: dbpSpotsData, isCurved: true, curveSmoothness: 0, - colors: [ + gradient: LinearGradient(colors: [ const Color(0xff00FA9A), const Color(0xff4af699), - ], + ]), barWidth: 3, isStrokeCapRound: true, dotData: FlDotData( show: true, ), - belowBarData: BarAreaData(show: true, colors: [ - const Color(0xff00FA9A).withOpacity(0.2), - const Color(0xff4af699).withOpacity(0.2), - ]), + belowBarData: BarAreaData( + show: true, + gradient: LinearGradient(colors: [ + const Color(0xff00FA9A).withOpacity(0.2), + const Color(0xff4af699).withOpacity(0.2), + ])), ); return [ lineChartBarData1, @@ -376,74 +358,77 @@ class _BPLineChartState extends State { ), gridData: FlGridData(show: false), titlesData: FlTitlesData( - bottomTitles: SideTitles( - showTitles: true, - reservedSize: 22, - getTextStyles: (value) => const TextStyle( - color: const Color(0xff72719b), - fontWeight: FontWeight.bold, - fontSize: 12, + bottomTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: true, + reservedSize: 22, + // getTextStyles: (value) => const TextStyle( + // color: const Color(0xff72719b), + // fontWeight: FontWeight.bold, + // fontSize: 12, + // ), + // margin: 10, + getTitlesWidget: (value, t) { + switch (value.toInt()) {} + return Text(''); + }, ), - margin: 10, - getTitles: (value) { - switch (value.toInt()) { - } - return ''; - }, ), - leftTitles: SideTitles( + leftTitles: AxisTitles( + sideTitles: SideTitles( showTitles: true, - getTextStyles: (value) => const TextStyle( - color: const Color(0xff75729e), - fontWeight: FontWeight.bold, - fontSize: 14, - ), - getTitles: (value) { + // getTextStyles: (value) => const TextStyle( + // color: const Color(0xff75729e), + // fontWeight: FontWeight.bold, + // fontSize: 14, + // ), + getTitlesWidget: (value, titleMeta) { switch (value.toInt()) { case 40: - return '40'; + return Text('40'); case 60: - return '60'; + return Text('60'); case 80: - return '80'; + return Text('80'); case 100: - return '100'; + return Text('100'); case 120: - return '120'; + return Text('120'); case 140: - return '140'; + return Text('140'); case 160: - return '160'; + return Text('160'); case 180: - return '180'; + return Text('180'); case 200: - return '200'; + return Text('200'); case 220: - return '220'; + return Text('220'); } - return ''; + return Text(''); }, - margin: 8, + // margin: 8, reservedSize: 30, - ), + )), ), borderData: FlBorderData( - show: true, - border: const Border( - bottom: BorderSide( - color: const Color(0xff4e4965), - width: 4, - ), - left: BorderSide( - color: Colors.transparent, - ), - right: BorderSide( - color: Colors.transparent, - ), - top: BorderSide( - color: Colors.transparent, - ), - )), + show: true, + border: const Border( + bottom: BorderSide( + color: const Color(0xff4e4965), + width: 4, + ), + left: BorderSide( + color: Colors.transparent, + ), + right: BorderSide( + color: Colors.transparent, + ), + top: BorderSide( + color: Colors.transparent, + ), + ), + ), minX: minx, maxX: maxx, maxY: (((max.toInt()) ~/ 10) * 10 + 10).toDouble(), @@ -457,36 +442,40 @@ class _BPLineChartState extends State { LineChartBarData( spots: getSBPAvgData(), isCurved: true, - colors: [ + gradient: LinearGradient(colors: [ const Color(0xffaa4cfc), const Color(0xffFF1493), - ], + ]), barWidth: 3, isStrokeCapRound: true, dotData: FlDotData( show: false, ), - belowBarData: BarAreaData(show: true, colors: [ - const Color(0xffaa4cfc).withOpacity(0.3), - const Color(0xffFF1493).withOpacity(0.2), - ]), + belowBarData: BarAreaData( + show: true, + gradient: LinearGradient(colors: [ + const Color(0xffaa4cfc).withOpacity(0.3), + const Color(0xffFF1493).withOpacity(0.2), + ])), ), LineChartBarData( spots: getDBPAvgData(), isCurved: true, - colors: [ + gradient: LinearGradient(colors: [ const Color(0xff00FA9A), const Color(0xff4af699), - ], + ]), barWidth: 3, isStrokeCapRound: true, dotData: FlDotData( show: false, ), - belowBarData: BarAreaData(show: true, colors: [ - const Color(0xff00FA9A).withOpacity(0.2), - const Color(0xff4af699).withOpacity(0.2), - ]), + belowBarData: BarAreaData( + show: true, + gradient: LinearGradient(colors: [ + const Color(0xff00FA9A).withOpacity(0.2), + const Color(0xff4af699).withOpacity(0.2), + ])), ), ]; } diff --git a/lib/components/lineChart2.dart b/lib/components/lineChart2.dart index f8c0b6b..5056ef4 100755 --- a/lib/components/lineChart2.dart +++ b/lib/components/lineChart2.dart @@ -11,10 +11,10 @@ class BSLineChart extends StatefulWidget { } class _BSLineChartState extends State { - static const double minx = 0; - static const double maxx = 9; - static const double miny = 0; - static const double maxy = 14; + static const double minX = 0; + static const double maxX = 9; + static const double minY = 0; + static const double maxY = 14; int segmentedControlGroupValue = 10; @@ -24,21 +24,22 @@ class _BSLineChartState extends State { const Color(0xff02d39a), const Color(0xff02d39a), ]; + //分值图标渐变色的配色 double avg = 0; //平均值 double addAll = 0; //用于计算平均值的总值 bool showAvg = false; - List spotDatas = []; //绘制曲线图表的点 + List spotData = []; //绘制曲线图表的点 //获得平均值的点 List getAvgData() { - List avgSpotDatas = []; //一个growable的List必须使用.add进行数据装填 - for (int x = 0; x <= maxx; x++) { - avgSpotDatas.add(FlSpot(x.toDouble(), avg)); + List avgSpotData = []; //一个growable的List必须使用.add进行数据装填 + for (int x = 0; x <= maxX; x++) { + avgSpotData.add(FlSpot(x.toDouble(), avg)); } - return avgSpotDatas; + return avgSpotData; } @override @@ -50,29 +51,29 @@ class _BSLineChartState extends State { builder: (context, snapshot) { if (snapshot.hasData) { int showLength = 0; - int addLength = 0; - if (snapshot.data.length - segmentedControlGroupValue > 0) { - showLength = snapshot.data.length - segmentedControlGroupValue; + int? addLength = 0; + if (snapshot.data!.length - segmentedControlGroupValue > 0) { + showLength = snapshot.data!.length - segmentedControlGroupValue; addLength = segmentedControlGroupValue; } else { - addLength = snapshot.data.length; + addLength = snapshot.data?.length; } - if (snapshot.data.length >= 10) { - spotDatas.clear(); + if (snapshot.data!.length >= 10) { + spotData.clear(); addAll = 0; - for (int x = 0; x < addLength; x++) { - spotDatas - .add(FlSpot(x.toDouble(), snapshot.data[x + showLength])); - addAll += snapshot.data[x + showLength]; + for (int x = 0; x < addLength!; x++) { + spotData.add( + FlSpot(x.toDouble(), snapshot.data?[x + showLength])); + addAll += snapshot.data?[x + showLength]; } avg = addAll / addLength; } else { - if (spotDatas.isEmpty) - for (int x = 0; x < snapshot.data.length; x++) { - spotDatas.add((FlSpot(x.toDouble(), snapshot.data[x]))); - addAll += snapshot.data[x]; + if (spotData.isEmpty) + for (int x = 0; x < snapshot.data!.length; x++) { + spotData.add((FlSpot(x.toDouble(), snapshot.data?[x]))); + addAll += snapshot.data?[x]; } - avg = addAll / snapshot.data.length; + avg = addAll / snapshot.data!.length; } return Container( decoration: const BoxDecoration( @@ -110,7 +111,7 @@ class _BSLineChartState extends State { }, onValueChanged: (i) { setState(() { - segmentedControlGroupValue = i; + segmentedControlGroupValue = i as int; }); }), Text( @@ -183,66 +184,68 @@ class _BSLineChartState extends State { ), titlesData: FlTitlesData( show: true, - bottomTitles: SideTitles( + bottomTitles: AxisTitles( + sideTitles: SideTitles( showTitles: true, reservedSize: 22, - getTextStyles: (value) => const TextStyle( - color: const Color(0xB3FFFFFF), - fontWeight: FontWeight.bold, - fontSize: 12), - getTitles: (value) { + // getTextStyles: (value) => const TextStyle( + // color: const Color(0xB3FFFFFF), + // fontWeight: FontWeight.bold, + // fontSize: 12), + getTitlesWidget: (value, titleMeta) { switch (value.toInt()) { case 0: - return '1'; + return Text('1'); case 4: - return '5'; + return Text('5'); case 9: - return '10'; + return Text('10'); case 14: - return '15'; + return Text('15'); case 19: - return '20'; + return Text('20'); case 24: - return '25'; + return Text('25'); case 29: - return '30'; + return Text('30'); } - return ''; + return Text(''); }, - margin: 8, - ), - leftTitles: SideTitles( + // margin: 8, + )), + leftTitles: AxisTitles( + sideTitles: SideTitles( showTitles: true, - getTextStyles: (value) => const TextStyle( - // color: Color(0xff67727d), - color: const Color(0xB3FFFFFF), - fontWeight: FontWeight.bold, - fontSize: 14, - ), - getTitles: (value) { + // getTextStyles: (value) => const TextStyle( + // // color: Color(0xff67727d), + // color: const Color(0xB3FFFFFF), + // fontWeight: FontWeight.bold, + // fontSize: 14, + // ), + getTitlesWidget: (value, titleMeta) { switch (value.toInt()) { case 0: - return '0'; + return Text('0'); case 2: - return '2'; + return Text('2'); case 4: - return '4'; + return Text('4'); case 6: - return '6'; + return Text('6'); case 8: - return '8'; + return Text('8'); case 10: - return '10'; + return Text('10'); case 12: - return '12'; + return Text('12'); case 14: - return '14'; + return Text('14'); } - return ''; + return Text(''); }, - margin: 8, + // margin: 8, reservedSize: 30, - ), + )), ), borderData: FlBorderData( show: true, @@ -258,16 +261,16 @@ class _BSLineChartState extends State { color: Colors.transparent, ), )), - minX: minx, + minX: minX, maxX: (segmentedControlGroupValue - 1).toDouble(), - minY: miny, - maxY: maxy, + minY: minY, + maxY: maxY, lineBarsData: [ LineChartBarData( - spots: spotDatas, + spots: spotData, isCurved: true, curveSmoothness: 0, - colors: gradientColors, + gradient: LinearGradient(colors: gradientColors), barWidth: 3, isStrokeCapRound: true, dotData: FlDotData( @@ -275,8 +278,10 @@ class _BSLineChartState extends State { ), belowBarData: BarAreaData( show: true, - colors: - gradientColors.map((color) => color.withOpacity(0.3)).toList(), + gradient: LinearGradient( + colors: gradientColors + .map((color) => color.withOpacity(0.3)) + .toList()), ), ), ], @@ -291,51 +296,52 @@ class _BSLineChartState extends State { ), titlesData: FlTitlesData( show: true, - bottomTitles: SideTitles( + bottomTitles: AxisTitles( + sideTitles: SideTitles( showTitles: true, reservedSize: 22, - getTextStyles: (value) => const TextStyle( - color: Color(0xff68737d), - fontWeight: FontWeight.bold, - fontSize: 16), - getTitles: (value) { - switch (value.toInt()) { - } - return ''; + // getTextStyles: (value) => const TextStyle( + // color: Color(0xff68737d), + // fontWeight: FontWeight.bold, + // fontSize: 16), + getTitlesWidget: (value, titleMeta) { + switch (value.toInt()) {} + return Text(''); }, - margin: 8, - ), - leftTitles: SideTitles( + // margin: 8, + )), + leftTitles: AxisTitles( + sideTitles: SideTitles( showTitles: true, - getTextStyles: (value) => const TextStyle( - color: const Color(0xff67727d), - fontWeight: FontWeight.bold, - fontSize: 15, - ), - getTitles: (value) { + // getTextStyles: (value) => const TextStyle( + // color: const Color(0xff67727d), + // fontWeight: FontWeight.bold, + // fontSize: 15, + // ), + getTitlesWidget: (value, titleMeta) { switch (value.toInt()) { case 0: - return '0'; + return Text('0'); case 2: - return '2'; + return Text('2'); case 4: - return '4'; + return Text('4'); case 6: - return '6'; + return Text('6'); case 8: - return '8'; + return Text('8'); case 10: - return '10'; + return Text('10'); case 12: - return '12'; + return Text('12'); case 14: - return '14'; + return Text('14'); } - return ''; + return Text(''); }, reservedSize: 30, - margin: 8, - ), + // margin: 8, + )), ), borderData: FlBorderData( show: true, @@ -354,33 +360,35 @@ class _BSLineChartState extends State { color: Colors.transparent, ), )), - minX: minx, - maxX: maxx, - minY: miny, - maxY: maxy, + minX: minX, + maxX: maxX, + minY: minY, + maxY: maxY, lineBarsData: [ LineChartBarData( spots: getAvgData(), isCurved: true, - colors: [ + gradient: LinearGradient(colors: [ ColorTween(begin: gradientColors[0], end: gradientColors[1]) - .lerp(0.2), + .lerp(0.2)!, ColorTween(begin: gradientColors[0], end: gradientColors[1]) - .lerp(0.2), - ], + .lerp(0.2)!, + ]), barWidth: 3, isStrokeCapRound: true, dotData: FlDotData( show: false, ), - belowBarData: BarAreaData(show: true, colors: [ - ColorTween(begin: gradientColors[0], end: gradientColors[1]) - .lerp(0.2) - .withOpacity(0.1), - ColorTween(begin: gradientColors[0], end: gradientColors[1]) - .lerp(0.2) - .withOpacity(0.1), - ]), + belowBarData: BarAreaData( + show: true, + gradient: LinearGradient(colors: [ + ColorTween(begin: gradientColors[0], end: gradientColors[1]) + .lerp(0.2)! + .withOpacity(0.1), + ColorTween(begin: gradientColors[0], end: gradientColors[1]) + .lerp(0.2)! + .withOpacity(0.1), + ])), ), ], ); diff --git a/lib/components/lineChart3.dart b/lib/components/lineChart3.dart index 735cbec..a610617 100755 --- a/lib/components/lineChart3.dart +++ b/lib/components/lineChart3.dart @@ -16,8 +16,8 @@ class BmiLineChart extends StatefulWidget { } class _BmiLineChartState extends State { - static const double minx = 0; - static const double maxx = 9; + static const double minX = 0; + static const double maxX = 9; //绘制图表X轴Y轴的起点和终点 int segmentedControlGroupValue = 10; @@ -42,7 +42,7 @@ class _BmiLineChartState extends State { //获得平均值的点 List getAvgData() { List avgSpotDatas = []; //一个growable的List必须使用.add进行数据装填 - for (int x = 0; x <= maxx; x++) { + for (int x = 0; x <= maxX; x++) { avgSpotDatas.add(FlSpot(x.toDouble(), avg)); } return avgSpotDatas; @@ -58,44 +58,44 @@ class _BmiLineChartState extends State { if (snapshot.hasData) { int showLength = 0; int addLength = 0; - if (snapshot.data.length - segmentedControlGroupValue > 0) { - showLength = snapshot.data.length - segmentedControlGroupValue; + if (snapshot.data!.length - segmentedControlGroupValue > 0) { + showLength = snapshot.data!.length - segmentedControlGroupValue; addLength = segmentedControlGroupValue; } else { - addLength = snapshot.data.length; + addLength = snapshot.data!.length; } - if (snapshot.data.length >= 10) { + if (snapshot.data!.length >= 10) { //可以完整显示最近的十条记录 spotDatas.clear(); addAll = 0; for (int x = 0; x < addLength; x++) { //获取最大值和最小值 - if (snapshot.data[x + showLength] > max) { - max = snapshot.data[x + showLength]; - } else if (snapshot.data[x + showLength] < min) { - min = snapshot.data[x + showLength]; + if (snapshot.data?[x + showLength] > max) { + max = snapshot.data?[x + showLength]; + } else if (snapshot.data?[x + showLength] < min) { + min = snapshot.data?[x + showLength]; } //添加数值到spotData spotDatas - .add(FlSpot(x.toDouble(), snapshot.data[x + showLength])); - addAll += snapshot.data[x + showLength]; + .add(FlSpot(x.toDouble(), snapshot.data?[x + showLength])); + addAll += snapshot.data?[x + showLength]; } avg = addAll / addLength; } else { //不能完整显示最近的十条记录 if (spotDatas.isEmpty) - for (int x = 0; x < snapshot.data.length; x++) { - //获取最大值和最小值 - if (snapshot.data[x] > max) { - max = snapshot.data[x]; - } else if (snapshot.data[x] < min) { - min = snapshot.data[x]; + for (int x = 0; x < snapshot.data!.length; x++) { + //获取最大值和最小值i + if (snapshot.data?[x] > max) { + max = snapshot.data?[x]; + } else if (snapshot.data?[x] < min) { + min = snapshot.data?[x]; } //添加数值到spotData - spotDatas.add((FlSpot(x.toDouble(), snapshot.data[x]))); - addAll += snapshot.data[x]; + spotDatas.add((FlSpot(x.toDouble(), snapshot.data?[x]))); + addAll += snapshot.data?[x]; } - avg = addAll / snapshot.data.length; + avg = addAll / snapshot.data!.length; } return Container( decoration: const BoxDecoration( @@ -133,7 +133,7 @@ class _BmiLineChartState extends State { }, onValueChanged: (i) { setState(() { - segmentedControlGroupValue = i; + segmentedControlGroupValue = i as int; }); }), Text( @@ -206,78 +206,82 @@ class _BmiLineChartState extends State { ), titlesData: FlTitlesData( show: true, - bottomTitles: SideTitles( - showTitles: true, - reservedSize: 22, - getTextStyles: (value) => const TextStyle( - color: const Color(0xB3FFFFFF), - fontWeight: FontWeight.bold, - fontSize: 12), - getTitles: (value) { - switch (value.toInt()) { - case 0: - return '1'; - case 4: - return '5'; - case 9: - return '10'; - case 14: - return '15'; - case 19: - return '20'; - case 24: - return '25'; - case 29: - return '30'; - } - return ''; - }, - margin: 8, + bottomTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: true, + reservedSize: 22, + // getTextStyles: (value,titleMeta) => const TextStyle( + // color: const Color(0xB3FFFFFF), + // fontWeight: FontWeight.bold, + // fontSize: 12), + getTitlesWidget: (value,titleMeta) { + switch (value.toInt()) { + case 0: + return Text('1'); + case 4: + return Text('5'); + case 9: + return Text('10'); + case 14: + return Text('15'); + case 19: + return Text('20'); + case 24: + return Text('25'); + case 29: + return Text('30'); + } + return Text(''); + }, + // margin: 8, + ) ), - leftTitles: SideTitles( - showTitles: true, - getTextStyles: (value) => const TextStyle( - color: const Color(0xB3FFFFFF), - fontWeight: FontWeight.bold, - fontSize: 15, - ), - getTitles: (value) { - switch (value.toInt()) { - case 0: - return '0'; - case 10: - return '10'; - case 20: - return '20'; - case 30: - return '30'; - case 40: - return '40'; - case 50: - return '50'; - case 60: - return '60'; - case 70: - return '70'; - case 80: - return '80'; - case 90: - return '90'; - case 100: - return '100'; - case 110: - return '110'; - case 120: - return '120'; - case 130: - return '130'; - case 140: - return '140'; - } - return ''; - }, - reservedSize: 28, - margin: 12, + leftTitles:AxisTitles( + sideTitles: SideTitles( + showTitles: true, + // getTextStyles: (value,titleMeta) => const TextStyle( + // color: const Color(0xB3FFFFFF), + // fontWeight: FontWeight.bold, + // fontSize: 15, + // ), + getTitlesWidget: (value,titleMeta) { + switch (value.toInt()) { + case 0: + return Text('0'); + case 10: + return Text('10'); + case 20: + return Text('20'); + case 30: + return Text('30'); + case 40: + return Text('40'); + case 50: + return Text('50'); + case 60: + return Text('60'); + case 70: + return Text('70'); + case 80: + return Text('80'); + case 90: + return Text('90'); + case 100: + return Text('100'); + case 110: + return Text('110'); + case 120: + return Text('120'); + case 130: + return Text('130'); + case 140: + return Text('140'); + } + return Text(''); + }, + reservedSize: 28, + // margin: 12, + ) ), ), borderData: FlBorderData( @@ -297,7 +301,7 @@ class _BmiLineChartState extends State { color: Colors.transparent, ), )), - minX: minx, + minX: minX, maxX: (segmentedControlGroupValue - 1).toDouble(), maxY: (((max.toInt()) ~/ 10) * 10 + 10).toDouble(), minY: (((min.toInt()) ~/ 10) * 10 - 10).toDouble(), @@ -305,7 +309,7 @@ class _BmiLineChartState extends State { LineChartBarData( spots: spotDatas, isCurved: true, - colors: gradientColors, + gradient: LinearGradient(colors: gradientColors), barWidth: 3, isStrokeCapRound: true, curveSmoothness: 0, @@ -314,8 +318,11 @@ class _BmiLineChartState extends State { ), belowBarData: BarAreaData( show: true, - colors: - gradientColors.map((color) => color.withOpacity(0.3)).toList(), + gradient: + LinearGradient( + colors: gradientColors.map((color) => color.withOpacity(0.3)).toList(), + + ) ), ), ], @@ -330,65 +337,65 @@ class _BmiLineChartState extends State { ), titlesData: FlTitlesData( show: true, - bottomTitles: SideTitles( + bottomTitles:AxisTitles(sideTitles: SideTitles( showTitles: true, reservedSize: 22, - getTextStyles: (value) => const TextStyle( - color: Color(0xff68737d), - fontWeight: FontWeight.bold, - fontSize: 16), - getTitles: (value) { + // getTextStyles: (value,titleMeta) => const TextStyle( + // color: Color(0xff68737d), + // fontWeight: FontWeight.bold, + // fontSize: 16), + getTitlesWidget: (value,titleMeta) { switch (value.toInt()) { } - return ''; + return Text(''); }, - margin: 8, - ), - leftTitles: SideTitles( + // margin: 8, + ),), + leftTitles: AxisTitles(sideTitles:SideTitles( showTitles: true, - getTextStyles: (value) => const TextStyle( - color: const Color(0xff67727d), - fontWeight: FontWeight.bold, - fontSize: 15, - ), - getTitles: (value) { + // getTextStyles: (value,titleMeta) => const TextStyle( + // color: const Color(0xff67727d), + // fontWeight: FontWeight.bold, + // fontSize: 15, + // ), + getTitlesWidget: (value,titleMeta) { switch (value.toInt()) { case 0: - return '0'; + return Text('0'); case 10: - return '10'; + return Text('10'); case 20: - return '20'; + return Text('20'); case 30: - return '30'; + return Text('30'); case 40: - return '40'; + return Text('40'); case 50: - return '50'; + return Text('50'); case 60: - return '60'; + return Text('60'); case 70: - return '70'; + return Text('70'); case 80: - return '80'; + return Text('80'); case 90: - return '90'; + return Text('90'); case 100: - return '100'; + return Text('100'); case 110: - return '110'; + return Text('110'); case 120: - return '120'; + return Text('120'); case 130: - return '130'; + return Text('130'); case 140: - return '140'; + return Text('140'); } - return ''; + return Text(''); }, reservedSize: 28, - margin: 12, - ), + // margin: 12, + )), ), borderData: FlBorderData( show: true, @@ -407,33 +414,33 @@ class _BmiLineChartState extends State { color: Colors.transparent, ), )), - minX: minx, - maxX: maxx, + minX: minX, + maxX: maxX, maxY: (((max.toInt()) ~/ 10) * 10 + 10).toDouble(), minY: (((min.toInt()) ~/ 10) * 10 - 10).toDouble(), lineBarsData: [ LineChartBarData( spots: getAvgData(), isCurved: true, - colors: [ + gradient: LinearGradient(colors: [ ColorTween(begin: gradientColors[0], end: gradientColors[1]) - .lerp(0.2), + .lerp(0.2)!, ColorTween(begin: gradientColors[0], end: gradientColors[1]) - .lerp(0.2), - ], + .lerp(0.2)!, + ]), barWidth: 3, isStrokeCapRound: true, dotData: FlDotData( show: false, ), - belowBarData: BarAreaData(show: true, colors: [ + belowBarData: BarAreaData(show: true, gradient: LinearGradient(colors:[ ColorTween(begin: gradientColors[0], end: gradientColors[1]) - .lerp(0.2) + .lerp(0.2)! .withOpacity(0.1), ColorTween(begin: gradientColors[0], end: gradientColors[1]) - .lerp(0.2) + .lerp(0.2)! .withOpacity(0.1), - ]), + ])), ), ], ); diff --git a/lib/components/lineChart4.dart b/lib/components/lineChart4.dart index 7e8b71e..ab8430e 100644 --- a/lib/components/lineChart4.dart +++ b/lib/components/lineChart4.dart @@ -18,6 +18,7 @@ class SleepLineChart extends StatefulWidget { class _SleepLineChartState extends State { static const double minx = 0; static const double maxx = 9; + //绘制图表X轴Y轴的起点和终点 int segmentedControlGroupValue = 10; @@ -58,44 +59,44 @@ class _SleepLineChartState extends State { if (snapshot.hasData) { int showLength = 0; int addLength = 0; - if (snapshot.data.length - segmentedControlGroupValue > 0) { - showLength = snapshot.data.length - segmentedControlGroupValue; + if (snapshot.data!.length - segmentedControlGroupValue > 0) { + showLength = snapshot.data!.length - segmentedControlGroupValue; addLength = segmentedControlGroupValue; } else { - addLength = snapshot.data.length; + addLength = snapshot.data!.length; } - if (snapshot.data.length >= 10) { + if (snapshot.data!.length >= 10) { //可以完整显示最近的十条记录 spotDatas.clear(); addAll = 0; for (int x = 0; x < addLength; x++) { //获取最大值和最小值 - if (snapshot.data[x + showLength] > max) { - max = snapshot.data[x + showLength]; - } else if (snapshot.data[x + showLength] < min) { - min = snapshot.data[x + showLength]; + if (snapshot.data?[x + showLength] > max) { + max = snapshot.data?[x + showLength]; + } else if (snapshot.data?[x + showLength] < min) { + min = snapshot.data?[x + showLength]; } //添加数值到spotData - spotDatas - .add(FlSpot(x.toDouble(), snapshot.data[x + showLength])); - addAll += snapshot.data[x + showLength]; + spotDatas.add( + FlSpot(x.toDouble(), snapshot.data?[x + showLength])); + addAll += snapshot.data?[x + showLength]; } avg = addAll / addLength; } else { //不能完整显示最近的十条记录 if (spotDatas.isEmpty) - for (int x = 0; x < snapshot.data.length; x++) { + for (int x = 0; x < snapshot.data!.length; x++) { //获取最大值和最小值 - if (snapshot.data[x] > max) { - max = snapshot.data[x]; - } else if (snapshot.data[x] < min) { - min = snapshot.data[x]; + if (snapshot.data?[x] > max) { + max = snapshot.data?[x]; + } else if (snapshot.data?[x] < min) { + min = snapshot.data?[x]; } //添加数值到spotData - spotDatas.add((FlSpot(x.toDouble(), snapshot.data[x]))); - addAll += snapshot.data[x]; + spotDatas.add((FlSpot(x.toDouble(), snapshot.data?[x]))); + addAll += snapshot.data?[x]; } - avg = addAll / snapshot.data.length; + avg = addAll / snapshot.data!.length; } return Container( decoration: const BoxDecoration( @@ -133,12 +134,12 @@ class _SleepLineChartState extends State { }, onValueChanged: (i) { setState(() { - segmentedControlGroupValue = i; + segmentedControlGroupValue = i as int; }); }), Text( AppLocalization.of(context) - .translate('sleep_chart_title'), + .translate('sleep_chart_title'), style: TextStyle( color: const Color(0xFFFFFFFF), fontSize: 32, @@ -206,79 +207,81 @@ class _SleepLineChartState extends State { ), titlesData: FlTitlesData( show: true, - bottomTitles: SideTitles( + bottomTitles: AxisTitles( + sideTitles: SideTitles( showTitles: true, reservedSize: 22, - getTextStyles: (value) => const TextStyle( - color: const Color(0xB3FFFFFF), - fontWeight: FontWeight.bold, - fontSize: 12), - getTitles: (value) { + // getTextStyles: (value,titleMeta) => const TextStyle( + // color: const Color(0xB3FFFFFF), + // fontWeight: FontWeight.bold, + // fontSize: 12), + getTitlesWidget: (value, titleMeta) { switch (value.toInt()) { case 0: - return '1'; + return Text('1'); case 4: - return '5'; + return Text('5'); case 9: - return '10'; + return Text('10'); case 14: - return '15'; + return Text('15'); case 19: - return '20'; + return Text('20'); case 24: - return '25'; + return Text('25'); case 29: - return '30'; + return Text('30'); } - return ''; + return Text(''); }, - margin: 8, - ), - leftTitles: SideTitles( + // margin: 8, + )), + leftTitles: AxisTitles( + sideTitles: SideTitles( showTitles: true, - getTextStyles: (value) => const TextStyle( - color: const Color(0xB3FFFFFF), - fontWeight: FontWeight.bold, - fontSize: 15, - ), - getTitles: (value) { + // getTextStyles: (value,titleMeta) => const TextStyle( + // color: const Color(0xB3FFFFFF), + // fontWeight: FontWeight.bold, + // fontSize: 15, + // ), + getTitlesWidget: (value, titleMeta) { switch (value.toInt()) { case 0: - return '0'; + return Text('0'); case 10: - return '10'; + return Text('10'); case 20: - return '20'; + return Text('20'); case 30: - return '30'; + return Text('30'); case 40: - return '40'; + return Text('40'); case 50: - return '50'; + return Text('50'); case 60: - return '60'; + return Text('60'); case 70: - return '70'; + return Text('70'); case 80: - return '80'; + return Text('80'); case 90: - return '90'; + return Text('90'); case 100: - return '100'; + return Text('100'); case 110: - return '110'; + return Text('110'); case 120: - return '120'; + return Text('120'); case 130: - return '130'; + return Text('130'); case 140: - return '140'; + return Text('140'); } - return ''; + return Text(''); }, reservedSize: 28, - margin: 12, - ), + // margin: 12, + )), ), borderData: FlBorderData( show: true, @@ -305,7 +308,7 @@ class _SleepLineChartState extends State { LineChartBarData( spots: spotDatas, isCurved: true, - colors: gradientColors, + gradient: LinearGradient(colors: gradientColors), barWidth: 3, isStrokeCapRound: true, curveSmoothness: 0, @@ -313,10 +316,12 @@ class _SleepLineChartState extends State { show: true, ), belowBarData: BarAreaData( - show: true, - colors: - gradientColors.map((color) => color.withOpacity(0.3)).toList(), - ), + show: true, + gradient: LinearGradient( + colors: gradientColors + .map((color) => color.withOpacity(0.3)) + .toList(), + )), ), ], ); @@ -330,65 +335,66 @@ class _SleepLineChartState extends State { ), titlesData: FlTitlesData( show: true, - bottomTitles: SideTitles( + bottomTitles: AxisTitles( + sideTitles: SideTitles( showTitles: true, reservedSize: 22, - getTextStyles: (value) => const TextStyle( - color: Color(0xff68737d), - fontWeight: FontWeight.bold, - fontSize: 16), - getTitles: (value) { - switch (value.toInt()) { - } - return ''; + // getTextStyles: (value, titleMeta) => const TextStyle( + // color: Color(0xff68737d), + // fontWeight: FontWeight.bold, + // fontSize: 16), + getTitlesWidget: (value, titleMeta) { + switch (value.toInt()) {} + return Text(''); }, - margin: 8, - ), - leftTitles: SideTitles( + // margin: 8, + )), + leftTitles: AxisTitles( + sideTitles: SideTitles( showTitles: true, - getTextStyles: (value) => const TextStyle( - color: const Color(0xff67727d), - fontWeight: FontWeight.bold, - fontSize: 15, - ), - getTitles: (value) { + // getTextStyles: (value, titleMeta) => const TextStyle( + // color: const Color(0xff67727d), + // fontWeight: FontWeight.bold, + // fontSize: 15, + // ), + getTitlesWidget: (value, titleMeta) { switch (value.toInt()) { case 0: - return '0'; + return Text('0'); case 10: - return '10'; + return Text('10'); case 20: - return '20'; + return Text('20'); case 30: - return '30'; + return Text('30'); case 40: - return '40'; + return Text('40'); case 50: - return '50'; + return Text('50'); case 60: - return '60'; + return Text('60'); case 70: - return '70'; + return Text('70'); case 80: - return '80'; + return Text('80'); case 90: - return '90'; + return Text('90'); case 100: - return '100'; + return Text('100'); case 110: - return '110'; + return Text('110'); case 120: - return '120'; + return Text('120'); case 130: - return '130'; + return Text('130'); case 140: - return '140'; + return Text('140'); } - return ''; + return Text(''); }, reservedSize: 28, - margin: 12, - ), + // margin: 12, + )), ), borderData: FlBorderData( show: true, @@ -415,25 +421,30 @@ class _SleepLineChartState extends State { LineChartBarData( spots: getAvgData(), isCurved: true, - colors: [ + gradient: LinearGradient(colors: [ ColorTween(begin: gradientColors[0], end: gradientColors[1]) - .lerp(0.2), + .lerp(0.2)!, ColorTween(begin: gradientColors[0], end: gradientColors[1]) - .lerp(0.2), - ], + .lerp(0.2)!, + ]), barWidth: 3, isStrokeCapRound: true, dotData: FlDotData( show: false, ), - belowBarData: BarAreaData(show: true, colors: [ - ColorTween(begin: gradientColors[0], end: gradientColors[1]) - .lerp(0.2) - .withOpacity(0.1), - ColorTween(begin: gradientColors[0], end: gradientColors[1]) - .lerp(0.2) - .withOpacity(0.1), - ]), + belowBarData: BarAreaData( + show: true, + gradient: LinearGradient( + colors: [ + ColorTween(begin: gradientColors[0], end: gradientColors[1]) + .lerp(0.2)! + .withOpacity(0.1), + ColorTween(begin: gradientColors[0], end: gradientColors[1]) + .lerp(0.2)! + .withOpacity(0.1), + ], + ), + ), ), ], ); diff --git a/lib/components/resusableCard.dart b/lib/components/resusableCard.dart index 19451e4..48befcc 100755 --- a/lib/components/resusableCard.dart +++ b/lib/components/resusableCard.dart @@ -2,15 +2,18 @@ import 'package:flutter/material.dart'; class ReusableCard extends StatelessWidget { - ReusableCard( - {@required this.color, - @required this.cardChild, - this.onPressed, - this.onLongPressed}); + ReusableCard({ + required this.color, + required this.cardChild, + this.onPressed, + this.onLongPressed, + }); + final Color color; final Widget cardChild; - final Function onPressed; - final Function onLongPressed; + final VoidCallback? onPressed; + final VoidCallback? onLongPressed; + @override Widget build(BuildContext context) { return GestureDetector( diff --git a/lib/db/alarm_databaseProvider.dart b/lib/db/alarm_databaseProvider.dart index eef6b72..9a8234d 100755 --- a/lib/db/alarm_databaseProvider.dart +++ b/lib/db/alarm_databaseProvider.dart @@ -16,15 +16,13 @@ class AlarmDataBaseProvider { AlarmDataBaseProvider._(); static final AlarmDataBaseProvider db = AlarmDataBaseProvider._(); - Database _database; + Database? _database; - // 返回数据库,一般情况无需更改 + // Returns the database, generally no need to change Future get database async { - if (_database != null) { - return _database; - } + if (_database != null) return _database!; _database = await createDatabase(); - return _database; + return _database!; } // 创建数据库参数,一般情况无需更改 diff --git a/lib/db/body_databaseProvider.dart b/lib/db/body_databaseProvider.dart index 419a1b1..5fed14f 100755 --- a/lib/db/body_databaseProvider.dart +++ b/lib/db/body_databaseProvider.dart @@ -16,15 +16,13 @@ class BodyDataBaseProvider { BodyDataBaseProvider._(); static final BodyDataBaseProvider db = BodyDataBaseProvider._(); - Database _database; + Database? _database; - //get database在flutter中为getter的写法 + // Returns the database, generally no need to change Future get database async { - if (_database != null) { - return _database; - } + if (_database != null) return _database!; _database = await createDatabase(); - return _database; + return _database!; } Future createDatabase() async { diff --git a/lib/db/bp_databaseProvider.dart b/lib/db/bp_databaseProvider.dart index 21f434c..c379cc0 100755 --- a/lib/db/bp_databaseProvider.dart +++ b/lib/db/bp_databaseProvider.dart @@ -15,15 +15,13 @@ class BpDataBaseProvider { BpDataBaseProvider._(); static final BpDataBaseProvider db = BpDataBaseProvider._(); - Database _database; + Database? _database; - //get database在flutter中为getter的写法 + // Returns the database, generally no need to change Future get database async { - if (_database != null) { - return _database; - } + if (_database != null) return _database!; _database = await createDatabase(); - return _database; + return _database!; } //注意数据类型 diff --git a/lib/db/bs_databaseProvider.dart b/lib/db/bs_databaseProvider.dart index 1a6fd1f..062526b 100755 --- a/lib/db/bs_databaseProvider.dart +++ b/lib/db/bs_databaseProvider.dart @@ -13,15 +13,13 @@ class BsDataBaseProvider { BsDataBaseProvider._(); static final BsDataBaseProvider db = BsDataBaseProvider._(); - Database _database; + Database? _database; - //get database在flutter中为getter的写法 + // Returns the database, generally no need to change Future get database async { - if (_database != null) { - return _database; - } + if (_database != null) return _database!; _database = await createDatabase(); - return _database; + return _database!; } Future createDatabase() async { diff --git a/lib/db/sleep_databaseProvider.dart b/lib/db/sleep_databaseProvider.dart index 88eae01..f4975a0 100644 --- a/lib/db/sleep_databaseProvider.dart +++ b/lib/db/sleep_databaseProvider.dart @@ -13,15 +13,13 @@ class SleepDataBaseProvider { SleepDataBaseProvider._(); static final SleepDataBaseProvider db = SleepDataBaseProvider._(); - Database _database; + Database? _database; - //get database在flutter中为getter的写法 + // Returns the database, generally no need to change Future get database async { - if (_database != null) { - return _database; - } + if (_database != null) return _database!; _database = await createDatabase(); - return _database; + return _database!; } Future createDatabase() async { diff --git a/lib/events/reminderBloc.dart b/lib/events/reminderBloc.dart index d9a95ed..6d7f3f7 100755 --- a/lib/events/reminderBloc.dart +++ b/lib/events/reminderBloc.dart @@ -4,20 +4,21 @@ import 'package:bp_notepad/models/alarmModel.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; class ReminderBloc extends Bloc> { + + ReminderBloc() : super([]); + + // ReminderBloc(List initialState) : super(initialState); + // 初始化一个AlarmDB列表 - @override List get initialState => []; - @override Stream> mapEventToState(ReminderEvent event) async* { if (event is SetAlarms) { yield event.alarmList; } else if (event is AddAlarm) { List newState = List.from(state); - if (event.newAlarm != null) { - newState.add(event.newAlarm); - } - yield newState; + newState.add(event.newAlarm); + yield newState; } else if (event is DeleteAlarm) { List newState = List.from(state); newState.removeAt(event.alarmIndex); diff --git a/lib/events/reminderEvent.dart b/lib/events/reminderEvent.dart index 814faaa..cce0dd5 100755 --- a/lib/events/reminderEvent.dart +++ b/lib/events/reminderEvent.dart @@ -6,7 +6,7 @@ abstract class ReminderEvent {} // 初始化提醒列表 class SetAlarms extends ReminderEvent { - List alarmList; + List alarmList = []; SetAlarms(List alarms) { alarmList = alarms; @@ -15,7 +15,7 @@ class SetAlarms extends ReminderEvent { // 删除提醒 class DeleteAlarm extends ReminderEvent { - int alarmIndex; + int alarmIndex = -1; DeleteAlarm(int index) { alarmIndex = index; @@ -24,9 +24,9 @@ class DeleteAlarm extends ReminderEvent { // 增加提醒 class AddAlarm extends ReminderEvent { - AlarmDB newAlarm; + AlarmDB newAlarm = new AlarmDB(); AddAlarm(AlarmDB alarm) { newAlarm = alarm; } -} +} \ No newline at end of file diff --git a/lib/localization/appLocalization.dart b/lib/localization/appLocalization.dart index 31edbaf..97278bb 100755 --- a/lib/localization/appLocalization.dart +++ b/lib/localization/appLocalization.dart @@ -10,11 +10,11 @@ class AppLocalization { AppLocalization(this.locale); static AppLocalization of(BuildContext context) { - return Localizations.of(context, AppLocalization); + return Localizations.of(context, AppLocalization)!; } // 将json文件读取到一个map中,方便使用 - Map _localizedStrings; + Map _localizedStrings ={}; // load函数来读取json文件 Future load() async { @@ -29,7 +29,7 @@ class AppLocalization { //翻译,translate会在每个widget需要的时候被调用 String translate(String key) { - return _localizedStrings[key]; + return _localizedStrings[key]!; } // static member to have simple access to the delegate from Material App diff --git a/lib/main.dart b/lib/main.dart index b51b350..4151c22 100755 --- a/lib/main.dart +++ b/lib/main.dart @@ -14,9 +14,9 @@ void main() { } class BpNotepad extends StatefulWidget { - const BpNotepad({Key key}) : super(key: key); + const BpNotepad({Key? key}) : super(key: key); static void setLocale(BuildContext context, Locale newLocale) { - _BpNotepadState state = context.findAncestorStateOfType<_BpNotepadState>(); + _BpNotepadState state = context.findAncestorStateOfType<_BpNotepadState>()!; state.setLocale(newLocale); } @@ -25,7 +25,7 @@ class BpNotepad extends StatefulWidget { } class _BpNotepadState extends State { - Locale _locale; + late Locale _locale; setLocale(Locale locale) { setState(() { _locale = locale; @@ -66,7 +66,7 @@ class _BpNotepadState extends State { ], // localization logic,返回需要使用的local,检查我们需要使用的语言是否在supportedLocales当中 localeResolutionCallback: (locale, supportedLocales) { - sysSupportedLocales.add(locale.languageCode); + sysSupportedLocales.add(locale?.languageCode); for (var supportedLocale in supportedLocales) { // 选择首选语言进行语言设置 if (supportedLocale.languageCode == sysSupportedLocales.first) { diff --git a/lib/models/alarmModel.dart b/lib/models/alarmModel.dart index bcf4b74..3061ca3 100755 --- a/lib/models/alarmModel.dart +++ b/lib/models/alarmModel.dart @@ -2,12 +2,12 @@ import 'package:bp_notepad/db/alarm_databaseProvider.dart'; class AlarmDB { - int id; - int pushID; - String date; - String state; - String medicine; - String dosage; + int? id; + int? pushID; + String? date; + String? state; + String? medicine; + String? dosage; AlarmDB({ this.id, @@ -27,10 +27,8 @@ class AlarmDB { AlarmDataBaseProvider.COLUMN_DOSAGE: dosage, AlarmDataBaseProvider.COLUMN_PUSHID: pushID, }; - if (id != null) { - map[AlarmDataBaseProvider.COLUMN_ID] = id; - } - return map; + map[AlarmDataBaseProvider.COLUMN_ID] = id; + return map; } AlarmDB.fromMap(Map map) { diff --git a/lib/models/bodyModel.dart b/lib/models/bodyModel.dart index 8210504..3c9b5f9 100755 --- a/lib/models/bodyModel.dart +++ b/lib/models/bodyModel.dart @@ -2,12 +2,12 @@ import 'package:bp_notepad/db/body_databaseProvider.dart'; class BodyDB { - int id; - int gender; - double bmi; - double bf; - double weight; - String date; + int? id; + int? gender; + double? bmi; + double? bf; + double? weight; + String? date; BodyDB({this.gender, this.weight, this.bmi, this.bf, this.date}); @@ -20,9 +20,7 @@ class BodyDB { BodyDataBaseProvider.COLUMN_WEIGHT: weight, BodyDataBaseProvider.COLUMN_GENDER: gender, }; - if (id != null) { - map[BodyDataBaseProvider.COLUMN_ID] = id; - } + map[BodyDataBaseProvider.COLUMN_ID] = id; return map; } diff --git a/lib/models/bpDBModel.dart b/lib/models/bpDBModel.dart index 078506d..a984caf 100755 --- a/lib/models/bpDBModel.dart +++ b/lib/models/bpDBModel.dart @@ -2,12 +2,12 @@ import 'package:bp_notepad/db/bp_databaseProvider.dart'; class BloodPressureDB { - int id; - int sbp; - int dbp; - int hr; - int state; - String date; + int? id; + int? sbp; + int? dbp; + int? hr; + int? state; + String? date; BloodPressureDB({this.sbp, this.dbp, this.hr, this.state, this.date}); @@ -20,10 +20,8 @@ class BloodPressureDB { BpDataBaseProvider.COLUMN_TIME: date, BpDataBaseProvider.COLUMN_STATE: state, }; - if (id != null) { - map[BpDataBaseProvider.COLUMN_ID] = id; - } - return map; + map[BpDataBaseProvider.COLUMN_ID] = id; + return map; } BloodPressureDB.fromMap(Map map) { diff --git a/lib/models/bsDBModel.dart b/lib/models/bsDBModel.dart index d12a2b5..d3df2c3 100755 --- a/lib/models/bsDBModel.dart +++ b/lib/models/bsDBModel.dart @@ -2,10 +2,10 @@ import 'package:bp_notepad/db/bs_databaseProvider.dart'; class BloodSugarDB { - int id; - double glu; - int state; - String date; + int? id; + double? glu; + int? state; + String? date; BloodSugarDB({this.id, this.glu, this.state, this.date}); @@ -16,10 +16,8 @@ class BloodSugarDB { BsDataBaseProvider.COLUMN_STATE: state, BsDataBaseProvider.COLUMN_TIME: date }; - if (id != null) { - map[BsDataBaseProvider.COLUMN_ID] = id; - } - return map; + map[BsDataBaseProvider.COLUMN_ID] = id; + return map; } BloodSugarDB.fromMap(Map map) { diff --git a/lib/models/sleepDBModel.dart b/lib/models/sleepDBModel.dart index bfd1bb4..d184a59 100644 --- a/lib/models/sleepDBModel.dart +++ b/lib/models/sleepDBModel.dart @@ -2,10 +2,10 @@ import 'package:bp_notepad/db/sleep_databaseProvider.dart'; class SleepDB { - int id; - double sleep; - int state; - String date; + int? id; + double? sleep; + int? state; + String? date; SleepDB({this.id, this.sleep, this.state, this.date}); @@ -16,10 +16,8 @@ class SleepDB { SleepDataBaseProvider.COLUMN_STATE: state, SleepDataBaseProvider.COLUMN_TIME: date }; - if (id != null) { - map[SleepDataBaseProvider.COLUMN_ID] = id; - } - return map; + map[SleepDataBaseProvider.COLUMN_ID] = id; + return map; } SleepDB.fromMap(Map map) { diff --git a/lib/request/flutterTencentOCR.dart b/lib/request/flutterTencentOCR.dart index 35be4ea..85ec11a 100644 --- a/lib/request/flutterTencentOCR.dart +++ b/lib/request/flutterTencentOCR.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; -import 'package:dio/adapter.dart'; import 'package:dio/dio.dart'; import 'package:crypto/crypto.dart'; @@ -10,6 +9,7 @@ import 'package:hex/hex.dart'; ///数据解析回调 typedef T JsonParse(dynamic data); +typedef CreateHttpClient = HttpClient Function(); class FlutterTencentOcr { /// 发起请求 @@ -19,14 +19,14 @@ class FlutterTencentOcr { String secretKey, String action, requestDataJson, { - JsonParse jsonParse, + JsonParse? jsonParse, String service = "ocr", String host = "ocr.tencentcloudapi.com", String algorithm = "TC3-HMAC-SHA256", String contentType = "application/json; charset=utf-8", String version = "2018-11-19", String region = "ap-guangzhou", - String findProxy, + String? findProxy, }) async { DateTime nowTime = DateTime.now(); String date = @@ -118,18 +118,15 @@ class FlutterTencentOcr { try { Dio dio = Dio(); - if (findProxy != null) { - (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = - (client) { - client.findProxy = (uri) { - return "PROXY $findProxy"; - }; - client.badCertificateCallback = - (X509Certificate cert, String host, int port) { - return true; - }; - }; - } + var client = HttpClient(); + + client.findProxy = (uri) { + return "PROXY $findProxy"; + }; + client.badCertificateCallback = + (X509Certificate cert, String host, int port) { + return true; + }; Response> response = await dio.post('https://$host/', options: Options( @@ -138,17 +135,17 @@ class FlutterTencentOcr { ), data: payloadJson); - if (response.data["Response"] != null) { + if (response.data?["Response"] != null) { if (jsonParse != null) { - return jsonParse(response.data["Response"]); + return jsonParse(response.data?["Response"]); } else { - return response.data["Response"]; + return response.data?["Response"]; } } else { - throw (Future.error( - DioError(error: "腾讯OCR数据下发格式异常", requestOptions: null))); + throw (Future.error(DioException( + error: "腾讯OCR数据下发格式异常", requestOptions: RequestOptions()))); } - } on DioError catch (e) { + } on DioException catch (e) { throw (Future.error(e)); } catch (e) { throw (Future.error(e)); diff --git a/lib/screens/FunctionScreen/alarmScreen.dart b/lib/screens/FunctionScreen/alarmScreen.dart index c148cb0..78f621d 100755 --- a/lib/screens/FunctionScreen/alarmScreen.dart +++ b/lib/screens/FunctionScreen/alarmScreen.dart @@ -19,12 +19,12 @@ import 'package:timezone/data/latest.dart' as tz; import 'package:intl/intl.dart'; class AlarmScreen extends StatefulWidget { - final String initialMedicineTitle; - final String initialMedicineDosage; - final String initialMedicineUsage; + final String? initialMedicineTitle; + final String? initialMedicineDosage; + final String? initialMedicineUsage; const AlarmScreen({ - Key key, + Key? key, this.initialMedicineTitle, this.initialMedicineDosage, this.initialMedicineUsage, @@ -38,11 +38,11 @@ class _AlarmScreenState extends State { DateTime _selectedDate = DateTime.now(); //获取一个当前的日期 String _formattedDate = DateFormat('yyyy-MM-dd kk:mm').format(DateTime.now()); //获取一个格式化后的当前日期 - FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin; //声明一个本地提醒的插件 + late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin; //声明一个本地提醒的插件 final TextEditingController _textEditingController = TextEditingController(); - TextEditingController _medicineInput; - TextEditingController _dosageInput; - TextEditingController _usageInput; + late TextEditingController _medicineInput; + late TextEditingController _dosageInput; + late TextEditingController _usageInput; // Create a text controller and use it to retrieve the current value // of the TextField. @@ -63,20 +63,37 @@ class _AlarmScreenState extends State { _usageInput = TextEditingController(text: widget.initialMedicineUsage); flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin(); var android = new AndroidInitializationSettings('@mipmap/ic_launcher'); - var iOS = new IOSInitializationSettings(); + var iOS = + DarwinInitializationSettings( + onDidReceiveLocalNotification: onDidReceiveLocalNotification); + var initSetttings = new InitializationSettings(android: android, iOS: iOS); flutterLocalNotificationsPlugin.initialize(initSetttings, - onSelectNotification: onSelectNotification); + onDidReceiveNotificationResponse: onDidReceiveNotificationResponse); + } // ignore: missing_return - Future onSelectNotification(String payload) { + Future onDidReceiveLocalNotification( + int id, String? title, String? body, String? payload) async { + + // Handle notification received + debugPrint("Notification Received: $payload"); + + } + + Future onDidReceiveNotificationResponse(NotificationResponse response) async { + + // Get payload from response + String? payload = response.payload; + + // Handle response debugPrint("payload : $payload"); showDialog( context: context, - builder: (_) => new AlertDialog( - title: new Text('Notification'), - content: new Text('$payload'), + builder: (_) => AlertDialog( + title: Text('Notification'), + content: Text('$payload'), ), ); } @@ -103,11 +120,11 @@ class _AlarmScreenState extends State { var android = new AndroidNotificationDetails( 'Reminder_Channel$_pushID', 'Medication reminders', - 'Reminder to take medication at the time you specify', + channelDescription: 'Reminder to take medication at the time you specify', priority: Priority.high, importance: Importance.max); // IOS设备 - var iOS = new IOSNotificationDetails(threadIdentifier: "thread_id"); + var iOS = new DarwinNotificationDetails(threadIdentifier: "thread_id"); var platform = new NotificationDetails(android: android, iOS: iOS); await flutterLocalNotificationsPlugin.zonedSchedule( _pushID, @@ -117,16 +134,16 @@ class _AlarmScreenState extends State { platform, uiLocalNotificationDateInterpretation: UILocalNotificationDateInterpretation.absoluteTime, - androidAllowWhileIdle: true); + androidScheduleMode: AndroidScheduleMode.exact); print(_pushID); } _selectDate() async { - DateTime pickedDate = await showModalBottomSheet( + DateTime? pickedDate = await showModalBottomSheet( backgroundColor: CupertinoDynamicColor.resolve(modalGroundColor, context), context: context, builder: (context) { - DateTime tempPickedDate; + DateTime? tempPickedDate; return Container( height: 350, child: Column( @@ -175,9 +192,9 @@ class _AlarmScreenState extends State { ); }, ); - if (pickedDate != null && pickedDate != _selectedDate) { + if (pickedDate != _selectedDate) { setState(() { - _selectedDate = pickedDate; + _selectedDate = pickedDate!; _textEditingController.text = pickedDate.toString(); _formattedDate = DateFormat('yyyy-MM-dd kk:mm').format(_selectedDate); }); @@ -304,7 +321,7 @@ class _AlarmScreenState extends State { ), ButtonButton( onTap: () { - _formKey.currentState.save(); + _formKey.currentState?.save(); if (_medicine != '') { _medicineInput.text = _medicine; } diff --git a/lib/screens/FunctionScreen/bmiScreen.dart b/lib/screens/FunctionScreen/bmiScreen.dart index 62c774e..eadf178 100755 --- a/lib/screens/FunctionScreen/bmiScreen.dart +++ b/lib/screens/FunctionScreen/bmiScreen.dart @@ -24,7 +24,7 @@ class BmiScreen extends StatefulWidget { } class _BmiScreenState extends State { - Gender selectedGender; + Gender? selectedGender; int _selectedHeight = 160; int _selectedWeightInt = 50; int _selectedWeightFloat = 0; @@ -65,7 +65,7 @@ class _BmiScreenState extends State { : CupertinoDynamicColor.resolve(backGroundColor, context), cardChild: IconFont( icon: FontAwesomeIcons.mars, - lable: AppLocalization.of(context).translate('male'), + label: AppLocalization.of(context).translate('male'), textStyle: selectedGender == Gender.male ? kSelctedTextStyle : kLabelTextStyle, @@ -89,7 +89,7 @@ class _BmiScreenState extends State { : CupertinoDynamicColor.resolve(backGroundColor, context), cardChild: IconFont( icon: FontAwesomeIcons.venus, - lable: + label: AppLocalization.of(context).translate('female'), textStyle: selectedGender == Gender.female ? kSelctedTextStyle @@ -434,7 +434,7 @@ class _BmiScreenState extends State { ButtonButton( buttonTitle: AppLocalization.of(context).translate('calc_buttom'), - onTap: () { + onTap: () async { double bmiResult = 0; double bfResult = 0; if (selectedGender != null) { @@ -442,7 +442,7 @@ class _BmiScreenState extends State { height: height, weight: weight, age: age, - gender: selectedGender.index); + gender: selectedGender!.index); var date = new DateTime.now().toLocal(); String time = "${date.year.toString()}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')} ${date.hour.toString().padLeft(2, '0')}:${date.minute.toString().padLeft(2, '0')}"; @@ -454,7 +454,7 @@ class _BmiScreenState extends State { bf: bfResult, weight: weight, date: time, - gender: selectedGender.index); + gender: selectedGender!.index); BodyDataBaseProvider.db.insert(bmiDB); Navigator.push( context, @@ -466,7 +466,7 @@ class _BmiScreenState extends State { ), ); } else { - return showDialog( + return await showDialog( context: context, barrierDismissible: false, // user must tap button! builder: (BuildContext context) { diff --git a/lib/screens/FunctionScreen/bpScreen.dart b/lib/screens/FunctionScreen/bpScreen.dart index 941b07e..7cacb78 100755 --- a/lib/screens/FunctionScreen/bpScreen.dart +++ b/lib/screens/FunctionScreen/bpScreen.dart @@ -22,7 +22,7 @@ class _BloodPressureState extends State { int dbPressure = 75; //低压 int heartRate = 60; - TextEditingController _voiceInputController; + late TextEditingController _voiceInputController; String _voiceInput = ''; _pressureWarningDialog(BuildContext context) { @@ -77,7 +77,7 @@ class _BloodPressureState extends State { RegExp regExp = new RegExp(r'([0-9]{3}|[0-9]{2})'); Iterable matches = regExp.allMatches(text); for (Match m in matches) { - int match = int.parse(m[0]); + int match = int.parse(m[0]!); bpData.add(match); } if (bpData.isEmpty) { @@ -465,7 +465,7 @@ class _BloodPressureState extends State { ), ), ButtonButton( - onTap: () { + onTap: () async { if (_voiceInput != "") { print(_voiceInput); List bpList = checkBP(_voiceInput); @@ -534,7 +534,7 @@ class _BloodPressureState extends State { } } else { // 匹配失败 - return showDialog( + return await showDialog( context: context, barrierDismissible: false, // user must tap button! builder: (BuildContext context) { diff --git a/lib/screens/FunctionScreen/bsScreen.dart b/lib/screens/FunctionScreen/bsScreen.dart index eff393b..a4f4640 100755 --- a/lib/screens/FunctionScreen/bsScreen.dart +++ b/lib/screens/FunctionScreen/bsScreen.dart @@ -28,7 +28,7 @@ class _BloodSugarState extends State { int _selectedGluInt = 4; int _selectedGluFloat = 0; - TextEditingController _voiceInputController; + late TextEditingController _voiceInputController; String _voiceInput = ''; List checkBS(String text) { @@ -38,7 +38,7 @@ class _BloodSugarState extends State { RegExp c = new RegExp(r'([0-9]{1,2}?)+(\.[0-9]{1,2})'); Iterable matches = c.allMatches(text); for (Match m in matches) { - double match = double.parse(m[0]); + double match = double.parse(m[0]!); bsData.add(match); } } else if (text.contains("后")) { @@ -46,7 +46,7 @@ class _BloodSugarState extends State { RegExp c = new RegExp(r'([0-9]{1,2}?)+(\.[0-9]{1,2})'); Iterable matches = c.allMatches(text); for (Match m in matches) { - double match = double.parse(m[0]); + double match = double.parse(m[0]!); bsData.add(match); } } @@ -72,7 +72,7 @@ class _BloodSugarState extends State { ); } - Meal selectedMeal; + late Meal selectedMeal; @override Widget build(BuildContext context) { return CupertinoPageScaffold( @@ -111,7 +111,7 @@ class _BloodSugarState extends State { backGroundColor, context), cardChild: IconFont( icon: CupertinoIcons.battery_25, - lable: AppLocalization.of(context) + label: AppLocalization.of(context) .translate('before_meal_state'), textStyle: selectedMeal == Meal.beforeMeal ? kSelctedTextStyle @@ -135,7 +135,7 @@ class _BloodSugarState extends State { backGroundColor, context), cardChild: IconFont( icon: CupertinoIcons.battery_100, - lable: AppLocalization.of(context) + label: AppLocalization.of(context) .translate('after_meal_state'), textStyle: selectedMeal == Meal.afterMeal ? kSelctedTextStyle @@ -286,7 +286,7 @@ class _BloodSugarState extends State { ), ), ButtonButton( - onTap: () { + onTap: () async { if (_voiceInput != "") { print(_voiceInput); List bsList = checkBS(_voiceInput); @@ -308,7 +308,7 @@ class _BloodSugarState extends State { builder: (context) => BSResultScreen( glu: bsList[2], state: bsList[1]))); } else { - return showDialog( + return await showDialog( context: context, barrierDismissible: false, // user must tap button! diff --git a/lib/screens/FunctionScreen/exportPDF.dart b/lib/screens/FunctionScreen/exportPDF.dart index 8348712..632688c 100644 --- a/lib/screens/FunctionScreen/exportPDF.dart +++ b/lib/screens/FunctionScreen/exportPDF.dart @@ -117,7 +117,7 @@ Future generateInvoice() async { drawGrid2(page6, pageSize, grid6, result); // Add invoice footer //Save and launch the document - final List bytes = document.save(); + final List bytes = await document.save(); //Dispose the document. document.dispose(); //Get the storage folder location using path_provider package. @@ -159,7 +159,7 @@ PdfLayoutResult drawHeader(PdfPage page, Size pageSize, PdfGrid grid) { return PdfTextElement(text: address, font: contentFont).draw( page: page, bounds: Rect.fromLTWH(30, 120, pageSize.width - (contentSize.width + 30), - pageSize.height - 120)); + pageSize.height - 120))!; } //Draws the grid @@ -178,7 +178,7 @@ PdfLayoutResult drawGrid( }; //Draw the PDF grid and get the result. result = grid.draw( - page: page, bounds: Rect.fromLTWH(0, result.bounds.bottom + 40, 0, 0)); + page: page, bounds: Rect.fromLTWH(0, result.bounds.bottom + 40, 0, 0))!; return result; } @@ -197,7 +197,7 @@ PdfLayoutResult drawGrid2( } }; //Draw the PDF grid and get the result. - result = grid.draw(page: page, bounds: Rect.fromLTWH(0, 0, 0, 0)); + result = grid.draw(page: page, bounds: Rect.fromLTWH(0, 0, 0, 0))!; return result; } diff --git a/lib/screens/FunctionScreen/medicineListScreen.dart b/lib/screens/FunctionScreen/medicineListScreen.dart index 180b79f..c3ebb22 100644 --- a/lib/screens/FunctionScreen/medicineListScreen.dart +++ b/lib/screens/FunctionScreen/medicineListScreen.dart @@ -5,9 +5,9 @@ import 'package:bp_notepad/screens/FunctionScreen/alarmScreen.dart'; import 'package:flutter/cupertino.dart'; class MedicineListScreen extends StatefulWidget { - final List medicineList; + final List? medicineList; - const MedicineListScreen({Key key, this.medicineList}) : super(key: key); + const MedicineListScreen({Key? key, this.medicineList}) : super(key: key); @override _MedicineListScreenState createState() => _MedicineListScreenState(); @@ -25,9 +25,9 @@ class _MedicineListScreenState extends State { ), child: ListView.builder( padding: EdgeInsets.only(top: 5.0), - itemCount: widget.medicineList.length, + itemCount: widget.medicineList?.length, itemBuilder: (BuildContext context, index) { - List _medicine = widget.medicineList[index].values.toList(); + List _medicine = widget.medicineList?[index].values.toList(); print(_medicine); return ReusableCard( color: CupertinoDynamicColor.resolve(backGroundColor, context), diff --git a/lib/screens/FunctionScreen/ocrScreen.dart b/lib/screens/FunctionScreen/ocrScreen.dart index 5671015..958ba61 100644 --- a/lib/screens/FunctionScreen/ocrScreen.dart +++ b/lib/screens/FunctionScreen/ocrScreen.dart @@ -21,7 +21,7 @@ class OCRDetect extends StatefulWidget { } class _OCRDetectState extends State { - File _image; + late File _image; final _picker = ImagePicker(); bool _isInAsyncCall = false; bool isFound = false; @@ -29,13 +29,13 @@ class _OCRDetectState extends State { String _medicineTitle = ''; String _medicineUsage = ''; String _medicineDosage = ''; - TextEditingController _medicineInputController; - String _medicineInput; + late TextEditingController _medicineInputController; + late String _medicineInput; List> result = []; Future _imageFromGallery() async { final pickedImgae = - await _picker.getImage(source: ImageSource.gallery, imageQuality: 50); + await _picker.pickImage(source: ImageSource.gallery, imageQuality: 50); setState(() { if (pickedImgae != null) { _image = File(pickedImgae.path); @@ -48,7 +48,7 @@ class _OCRDetectState extends State { Future _imageFromCamera() async { final pickedFile = - await _picker.getImage(source: ImageSource.camera, imageQuality: 50); + await _picker.pickImage(source: ImageSource.camera, imageQuality: 50); setState(() { if (pickedFile != null) { diff --git a/lib/screens/FunctionScreen/sleepScreen.dart b/lib/screens/FunctionScreen/sleepScreen.dart index d2c5fe9..b96239a 100644 --- a/lib/screens/FunctionScreen/sleepScreen.dart +++ b/lib/screens/FunctionScreen/sleepScreen.dart @@ -28,7 +28,7 @@ class _SleepScreenState extends State { int _selectedTimeInt = 7; int _selectedTimeFloat = 0; - TextEditingController _voiceInputController; + late TextEditingController _voiceInputController; String _voiceInput = ''; List checkBS(String text) { @@ -38,7 +38,7 @@ class _SleepScreenState extends State { RegExp c = new RegExp(r'([0-9]{1,2}?)+(\.[0-9]{1,2})'); Iterable matches = c.allMatches(text); for (Match m in matches) { - double match = double.parse(m[0]); + double match = double.parse(m[0]!); bsData.add(match); } } else if (text.contains("后")) { @@ -46,7 +46,7 @@ class _SleepScreenState extends State { RegExp c = new RegExp(r'([0-9]{1,2}?)+(\.[0-9]{1,2})'); Iterable matches = c.allMatches(text); for (Match m in matches) { - double match = double.parse(m[0]); + double match = double.parse(m[0]!); bsData.add(match); } } @@ -72,7 +72,7 @@ class _SleepScreenState extends State { ); } - Quality selectedState; + Quality? selectedState; @override Widget build(BuildContext context) { return CupertinoPageScaffold( @@ -111,7 +111,7 @@ class _SleepScreenState extends State { backGroundColor, context), cardChild: IconFont( icon: CupertinoIcons.battery_25, - lable: AppLocalization.of(context).translate("sleep_input_button1"), + label: AppLocalization.of(context).translate("sleep_input_button1"), textStyle: selectedState == Quality.bad ? kSelctedTextStyle : kLabelTextStyle, @@ -134,7 +134,7 @@ class _SleepScreenState extends State { backGroundColor, context), cardChild: IconFont( icon: CupertinoIcons.smiley, - lable: AppLocalization.of(context).translate("sleep_input_button2"), + label: AppLocalization.of(context).translate("sleep_input_button2"), textStyle: selectedState == Quality.good ? kSelctedTextStyle : kLabelTextStyle, @@ -284,7 +284,7 @@ class _SleepScreenState extends State { ), ), ButtonButton( - onTap: () { + onTap: () async { if (_voiceInput != "") { print(_voiceInput); List bsList = checkBS(_voiceInput); @@ -306,7 +306,7 @@ class _SleepScreenState extends State { builder: (context) => SleepResultScreen( sleep: bsList[2], state: bsList[1]))); } else { - return showDialog( + return await showDialog( context: context, barrierDismissible: false, // user must tap button! @@ -368,7 +368,7 @@ class _SleepScreenState extends State { "${date.year.toString()}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')} ${date.hour.toString().padLeft(2, '0')}:${date.minute.toString().padLeft(2, '0')}"; SleepDB sleepDB = SleepDB( sleep: sleepTime, - state: selectedState.index, + state: selectedState!.index, date: time, ); SleepDataBaseProvider.db.insert(sleepDB); @@ -376,7 +376,7 @@ class _SleepScreenState extends State { context, CupertinoPageRoute( builder: (context) => SleepResultScreen( - sleep: sleepTime, state: selectedState.index))); + sleep: sleepTime, state: selectedState!.index))); } else { return showDialog( context: context, diff --git a/lib/screens/ResultScreen/bmiResultScreen.dart b/lib/screens/ResultScreen/bmiResultScreen.dart index a81cfab..e8a27a3 100755 --- a/lib/screens/ResultScreen/bmiResultScreen.dart +++ b/lib/screens/ResultScreen/bmiResultScreen.dart @@ -5,10 +5,10 @@ import 'package:flutter/cupertino.dart'; import 'package:bp_notepad/components/constants.dart'; import 'package:bp_notepad/components/resusableCard.dart'; -TextStyle selectedStyle; +TextStyle? selectedStyle; class BMIResultScreen extends StatefulWidget { - BMIResultScreen({this.bmiResult, this.brResult}); + BMIResultScreen({required this.bmiResult, required this.brResult}); final double bmiResult; final double brResult; @@ -18,23 +18,23 @@ class BMIResultScreen extends StatefulWidget { } class _BMIResultScreenState extends State { - String resultText; + String? resultText; @override Widget build(BuildContext context) { var deviceData = MediaQuery.of(context); - if (widget.bmiResult > 25 || widget.bmiResult < 18.5) { + if (widget.bmiResult> 25 || widget.bmiResult< 18.5) { selectedStyle = kWarningResultTextStyle; } else { selectedStyle = kBMINormalResultTextStyle; } - if (widget.bmiResult > 25 && widget.bmiResult <= 30) { + if (widget.bmiResult> 25 && widget.bmiResult<= 30) { resultText = AppLocalization.of(context).translate('overweight'); - } else if (widget.bmiResult > 18.5 && widget.bmiResult <= 25) { + } else if (widget.bmiResult> 18.5 && widget.bmiResult<= 25) { resultText = AppLocalization.of(context).translate('healthy_weight'); - } else if (widget.bmiResult <= 18.5) { + } else if (widget.bmiResult<= 18.5) { resultText = AppLocalization.of(context).translate('underweight'); - } else if (widget.bmiResult > 30) { + } else if (widget.bmiResult> 30) { resultText = AppLocalization.of(context).translate('obese'); } else { resultText = 'Error'; @@ -71,7 +71,7 @@ class _BMIResultScreenState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( - resultText.toUpperCase(), + resultText!.toUpperCase(), style: selectedStyle, ), diff --git a/lib/screens/ResultScreen/bpResultScreen.dart b/lib/screens/ResultScreen/bpResultScreen.dart index e1bf0e1..8bbe351 100755 --- a/lib/screens/ResultScreen/bpResultScreen.dart +++ b/lib/screens/ResultScreen/bpResultScreen.dart @@ -2,24 +2,23 @@ import 'package:bp_notepad/components/resusableCard.dart'; import 'package:bp_notepad/localization/appLocalization.dart'; import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; import 'package:bp_notepad/components/constants.dart'; import 'package:bp_notepad/components/lineChart1.dart'; -TextStyle selectedStyle; +TextStyle? selectedStyle; class BPResultScreen extends StatefulWidget { final int sbp; final int dbp; final int pulse; - BPResultScreen({this.sbp, this.dbp, this.pulse}); + BPResultScreen({required this.sbp, required this.dbp, required this.pulse}); @override _BPResultScreenState createState() => _BPResultScreenState(); } class _BPResultScreenState extends State { - String resultText; + String resultText = ''; Widget build(BuildContext context) { var deviceData = MediaQuery.of(context); diff --git a/lib/screens/ResultScreen/bsResultScreen.dart b/lib/screens/ResultScreen/bsResultScreen.dart index 8c76985..57b6e07 100755 --- a/lib/screens/ResultScreen/bsResultScreen.dart +++ b/lib/screens/ResultScreen/bsResultScreen.dart @@ -5,19 +5,19 @@ import 'package:flutter/cupertino.dart'; import 'package:bp_notepad/components/constants.dart'; import 'package:bp_notepad/components/lineChart2.dart'; -TextStyle selectedStyle; +TextStyle? selectedStyle; class BSResultScreen extends StatefulWidget { final double glu; final int state; - BSResultScreen({this.glu, this.state}); + BSResultScreen({required this.glu, required this.state}); @override _BSResultScreenState createState() => _BSResultScreenState(); } class _BSResultScreenState extends State { - String resultText; + late String resultText; Widget build(BuildContext context) { var deviceData = MediaQuery.of(context); diff --git a/lib/screens/ResultScreen/sleepResultScreen.dart b/lib/screens/ResultScreen/sleepResultScreen.dart index b0dffe7..73af2e9 100644 --- a/lib/screens/ResultScreen/sleepResultScreen.dart +++ b/lib/screens/ResultScreen/sleepResultScreen.dart @@ -5,19 +5,19 @@ import 'package:bp_notepad/localization/appLocalization.dart'; import 'package:flutter/cupertino.dart'; import 'package:bp_notepad/components/constants.dart'; -TextStyle selectedStyle; +TextStyle? selectedStyle; class SleepResultScreen extends StatefulWidget { final double sleep; final int state; - SleepResultScreen({this.sleep, this.state}); + SleepResultScreen({required this.sleep, required this.state}); @override _SleepResultScreenState createState() => _SleepResultScreenState(); } class _SleepResultScreenState extends State { - String resultText; + late String resultText; Widget build(BuildContext context) { var deviceData = MediaQuery.of(context); diff --git a/lib/screens/historyScreen.dart b/lib/screens/historyScreen.dart index 9fdf8d0..8ff777f 100755 --- a/lib/screens/historyScreen.dart +++ b/lib/screens/historyScreen.dart @@ -12,22 +12,24 @@ import 'package:table_calendar/table_calendar.dart'; import 'package:async/async.dart'; class HistoryScreen extends StatefulWidget { - HistoryScreen({Key key}) : super(key: key); + HistoryScreen({Key? key}) : super(key: key); + @override _HistoryScreenState createState() => _HistoryScreenState(); } class _HistoryScreenState extends State with TickerProviderStateMixin { - Map _events = {}; + Map> _events = {}; final _selectedDay = DateTime.now(); - List _selectedEvents; - AnimationController _animationController; - CalendarController _calendarController; - AsyncMemoizer _memoizer; + late List _selectedEvents; + AnimationController? _animationController; + + // CalendarController _calendarController; + late AsyncMemoizer _memorizer; getDatabaseEvent() async { - return this._memoizer.runOnce(() async { + return this._memorizer.runOnce(() async { Future bpEvents = BpDataBaseProvider.db.getData(); Future bsEvents = BsDataBaseProvider.db.getData(); Future bmiEvents = BodyDataBaseProvider.db.getData(); @@ -120,31 +122,36 @@ class _HistoryScreenState extends State void initState() { super.initState(); - _memoizer = AsyncMemoizer(); + _memorizer = AsyncMemoizer(); - _selectedEvents = _events[_selectedDay] ?? []; + _selectedEvents = + _events[_selectedDay]?.map((date) => DateTime.parse(date)).toList() ?? + []; - _calendarController = CalendarController(); + // _calendarController = CalendarController(); _animationController = AnimationController( vsync: this, duration: const Duration(milliseconds: 400), ); - _animationController.forward(); + _animationController?.forward(); } @override void dispose() { - _animationController.dispose(); - _calendarController.dispose(); + _animationController?.dispose(); + // _calendarController.dispose(); super.dispose(); } - void _onDaySelected(DateTime day, List events, List holidays) { + void _onDaySelected( + DateTime day, + DateTime focusedDay, + ) { // print('CALLBACK: _onDaySelected'); setState(() { - _selectedEvents = events; + _selectedEvents.add(focusedDay); }); } @@ -153,8 +160,7 @@ class _HistoryScreenState extends State // print('CALLBACK: _onVisibleDaysChanged'); } - void _onCalendarCreated( - DateTime first, DateTime last, CalendarFormat format) { + void _onCalendarCreated(PageController pageController) { // print('CALLBACK: _onCalendarCreated'); } @@ -178,11 +184,14 @@ class _HistoryScreenState extends State return Column( children: [ TableCalendar( - locale: 'zh_CN', - calendarController: _calendarController, - events: snapshot.data, - initialCalendarFormat: CalendarFormat.month, - formatAnimation: FormatAnimation.slide, + firstDay: DateTime.utc(2020, 10, 16), + lastDay: DateTime.utc(2030, 3, 14), + focusedDay: DateTime.now(), + locale: 'en_US', + // calendarController: _calendarController, + // events: snapshot.data, + // initialCalendarFormat: CalendarFormat.month, + // formatAnimation: FormatAnimation.slide, startingDayOfWeek: StartingDayOfWeek.sunday, availableGestures: AvailableGestures.all, availableCalendarFormats: const { @@ -190,19 +199,19 @@ class _HistoryScreenState extends State CalendarFormat.week: '', }, calendarStyle: CalendarStyle( - selectedColor: CupertinoColors.systemRed, - todayColor: Colors.red[200], + // selectedColor: CupertinoColors.systemRed, + // todayColor: Colors.red[200], outsideDaysVisible: false, - weekdayStyle: TextStyle().copyWith( - color: CupertinoDynamicColor.resolve( - textColor, context)), - eventDayStyle: TextStyle().copyWith( - color: CupertinoDynamicColor.resolve( - textColor, context)), - weekendStyle: TextStyle() - .copyWith(color: CupertinoColors.systemGrey), - holidayStyle: TextStyle() - .copyWith(color: CupertinoColors.systemBlue), + // weekdayStyle: TextStyle().copyWith( + // color: CupertinoDynamicColor.resolve( + // textColor, context)), + // eventDayStyle: TextStyle().copyWith( + // color: CupertinoDynamicColor.resolve( + // textColor, context)), + // weekendStyle: TextStyle() + // .copyWith(color: CupertinoColors.systemGrey), + // holidayStyle: TextStyle() + // .copyWith(color: CupertinoColors.systemBlue), ), daysOfWeekStyle: DaysOfWeekStyle( weekendStyle: TextStyle() @@ -213,51 +222,45 @@ class _HistoryScreenState extends State fontSize: 16, color: CupertinoDynamicColor.resolve( textColor, context)), - centerHeaderTitle: true, + // centerHeaderTitle: true, formatButtonVisible: false, ), - builders: CalendarBuilders( - markersBuilder: (context, date, events, holidays) { - final children = []; + calendarBuilders: CalendarBuilders( + markerBuilder: (context, date, events) { if (events.isNotEmpty) { - children.add( - Positioned( - right: 1, - bottom: 1, - child: AnimatedContainer( - duration: - const Duration(milliseconds: 300), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: _calendarController - .isSelected(date) - ? CupertinoColors.systemRed - : _calendarController.isToday(date) - ? Colors.red[200] - : CupertinoColors.activeBlue, - ), - width: 20.0, - height: 20.0, - child: Center( - child: Text( - '${events.length}', - style: TextStyle().copyWith( - color: Colors.white, - fontSize: 12.0, - ), - ), + return Positioned( + right: 1, + bottom: 1, + child: AnimatedContainer( + duration: const Duration(milliseconds: 300), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: date == DateTime.now() + ? Colors.red[200] + : CupertinoColors.activeBlue, + ), + width: 20.0, + height: 20.0, + child: Center( + child: Text( + '${events.length}', + style: TextStyle().copyWith( + color: Colors.white, + fontSize: 12.0, ), - )), + ), + ), + ), ); } - return children; + return null; }, ), - onDaySelected: (date, events, holidays) { - _onDaySelected(date, events, holidays); - _animationController.forward(from: 0.0); + onDaySelected: (selectedDay, focusedDay) { + _onDaySelected(selectedDay, focusedDay); + _animationController?.forward(from: 0.0); }, - onVisibleDaysChanged: _onVisibleDaysChanged, + // onVisibleDaysChanged: _onVisibleDaysChanged, onCalendarCreated: _onCalendarCreated, ), const SizedBox(height: 8.0), diff --git a/lib/screens/languageView.dart b/lib/screens/languageView.dart index a12631b..62de185 100755 --- a/lib/screens/languageView.dart +++ b/lib/screens/languageView.dart @@ -9,7 +9,7 @@ import 'package:flutter/material.dart'; import '../main.dart'; class LanguageView extends StatefulWidget { - LanguageView({Key key}) : super(key: key); + LanguageView({Key? key}) : super(key: key); @override _LanguageViewState createState() => _LanguageViewState(); diff --git a/lib/screens/mainScreen.dart b/lib/screens/mainScreen.dart index ab734c3..d59c30b 100755 --- a/lib/screens/mainScreen.dart +++ b/lib/screens/mainScreen.dart @@ -8,7 +8,7 @@ import 'package:bp_notepad/screens/recordScreen.dart'; import 'package:flutter/cupertino.dart'; class MyHomePage extends StatefulWidget { - MyHomePage({Key key}) : super(key: key); + MyHomePage({Key? key}) : super(key: key); @override _MyHomePageState createState() => _MyHomePageState(); diff --git a/lib/screens/reminderScreen.dart b/lib/screens/reminderScreen.dart index ac33c07..373823f 100755 --- a/lib/screens/reminderScreen.dart +++ b/lib/screens/reminderScreen.dart @@ -31,17 +31,17 @@ List icons = [ ), ]; -Icon _iconState; //切换图标的显示 +late Icon _iconState; //切换图标的显示 class ReminderScreen extends StatefulWidget { - const ReminderScreen({Key key}) : super(key: key); + const ReminderScreen({Key? key}) : super(key: key); @override _ReminderScreenState createState() => _ReminderScreenState(); } class _ReminderScreenState extends State { - FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin; //声明一个本地提醒的插件 + late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin; //声明一个本地提醒的插件 @override void initState() { @@ -54,20 +54,34 @@ class _ReminderScreenState extends State { flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin(); var android = new AndroidInitializationSettings('@mipmap/ic_launcher'); - var iOS = new IOSInitializationSettings(); - var initSetttings = new InitializationSettings(android: android, iOS: iOS); - flutterLocalNotificationsPlugin.initialize(initSetttings, - onSelectNotification: onSelectNotification); + var iOS = + DarwinInitializationSettings( + onDidReceiveLocalNotification: onDidReceiveLocalNotification); + var initSettings = new InitializationSettings(android: android, iOS: iOS); + flutterLocalNotificationsPlugin.initialize(initSettings, + onDidReceiveNotificationResponse: onDidReceiveNotificationResponse); + } + Future onDidReceiveLocalNotification( + int id, String? title, String? body, String? payload) async { + + // Handle notification received + debugPrint("Notification Received: $payload"); + } // ignore: missing_return - Future onSelectNotification(String payload) { + Future onDidReceiveNotificationResponse(NotificationResponse response) async { + + // Get payload from response + String? payload = response.payload; + + // Handle response debugPrint("payload : $payload"); showDialog( context: context, - builder: (_) => new AlertDialog( - title: new Text('Notification'), - content: new Text('$payload'), + builder: (_) => AlertDialog( + title: Text('Notification'), + content: Text('$payload'), ), ); } @@ -93,11 +107,11 @@ class _ReminderScreenState extends State { actions: [ CupertinoDialogAction( onPressed: () => - AlarmDataBaseProvider.db.delete(alarm.id).then((_) { + AlarmDataBaseProvider.db.delete(alarm.id!).then((_) { BlocProvider.of(context).add( DeleteAlarm(index), ); - cancelNotification(alarm.pushID); + cancelNotification(alarm.pushID!); Navigator.pop(context); }), child: Text(AppLocalization.of(context).translate('delete')), diff --git a/pubspec.lock b/pubspec.lock index 39eb23f..df1d31c 100755 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,198 +5,266 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - url: "https://pub.dartlang.org" + sha256: "4826f97faae3af9761f26c52e56b2aa5ffd18d2c1721d984ad85137721c25f43" + url: "https://pub.dev" source: hosted - version: "22.0.0" + version: "31.0.0" analyzer: dependency: transitive description: name: analyzer - url: "https://pub.dartlang.org" + sha256: "7337610c3f9cd13e6b7c6bb0f410644091cf63c9a1436e73352a70f3286abb03" + url: "https://pub.dev" source: hosted - version: "1.7.2" + version: "2.8.0" args: dependency: transitive description: name: args - url: "https://pub.dartlang.org" + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.4.2" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.8.2" + version: "2.11.0" bloc: dependency: transitive description: name: bloc - url: "https://pub.dartlang.org" + sha256: "3820f15f502372d979121de1f6b97bfcf1630ebff8fe1d52fb2b0bfa49be5b49" + url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "8.1.2" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" camera: dependency: "direct dev" description: name: camera - url: "https://pub.dartlang.org" + sha256: "0b8003c790c1618a00d6f2748ef8c0a8aea6e91344b3bd5505e1d38b8152c464" + url: "https://pub.dev" source: hosted version: "0.8.1+4" camera_platform_interface: dependency: transitive description: name: camera_platform_interface - url: "https://pub.dartlang.org" + sha256: edfcc5be7b3567187fc4578bb7aa6d2bd36737aebb1cd5bd5bc9725a7d02ef0f + url: "https://pub.dev" source: hosted version: "2.0.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.dartlang.org" + sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306 + url: "https://pub.dev" source: hosted version: "1.3.1" cli_util: dependency: transitive description: name: cli_util - url: "https://pub.dartlang.org" + sha256: cd9cfe046f8b4d87f45abce8f14ec315a4eaedcf92a211e83fa080faf9ec7c1c + url: "https://pub.dev" source: hosted version: "0.3.3" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.17.2" convert: dependency: transitive description: name: convert - url: "https://pub.dartlang.org" + sha256: f08428ad63615f96a27e34221c65e1a451439b5f26030f78d790f461c686d65d + url: "https://pub.dev" source: hosted version: "3.0.1" cross_file: dependency: transitive description: name: cross_file - url: "https://pub.dartlang.org" + sha256: "437b2b8da454fe1e01131f4410274fd607347325e9330f0b469ed5a204991068" + url: "https://pub.dev" source: hosted version: "0.3.1+4" crypto: dependency: "direct dev" description: name: crypto - url: "https://pub.dartlang.org" + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.3" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d + url: "https://pub.dev" source: hosted - version: "1.0.3" + version: "1.0.6" + dbus: + dependency: transitive + description: + name: dbus + sha256: "6f07cba3f7b3448d42d015bfd3d53fe12e5b36da2423f23838efc1d5fb31a263" + url: "https://pub.dev" + source: hosted + version: "0.7.8" dcdg: dependency: "direct dev" description: name: dcdg - url: "https://pub.dartlang.org" + sha256: ad090ac440da4f42dba0c9cf488593abb3ef628114f3fdc32cbde93624eb651a + url: "https://pub.dev" source: hosted - version: "3.1.1" + version: "4.1.0" device_info: dependency: "direct dev" description: name: device_info - url: "https://pub.dartlang.org" + sha256: f4a8156cb7b7480d969cb734907d18b333c8f0bc0b1ad0b342cdcecf30d62c48 + url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.0.3" device_info_platform_interface: dependency: transitive description: name: device_info_platform_interface - url: "https://pub.dartlang.org" + sha256: b148e0bf9640145d09a4f8dea96614076f889e7f7f8b5ecab1c7e5c2dbc73c1b + url: "https://pub.dev" source: hosted version: "2.0.1" dio: dependency: "direct dev" description: name: dio - url: "https://pub.dartlang.org" + sha256: "417e2a6f9d83ab396ec38ff4ea5da6c254da71e4db765ad737a42af6930140b7" + url: "https://pub.dev" source: hosted - version: "4.0.0" + version: "5.3.3" easy_localization: dependency: "direct dev" description: name: easy_localization - url: "https://pub.dartlang.org" + sha256: de63e3b422adfc97f256cbb3f8cf12739b6a4993d390f3cadb3f51837afaefe5 + url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "3.0.3" easy_logger: dependency: transitive description: name: easy_logger - url: "https://pub.dartlang.org" + sha256: c764a6e024846f33405a2342caf91c62e357c24b02c04dbc712ef232bf30ffb7 + url: "https://pub.dev" source: hosted version: "0.0.2" equatable: dependency: transitive description: name: equatable - url: "https://pub.dartlang.org" + sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2 + url: "https://pub.dev" source: hosted - version: "2.0.3" + version: "2.0.5" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.1" ffi: dependency: transitive description: name: ffi - url: "https://pub.dartlang.org" + sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" + url: "https://pub.dev" source: hosted - version: "1.1.2" + version: "2.1.0" file: dependency: transitive description: name: file - url: "https://pub.dartlang.org" + sha256: b69516f2c26a5bcac4eee2e32512e1a5205ab312b3536c1c1227b2b942b5f9ad + url: "https://pub.dev" source: hosted version: "6.1.2" + file_selector_linux: + dependency: transitive + description: + name: file_selector_linux + sha256: "045d372bf19b02aeb69cacf8b4009555fb5f6f0b7ad8016e5f46dd1387ddd492" + url: "https://pub.dev" + source: hosted + version: "0.9.2+1" + file_selector_macos: + dependency: transitive + description: + name: file_selector_macos + sha256: b15c3da8bd4908b9918111fa486903f5808e388b8d1c559949f584725a6594d6 + url: "https://pub.dev" + source: hosted + version: "0.9.3+3" + file_selector_platform_interface: + dependency: transitive + description: + name: file_selector_platform_interface + sha256: "0aa47a725c346825a2bd396343ce63ac00bda6eff2fbc43eabe99737dede8262" + url: "https://pub.dev" + source: hosted + version: "2.6.1" + file_selector_windows: + dependency: transitive + description: + name: file_selector_windows + sha256: d3547240c20cabf205c7c7f01a50ecdbc413755814d6677f3cb366f04abcead0 + url: "https://pub.dev" + source: hosted + version: "0.9.3+1" fl_chart: dependency: "direct dev" description: name: fl_chart - url: "https://pub.dartlang.org" + sha256: c1e26c7e48496be85104c16c040950b0436674cdf0737f3f6e95511b2529b592 + url: "https://pub.dev" source: hosted - version: "0.30.0" + version: "0.63.0" flutter: dependency: "direct main" description: flutter @@ -206,23 +274,34 @@ packages: dependency: "direct dev" description: name: flutter_bloc - url: "https://pub.dartlang.org" + sha256: e74efb89ee6945bcbce74a5b3a5a3376b088e5f21f55c263fc38cbdc6237faae + url: "https://pub.dev" source: hosted - version: "3.2.0" + version: "8.1.3" flutter_local_notifications: dependency: "direct dev" description: name: flutter_local_notifications - url: "https://pub.dartlang.org" + sha256: "3002092e5b8ce2f86c3361422e52e6db6776c23ee21e0b2f71b892bf4259ef04" + url: "https://pub.dev" source: hosted - version: "5.0.0+4" + version: "15.1.1" + flutter_local_notifications_linux: + dependency: transitive + description: + name: flutter_local_notifications_linux + sha256: "33f741ef47b5f63cc7f78fe75eeeac7e19f171ff3c3df054d84c1e38bedb6a03" + url: "https://pub.dev" + source: hosted + version: "4.0.0+1" flutter_local_notifications_platform_interface: dependency: transitive description: name: flutter_local_notifications_platform_interface - url: "https://pub.dartlang.org" + sha256: "7cf643d6d5022f3baed0be777b0662cce5919c0a7b86e700299f22dc4ae660ef" + url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "7.0.0+1" flutter_localizations: dependency: transitive description: flutter @@ -232,14 +311,16 @@ packages: dependency: "direct dev" description: name: flutter_native_timezone - url: "https://pub.dartlang.org" + sha256: ed7bfb982f036243de1c068e269182a877100c994f05143c8b26a325e28c1b02 + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "2.0.0" flutter_plugin_android_lifecycle: dependency: transitive description: name: flutter_plugin_android_lifecycle - url: "https://pub.dartlang.org" + sha256: aa36b33c721ac6e889adad07e3c87e6a07b33c28d1f2bc22f2561762cd7d2162 + url: "https://pub.dev" source: hosted version: "2.0.2" flutter_test: @@ -256,275 +337,354 @@ packages: dependency: "direct dev" description: name: font_awesome_flutter - url: "https://pub.dartlang.org" + sha256: "5fb789145cae1f4c3245c58b3f8fb287d055c26323879eab57a7bf0cfd1e45f3" + url: "https://pub.dev" source: hosted - version: "8.12.0" + version: "10.5.0" glob: dependency: transitive description: name: glob - url: "https://pub.dartlang.org" + sha256: dda85ce2aefce16f7e75586acbcb1e8320bf176f69fd94082e31945d6de67f3e + url: "https://pub.dev" source: hosted version: "2.0.1" hex: dependency: "direct dev" description: name: hex - url: "https://pub.dartlang.org" + sha256: "4e7cd54e4b59ba026432a6be2dd9d96e4c5205725194997193bf871703b82c4a" + url: "https://pub.dev" source: hosted version: "0.2.0" http: dependency: transitive description: name: http - url: "https://pub.dartlang.org" + sha256: b6f1f143a71e1fe1b34670f1acd6f13960ade2557c96b87e127e0cf661969791 + url: "https://pub.dev" source: hosted version: "0.13.3" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + sha256: e362d639ba3bc07d5a71faebb98cde68c05bfbcfbbb444b60b6f60bb67719185 + url: "https://pub.dev" source: hosted version: "4.0.0" image_picker: dependency: "direct dev" description: name: image_picker - url: "https://pub.dartlang.org" + sha256: "7d7f2768df2a8b0a3cefa5ef4f84636121987d403130e70b17ef7e2cf650ba84" + url: "https://pub.dev" source: hosted - version: "0.7.5+4" + version: "1.0.4" + image_picker_android: + dependency: transitive + description: + name: image_picker_android + sha256: "0c7b83bbe2980c8a8e36e974f055e11e51675784e13a4762889feed0f3937ff2" + url: "https://pub.dev" + source: hosted + version: "0.8.8+1" image_picker_for_web: dependency: transitive description: name: image_picker_for_web - url: "https://pub.dartlang.org" + sha256: "50bc9ae6a77eea3a8b11af5eb6c661eeb858fdd2f734c2a4fd17086922347ef7" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "3.0.1" + image_picker_ios: + dependency: transitive + description: + name: image_picker_ios + sha256: c5538cacefacac733c724be7484377923b476216ad1ead35a0d2eadcdc0fc497 + url: "https://pub.dev" + source: hosted + version: "0.8.8+2" + image_picker_linux: + dependency: transitive + description: + name: image_picker_linux + sha256: "4ed1d9bb36f7cd60aa6e6cd479779cc56a4cb4e4de8f49d487b1aaad831300fa" + url: "https://pub.dev" + source: hosted + version: "0.2.1+1" + image_picker_macos: + dependency: transitive + description: + name: image_picker_macos + sha256: "3f5ad1e8112a9a6111c46d0b57a7be2286a9a07fc6e1976fdf5be2bd31d4ff62" + url: "https://pub.dev" + source: hosted + version: "0.2.1+1" image_picker_platform_interface: dependency: transitive description: name: image_picker_platform_interface - url: "https://pub.dartlang.org" + sha256: ed9b00e63977c93b0d2d2b343685bed9c324534ba5abafbb3dfbd6a780b1b514 + url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.9.1" + image_picker_windows: + dependency: transitive + description: + name: image_picker_windows + sha256: "6ad07afc4eb1bc25f3a01084d28520496c4a3bb0cb13685435838167c9dcedeb" + url: "https://pub.dev" + source: hosted + version: "0.2.1+1" intl: dependency: transitive description: name: intl - url: "https://pub.dartlang.org" + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + url: "https://pub.dev" source: hosted - version: "0.17.0" + version: "0.18.1" js: dependency: transitive description: name: js - url: "https://pub.dartlang.org" + sha256: d9bdfd70d828eeb352390f81b18d6a354ef2044aa28ef25682079797fa7cd174 + url: "https://pub.dev" source: hosted version: "0.6.3" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" source: hosted - version: "0.12.11" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + url: "https://pub.dev" source: hosted - version: "0.1.3" + version: "0.5.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.dev" source: hosted - version: "1.7.0" + version: "1.9.1" + mime: + dependency: transitive + description: + name: mime + sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e + url: "https://pub.dev" + source: hosted + version: "1.0.4" modal_progress_hud_nsn: dependency: "direct dev" description: name: modal_progress_hud_nsn - url: "https://pub.dartlang.org" + sha256: "0b0d95e5ce3e1884390624fbe79fcf90d7de10abe05d26c0e276c25e7130e3e0" + url: "https://pub.dev" source: hosted - version: "0.1.0-nullsafety-1" + version: "0.4.0" nested: dependency: transitive description: name: nested - url: "https://pub.dartlang.org" + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" source: hosted version: "1.0.0" open_file: dependency: "direct dev" description: name: open_file - url: "https://pub.dartlang.org" + sha256: a5a32d44acb7c899987d0999e1e3cbb0a0f1adebbf41ac813ec6d2d8faa0af20 + url: "https://pub.dev" source: hosted - version: "3.2.1" + version: "3.3.2" package_config: dependency: transitive description: name: package_config - url: "https://pub.dartlang.org" + sha256: a4d5ede5ca9c3d88a2fef1147a078570c861714c806485c596b109819135bc12 + url: "https://pub.dev" source: hosted version: "2.0.2" path: dependency: "direct dev" description: name: path - url: "https://pub.dartlang.org" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.8.3" path_provider: dependency: "direct dev" description: name: path_provider - url: "https://pub.dartlang.org" + sha256: cfdc261c62a7273be7e051b19d27e503927a40919932f790681042a038f3605d + url: "https://pub.dev" source: hosted version: "2.0.2" path_provider_linux: dependency: transitive description: name: path_provider_linux - url: "https://pub.dartlang.org" + sha256: "938d2b6591587bcb009d2109a6ea464fd8fb2a75dc6423171b0d0afb1d27c708" + url: "https://pub.dev" source: hosted version: "2.0.0" path_provider_macos: dependency: transitive description: name: path_provider_macos - url: "https://pub.dartlang.org" + sha256: eb58b896ea3a504f0b0fa7870646bda6935a6f752b2a54df33f97070dacca8d4 + url: "https://pub.dev" source: hosted version: "2.0.0" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface - url: "https://pub.dartlang.org" + sha256: c2af5a8a6369992d915f8933dfc23172071001359d17896e83db8be57db8a397 + url: "https://pub.dev" source: hosted version: "2.0.1" path_provider_windows: dependency: transitive description: name: path_provider_windows - url: "https://pub.dartlang.org" + sha256: "1cb68ba4cd3a795033de62ba1b7b4564dace301f952de6bfb3cd91b202b6ee96" + url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.7" pedantic: dependency: transitive description: name: pedantic - url: "https://pub.dartlang.org" + sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" + url: "https://pub.dev" source: hosted version: "1.11.1" petitparser: dependency: transitive description: name: petitparser - url: "https://pub.dartlang.org" + sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 + url: "https://pub.dev" source: hosted - version: "4.1.0" + version: "5.4.0" platform: dependency: "direct main" description: name: platform - url: "https://pub.dartlang.org" + sha256: ae68c7bfcd7383af3629daafb32fb4e8681c7154428da4febcff06200585f102 + url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.1.2" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d + url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.6" process: dependency: transitive description: name: process - url: "https://pub.dartlang.org" + sha256: dc3c073b5bc0db4e0f3dbc6b69f8e9cf2f336dafb3db996242ebdacf94c295dd + url: "https://pub.dev" source: hosted version: "4.2.1" provider: dependency: transitive description: name: provider - url: "https://pub.dartlang.org" + sha256: cdbe7530b12ecd9eb455bdaa2fcb8d4dad22e80b8afb4798b41479d5ce26847f + url: "https://pub.dev" source: hosted - version: "4.3.3" + version: "6.0.5" pub_semver: dependency: transitive description: name: pub_semver - url: "https://pub.dartlang.org" + sha256: b5a5fcc6425ea43704852ba4453ba94b08c2226c63418a260240c3a054579014 + url: "https://pub.dev" source: hosted version: "2.1.0" quiver: dependency: transitive description: name: quiver - url: "https://pub.dartlang.org" + sha256: "5e592c348a6c528fb8deb7cc7d85a7097ce65bf2349121ad004d1fc5d5905eaa" + url: "https://pub.dev" source: hosted version: "3.0.1" - rxdart: - dependency: transitive - description: - name: rxdart - url: "https://pub.dartlang.org" - source: hosted - version: "0.23.1" shared_preferences: dependency: transitive description: name: shared_preferences - url: "https://pub.dartlang.org" + sha256: "5c34bd1fd5ddfca85766659b1b82342d8b047ceb3ecf34f6dd439640a41ccff6" + url: "https://pub.dev" source: hosted version: "2.0.6" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux - url: "https://pub.dartlang.org" + sha256: "33fc7c6ced70d226645a9612132fbff9890805df4edd34f30840e7e738866fee" + url: "https://pub.dev" source: hosted version: "2.0.0" shared_preferences_macos: dependency: transitive description: name: shared_preferences_macos - url: "https://pub.dartlang.org" + sha256: "5d2bad07b196b6ad4cf21af6f7197a87264ef569199502b9352f76e5054f06ae" + url: "https://pub.dev" source: hosted version: "2.0.0" shared_preferences_platform_interface: dependency: transitive description: name: shared_preferences_platform_interface - url: "https://pub.dartlang.org" + sha256: "992f0fdc46d0a3c0ac2e5859f2de0e577bbe51f78a77ee8f357cbe626a2ad32d" + url: "https://pub.dev" source: hosted version: "2.0.0" shared_preferences_web: dependency: transitive description: name: shared_preferences_web - url: "https://pub.dartlang.org" + sha256: "09b72ec530a1b1f26cdbec6b138f980d97d4d86ebb86dbf6365369fbd4bb05c8" + url: "https://pub.dev" source: hosted version: "2.0.0" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows - url: "https://pub.dartlang.org" + sha256: "76c54a0148780d779a3fe332ece9ba8ad2c9dd0bc717ee7fce58bd06b5e8118f" + url: "https://pub.dev" source: hosted version: "2.0.0" simple_gesture_detector: dependency: transitive description: name: simple_gesture_detector - url: "https://pub.dartlang.org" + sha256: "86d08f85f1f58583b7b4b941d989f48ea6ce08c1724a1d10954a277c2ec36592" + url: "https://pub.dev" source: hosted - version: "0.1.6" + version: "0.2.0" sky_engine: dependency: transitive description: flutter @@ -534,156 +694,186 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.8.1" + version: "1.10.0" sqflite: dependency: "direct dev" description: name: sqflite - url: "https://pub.dartlang.org" + sha256: "591f1602816e9c31377d5f008c2d9ef7b8aca8941c3f89cc5fd9d84da0c38a9a" + url: "https://pub.dev" source: hosted - version: "1.3.2+4" + version: "2.3.0" sqflite_common: dependency: transitive description: name: sqflite_common - url: "https://pub.dartlang.org" + sha256: "1b92f368f44b0dee2425bb861cfa17b6f6cf3961f762ff6f941d20b33355660a" + url: "https://pub.dev" source: hosted - version: "1.0.3+3" + version: "2.5.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" stream_transform: dependency: transitive description: name: stream_transform - url: "https://pub.dartlang.org" + sha256: ed464977cb26a1f41537e177e190c67223dbd9f4f683489b6ab2e5d211ec564e + url: "https://pub.dev" source: hosted version: "2.0.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" string_similarity: dependency: "direct dev" description: name: string_similarity - url: "https://pub.dartlang.org" + sha256: "5219d2ca048f6d3b8954747644b99b103244b5f84ef62b2577d29eb6bdeb61bb" + url: "https://pub.dev" source: hosted version: "2.0.0" syncfusion_flutter_core: dependency: transitive description: name: syncfusion_flutter_core - url: "https://pub.dartlang.org" + sha256: "295954bc4bda923c88f361da35611801b56f4258179aa355730b236e4ae3ec60" + url: "https://pub.dev" source: hosted - version: "18.4.49" + version: "23.1.38" syncfusion_flutter_pdf: dependency: "direct dev" description: name: syncfusion_flutter_pdf - url: "https://pub.dartlang.org" + sha256: "567d42bd3421f1d3691c5c40741cc921e12b5fc4cc665be170716cca1c1ab824" + url: "https://pub.dev" source: hosted - version: "18.4.49-beta" + version: "23.1.38" synchronized: dependency: transitive description: name: synchronized - url: "https://pub.dartlang.org" + sha256: "5fcbd27688af6082f5abd611af56ee575342c30e87541d0245f7ff99faa02c60" + url: "https://pub.dev" source: hosted - version: "2.2.0+2" + version: "3.1.0" table_calendar: dependency: "direct dev" description: name: table_calendar - url: "https://pub.dartlang.org" + sha256: "1e3521a3e6d3fc7f645a58b135ab663d458ab12504f1ea7f9b4b81d47086c478" + url: "https://pub.dev" source: hosted - version: "2.3.3" + version: "3.0.9" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + url: "https://pub.dev" source: hosted - version: "0.4.8" + version: "0.6.0" timezone: dependency: transitive description: name: timezone - url: "https://pub.dartlang.org" + sha256: "1cfd8ddc2d1cfd836bc93e67b9be88c3adaeca6f40a00ca999104c30693cdca0" + url: "https://pub.dev" source: hosted - version: "0.7.0" + version: "0.9.2" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: "53bdf7e979cfbf3e28987552fd72f637e63f3c8724c9e56d9246942dc2fa36ee" + url: "https://pub.dev" source: hosted version: "1.3.0" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.4" watcher: dependency: transitive description: name: watcher - url: "https://pub.dartlang.org" + sha256: "68173f2fa67d241323a4123be7ed4e43424c54befa5505d71c8ad4b7baf8f71d" + url: "https://pub.dev" source: hosted version: "1.0.0" + web: + dependency: transitive + description: + name: web + sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + url: "https://pub.dev" + source: hosted + version: "0.1.4-beta" win32: dependency: transitive description: name: win32 - url: "https://pub.dartlang.org" + sha256: "350a11abd2d1d97e0cc7a28a81b781c08002aa2864d9e3f192ca0ffa18b06ed3" + url: "https://pub.dev" source: hosted - version: "2.2.5" + version: "5.0.9" xdg_directories: dependency: transitive description: name: xdg_directories - url: "https://pub.dartlang.org" + sha256: bd512f03919aac5f1313eb8249f223bacf4927031bf60b02601f81f687689e86 + url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.2.0+3" xml: dependency: transitive description: name: xml - url: "https://pub.dartlang.org" + sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84" + url: "https://pub.dev" source: hosted - version: "5.1.2" + version: "6.3.0" yaml: dependency: transitive description: name: yaml - url: "https://pub.dartlang.org" + sha256: "3cee79b1715110341012d27756d9bae38e650588acd38d3f3c610822e1337ace" + url: "https://pub.dev" source: hosted version: "3.1.0" sdks: - dart: ">=2.14.0 <3.0.0" - flutter: ">=2.0.0" + dart: ">=3.1.1 <4.0.0" + flutter: ">=3.7.0" diff --git a/pubspec.yaml b/pubspec.yaml index e9fb769..0c3049c 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,19 +15,19 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.0+1 +version: 0.1.0 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: ">=3.1.1 <=4.1.1" dependencies: - platform: ^3.1.0 + platform: ^3.1.2 flutter: sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.2 + cupertino_icons: ^1.0.6 dev_dependencies: flutter_test: @@ -38,24 +38,24 @@ dev_dependencies: # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec - font_awesome_flutter: ^8.11.0 - sqflite: ^1.3.0 - fl_chart: ^0.30.0 - flutter_local_notifications: ^5.0.0 - flutter_native_timezone: ^1.0.10 - flutter_bloc: ^3.2.0 - easy_localization: ^3.0.0 - device_info: ^2.0.0 - table_calendar: ^2.3.3 - image_picker: ^0.7.0 - crypto: ^3.0.1 + font_awesome_flutter: ^10.5.0 + sqflite: ^2.3.0 + fl_chart: ^0.63.0 + flutter_local_notifications: ^15.1.1 + flutter_native_timezone: ^2.0.0 + flutter_bloc: ^8.1.3 + easy_localization: ^3.0.3 + device_info: ^2.0.3 + table_calendar: ^3.0.9 + image_picker: ^1.0.4 + crypto: ^3.0.3 hex: ^0.2.0 - dio: ^4.0.0 - modal_progress_hud_nsn: ^0.1.0-nullsafety-1 - syncfusion_flutter_pdf: ^18.4.49-beta - open_file: ^3.2.1 + dio: ^5.3.3 + modal_progress_hud_nsn: ^0.4.0 + syncfusion_flutter_pdf: ^23.1.38 + open_file: ^3.3.2 string_similarity: ^2.0.0 - dcdg: ^3.1.1 + dcdg: ^4.1.0