mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 20:14:08 +00:00
Version number to bundle files
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../providers/auth_provider.dart';
|
||||
import '../services/offline_storage_service.dart';
|
||||
@@ -14,11 +15,20 @@ class SettingsScreen extends StatefulWidget {
|
||||
|
||||
class _SettingsScreenState extends State<SettingsScreen> {
|
||||
bool _groupByType = false;
|
||||
String? _appVersion;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadPreferences();
|
||||
_loadAppVersion();
|
||||
}
|
||||
|
||||
Future<void> _loadAppVersion() async {
|
||||
final packageInfo = await PackageInfo.fromPlatform();
|
||||
if (mounted) {
|
||||
setState(() => _appVersion = packageInfo.version);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _loadPreferences() async {
|
||||
@@ -179,7 +189,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
// App version
|
||||
ListTile(
|
||||
leading: const Icon(Icons.info_outline),
|
||||
title: const Text('App Version: 0.6.8'),
|
||||
title: Text('App Version: ${_appVersion ?? '…'}'),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class DeviceService {
|
||||
@@ -7,20 +8,21 @@ class DeviceService {
|
||||
|
||||
Future<Map<String, String>> getDeviceInfo() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
final packageInfo = await PackageInfo.fromPlatform();
|
||||
|
||||
// Get or generate device ID
|
||||
String? deviceId = prefs.getString(_deviceIdKey);
|
||||
if (deviceId == null) {
|
||||
deviceId = _generateDeviceId();
|
||||
await prefs.setString(_deviceIdKey, deviceId);
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
'device_id': deviceId,
|
||||
'device_name': _getDeviceName(),
|
||||
'device_type': _getDeviceType(),
|
||||
'os_version': _getOsVersion(),
|
||||
'app_version': '1.0.0',
|
||||
'app_version': packageInfo.version,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user