add package info plus and getApkVersion function
parent
2e13113cbe
commit
9aea59e5a2
|
@ -3,6 +3,7 @@ import 'package:bloc/bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:unit2/model/login_data/user_info/user_data.dart';
|
import 'package:unit2/model/login_data/user_info/user_data.dart';
|
||||||
import 'package:unit2/model/login_data/version_info.dart';
|
import 'package:unit2/model/login_data/version_info.dart';
|
||||||
|
import 'package:unit2/screens/unit2/login/functions/get_app_version.dart';
|
||||||
import 'package:unit2/sevices/login_service/auth_service.dart';
|
import 'package:unit2/sevices/login_service/auth_service.dart';
|
||||||
|
|
||||||
import '../../utils/scanner.dart';
|
import '../../utils/scanner.dart';
|
||||||
|
@ -21,7 +22,8 @@ class UserBloc extends Bloc<UserEvent, UserState> {
|
||||||
emit(SplashScreen());
|
emit(SplashScreen());
|
||||||
VersionInfo versionInfo = await AuthService.instance.getVersionInfo();
|
VersionInfo versionInfo = await AuthService.instance.getVersionInfo();
|
||||||
_versionInfo = versionInfo;
|
_versionInfo = versionInfo;
|
||||||
emit(VersionLoaded(versionInfo: _versionInfo));
|
String apkVersion = await getAppVersion();
|
||||||
|
emit(VersionLoaded(versionInfo: _versionInfo,apkVersion: apkVersion));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(UserError(
|
emit(UserError(
|
||||||
message: e.toString(),
|
message: e.toString(),
|
||||||
|
|
|
@ -37,7 +37,8 @@ class UserLoggedIn extends UserState{
|
||||||
|
|
||||||
class VersionLoaded extends UserState {
|
class VersionLoaded extends UserState {
|
||||||
final VersionInfo? versionInfo;
|
final VersionInfo? versionInfo;
|
||||||
VersionLoaded({this.versionInfo});
|
final String? apkVersion;
|
||||||
|
VersionLoaded({this.versionInfo,this.apkVersion});
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [versionInfo!];
|
List<Object> get props => [versionInfo!];
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,9 @@ import 'package:unit2/theme-data.dart/btn-style.dart';
|
||||||
import '../../../../theme-data.dart/colors.dart';
|
import '../../../../theme-data.dart/colors.dart';
|
||||||
|
|
||||||
class Update extends StatefulWidget {
|
class Update extends StatefulWidget {
|
||||||
const Update({super.key});
|
final String apkVersion;
|
||||||
|
final String currenVersion;
|
||||||
|
const Update({super.key,required this.apkVersion,required this.currenVersion});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<Update> createState() => _UpdateState();
|
State<Update> createState() => _UpdateState();
|
||||||
|
@ -58,16 +60,16 @@ class _UpdateState extends State<Update> {
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
),
|
),
|
||||||
children: <TextSpan>[
|
children: <TextSpan>[
|
||||||
const TextSpan(
|
TextSpan(
|
||||||
text: "mobileVersion",
|
text: widget.apkVersion,
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
color: primary, fontWeight: FontWeight.bold)),
|
color: primary, fontWeight: FontWeight.bold)),
|
||||||
const TextSpan(
|
const TextSpan(
|
||||||
text: " did not match with the latest version ",
|
text: " did not match with the latest version ",
|
||||||
style: TextStyle(color: Colors.black)),
|
style: TextStyle(color: Colors.black)),
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text:
|
text:
|
||||||
"widget.currentVersion.data.version".toString(),
|
widget.currenVersion,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: primary, fontWeight: FontWeight.bold)),
|
color: primary, fontWeight: FontWeight.bold)),
|
||||||
const TextSpan(
|
const TextSpan(
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
|
|
||||||
|
Future<String> getAppVersion() async{
|
||||||
|
String appVersion;
|
||||||
|
try{
|
||||||
|
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||||
|
appVersion = packageInfo.version;
|
||||||
|
}catch(e){
|
||||||
|
throw(e.toString());
|
||||||
|
}
|
||||||
|
return appVersion;
|
||||||
|
|
||||||
|
}
|
|
@ -4,17 +4,12 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||||
import 'package:fluttericon/font_awesome5_icons.dart';
|
import 'package:fluttericon/font_awesome5_icons.dart';
|
||||||
import 'package:fluttertoast/fluttertoast.dart';
|
|
||||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||||
|
|
||||||
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
|
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
|
||||||
import 'package:unit2/bloc/bloc/user_bloc.dart';
|
import 'package:unit2/bloc/bloc/user_bloc.dart';
|
||||||
import 'package:unit2/model/login_data/user_info/user_data.dart';
|
import 'package:unit2/screens/unit2/login/components/update_required.dart';
|
||||||
import 'package:unit2/screens/unit2/login/qr_login.dart';
|
|
||||||
import 'package:unit2/utils/text_container.dart';
|
import 'package:unit2/utils/text_container.dart';
|
||||||
import 'package:unit2/widgets/error_state.dart';
|
import 'package:unit2/widgets/error_state.dart';
|
||||||
|
|
||||||
import '../../../utils/scanner.dart';
|
|
||||||
import '../../../widgets/splash_screen.dart';
|
import '../../../widgets/splash_screen.dart';
|
||||||
import '../../../widgets/wave.dart';
|
import '../../../widgets/wave.dart';
|
||||||
import '../../../utils/global.dart';
|
import '../../../utils/global.dart';
|
||||||
|
@ -53,10 +48,11 @@ class _UniT2LoginState extends State<UniT2Login> {
|
||||||
}, builder: (context, state) {
|
}, builder: (context, state) {
|
||||||
if (state is VersionLoaded) {
|
if (state is VersionLoaded) {
|
||||||
return Builder(builder: (context) {
|
return Builder(builder: (context) {
|
||||||
return SizedBox(
|
if(state.versionInfo!.version == state.apkVersion){
|
||||||
|
return SizedBox(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Stack(
|
child: Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
|
@ -273,6 +269,10 @@ class _UniT2LoginState extends State<UniT2Login> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}else{
|
||||||
|
return Update(apkVersion: state.apkVersion!,currenVersion: state.versionInfo!.version!,);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (state is UserError) {
|
if (state is UserError) {
|
||||||
|
|
|
@ -5,11 +5,13 @@
|
||||||
import FlutterMacOS
|
import FlutterMacOS
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
import package_info_plus
|
||||||
import path_provider_macos
|
import path_provider_macos
|
||||||
import shared_preferences_macos
|
import shared_preferences_macos
|
||||||
import sqflite
|
import sqflite
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
|
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
|
||||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||||
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
||||||
|
|
|
@ -406,6 +406,20 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.2"
|
version: "1.0.2"
|
||||||
|
package_info_plus:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: package_info_plus
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.2"
|
||||||
|
package_info_plus_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: package_info_plus_platform_interface
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.1"
|
||||||
path:
|
path:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -60,6 +60,7 @@ dependencies:
|
||||||
system_info2: ^2.0.4
|
system_info2: ^2.0.4
|
||||||
flutter_bloc: ^8.0.0
|
flutter_bloc: ^8.0.0
|
||||||
equatable: ^2.0.5
|
equatable: ^2.0.5
|
||||||
|
package_info_plus: ^3.0.2
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
Loading…
Reference in New Issue