mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-07 21:48:14 -08:00
Separated the build number from version
This commit is contained in:
parent
c4f33e5039
commit
930b223fe8
5 changed files with 222 additions and 32 deletions
|
|
@ -1,14 +1,16 @@
|
|||
import 'package:fladder/providers/shared_provider.dart';
|
||||
import 'package:fladder/util/application_info.dart';
|
||||
import 'package:fladder/util/string_extensions.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:media_kit/media_kit.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'package:fladder/providers/shared_provider.dart';
|
||||
import 'package:fladder/util/application_info.dart';
|
||||
import 'package:fladder/util/string_extensions.dart';
|
||||
|
||||
void main() async {
|
||||
_setupLogging();
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
|
@ -22,8 +24,14 @@ void main() async {
|
|||
ProviderScope(
|
||||
overrides: [
|
||||
sharedPreferencesProvider.overrideWith((ref) => sharedPreferences),
|
||||
applicationInfoProvider.overrideWith((ref) => ApplicationInfo(
|
||||
name: packageInfo.appName, version: packageInfo.version, os: defaultTargetPlatform.name.capitalize())),
|
||||
applicationInfoProvider.overrideWith(
|
||||
(ref) => ApplicationInfo(
|
||||
name: packageInfo.appName,
|
||||
buildNumber: packageInfo.buildNumber,
|
||||
version: packageInfo.version,
|
||||
os: defaultTargetPlatform.name.capitalize(),
|
||||
),
|
||||
),
|
||||
],
|
||||
child: const Main(),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -84,7 +84,8 @@ void main() async {
|
|||
|
||||
final applicationInfo = ApplicationInfo(
|
||||
name: packageInfo.appName.capitalize(),
|
||||
version: "${packageInfo.version}(${packageInfo.buildNumber})",
|
||||
version: packageInfo.version,
|
||||
buildNumber: packageInfo.buildNumber,
|
||||
os: !kIsWeb ? defaultTargetPlatform.name.capitalize() : "${defaultTargetPlatform.name.capitalize()} Web",
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -139,11 +139,12 @@ class _SettingsScreenState extends ConsumerState<SettingsScreen> {
|
|||
label: Text(context.localized.about),
|
||||
subLabel: const Text("Fladder"),
|
||||
suffix: Opacity(
|
||||
opacity: 1,
|
||||
child: FladderIconOutlined(
|
||||
size: 24,
|
||||
color: context.colors.onSurfaceVariant,
|
||||
)),
|
||||
opacity: 1,
|
||||
child: FladderIconOutlined(
|
||||
size: 24,
|
||||
color: context.colors.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
onTap: () => showAboutDialog(
|
||||
context: context,
|
||||
applicationIcon: const FladderIcon(size: 85),
|
||||
|
|
|
|||
|
|
@ -1,37 +1,30 @@
|
|||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'application_info.freezed.dart';
|
||||
|
||||
final applicationInfoProvider = StateProvider<ApplicationInfo>((ref) {
|
||||
return ApplicationInfo(
|
||||
name: "",
|
||||
version: "",
|
||||
buildNumber: "",
|
||||
os: "",
|
||||
);
|
||||
});
|
||||
|
||||
class ApplicationInfo {
|
||||
final String name;
|
||||
final String version;
|
||||
final String os;
|
||||
ApplicationInfo({
|
||||
required this.name,
|
||||
required this.version,
|
||||
required this.os,
|
||||
});
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
class ApplicationInfo with _$ApplicationInfo {
|
||||
const ApplicationInfo._();
|
||||
|
||||
ApplicationInfo copyWith({
|
||||
String? name,
|
||||
String? version,
|
||||
String? os,
|
||||
}) {
|
||||
return ApplicationInfo(
|
||||
name: name ?? this.name,
|
||||
version: version ?? this.version,
|
||||
os: os ?? this.os,
|
||||
);
|
||||
}
|
||||
factory ApplicationInfo({
|
||||
required String name,
|
||||
required String version,
|
||||
required String buildNumber,
|
||||
required String os,
|
||||
}) = _ApplicationInfo;
|
||||
|
||||
String get versionAndPlatform => "$version ($os)";
|
||||
String get versionAndPlatform => "$version ($os)\n#$buildNumber";
|
||||
|
||||
@override
|
||||
String toString() => 'ApplicationInfo(name: $name, version: $version, os: $os)';
|
||||
|
|
|
|||
187
lib/util/application_info.freezed.dart
Normal file
187
lib/util/application_info.freezed.dart
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'application_info.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ApplicationInfo {
|
||||
String get name => throw _privateConstructorUsedError;
|
||||
String get version => throw _privateConstructorUsedError;
|
||||
String get buildNumber => throw _privateConstructorUsedError;
|
||||
String get os => throw _privateConstructorUsedError;
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
$ApplicationInfoCopyWith<ApplicationInfo> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ApplicationInfoCopyWith<$Res> {
|
||||
factory $ApplicationInfoCopyWith(
|
||||
ApplicationInfo value, $Res Function(ApplicationInfo) then) =
|
||||
_$ApplicationInfoCopyWithImpl<$Res, ApplicationInfo>;
|
||||
@useResult
|
||||
$Res call({String name, String version, String buildNumber, String os});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ApplicationInfoCopyWithImpl<$Res, $Val extends ApplicationInfo>
|
||||
implements $ApplicationInfoCopyWith<$Res> {
|
||||
_$ApplicationInfoCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? name = null,
|
||||
Object? version = null,
|
||||
Object? buildNumber = null,
|
||||
Object? os = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
name: null == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
version: null == version
|
||||
? _value.version
|
||||
: version // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
buildNumber: null == buildNumber
|
||||
? _value.buildNumber
|
||||
: buildNumber // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
os: null == os
|
||||
? _value.os
|
||||
: os // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ApplicationInfoImplCopyWith<$Res>
|
||||
implements $ApplicationInfoCopyWith<$Res> {
|
||||
factory _$$ApplicationInfoImplCopyWith(_$ApplicationInfoImpl value,
|
||||
$Res Function(_$ApplicationInfoImpl) then) =
|
||||
__$$ApplicationInfoImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({String name, String version, String buildNumber, String os});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ApplicationInfoImplCopyWithImpl<$Res>
|
||||
extends _$ApplicationInfoCopyWithImpl<$Res, _$ApplicationInfoImpl>
|
||||
implements _$$ApplicationInfoImplCopyWith<$Res> {
|
||||
__$$ApplicationInfoImplCopyWithImpl(
|
||||
_$ApplicationInfoImpl _value, $Res Function(_$ApplicationInfoImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? name = null,
|
||||
Object? version = null,
|
||||
Object? buildNumber = null,
|
||||
Object? os = null,
|
||||
}) {
|
||||
return _then(_$ApplicationInfoImpl(
|
||||
name: null == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
version: null == version
|
||||
? _value.version
|
||||
: version // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
buildNumber: null == buildNumber
|
||||
? _value.buildNumber
|
||||
: buildNumber // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
os: null == os
|
||||
? _value.os
|
||||
: os // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ApplicationInfoImpl extends _ApplicationInfo {
|
||||
_$ApplicationInfoImpl(
|
||||
{required this.name,
|
||||
required this.version,
|
||||
required this.buildNumber,
|
||||
required this.os})
|
||||
: super._();
|
||||
|
||||
@override
|
||||
final String name;
|
||||
@override
|
||||
final String version;
|
||||
@override
|
||||
final String buildNumber;
|
||||
@override
|
||||
final String os;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ApplicationInfoImpl &&
|
||||
(identical(other.name, name) || other.name == name) &&
|
||||
(identical(other.version, version) || other.version == version) &&
|
||||
(identical(other.buildNumber, buildNumber) ||
|
||||
other.buildNumber == buildNumber) &&
|
||||
(identical(other.os, os) || other.os == os));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, name, version, buildNumber, os);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ApplicationInfoImplCopyWith<_$ApplicationInfoImpl> get copyWith =>
|
||||
__$$ApplicationInfoImplCopyWithImpl<_$ApplicationInfoImpl>(
|
||||
this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _ApplicationInfo extends ApplicationInfo {
|
||||
factory _ApplicationInfo(
|
||||
{required final String name,
|
||||
required final String version,
|
||||
required final String buildNumber,
|
||||
required final String os}) = _$ApplicationInfoImpl;
|
||||
_ApplicationInfo._() : super._();
|
||||
|
||||
@override
|
||||
String get name;
|
||||
@override
|
||||
String get version;
|
||||
@override
|
||||
String get buildNumber;
|
||||
@override
|
||||
String get os;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$ApplicationInfoImplCopyWith<_$ApplicationInfoImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue