From 800277fb28e1dae33bb286638cc6a5b76162a798 Mon Sep 17 00:00:00 2001 From: BrightDV <92821484+BrightDV@users.noreply.github.com> Date: Wed, 6 Dec 2023 20:07:53 +0100 Subject: [PATCH] [chores] support flutter 3.16.3 --- .flutter | 2 +- .../plugins/GeneratedPluginRegistrant.java | 9 +- ios/Runner/GeneratedPluginRegistrant.m | 19 +- lib/main.dart | 1 + pubspec.lock | 196 +++++++++--------- pubspec.yaml | 6 +- .../lib/controller/story_controller.dart | 1 - story_view/lib/widgets/story_image.dart | 45 ++-- story_view/lib/widgets/story_video.dart | 20 +- story_view/lib/widgets/story_view.dart | 168 ++++++++------- web/index.html | 4 +- 11 files changed, 230 insertions(+), 241 deletions(-) diff --git a/.flutter b/.flutter index 2f708eb8..b0366e0a 160000 --- a/.flutter +++ b/.flutter @@ -1 +1 @@ -Subproject commit 2f708eb8396e362e280fac22cf171c2cb467343c +Subproject commit b0366e0a3f089e15fd89c97604ab402fe26b724c diff --git a/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java b/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java index 84964fcc..19ac9854 100644 --- a/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java +++ b/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java @@ -41,9 +41,9 @@ public static void registerWith(@NonNull FlutterEngine flutterEngine) { Log.e(TAG, "Error registering plugin device_info_plus, dev.fluttercommunity.plus.device_info.DeviceInfoPlusPlugin", e); } try { - flutterEngine.getPlugins().add(new com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin()); + flutterEngine.getPlugins().add(new com.pichillilorenzo.flutter_inappwebview_android.InAppWebViewFlutterPlugin()); } catch (Exception e) { - Log.e(TAG, "Error registering plugin flutter_inappwebview, com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin", e); + Log.e(TAG, "Error registering plugin flutter_inappwebview_android, com.pichillilorenzo.flutter_inappwebview_android.InAppWebViewFlutterPlugin", e); } try { flutterEngine.getPlugins().add(new io.github.ponnamkarthik.toast.fluttertoast.FlutterToastPlugin()); @@ -95,10 +95,5 @@ public static void registerWith(@NonNull FlutterEngine flutterEngine) { } catch (Exception e) { Log.e(TAG, "Error registering plugin wakelock, creativemaybeno.wakelock.WakelockPlugin", e); } - try { - flutterEngine.getPlugins().add(new dev.fluttercommunity.workmanager.WorkmanagerPlugin()); - } catch (Exception e) { - Log.e(TAG, "Error registering plugin workmanager, dev.fluttercommunity.workmanager.WorkmanagerPlugin", e); - } } } diff --git a/ios/Runner/GeneratedPluginRegistrant.m b/ios/Runner/GeneratedPluginRegistrant.m index 12985c93..6ec7bdf1 100644 --- a/ios/Runner/GeneratedPluginRegistrant.m +++ b/ios/Runner/GeneratedPluginRegistrant.m @@ -36,10 +36,10 @@ @import device_info_plus; #endif -#if __has_include() -#import +#if __has_include() +#import #else -@import flutter_inappwebview; +@import flutter_inappwebview_ios; #endif #if __has_include() @@ -84,8 +84,8 @@ @import syncfusion_flutter_pdfviewer; #endif -#if __has_include() -#import +#if __has_include() +#import #else @import url_launcher_ios; #endif @@ -102,12 +102,6 @@ @import wakelock; #endif -#if __has_include() -#import -#else -@import workmanager; -#endif - @implementation GeneratedPluginRegistrant + (void)registerWithRegistry:(NSObject*)registry { @@ -124,10 +118,9 @@ + (void)registerWithRegistry:(NSObject*)registry { [FLTSharePlusPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTSharePlusPlugin"]]; [SqflitePlugin registerWithRegistrar:[registry registrarForPlugin:@"SqflitePlugin"]]; [SyncfusionFlutterPdfViewerPlugin registerWithRegistrar:[registry registrarForPlugin:@"SyncfusionFlutterPdfViewerPlugin"]]; - [FLTURLLauncherPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTURLLauncherPlugin"]]; + [URLLauncherPlugin registerWithRegistrar:[registry registrarForPlugin:@"URLLauncherPlugin"]]; [FVPVideoPlayerPlugin registerWithRegistrar:[registry registrarForPlugin:@"FVPVideoPlayerPlugin"]]; [WakelockPlugin registerWithRegistrar:[registry registrarForPlugin:@"WakelockPlugin"]]; - [WorkmanagerPlugin registerWithRegistrar:[registry registrarForPlugin:@"WorkmanagerPlugin"]]; } @end diff --git a/lib/main.dart b/lib/main.dart index 41526cb6..4b67ee99 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -340,6 +340,7 @@ class _MyAppState extends State { fontFamily: 'Formula1', primarySwatch: colorCustom, scaffoldBackgroundColor: const Color(0xff12121a), + useMaterial3: false, // TODO: implement md3 ), localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: supportedLocales, diff --git a/pubspec.lock b/pubspec.lock index 3360770e..9fc049c9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -110,10 +110,10 @@ packages: dependency: transitive description: name: collection - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.2" + version: "1.18.0" connectivity_plus: dependency: "direct main" description: @@ -142,10 +142,10 @@ packages: dependency: transitive description: name: cross_file - sha256: "445db18de832dba8d851e287aff8ccf169bed30d2e94243cb54c7d2f1ed2142c" + sha256: fedaadfa3a6996f75211d835aaeb8fede285dae94262485698afd832371b9a5e url: "https://pub.dev" source: hosted - version: "0.3.3+6" + version: "0.3.3+8" crypto: dependency: transitive description: @@ -174,10 +174,10 @@ packages: dependency: transitive description: name: dbus - sha256: "6f07cba3f7b3448d42d015bfd3d53fe12e5b36da2423f23838efc1d5fb31a263" + sha256: "365c771ac3b0e58845f39ec6deebc76e3276aa9922b0cc60840712094d9047ac" url: "https://pub.dev" source: hosted - version: "0.7.8" + version: "0.7.10" device_info_plus: dependency: transitive description: @@ -259,26 +259,58 @@ packages: dependency: "direct main" description: name: flutter_inappwebview - sha256: "786b124c944f4914670868c9775c90600a4d4674497f617190c0d676019e337b" + sha256: b34fb3b0a8232a5adae1501e4beb6997717e4a17664eab528d4a0b8fd596d417 url: "https://pub.dev" source: hosted - version: "6.0.0-beta.25" + version: "6.0.0-beta.31" + flutter_inappwebview_android: + dependency: transitive + description: + name: flutter_inappwebview_android + sha256: "297ef285b47529332dda074f3bca6dbe103f9e83534b7aca5f081be45da80610" + url: "https://pub.dev" + source: hosted + version: "1.0.7" flutter_inappwebview_internal_annotations: dependency: transitive description: name: flutter_inappwebview_internal_annotations - sha256: "064a8ccbc76217dcd3b0fd6c6ea6f549e69b2849a0233b5bb46af9632c3ce2ff" + sha256: "5f80fd30e208ddded7dbbcd0d569e7995f9f63d45ea3f548d8dd4c0b473fb4c8" url: "https://pub.dev" source: hosted - version: "1.1.0" - flutter_lints: + version: "1.1.1" + flutter_inappwebview_ios: + dependency: transitive + description: + name: flutter_inappwebview_ios + sha256: "6b1e3b4f46596700a2393aeb7023379e8a4cd609d2f4d05d358697bcffdcf010" + url: "https://pub.dev" + source: hosted + version: "1.0.8" + flutter_inappwebview_macos: dependency: transitive description: - name: flutter_lints - sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 + name: flutter_inappwebview_macos + sha256: f341d16cf471c072e5424eed748aac90b48a7ff1b4897a254ada189bb551145f url: "https://pub.dev" source: hosted - version: "2.0.3" + version: "1.0.6" + flutter_inappwebview_platform_interface: + dependency: transitive + description: + name: flutter_inappwebview_platform_interface + sha256: efc08458cde40f1b2ea213334d02892910c0f5bf2c8a8cd418d0f0522de7e016 + url: "https://pub.dev" + source: hosted + version: "1.0.5" + flutter_inappwebview_web: + dependency: transitive + description: + name: flutter_inappwebview_web + sha256: "77ac7a82fec6e7a84ad4ea9d219cc84c8e542fb5791f208614e82620a4c3d7f4" + url: "https://pub.dev" + source: hosted + version: "1.0.3" flutter_localizations: dependency: "direct main" description: flutter @@ -296,10 +328,10 @@ packages: dependency: "direct main" description: name: flutter_markdown - sha256: "8afc9a6aa6d8e8063523192ba837149dbf3d377a37c0b0fc579149a1fbd4a619" + sha256: "35108526a233cc0755664d445f8a6b4b61e6f8fe993b3658b80b4a26827fc196" url: "https://pub.dev" source: hosted - version: "0.6.18" + version: "0.6.18+2" flutter_swiper_view: dependency: "direct main" description: @@ -317,10 +349,10 @@ packages: dependency: "direct main" description: name: flutter_timer_countdown - sha256: "1a88e0b99efd415a0557949294f5b4652b79b931c59ba6e04729be1afc3fd4be" + sha256: "0c73e1593ad7949c007752199a17e7ed50bb581568743dbc32f061f49873219e" url: "https://pub.dev" source: hosted - version: "1.0.6" + version: "1.0.7" flutter_web_plugins: dependency: transitive description: flutter @@ -338,10 +370,10 @@ packages: dependency: "direct main" description: name: fluttertoast - sha256: "474f7d506230897a3cd28c965ec21c5328ae5605fc9c400cd330e9e9d6ac175c" + sha256: dfdde255317af381bfc1c486ed968d5a43a2ded9c931e87cbecd88767d6a71c1 url: "https://pub.dev" source: hosted - version: "8.2.2" + version: "8.2.4" font_awesome_flutter: dependency: "direct main" description: @@ -362,10 +394,10 @@ packages: dependency: transitive description: name: fwfh_text_style - sha256: f0883ccb64b7bb3f2a7a091542c2e834fc3e2a6aa54158f46b3c43b55675d8f7 + sha256: "5f8b587fd223a6bf14aad3d3da5e7ced0628becbd0768f8e7ae25ff6b9f3d2ec" url: "https://pub.dev" source: hosted - version: "2.22.8+3" + version: "2.23.8" geodesy: dependency: transitive description: @@ -386,10 +418,10 @@ packages: dependency: "direct main" description: name: geojson_vi - sha256: a364e173c2093b67e24b542c73aa7b43aa5ddcbc58c65fe9eac5ae38bd26e977 + sha256: "4f2786db7159c7cbd116b10c29ff396be1e6dd890f27b08d2a4e61162d999d85" url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.2.1" geopoint: dependency: transitive description: @@ -494,14 +526,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.8.2" - lints: - dependency: transitive - description: - name: lints - sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" - url: "https://pub.dev" - source: hosted - version: "2.1.1" lists: dependency: transitive description: @@ -518,14 +542,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.1" - logging: - dependency: transitive - description: - name: logging - sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" - url: "https://pub.dev" - source: hosted - version: "1.2.0" map_controller_plus: dependency: "direct main" description: @@ -571,10 +587,10 @@ packages: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" mgrs_dart: dependency: transitive description: @@ -643,10 +659,10 @@ packages: dependency: transitive description: name: path_provider_android - sha256: "6b8b19bd80da4f11ce91b2d1fb931f3006911477cec227cce23d3253d80df3f1" + sha256: e595b98692943b4881b219f0a9e3945118d3c16bd7e2813f98ec6e532d905f72 url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.2.1" path_provider_foundation: dependency: transitive description: @@ -691,10 +707,10 @@ packages: dependency: transitive description: name: petitparser - sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 + sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 url: "https://pub.dev" source: hosted - version: "5.4.0" + version: "6.0.2" platform: dependency: transitive description: @@ -707,10 +723,10 @@ packages: dependency: transitive description: name: plugin_platform_interface - sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d + sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8 url: "https://pub.dev" source: hosted - version: "2.1.6" + version: "2.1.7" polylabel: dependency: transitive description: @@ -809,18 +825,18 @@ packages: dependency: transitive description: name: sqflite_common - sha256: "1b92f368f44b0dee2425bb861cfa17b6f6cf3961f762ff6f941d20b33355660a" + sha256: bb4738f15b23352822f4c42a531677e5c6f522e079461fd240ead29d8d8a54a6 url: "https://pub.dev" source: hosted - version: "2.5.0" + version: "2.5.0+2" stack_trace: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" story_view: dependency: "direct main" description: @@ -832,10 +848,10 @@ packages: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -920,18 +936,18 @@ packages: dependency: transitive description: name: test_api - sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" url: "https://pub.dev" source: hosted - version: "0.6.0" + version: "0.6.1" timeago: dependency: "direct main" description: name: timeago - sha256: "4addcda362e51f23cf7ae2357fccd053f29d59b4ddd17fb07fc3e7febb47a456" + sha256: c44b80cbc6b44627c00d76960f2af571f6f50e5dbedef4d9215d455e4335165b url: "https://pub.dev" source: hosted - version: "3.5.0" + version: "3.6.0" tuple: dependency: transitive description: @@ -960,66 +976,66 @@ packages: dependency: "direct main" description: name: url_launcher - sha256: "47e208a6711459d813ba18af120d9663c20bdf6985d6ad39fe165d2538378d27" + sha256: b1c9e98774adf8820c96fbc7ae3601231d324a7d5ebd8babe27b6dfac91357ba url: "https://pub.dev" source: hosted - version: "6.1.14" + version: "6.2.1" url_launcher_android: dependency: transitive description: name: url_launcher_android - sha256: b04af59516ab45762b2ca6da40fa830d72d0f6045cd97744450b73493fa76330 + sha256: "31222ffb0063171b526d3e569079cf1f8b294075ba323443fdc690842bfd4def" url: "https://pub.dev" source: hosted - version: "6.1.0" + version: "6.2.0" url_launcher_ios: dependency: transitive description: name: url_launcher_ios - sha256: "7c65021d5dee51813d652357bc65b8dd4a6177082a9966bc8ba6ee477baa795f" + sha256: bba3373219b7abb6b5e0d071b0fe66dfbe005d07517a68e38d4fc3638f35c6d3 url: "https://pub.dev" source: hosted - version: "6.1.5" + version: "6.2.1" url_launcher_linux: dependency: transitive description: name: url_launcher_linux - sha256: b651aad005e0cb06a01dbd84b428a301916dc75f0e7ea6165f80057fee2d8e8e + sha256: "9f2d390e096fdbe1e6e6256f97851e51afc2d9c423d3432f1d6a02a8a9a8b9fd" url: "https://pub.dev" source: hosted - version: "3.0.6" + version: "3.1.0" url_launcher_macos: dependency: transitive description: name: url_launcher_macos - sha256: b55486791f666e62e0e8ff825e58a023fd6b1f71c49926483f1128d3bbd8fe88 + sha256: b7244901ea3cf489c5335bdacda07264a6e960b1c1b1a9f91e4bc371d9e68234 url: "https://pub.dev" source: hosted - version: "3.0.7" + version: "3.1.0" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface - sha256: "95465b39f83bfe95fcb9d174829d6476216f2d548b79c38ab2506e0458787618" + sha256: "980e8d9af422f477be6948bdfb68df8433be71f5743a188968b0c1b887807e50" url: "https://pub.dev" source: hosted - version: "2.1.5" + version: "2.2.0" url_launcher_web: dependency: transitive description: name: url_launcher_web - sha256: "2942294a500b4fa0b918685aff406773ba0a4cd34b7f42198742a94083020ce5" + sha256: "138bd45b3a456dcfafc46d1a146787424f8d2edfbf2809c9324361e58f851cf7" url: "https://pub.dev" source: hosted - version: "2.0.20" + version: "2.2.1" url_launcher_windows: dependency: transitive description: name: url_launcher_windows - sha256: "95fef3129dc7cfaba2bc3d5ba2e16063bb561fc6d78e63eee16162bc70029069" + sha256: "7754a1ad30ee896b265f8d14078b0513a4dba28d358eabb9d5f339886f4a1adc" url: "https://pub.dev" source: hosted - version: "3.0.8" + version: "3.1.0" uuid: dependency: transitive description: @@ -1040,10 +1056,10 @@ packages: dependency: "direct main" description: name: video_player - sha256: "74b86e63529cf5885130c639d74cd2f9232e7c8a66cbecbddd1dcb9dbd060d1e" + sha256: e16f0a83601a78d165dabc17e4dac50997604eb9e4cc76e10fa219046b70cef3 url: "https://pub.dev" source: hosted - version: "2.7.2" + version: "2.8.1" video_player_android: dependency: transitive description: @@ -1056,10 +1072,10 @@ packages: dependency: transitive description: name: video_player_avfoundation - sha256: "6387c2de77763b45104256b3b00b660089be4f909ded8631457dc11bf635e38f" + sha256: bc923884640d6dc403050586eb40713cdb8d1d84e6886d8aca50ab04c59124c2 url: "https://pub.dev" source: hosted - version: "2.5.0" + version: "2.5.2" video_player_platform_interface: dependency: transitive description: @@ -1072,10 +1088,10 @@ packages: dependency: transitive description: name: video_player_web - sha256: "2dd24f7ba46bfb5d070e9c795001db95e0ca5f2a3d025e98f287c10c9f0fd62f" + sha256: ab7a462b07d9ca80bed579e30fb3bce372468f1b78642e0911b10600f2c5cb5b url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" visibility_detector: dependency: transitive description: @@ -1128,10 +1144,10 @@ packages: dependency: transitive description: name: web - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 url: "https://pub.dev" source: hosted - version: "0.1.4-beta" + version: "0.3.0" webfeed: dependency: "direct main" description: @@ -1157,14 +1173,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.0" - workmanager: - dependency: "direct main" - description: - name: workmanager - sha256: ed13530cccd28c5c9959ad42d657cd0666274ca74c56dea0ca183ddd527d3a00 - url: "https://pub.dev" - source: hosted - version: "0.5.2" xdg_directories: dependency: transitive description: @@ -1177,10 +1185,10 @@ packages: dependency: transitive description: name: xml - sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84" + sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 url: "https://pub.dev" source: hosted - version: "6.3.0" + version: "6.5.0" youtube_explode_dart: dependency: "direct main" description: @@ -1190,5 +1198,5 @@ packages: source: hosted version: "1.12.4" sdks: - dart: ">=3.1.2 <3.4.4" - flutter: ">=3.13.0" + dart: ">=3.2.0 <3.4.4" + flutter: ">=3.16.0" diff --git a/pubspec.yaml b/pubspec.yaml index af7d0970..ba73ed94 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -30,12 +30,12 @@ dependencies: git: url: https://github.com/tintran-dev/betterplayer.git ref: master - cached_network_image: ^3.2.0 + cached_network_image: ^3.3.0 carousel_slider: ^4.1.1 connectivity_plus: ^4.0.2 dotted_line: ^3.2.2 flutter_cache_manager: ^3.3.0 - flutter_inappwebview: ^6.0.0-beta.23 + flutter_inappwebview: ^6.0.0-beta.31 flutter_localizations: sdk: flutter flutter_map: ^4.0.0 @@ -77,7 +77,7 @@ dependencies: git: url: https://github.com/marcjoha/webfeed.git ref: master - workmanager: ^0.5.1 + #workmanager: ^0.5.1 youtube_explode_dart: ^1.12.4 dev_dependencies: diff --git a/story_view/lib/controller/story_controller.dart b/story_view/lib/controller/story_controller.dart index e0b2b999..9636aa75 100644 --- a/story_view/lib/controller/story_controller.dart +++ b/story_view/lib/controller/story_controller.dart @@ -1,4 +1,3 @@ -// ignore: depend_on_referenced_packages import 'package:rxdart/rxdart.dart'; enum PlaybackState { pause, play, next, previous } diff --git a/story_view/lib/widgets/story_image.dart b/story_view/lib/widgets/story_image.dart index 309a0ef6..f88babd5 100644 --- a/story_view/lib/widgets/story_image.dart +++ b/story_view/lib/widgets/story_image.dart @@ -23,39 +23,38 @@ class ImageLoader { /// Load image from disk cache first, if not found then load from network. /// `onComplete` is called when [imageBytes] become available. void loadImage(VoidCallback onComplete) { - if (frames != null) { - state = LoadState.success; + if (this.frames != null) { + this.state = LoadState.success; onComplete(); } - final fileStream = DefaultCacheManager() - .getFileStream(url, headers: requestHeaders as Map?); + final fileStream = DefaultCacheManager().getFileStream(this.url, + headers: this.requestHeaders as Map?); fileStream.listen( (fileResponse) { - if (fileResponse is! FileInfo) return; + if (!(fileResponse is FileInfo)) return; // the reason for this is that, when the cache manager fetches // the image again from network, the provided `onComplete` should // not be called again - if (frames != null) { + if (this.frames != null) { return; } final imageBytes = fileResponse.file.readAsBytesSync(); - state = LoadState.success; + this.state = LoadState.success; - PaintingBinding.instance.instantiateImageCodec(imageBytes).then( - (codec) { - frames = codec; + ui.instantiateImageCodec(imageBytes).then((codec) { + this.frames = codec; onComplete(); }, onError: (error) { - state = LoadState.failure; + this.state = LoadState.failure; onComplete(); }); }, onError: (error) { - state = LoadState.failure; + this.state = LoadState.failure; onComplete(); }, ); @@ -113,7 +112,7 @@ class StoryImageState extends State { super.initState(); if (widget.controller != null) { - _streamSubscription = + this._streamSubscription = widget.controller!.playbackNotifier.listen((playbackState) { // for the case of gifs we need to pause/play if (widget.imageLoader.frames == null) { @@ -121,7 +120,7 @@ class StoryImageState extends State { } if (playbackState == PlaybackState.pause) { - _timer?.cancel(); + this._timer?.cancel(); } else { forward(); } @@ -159,7 +158,7 @@ class StoryImageState extends State { } void forward() async { - _timer?.cancel(); + this._timer?.cancel(); if (widget.controller != null && widget.controller!.playbackNotifier.stream.value == @@ -169,10 +168,10 @@ class StoryImageState extends State { final nextFrame = await widget.imageLoader.frames!.getNextFrame(); - currentFrame = nextFrame.image; + this.currentFrame = nextFrame.image; - if (nextFrame.duration > const Duration(milliseconds: 0)) { - _timer = Timer(nextFrame.duration, forward); + if (nextFrame.duration > Duration(milliseconds: 0)) { + this._timer = Timer(nextFrame.duration, forward); } setState(() {}); @@ -182,11 +181,11 @@ class StoryImageState extends State { switch (widget.imageLoader.state) { case LoadState.success: return RawImage( - image: currentFrame, + image: this.currentFrame, fit: widget.fit, ); case LoadState.failure: - return const Center( + return Center( child: Text( "Image failed to load.", style: TextStyle( @@ -194,8 +193,8 @@ class StoryImageState extends State { ), )); default: - return const Center( - child: SizedBox( + return Center( + child: Container( width: 70, height: 70, child: CircularProgressIndicator( @@ -209,7 +208,7 @@ class StoryImageState extends State { @override Widget build(BuildContext context) { - return SizedBox( + return Container( width: double.infinity, height: double.infinity, child: getContentView(), diff --git a/story_view/lib/widgets/story_video.dart b/story_view/lib/widgets/story_video.dart index a5807ef0..8924855b 100644 --- a/story_view/lib/widgets/story_video.dart +++ b/story_view/lib/widgets/story_video.dart @@ -20,19 +20,19 @@ class VideoLoader { VideoLoader(this.url, {this.requestHeaders}); void loadVideo(VoidCallback onComplete) { - if (videoFile != null) { - state = LoadState.success; + if (this.videoFile != null) { + this.state = LoadState.success; onComplete(); } final fileStream = DefaultCacheManager() - .getFileStream(url, headers: requestHeaders as Map?); + .getFileStream(this.url, headers: this.requestHeaders as Map?); fileStream.listen((fileResponse) { if (fileResponse is FileInfo) { - if (videoFile == null) { - state = LoadState.success; - videoFile = fileResponse.file; + if (this.videoFile == null) { + this.state = LoadState.success; + this.videoFile = fileResponse.file; onComplete(); } } @@ -79,7 +79,7 @@ class StoryVideoState extends State { widget.videoLoader.loadVideo(() { if (widget.videoLoader.state == LoadState.success) { - playerController = + this.playerController = VideoPlayerController.file(widget.videoLoader.videoFile!); playerController!.initialize().then((v) { @@ -115,8 +115,8 @@ class StoryVideoState extends State { } return widget.videoLoader.state == LoadState.loading - ? const Center( - child: SizedBox( + ? Center( + child: Container( width: 70, height: 70, child: CircularProgressIndicator( @@ -125,7 +125,7 @@ class StoryVideoState extends State { ), ), ) - : const Center( + : Center( child: Text( "Media failed to load.", style: TextStyle( diff --git a/story_view/lib/widgets/story_view.dart b/story_view/lib/widgets/story_view.dart index 1489c0d0..5b1bb169 100644 --- a/story_view/lib/widgets/story_view.dart +++ b/story_view/lib/widgets/story_view.dart @@ -78,7 +78,7 @@ class StoryItem { bottom: Radius.circular(roundedBottom ? 8 : 0), ), ), - padding: const EdgeInsets.symmetric( + padding: EdgeInsets.symmetric( horizontal: 24, vertical: 16, ), @@ -98,7 +98,7 @@ class StoryItem { //color: backgroundColor, ), shown: shown, - duration: duration ?? const Duration(seconds: 3), + duration: duration ?? Duration(seconds: 3), ); } @@ -131,10 +131,10 @@ class StoryItem { alignment: Alignment.bottomCenter, child: Container( width: double.infinity, - margin: const EdgeInsets.only( + margin: EdgeInsets.only( bottom: 24, ), - padding: const EdgeInsets.symmetric( + padding: EdgeInsets.symmetric( horizontal: 24, vertical: 8, ), @@ -142,13 +142,13 @@ class StoryItem { child: caption != null ? Text( caption, - style: const TextStyle( + style: TextStyle( fontSize: 15, color: Colors.white, ), textAlign: TextAlign.center, ) - : const SizedBox(), + : SizedBox(), ), ), ) @@ -156,7 +156,7 @@ class StoryItem { ), ), shown: shown, - duration: duration ?? const Duration(seconds: 3), + duration: duration ?? Duration(seconds: 3), ); } @@ -177,10 +177,6 @@ class StoryItem { return StoryItem( ClipRRect( key: key, - borderRadius: BorderRadius.vertical( - top: Radius.circular(roundedTop ? 8 : 0), - bottom: Radius.circular(roundedBottom ? 8 : 0), - ), child: Container( color: Colors.grey[100], child: Container( @@ -194,14 +190,13 @@ class StoryItem { requestHeaders: requestHeaders, ), Container( - margin: const EdgeInsets.only(bottom: 16), - padding: - const EdgeInsets.symmetric(horizontal: 24, vertical: 8), + margin: EdgeInsets.only(bottom: 16), + padding: EdgeInsets.symmetric(horizontal: 24, vertical: 8), child: Align( alignment: Alignment.bottomLeft, - child: SizedBox( + child: Container( + child: caption == null ? SizedBox() : caption, width: double.infinity, - child: caption ?? const SizedBox(), ), ), ), @@ -209,9 +204,13 @@ class StoryItem { ), ), ), + borderRadius: BorderRadius.vertical( + top: Radius.circular(roundedTop ? 8 : 0), + bottom: Radius.circular(roundedBottom ? 8 : 0), + ), ), shown: shown, - duration: duration ?? const Duration(seconds: 3), + duration: duration ?? Duration(seconds: 3), ); } @@ -243,19 +242,17 @@ class StoryItem { alignment: Alignment.bottomCenter, child: Container( width: double.infinity, - margin: const EdgeInsets.only(bottom: 24), - padding: - const EdgeInsets.symmetric(horizontal: 24, vertical: 8), + margin: EdgeInsets.only(bottom: 24), + padding: EdgeInsets.symmetric(horizontal: 24, vertical: 8), color: caption != null ? Colors.black54 : Colors.transparent, child: caption != null ? Text( caption, - style: const TextStyle( - fontSize: 15, color: Colors.white), + style: TextStyle(fontSize: 15, color: Colors.white), textAlign: TextAlign.center, ) - : const SizedBox(), + : SizedBox(), ), ), ) @@ -263,7 +260,7 @@ class StoryItem { ), ), shown: shown, - duration: duration ?? const Duration(seconds: 10)); + duration: duration ?? Duration(seconds: 10)); } /// Shorthand for creating a story item from an image provider such as `AssetImage` @@ -296,10 +293,10 @@ class StoryItem { alignment: Alignment.bottomCenter, child: Container( width: double.infinity, - margin: const EdgeInsets.only( + margin: EdgeInsets.only( bottom: 24, ), - padding: const EdgeInsets.symmetric( + padding: EdgeInsets.symmetric( horizontal: 24, vertical: 8, ), @@ -308,13 +305,13 @@ class StoryItem { child: caption != null ? Text( caption, - style: const TextStyle( + style: TextStyle( fontSize: 15, color: Colors.white, ), textAlign: TextAlign.center, ) - : const SizedBox(), + : SizedBox(), ), ), ) @@ -322,7 +319,7 @@ class StoryItem { ), ), shown: shown, - duration: duration ?? const Duration(seconds: 3)); + duration: duration ?? Duration(seconds: 3)); } /// Shorthand for creating an inline story item from an image provider such as `AssetImage` @@ -351,24 +348,24 @@ class StoryItem { fit: BoxFit.cover, )), child: Container( - margin: const EdgeInsets.only( + margin: EdgeInsets.only( bottom: 16, ), - padding: const EdgeInsets.symmetric( + padding: EdgeInsets.symmetric( horizontal: 24, vertical: 8, ), child: Align( alignment: Alignment.bottomLeft, - child: SizedBox( + child: Container( + child: caption == null ? SizedBox() : caption, width: double.infinity, - child: caption ?? const SizedBox(), ), ), ), ), shown: shown, - duration: duration ?? const Duration(seconds: 3), + duration: duration ?? Duration(seconds: 3), ); } } @@ -408,10 +405,11 @@ class StoryView extends StatefulWidget { final StoryController controller; // Indicator Color - final Color indicatorColor; + final Color? indicatorColor; + // Indicator Foreground Color + final Color? indicatorForegroundColor; - const StoryView({ - Key? key, + StoryView({ required this.storyItems, required this.controller, this.onComplete, @@ -420,8 +418,9 @@ class StoryView extends StatefulWidget { this.repeat = false, this.inline = false, this.onVerticalSwipeComplete, - this.indicatorColor = Colors.white, - }) : super(key: key); + this.indicatorColor, + this.indicatorForegroundColor, + }); @override State createState() { @@ -456,9 +455,9 @@ class StoryViewState extends State with TickerProviderStateMixin { // false final firstPage = widget.storyItems.firstWhereOrNull((it) => !it!.shown); if (firstPage == null) { - for (var it2 in widget.storyItems) { + widget.storyItems.forEach((it2) { it2!.shown = false; - } + }); } else { final lastShownPos = widget.storyItems.indexOf(firstPage); widget.storyItems.sublist(lastShownPos).forEach((it) { @@ -466,17 +465,17 @@ class StoryViewState extends State with TickerProviderStateMixin { }); } - _playbackSubscription = + this._playbackSubscription = widget.controller.playbackNotifier.listen((playbackStatus) { switch (playbackStatus) { case PlaybackState.play: _removeNextHold(); - _animationController?.forward(); + this._animationController?.forward(); break; case PlaybackState.pause: _holdNext(); // then pause animation - _animationController?.stop(canceled: false); + this._animationController?.stop(canceled: false); break; case PlaybackState.next: @@ -555,9 +554,9 @@ class StoryViewState extends State with TickerProviderStateMixin { } if (widget.repeat) { - for (var it in widget.storyItems) { + widget.storyItems.forEach((it) { it!.shown = false; - } + }); _beginPlay(); } @@ -566,15 +565,15 @@ class StoryViewState extends State with TickerProviderStateMixin { void _goBack() { _animationController!.stop(); - if (_currentStory == null) { + if (this._currentStory == null) { widget.storyItems.last!.shown = false; } - if (_currentStory == widget.storyItems.first) { + if (this._currentStory == widget.storyItems.first) { _beginPlay(); } else { - _currentStory!.shown = false; - int lastPos = widget.storyItems.indexOf(_currentStory); + this._currentStory!.shown = false; + int lastPos = widget.storyItems.indexOf(this._currentStory); final previous = widget.storyItems[lastPos - 1]!; previous.shown = false; @@ -584,22 +583,22 @@ class StoryViewState extends State with TickerProviderStateMixin { } void _goForward() { - if (_currentStory != widget.storyItems.last) { + if (this._currentStory != widget.storyItems.last) { _animationController!.stop(); // get last showing - final last = _currentStory; + final _last = this._currentStory; - if (last != null) { - last.shown = true; - if (last != widget.storyItems.last) { + if (_last != null) { + _last.shown = true; + if (_last != widget.storyItems.last) { _beginPlay(); } } } else { // this is the last page, progress animation should skip to end _animationController! - .animateTo(1.0, duration: const Duration(milliseconds: 10)); + .animateTo(1.0, duration: Duration(milliseconds: 10)); } } @@ -615,7 +614,7 @@ class StoryViewState extends State with TickerProviderStateMixin { void _holdNext() { _nextDebouncer?.cancel(); - _nextDebouncer = Timer(const Duration(milliseconds: 500), () {}); + _nextDebouncer = Timer(Duration(milliseconds: 500), () {}); } @override @@ -635,7 +634,7 @@ class StoryViewState extends State with TickerProviderStateMixin { bottom: widget.inline ? false : true, // we use SafeArea here for notched and bezeles phones child: Container( - padding: const EdgeInsets.symmetric( + padding: EdgeInsets.symmetric( horizontal: 16, vertical: 8, ), @@ -643,30 +642,21 @@ class StoryViewState extends State with TickerProviderStateMixin { widget.storyItems .map((it) => PageData(it!.duration, it.shown)) .toList(), - _currentAnimation, + this._currentAnimation, key: UniqueKey(), indicatorHeight: widget.inline ? IndicatorHeight.small : IndicatorHeight.large, indicatorColor: widget.indicatorColor, + indicatorForegroundColor: widget.indicatorForegroundColor, ), ), ), ), ), - Align( - alignment: Alignment.centerLeft, - child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: _goBack, - child: const SizedBox( - height: double.infinity, - width: 80, - ), - ), - ), Align( alignment: Alignment.centerRight, + heightFactor: 1, child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: _goForward, @@ -697,13 +687,15 @@ class PageBar extends StatefulWidget { final List pages; final Animation? animation; final IndicatorHeight indicatorHeight; - final Color indicatorColor; + final Color? indicatorColor; + final Color? indicatorForegroundColor; - const PageBar( + PageBar( this.pages, this.animation, { this.indicatorHeight = IndicatorHeight.large, - this.indicatorColor = Colors.white, + this.indicatorColor, + this.indicatorForegroundColor, Key? key, }) : super(key: key); @@ -745,13 +737,14 @@ class PageBarState extends State { children: widget.pages.map((it) { return Expanded( child: Container( - padding: - EdgeInsets.only(right: widget.pages.last == it ? 0 : spacing), + padding: EdgeInsets.only( + right: widget.pages.last == it ? 0 : this.spacing), child: StoryProgressIndicator( isPlaying(it) ? widget.animation!.value : (it.shown ? 1 : 0), indicatorHeight: widget.indicatorHeight == IndicatorHeight.large ? 5 : 3, indicatorColor: widget.indicatorColor, + indicatorForegroundColor: widget.indicatorForegroundColor, ), ), ); @@ -766,27 +759,28 @@ class StoryProgressIndicator extends StatelessWidget { /// From `0.0` to `1.0`, determines the progress of the indicator final double value; final double indicatorHeight; - final Color indicatorColor; + final Color? indicatorColor; + final Color? indicatorForegroundColor; - const StoryProgressIndicator( + StoryProgressIndicator( this.value, { - Key? key, this.indicatorHeight = 5, - this.indicatorColor = Colors.white, - }) : super(key: key); + this.indicatorColor, + this.indicatorForegroundColor, + }); @override Widget build(BuildContext context) { return CustomPaint( size: Size.fromHeight( - indicatorHeight, + this.indicatorHeight, ), foregroundPainter: IndicatorOval( - indicatorColor.withOpacity(0.8), - value, + this.indicatorForegroundColor ?? Colors.white.withOpacity(0.8), + this.value, ), painter: IndicatorOval( - indicatorColor.withOpacity(0.4), + this.indicatorColor ?? Colors.white.withOpacity(0.4), 1.0, ), ); @@ -801,11 +795,11 @@ class IndicatorOval extends CustomPainter { @override void paint(Canvas canvas, Size size) { - final paint = Paint()..color = color; + final paint = Paint()..color = this.color; canvas.drawRRect( RRect.fromRectAndRadius( - Rect.fromLTWH(0, 0, size.width * widthFactor, size.height), - const Radius.circular(3)), + Rect.fromLTWH(0, 0, size.width * this.widthFactor, size.height), + Radius.circular(3)), paint); } diff --git a/web/index.html b/web/index.html index 12619ef9..5c2504fd 100644 --- a/web/index.html +++ b/web/index.html @@ -18,8 +18,8 @@ Box, Box! - + +