application adpted to Flutter 3.0

Got ready for F-Droid release
This commit is contained in:
Kingkor Roy Tirtho 2022-05-21 17:15:46 +06:00
parent 9b0c002684
commit 31551ac1dc
10 changed files with 205 additions and 61 deletions

View File

@ -3,6 +3,139 @@ import 'dart:io';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
// blob metadata for de-stringifying
const randHash = [
49,
111,
98,
72,
78,
122,
98,
48,
112,
73,
81,
50,
112,
89,
90,
50,
116,
83,
84,
110,
99,
105,
76,
67,
74,
67,
89,
121,
48,
119,
77,
106,
69,
50,
86,
69,
53,
107,
77,
69,
86,
71,
101,
68,
66,
113,
78,
110,
66,
119
];
const sugarCarbonator = [
81,
119,
79,
71,
85,
53,
78,
50,
69,
52,
90,
68,
107,
120,
77,
87,
89,
52,
89,
84,
73
];
const randomSalt = [
70,
117,
67,
75,
117,
116,
72,
101,
105,
102,
65,
110,
68,
87,
72,
97,
84,
85,
82,
100,
79,
73,
110,
103,
83,
117,
75,
115
];
const algorithmicSugar = [
70,
117,
67,
75,
117,
116,
72,
101,
105,
102,
65,
78,
100,
102,
68,
114,
79,
105,
100,
115,
85,
99,
107,
83
];
void main(List<String> args) async { void main(List<String> args) async {
List<String> val; List<String> val;
List<Map> val2; List<Map> val2;
@ -10,7 +143,7 @@ void main(List<String> args) async {
final cwd = Directory.current.path; final cwd = Directory.current.path;
final binSafe = cwd.endsWith("/bin") ? ".." : ""; final binSafe = cwd.endsWith("/bin") ? ".." : "";
if (args.isEmpty) { if (args.isEmpty) {
throw ArgumentError("Expected 1-2 arguments but passed none"); throw ArgumentError("Expected 1-3 arguments but passed none");
} }
if (args.contains("--local")) { if (args.contains("--local")) {
final secretFilePath = path.join(cwd, binSafe, "secrets.json"); final secretFilePath = path.join(cwd, binSafe, "secrets.json");
@ -19,11 +152,22 @@ void main(List<String> args) async {
final data = jsonDecode(await file.readAsString()); final data = jsonDecode(await file.readAsString());
val = List.castFrom<dynamic, String>(data["LYRICS_SECRET"]); val = List.castFrom<dynamic, String>(data["LYRICS_SECRET"]);
val2 = List.castFrom<dynamic, Map>(data["SPOTIFY_SECRET"]); val2 = List.castFrom<dynamic, Map>(data["SPOTIFY_SECRET"]);
} else if (args.contains("--fdroid")) {
final decodedLyricSecret = utf8.decode(base64Decode(
args[1].replaceAll(
String.fromCharCodes(randomSalt), String.fromCharCodes(randHash)),
));
final decodedSpotifySecret = utf8.decode(base64Decode(
args.last.replaceAll(String.fromCharCodes(algorithmicSugar),
String.fromCharCodes(sugarCarbonator)),
));
val = List.castFrom<dynamic, String>(jsonDecode(decodedLyricSecret));
val2 = List.castFrom<dynamic, Map>(jsonDecode(decodedSpotifySecret));
} else { } else {
final decodedLyricSecret = utf8.decode(base64Decode(args.first)); final decodedLyricSecret = utf8.decode(base64Decode(args.first));
final decodedSpotifySecrete = utf8.decode(base64Decode(args.last)); final decodedSpotifySecret = utf8.decode(base64Decode(args.last));
val = List.castFrom<dynamic, String>(jsonDecode(decodedLyricSecret)); val = List.castFrom<dynamic, String>(jsonDecode(decodedLyricSecret));
val2 = List.castFrom<dynamic, Map>(jsonDecode(decodedSpotifySecrete)); val2 = List.castFrom<dynamic, Map>(jsonDecode(decodedSpotifySecret));
} }
await File(path.join(cwd, binSafe, "lib/models/generated_secrets.dart")) await File(path.join(cwd, binSafe, "lib/models/generated_secrets.dart"))

View File

@ -81,7 +81,7 @@ class Sidebar extends HookConsumerWidget {
trailing: FutureBuilder<User>( trailing: FutureBuilder<User>(
future: spotify.me.get(), future: spotify.me.get(),
builder: (context, snapshot) { builder: (context, snapshot) {
var avatarImg = imageToUrlString(snapshot.data?.images, final avatarImg = imageToUrlString(snapshot.data?.images,
index: (snapshot.data?.images?.length ?? 1) - 1); index: (snapshot.data?.images?.length ?? 1) - 1);
return extended.value return extended.value
? Padding( ? Padding(

View File

@ -21,7 +21,7 @@ class _UserArtistsState extends ConsumerState<UserArtists> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
WidgetsBinding.instance?.addPostFrameCallback((timestamp) { WidgetsBinding.instance.addPostFrameCallback((timestamp) {
_pagingController.addPageRequestListener((pageKey) async { _pagingController.addPageRequestListener((pageKey) async {
try { try {
SpotifyApi spotifyApi = ref.read(spotifyProvider); SpotifyApi spotifyApi = ref.read(spotifyProvider);

View File

@ -92,7 +92,7 @@ class Player extends HookConsumerWidget {
// I can't believe useEffect doesn't run Post Frame aka // I can't believe useEffect doesn't run Post Frame aka
// after rendering/painting the UI // after rendering/painting the UI
// `My disappointment is immeasurable and my day is ruined` XD // `My disappointment is immeasurable and my day is ruined` XD
WidgetsBinding.instance?.addPostFrameCallback((time) { WidgetsBinding.instance.addPostFrameCallback((time) {
// clearing the overlay-entry as passing the already available // clearing the overlay-entry as passing the already available
// entry will result in splashing while resizing the window // entry will result in splashing while resizing the window
if (breakpoint.isLessThanOrEqualTo(Breakpoints.md) && if (breakpoint.isLessThanOrEqualTo(Breakpoints.md) &&

View File

@ -29,7 +29,7 @@ class PlayerView extends HookConsumerWidget {
useEffect(() { useEffect(() {
if (breakpoint.isMoreThan(Breakpoints.md)) { if (breakpoint.isMoreThan(Breakpoints.md)) {
WidgetsBinding.instance?.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
GoRouter.of(context).pop(); GoRouter.of(context).pop();
}); });
} }

View File

@ -13,7 +13,7 @@ class RecordHotKeyDialog extends HookWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var _hotKey = useState(HotKey(null)); final _hotKey = useState<HotKey?>(null);
return AlertDialog( return AlertDialog(
content: SingleChildScrollView( content: SingleChildScrollView(
child: ListBody( child: ListBody(
@ -72,10 +72,10 @@ class RecordHotKeyDialog extends HookWidget {
), ),
TextButton( TextButton(
child: const Text('OK'), child: const Text('OK'),
onPressed: !_hotKey.value.isSetted onPressed: _hotKey.value == null
? null ? null
: () { : () {
onHotKeyRecorded(_hotKey.value); onHotKeyRecorded(_hotKey.value!);
GoRouter.of(context).pop(); GoRouter.of(context).pop();
}, },
), ),

View File

@ -30,7 +30,7 @@ Future<SpotubeTrack> toSpotubeTrack(
.replaceAll("\$FEATURED_ARTISTS", featuredArtists); .replaceAll("\$FEATURED_ARTISTS", featuredArtists);
logger.v("[Youtube Search Term] $queryString"); logger.v("[Youtube Search Term] $queryString");
SearchList videos = await youtube.search.getVideos(queryString); VideoSearchList videos = await youtube.search.search(queryString);
List<Map> ratedRankedVideos = videos List<Map> ratedRankedVideos = videos
.map((video) { .map((video) {

View File

@ -6,7 +6,7 @@ bool? useIsCurrentRoute([String matcher = "/"]) {
final isCurrentRoute = useState<bool?>(null); final isCurrentRoute = useState<bool?>(null);
final context = useContext(); final context = useContext();
useEffect(() { useEffect(() {
WidgetsBinding.instance?.addPostFrameCallback((timer) { WidgetsBinding.instance.addPostFrameCallback((timer) {
final isCurrent = GoRouter.of(context).location == matcher; final isCurrent = GoRouter.of(context).location == matcher;
if (isCurrent != isCurrentRoute.value) { if (isCurrent != isCurrentRoute.value) {
isCurrentRoute.value = isCurrent; isCurrentRoute.value = isCurrent;

View File

@ -9,7 +9,7 @@ PaletteColor usePaletteColor(BuildContext context, String imageUrl) {
final mounted = useIsMounted(); final mounted = useIsMounted();
useEffect(() { useEffect(() {
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) async { WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
final palette = await PaletteGenerator.fromImageProvider( final palette = await PaletteGenerator.fromImageProvider(
CachedNetworkImageProvider( CachedNetworkImageProvider(
imageUrl, imageUrl,

View File

@ -14,14 +14,14 @@ packages:
name: archive name: archive
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.2.1" version: "3.3.0"
args: args:
dependency: transitive dependency: transitive
description: description:
name: args name: args
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.3.0" version: "2.3.1"
async: async:
dependency: transitive dependency: transitive
description: description:
@ -105,7 +105,7 @@ packages:
name: cached_network_image name: cached_network_image
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.2.0" version: "3.2.1"
cached_network_image_platform_interface: cached_network_image_platform_interface:
dependency: transitive dependency: transitive
description: description:
@ -154,7 +154,7 @@ packages:
name: crypto name: crypto
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.1" version: "3.0.2"
csslib: csslib:
dependency: transitive dependency: transitive
description: description:
@ -189,7 +189,7 @@ packages:
name: ffi name: ffi
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.2" version: "1.2.1"
file: file:
dependency: transitive dependency: transitive
description: description:
@ -208,7 +208,7 @@ packages:
name: flutter_blurhash name: flutter_blurhash
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.6.4" version: "0.7.0"
flutter_cache_manager: flutter_cache_manager:
dependency: transitive dependency: transitive
description: description:
@ -222,7 +222,7 @@ packages:
name: flutter_hooks name: flutter_hooks
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.18.2+1" version: "0.18.4"
flutter_launcher_icons: flutter_launcher_icons:
dependency: "direct dev" dependency: "direct dev"
description: description:
@ -243,7 +243,7 @@ packages:
name: flutter_riverpod name: flutter_riverpod
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.3" version: "1.0.4"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@ -267,21 +267,21 @@ packages:
name: go_router name: go_router
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.4" version: "3.1.0"
hooks_riverpod: hooks_riverpod:
dependency: "direct main" dependency: "direct main"
description: description:
name: hooks_riverpod name: hooks_riverpod
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.3" version: "1.0.4"
hotkey_manager: hotkey_manager:
dependency: "direct main" dependency: "direct main"
description: description:
name: hotkey_manager name: hotkey_manager
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.1.6" version: "0.1.7"
html: html:
dependency: "direct main" dependency: "direct main"
description: description:
@ -302,7 +302,7 @@ packages:
name: http_parser name: http_parser
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.0" version: "4.0.1"
image: image:
dependency: transitive dependency: transitive
description: description:
@ -330,14 +330,14 @@ packages:
name: json_annotation name: json_annotation
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.4.0" version: "4.5.0"
just_audio: just_audio:
dependency: "direct main" dependency: "direct main"
description: description:
name: just_audio name: just_audio
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.9.20" version: "0.9.21"
just_audio_background: just_audio_background:
dependency: "direct main" dependency: "direct main"
description: description:
@ -400,7 +400,7 @@ packages:
name: marquee name: marquee
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.2.1" version: "2.2.2"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
@ -442,7 +442,7 @@ packages:
name: octo_image name: octo_image
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.1" version: "1.0.2"
package_config: package_config:
dependency: transitive dependency: transitive
description: description:
@ -512,49 +512,49 @@ packages:
name: path_provider name: path_provider
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.9" version: "2.0.10"
path_provider_android: path_provider_android:
dependency: transitive dependency: transitive
description: description:
name: path_provider_android name: path_provider_android
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.11" version: "2.0.14"
path_provider_ios: path_provider_ios:
dependency: transitive dependency: transitive
description: description:
name: path_provider_ios name: path_provider_ios
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.7" version: "2.0.9"
path_provider_linux: path_provider_linux:
dependency: transitive dependency: transitive
description: description:
name: path_provider_linux name: path_provider_linux
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.5" version: "2.1.6"
path_provider_macos: path_provider_macos:
dependency: transitive dependency: transitive
description: description:
name: path_provider_macos name: path_provider_macos
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.5" version: "2.0.6"
path_provider_platform_interface: path_provider_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: path_provider_platform_interface name: path_provider_platform_interface
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.3" version: "2.0.4"
path_provider_windows: path_provider_windows:
dependency: transitive dependency: transitive
description: description:
name: path_provider_windows name: path_provider_windows
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.5" version: "2.0.6"
pedantic: pedantic:
dependency: transitive dependency: transitive
description: description:
@ -582,7 +582,7 @@ packages:
name: permission_handler_apple name: permission_handler_apple
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "9.0.3" version: "9.0.4"
permission_handler_platform_interface: permission_handler_platform_interface:
dependency: transitive dependency: transitive
description: description:
@ -603,7 +603,7 @@ packages:
name: petitparser name: petitparser
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.4.0" version: "5.0.0"
platform: platform:
dependency: transitive dependency: transitive
description: description:
@ -652,35 +652,35 @@ packages:
name: shared_preferences name: shared_preferences
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.13" version: "2.0.15"
shared_preferences_android: shared_preferences_android:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_android name: shared_preferences_android
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.11" version: "2.0.12"
shared_preferences_ios: shared_preferences_ios:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_ios name: shared_preferences_ios
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.1"
shared_preferences_linux: shared_preferences_linux:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_linux name: shared_preferences_linux
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.1"
shared_preferences_macos: shared_preferences_macos:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_macos name: shared_preferences_macos
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.3" version: "2.0.4"
shared_preferences_platform_interface: shared_preferences_platform_interface:
dependency: transitive dependency: transitive
description: description:
@ -694,14 +694,14 @@ packages:
name: shared_preferences_web name: shared_preferences_web
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.3" version: "2.0.4"
shared_preferences_windows: shared_preferences_windows:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_windows name: shared_preferences_windows
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.1"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -713,7 +713,7 @@ packages:
name: sliver_tools name: sliver_tools
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.5" version: "0.2.6"
source_span: source_span:
dependency: transitive dependency: transitive
description: description:
@ -736,14 +736,14 @@ packages:
name: sqflite name: sqflite
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.2" version: "2.0.2+1"
sqflite_common: sqflite_common:
dependency: transitive dependency: transitive
description: description:
name: sqflite_common name: sqflite_common
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.2.0" version: "2.2.1+1"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
@ -778,7 +778,7 @@ packages:
name: synchronized name: synchronized
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.0" version: "3.0.0+2"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
@ -799,42 +799,42 @@ packages:
name: typed_data name: typed_data
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.3.1"
url_launcher: url_launcher:
dependency: "direct main" dependency: "direct main"
description: description:
name: url_launcher name: url_launcher
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "6.0.20" version: "6.1.2"
url_launcher_android: url_launcher_android:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_android name: url_launcher_android
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "6.0.15" version: "6.0.17"
url_launcher_ios: url_launcher_ios:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_ios name: url_launcher_ios
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "6.0.15" version: "6.0.17"
url_launcher_linux: url_launcher_linux:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_linux name: url_launcher_linux
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.0" version: "3.0.1"
url_launcher_macos: url_launcher_macos:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_macos name: url_launcher_macos
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.0" version: "3.0.1"
url_launcher_platform_interface: url_launcher_platform_interface:
dependency: transitive dependency: transitive
description: description:
@ -848,14 +848,14 @@ packages:
name: url_launcher_web name: url_launcher_web
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.8" version: "2.0.11"
url_launcher_windows: url_launcher_windows:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_windows name: url_launcher_windows
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.0" version: "3.0.1"
uuid: uuid:
dependency: transitive dependency: transitive
description: description:
@ -890,21 +890,21 @@ packages:
name: xml name: xml
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "5.3.1" version: "5.4.1"
yaml: yaml:
dependency: transitive dependency: transitive
description: description:
name: yaml name: yaml
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.1.0" version: "3.1.1"
youtube_explode_dart: youtube_explode_dart:
dependency: "direct main" dependency: "direct main"
description: description:
name: youtube_explode_dart name: youtube_explode_dart
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.10.9+1" version: "1.11.0"
sdks: sdks:
dart: ">=2.17.0 <3.0.0" dart: ">=2.17.0 <3.0.0"
flutter: ">=2.10.0" flutter: ">=3.0.0"