Skip to content

Commit

Permalink
♻️ miscellaneous updates
Browse files Browse the repository at this point in the history
- Upgrade dependencies.
- Use package_info_plus for version requirements.
  • Loading branch information
BirjuVachhani committed Mar 24, 2024
1 parent 17f6a11 commit b2901b2
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 28 deletions.
6 changes: 3 additions & 3 deletions lib/home/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import 'package:intl/intl.dart';
import 'package:mobx/mobx.dart';
import 'package:provider/provider.dart';

import '../main.dart';
import '../model/background_settings.dart';
import '../resources/storage_keys.dart';
import '../settings/changelog_dialog.dart';
import '../settings/settings_panel.dart';
import '../src/version.dart';
import '../ui/message_banner/message_banner.dart';
import '../ui/message_banner/message_view.dart';
import '../utils/custom_observer.dart';
Expand Down Expand Up @@ -203,9 +203,9 @@ class _HomeState extends State<Home> {
Future<void> _shouldShowChangelog() async {
final String? storedVersion =
await storageManager.getString(StorageKeys.version);
if (storedVersion == null || storedVersion != packageVersion) {
if (storedVersion == null || storedVersion != packageInfo.version) {
log('Showing changelog dialog');
await storageManager.setString(StorageKeys.version, packageVersion);
await storageManager.setString(StorageKeys.version, packageInfo.version);
await Future.delayed(const Duration(seconds: 1));
if (!mounted) return;
showDialog(
Expand Down
2 changes: 0 additions & 2 deletions lib/home/widgets/timer_widget.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:intl/intl.dart' hide TextDirection;
Expand Down
8 changes: 8 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
import 'package:package_info_plus/package_info_plus.dart';

import 'home/home.dart';
import 'resources/colors.dart';
Expand All @@ -15,6 +16,11 @@ void main() async {
runApp(const MyApp());
}

late PackageInfo packageInfo;

Future<void> loadPackageInfo() async =>
packageInfo = await PackageInfo.fromPlatform();

class MyApp extends StatelessWidget {
const MyApp({super.key});

Expand All @@ -40,6 +46,8 @@ Future<void> initialize() async {
GetIt.instance.registerSingleton<WeatherService>(OpenMeteoWeatherService());
GetIt.instance
.registerSingleton<GeocodingService>(OpenMeteoGeocodingService());

await loadPackageInfo();
}

ThemeData buildTheme(BuildContext context) {
Expand Down
4 changes: 2 additions & 2 deletions lib/settings/about.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'dart:math';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

import '../main.dart';
import '../resources/fonts.dart';
import '../src/version.dart';
import '../ui/gesture_detector_with_cursor.dart';

class About extends StatelessWidget {
Expand Down Expand Up @@ -33,7 +33,7 @@ class About extends StatelessWidget {
),
const SizedBox(height: 12),
Text(
'v$packageVersion'.toUpperCase(),
'v${packageInfo.version}'.toUpperCase(),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 10,
Expand Down
4 changes: 2 additions & 2 deletions lib/settings/changelog_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import 'package:http/http.dart' as http;
import 'package:intl/intl.dart';
import 'package:url_launcher/url_launcher.dart';

import '../main.dart';
import '../resources/colors.dart';
import '../src/version.dart';
import '../ui/gesture_detector_with_cursor.dart';

class ChangelogDialog extends StatefulWidget {
Expand Down Expand Up @@ -185,7 +185,7 @@ class _ChangelogDialogState extends State<ChangelogDialog> {
isLoading = true;
if (mounted) setState(() {});
try {
version = packageVersion;
version = packageInfo.version;
final response = await http.get(Uri.parse(
'https://raw.githubusercontent.com/BirjuVachhani/pluto/$version/CHANGELOG.md'));

Expand Down
1 change: 0 additions & 1 deletion lib/src/version.dart

This file was deleted.

2 changes: 2 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import FlutterMacOS
import Foundation

import package_info_plus
import shared_preferences_foundation
import url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
}
28 changes: 14 additions & 14 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,37 @@ dependencies:
sdk: flutter
equatable: ^2.0.5
shared_preferences: ^2.2.2
provider: ^6.1.1
get_it: ^7.6.4
provider: ^6.1.2
get_it: ^7.6.7
json_annotation: ^4.8.1
collection: ^1.18.0
intl: ^0.19.0
http: ^1.1.2
http: ^1.2.1
# dropdown_button2: ^1.9.2
file_picker: ^6.1.1
screwdriver: ^5.3.0
flutter_multi_formatter: ^2.12.3
url_launcher: ^6.2.2
# package_info_plus: ^3.0.2
flutter_screwdriver: ^3.1.0
file_picker: ^8.0.0+1
screwdriver: ^5.3.1
flutter_multi_formatter: ^2.12.4
url_launcher: ^6.2.5
package_info_plus: ^6.0.0
flutter_screwdriver: ^3.2.0
flutter_markdown: ^0.6.18+2
mobx: ^2.2.3+1
flutter_mobx: ^2.2.0+1
mobx: ^2.3.1
flutter_mobx: ^2.2.0+2
rxdart: ^0.27.7
universal_html: ^2.2.4
universal_io: ^2.2.2

dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^2.4.7
build_runner: ^2.4.8
flutter_lints: ^3.0.1
characters: ^1.3.0
dart_style: ^2.3.4
dart_style: ^2.3.6
json_serializable: ^6.7.1
flutter_launcher_icons: ^0.13.1
yaml: ^3.1.2
mobx_codegen: ^2.4.1
mobx_codegen: ^2.6.0+1

dependency_overrides:
watcher: ^1.1.0
Expand Down
6 changes: 3 additions & 3 deletions scripts/update_version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ void main(List<String> args) {
.writeAsStringSync(const JsonEncoder.withIndent(' ').convert(manifest));
stdout.writeln('Updated manifest version to $version');

final File versionFile = File('lib/src/version.dart');
versionFile.createSync(recursive: true);
// final File versionFile = File('lib/src/version.dart');
// versionFile.createSync(recursive: true);

versionFile.writeAsStringSync('const String packageVersion = \'$version\';');
// versionFile.writeAsStringSync('const String packageVersion = \'$version\';');
stdout.writeln('Updated version.dart to $version');
exit(0);
}
2 changes: 1 addition & 1 deletion web/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Pluto",
"description": "A beautiful new tab for your browser.",
"version": "0.4.0",
"version": "0.5.0",
"manifest_version": 3,
"short_name": "Pluto",
"content_security_policy": {
Expand Down

0 comments on commit b2901b2

Please sign in to comment.