mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-08 23:18:16 -07: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/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
import 'package:media_kit/media_kit.dart';
|
import 'package:media_kit/media_kit.dart';
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.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 {
|
void main() async {
|
||||||
_setupLogging();
|
_setupLogging();
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
@ -22,8 +24,14 @@ void main() async {
|
||||||
ProviderScope(
|
ProviderScope(
|
||||||
overrides: [
|
overrides: [
|
||||||
sharedPreferencesProvider.overrideWith((ref) => sharedPreferences),
|
sharedPreferencesProvider.overrideWith((ref) => sharedPreferences),
|
||||||
applicationInfoProvider.overrideWith((ref) => ApplicationInfo(
|
applicationInfoProvider.overrideWith(
|
||||||
name: packageInfo.appName, version: packageInfo.version, os: defaultTargetPlatform.name.capitalize())),
|
(ref) => ApplicationInfo(
|
||||||
|
name: packageInfo.appName,
|
||||||
|
buildNumber: packageInfo.buildNumber,
|
||||||
|
version: packageInfo.version,
|
||||||
|
os: defaultTargetPlatform.name.capitalize(),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
child: const Main(),
|
child: const Main(),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,8 @@ void main() async {
|
||||||
|
|
||||||
final applicationInfo = ApplicationInfo(
|
final applicationInfo = ApplicationInfo(
|
||||||
name: packageInfo.appName.capitalize(),
|
name: packageInfo.appName.capitalize(),
|
||||||
version: "${packageInfo.version}(${packageInfo.buildNumber})",
|
version: packageInfo.version,
|
||||||
|
buildNumber: packageInfo.buildNumber,
|
||||||
os: !kIsWeb ? defaultTargetPlatform.name.capitalize() : "${defaultTargetPlatform.name.capitalize()} Web",
|
os: !kIsWeb ? defaultTargetPlatform.name.capitalize() : "${defaultTargetPlatform.name.capitalize()} Web",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -139,11 +139,12 @@ class _SettingsScreenState extends ConsumerState<SettingsScreen> {
|
||||||
label: Text(context.localized.about),
|
label: Text(context.localized.about),
|
||||||
subLabel: const Text("Fladder"),
|
subLabel: const Text("Fladder"),
|
||||||
suffix: Opacity(
|
suffix: Opacity(
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
child: FladderIconOutlined(
|
child: FladderIconOutlined(
|
||||||
size: 24,
|
size: 24,
|
||||||
color: context.colors.onSurfaceVariant,
|
color: context.colors.onSurfaceVariant,
|
||||||
)),
|
),
|
||||||
|
),
|
||||||
onTap: () => showAboutDialog(
|
onTap: () => showAboutDialog(
|
||||||
context: context,
|
context: context,
|
||||||
applicationIcon: const FladderIcon(size: 85),
|
applicationIcon: const FladderIcon(size: 85),
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,30 @@
|
||||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
|
part 'application_info.freezed.dart';
|
||||||
|
|
||||||
final applicationInfoProvider = StateProvider<ApplicationInfo>((ref) {
|
final applicationInfoProvider = StateProvider<ApplicationInfo>((ref) {
|
||||||
return ApplicationInfo(
|
return ApplicationInfo(
|
||||||
name: "",
|
name: "",
|
||||||
version: "",
|
version: "",
|
||||||
|
buildNumber: "",
|
||||||
os: "",
|
os: "",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
class ApplicationInfo {
|
@Freezed(toJson: false, fromJson: false)
|
||||||
final String name;
|
class ApplicationInfo with _$ApplicationInfo {
|
||||||
final String version;
|
const ApplicationInfo._();
|
||||||
final String os;
|
|
||||||
ApplicationInfo({
|
|
||||||
required this.name,
|
|
||||||
required this.version,
|
|
||||||
required this.os,
|
|
||||||
});
|
|
||||||
|
|
||||||
ApplicationInfo copyWith({
|
factory ApplicationInfo({
|
||||||
String? name,
|
required String name,
|
||||||
String? version,
|
required String version,
|
||||||
String? os,
|
required String buildNumber,
|
||||||
}) {
|
required String os,
|
||||||
return ApplicationInfo(
|
}) = _ApplicationInfo;
|
||||||
name: name ?? this.name,
|
|
||||||
version: version ?? this.version,
|
|
||||||
os: os ?? this.os,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
String get versionAndPlatform => "$version ($os)";
|
String get versionAndPlatform => "$version ($os)\n#$buildNumber";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => 'ApplicationInfo(name: $name, version: $version, os: $os)';
|
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