├── linux ├── .gitignore ├── main.cc ├── flutter │ ├── generated_plugin_registrant.h │ ├── generated_plugin_registrant.cc │ ├── generated_plugins.cmake │ └── CMakeLists.txt ├── my_application.h ├── my_application.cc └── CMakeLists.txt ├── lib ├── features │ ├── home │ │ ├── view │ │ │ ├── view.dart │ │ │ └── home_page.dart │ │ ├── home.dart │ │ └── cubit │ │ │ ├── home_state.dart │ │ │ └── home_cubit.dart │ └── detail │ │ ├── core │ │ ├── data │ │ │ ├── constants.dart │ │ │ ├── detail_local_service.dart │ │ │ ├── detail_dto.dart │ │ │ ├── detail_remote_service.dart │ │ │ └── detail_dto.g.dart │ │ └── domain │ │ │ └── detail.dart │ │ ├── dart_detail │ │ ├── data │ │ │ ├── dart_detail_local_service.dart │ │ │ ├── dart_detail_remote_service.dart │ │ │ └── dart_detail_repository.dart │ │ ├── application │ │ │ ├── dart_detail_event.dart │ │ │ ├── dart_detail_state.dart │ │ │ └── dart_detail_bloc.dart │ │ └── presentation │ │ │ └── view │ │ │ └── dart_changelog_page.dart │ │ └── flutter_detail │ │ ├── data │ │ ├── flutter_detail_local_service.dart │ │ ├── flutter_detail_remote_service.dart │ │ └── flutter_detail_repository.dart │ │ ├── application │ │ ├── flutter_detail_event.dart │ │ ├── flutter_detail_state.dart │ │ └── flutter_detail_bloc.dart │ │ └── presentation │ │ └── view │ │ ├── flutter_whats_new_page.dart │ │ ├── flutter_release_notes_page.dart │ │ ├── flutter_detail_page.dart │ │ └── flutter_detail_common.dart ├── core │ ├── data │ │ ├── id.dart │ │ ├── data.dart │ │ ├── dio_extension.dart │ │ ├── utils.dart │ │ ├── isar_database.dart │ │ ├── github_header.dart │ │ ├── remote_response.dart │ │ └── github_header_cache.dart │ ├── presentation │ │ ├── assets_path.dart │ │ ├── responsive.dart │ │ ├── no_results_display.dart │ │ ├── no_connection_toast.dart │ │ └── lazy_indexed_stack.dart │ └── domain │ │ ├── failure.dart │ │ └── fresh.dart ├── app │ ├── app_bloc_observer.dart │ └── app.dart ├── main.dart └── bootstrap.dart ├── ios ├── Runner │ ├── Runner-Bridging-Header.h │ ├── Assets.xcassets │ │ ├── LaunchImage.imageset │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ ├── README.md │ │ │ └── Contents.json │ │ └── AppIcon.appiconset │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ └── Contents.json │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard │ └── Info.plist ├── Flutter │ ├── Debug.xcconfig │ ├── Release.xcconfig │ └── AppFrameworkInfo.plist ├── Runner.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── WorkspaceSettings.xcsettings │ │ └── IDEWorkspaceChecks.plist ├── .gitignore ├── Podfile.lock └── Podfile ├── web ├── favicon.png ├── icons │ ├── Icon-192.png │ ├── Icon-512.png │ ├── Icon-maskable-192.png │ └── Icon-maskable-512.png ├── manifest.json └── index.html ├── assets ├── icon_dart.svg.vec └── icon_flutter.svg.vec ├── android ├── gradle.properties ├── app │ ├── src │ │ ├── main │ │ │ ├── res │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── drawable │ │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable-v21 │ │ │ │ │ └── launch_background.xml │ │ │ │ ├── values │ │ │ │ │ └── styles.xml │ │ │ │ └── values-night │ │ │ │ │ └── styles.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── now_in_dart_flutter │ │ │ │ │ └── MainActivity.kt │ │ │ └── AndroidManifest.xml │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ └── profile │ │ │ └── AndroidManifest.xml │ └── build.gradle ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle └── build.gradle ├── macos ├── Runner │ ├── Configs │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ ├── Warnings.xcconfig │ │ └── AppInfo.xcconfig │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ ├── app_icon_1024.png │ │ │ ├── app_icon_128.png │ │ │ ├── app_icon_16.png │ │ │ ├── app_icon_256.png │ │ │ ├── app_icon_32.png │ │ │ ├── app_icon_512.png │ │ │ ├── app_icon_64.png │ │ │ └── Contents.json │ ├── AppDelegate.swift │ ├── Release.entitlements │ ├── DebugProfile.entitlements │ ├── MainFlutterWindow.swift │ └── Info.plist ├── .gitignore ├── Flutter │ ├── Flutter-Debug.xcconfig │ ├── Flutter-Release.xcconfig │ └── GeneratedPluginRegistrant.swift ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── Runner.xcodeproj │ ├── project.xcworkspace │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme └── Podfile ├── windows ├── runner │ ├── resources │ │ └── app_icon.ico │ ├── resource.h │ ├── utils.h │ ├── runner.exe.manifest │ ├── flutter_window.h │ ├── main.cpp │ ├── CMakeLists.txt │ ├── utils.cpp │ ├── flutter_window.cpp │ ├── Runner.rc │ ├── win32_window.h │ └── win32_window.cpp ├── .gitignore ├── flutter │ ├── generated_plugin_registrant.h │ ├── generated_plugin_registrant.cc │ ├── generated_plugins.cmake │ └── CMakeLists.txt └── CMakeLists.txt ├── .github └── ISSUE_TEMPLATE │ ├── todo.md │ ├── feature_request.md │ └── bug_report.md ├── test ├── helpers │ ├── fakes.dart │ ├── register_multiple_fallback_values.dart │ └── mocks.dart └── features │ └── detail │ └── core │ └── data │ ├── detail_local_service_test.dart │ └── detail_remote_service_test.dart ├── analysis_options.yaml ├── .gitignore ├── pubspec.yaml ├── LICENSE ├── .metadata └── README.md /linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /lib/features/home/view/view.dart: -------------------------------------------------------------------------------- 1 | export 'home_page.dart'; 2 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /lib/features/home/home.dart: -------------------------------------------------------------------------------- 1 | export 'cubit/home_cubit.dart'; 2 | export 'view/view.dart'; 3 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/web/icons/Icon-512.png -------------------------------------------------------------------------------- /assets/icon_dart.svg.vec: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/assets/icon_dart.svg.vec -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /assets/icon_flutter.svg.vec: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/assets/icon_flutter.svg.vec -------------------------------------------------------------------------------- /macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/todo.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Todo 3 | about: Need to work on this task 4 | title: TODO 5 | labels: todo 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /lib/core/data/id.dart: -------------------------------------------------------------------------------- 1 | abstract class EntityId { 2 | static const dartChangelogDetail = 1; 3 | static const flutterWhatsNewDetail = 2; 4 | static const flutterReleaseNotesDetail = 3; 5 | } 6 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Biplab-Dutta/now-in-dart-flutter/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /lib/core/data/data.dart: -------------------------------------------------------------------------------- 1 | export 'dio_extension.dart'; 2 | export 'github_header.dart'; 3 | export 'github_header_cache.dart'; 4 | export 'isar_database.dart'; 5 | export 'remote_response.dart'; 6 | export 'utils.dart'; 7 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/now_in_dart_flutter/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.now_in_dart_flutter 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /lib/core/data/dio_extension.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | 3 | extension DioExceptionExtension on DioException { 4 | bool get isNoConnectionError { 5 | return type == DioExceptionType.connectionError; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/helpers/fakes.dart: -------------------------------------------------------------------------------- 1 | part of 'mocks.dart'; 2 | 3 | class FakeUri extends Fake implements Uri {} 4 | 5 | class FakeOptions extends Fake implements Options {} 6 | 7 | class FakeGithubHeader extends Fake implements GithubHeader {} 8 | -------------------------------------------------------------------------------- /test/helpers/register_multiple_fallback_values.dart: -------------------------------------------------------------------------------- 1 | import 'package:mocktail/mocktail.dart'; 2 | 3 | void registerMultipleFallbackValues(List values) { 4 | for (final value in values) { 5 | registerFallbackValue(value); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip 6 | -------------------------------------------------------------------------------- /lib/core/presentation/assets_path.dart: -------------------------------------------------------------------------------- 1 | abstract class AssetsPath { 2 | /// assets/icon_dart.svg.vec 3 | static const dartIcon = 'assets/icon_dart.svg.vec'; 4 | 5 | /// assets/icon_flutter.svg.vec 6 | static const flutterIcon = 'assets/icon_flutter.svg.vec'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/features/home/cubit/home_state.dart: -------------------------------------------------------------------------------- 1 | part of 'home_cubit.dart'; 2 | 3 | class HomeState extends Equatable { 4 | const HomeState({ 5 | this.index = 0, 6 | }); 7 | 8 | final int index; 9 | 10 | @override 11 | List get props => [index]; 12 | } 13 | -------------------------------------------------------------------------------- /macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/features/home/cubit/home_cubit.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | 4 | part 'home_state.dart'; 5 | 6 | class HomeCubit extends Cubit { 7 | HomeCubit() : super(const HomeState()); 8 | 9 | void setTab(int index) => emit(HomeState(index: index)); 10 | } 11 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /lib/core/data/utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:now_in_dart_flutter/core/domain/failure.dart'; 3 | 4 | IOEither uriParser(String uri) { 5 | return IOEither.tryCatch( 6 | () => Uri.parse(uri), 7 | (e, stackTrace) => UriParserFailure( 8 | 'Invalid Uri string', 9 | errorObject: e, 10 | stackTrace: stackTrace, 11 | ), 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:very_good_analysis/analysis_options.yaml 2 | 3 | linter: 4 | rules: 5 | public_member_api_docs: false 6 | avoid_private_typedef_functions: false 7 | library_private_types_in_public_api: false 8 | sort_pub_dependencies: false 9 | avoid_multiple_declarations_per_line: false 10 | 11 | analyzer: 12 | exclude: 13 | - '**/*.g.dart' 14 | - '**/*.freezed.dart' 15 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /lib/features/detail/core/data/constants.dart: -------------------------------------------------------------------------------- 1 | /// repos/flutter/website/contents/src/release/whats-new.md 2 | const flutterWhatsNewPath = 3 | 'repos/flutter/website/contents/src/release/whats-new.md'; 4 | 5 | /// repos/flutter/website/contents/src/release/release-notes/index.md 6 | const flutterReleaseNotesPath = 7 | 'repos/flutter/website/contents/src/release/release-notes/index.md'; 8 | 9 | /// repos/dart-lang/sdk/contents/CHANGELOG.md 10 | const dartChangelogPath = 'repos/dart-lang/sdk/contents/CHANGELOG.md'; 11 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/app/app_bloc_observer.dart: -------------------------------------------------------------------------------- 1 | import 'dart:developer'; 2 | 3 | import 'package:flutter_bloc/flutter_bloc.dart'; 4 | 5 | class AppBlocObserver extends BlocObserver { 6 | @override 7 | void onChange(BlocBase bloc, Change change) { 8 | super.onChange(bloc, change); 9 | log('onChange(${bloc.runtimeType}, change)'); 10 | } 11 | 12 | @override 13 | void onError(BlocBase bloc, Object error, StackTrace stackTrace) { 14 | log('onError(${bloc.runtimeType}, error, stackTrace)'); 15 | super.onError(bloc, error, stackTrace); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/features/detail/dart_detail/data/dart_detail_local_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:now_in_dart_flutter/features/detail/core/data/detail_dto.dart'; 3 | import 'package:now_in_dart_flutter/features/detail/core/data/detail_local_service.dart'; 4 | 5 | class DartDetailLocalService extends DetailLocalService { 6 | DartDetailLocalService({super.isarDb}); 7 | 8 | Task upsertDartDetail(DetailDTO detailDTO) { 9 | return super.upsertDetail(detailDTO); 10 | } 11 | 12 | Task getDartDetail(int id) => super.getDetail(id); 13 | } 14 | -------------------------------------------------------------------------------- /lib/features/detail/dart_detail/application/dart_detail_event.dart: -------------------------------------------------------------------------------- 1 | part of 'dart_detail_bloc.dart'; 2 | 3 | sealed class DartDetailEvent { 4 | const DartDetailEvent(); 5 | } 6 | 7 | class DartChangelogDetailRequested extends DartDetailEvent { 8 | const DartChangelogDetailRequested(this.id); 9 | 10 | final int id; 11 | } 12 | 13 | extension DartDetailEventExt on DartDetailEvent { 14 | A when({required A Function(int) changelogDetailRequested}) { 15 | return switch (this) { 16 | DartChangelogDetailRequested(:final id) => changelogDetailRequested(id), 17 | }; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | 12 | void RegisterPlugins(flutter::PluginRegistry* registry) { 13 | IsarFlutterLibsPluginRegisterWithRegistrar( 14 | registry->GetRegistrarForPlugin("IsarFlutterLibsPlugin")); 15 | UrlLauncherWindowsRegisterWithRegistrar( 16 | registry->GetRegistrarForPlugin("UrlLauncherWindows")); 17 | } 18 | -------------------------------------------------------------------------------- /lib/features/detail/flutter_detail/data/flutter_detail_local_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:now_in_dart_flutter/features/detail/core/data/detail_dto.dart'; 3 | import 'package:now_in_dart_flutter/features/detail/core/data/detail_local_service.dart'; 4 | 5 | class FlutterDetailLocalService extends DetailLocalService { 6 | FlutterDetailLocalService({super.isarDb}); 7 | 8 | Task upsertFlutterDetail(DetailDTO detailDTO) { 9 | return super.upsertDetail(detailDTO); 10 | } 11 | 12 | Task getFlutterDetail(int id) => super.getDetail(id); 13 | } 14 | -------------------------------------------------------------------------------- /macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import isar_flutter_libs 9 | import path_provider_foundation 10 | import url_launcher_macos 11 | 12 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 13 | IsarFlutterLibsPlugin.register(with: registry.registrar(forPlugin: "IsarFlutterLibsPlugin")) 14 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 15 | UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) 16 | } 17 | -------------------------------------------------------------------------------- /lib/features/detail/core/domain/detail.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | class Detail extends Equatable { 4 | const Detail({required this.html}); 5 | 6 | final String html; 7 | 8 | /// An empty detail used to represent null detail. 9 | 10 | // This pattern helps us to work with concrete domain level entities and 11 | // avoid nulls. 12 | static const empty = Detail(html: ''); 13 | 14 | /// Convenience getter to determine whether the current detail is empty. 15 | bool get isEmpty => this == Detail.empty; 16 | 17 | @override 18 | List get props => [html]; 19 | } 20 | -------------------------------------------------------------------------------- /lib/core/presentation/responsive.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class Responsive extends StatelessWidget { 4 | const Responsive({ 5 | required this.mobile, 6 | required this.tabletOrDesktop, 7 | super.key, 8 | }); 9 | 10 | final Widget mobile, tabletOrDesktop; 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return LayoutBuilder( 15 | builder: (context, constraints) { 16 | if (constraints.maxWidth < 650) { 17 | return mobile; 18 | } else { 19 | return tabletOrDesktop; 20 | } 21 | }, 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = now_in_dart_flutter 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.nowInDartFlutter 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2022 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.9.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.4.2' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | tasks.register("clean", Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /lib/features/detail/dart_detail/data/dart_detail_remote_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:now_in_dart_flutter/core/data/remote_response.dart'; 3 | import 'package:now_in_dart_flutter/core/domain/failure.dart'; 4 | import 'package:now_in_dart_flutter/features/detail/core/data/constants.dart'; 5 | import 'package:now_in_dart_flutter/features/detail/core/data/detail_remote_service.dart'; 6 | 7 | typedef _DartDetail = TaskEither>; 8 | 9 | class DartDetailRemoteService extends DetailRemoteService { 10 | DartDetailRemoteService({ 11 | super.dio, 12 | super.headerCache, 13 | }); 14 | 15 | _DartDetail getDartChangelogDetail(int id) { 16 | return super.getDetail(id, dartChangelogPath); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | 12 | void fl_register_plugins(FlPluginRegistry* registry) { 13 | g_autoptr(FlPluginRegistrar) isar_flutter_libs_registrar = 14 | fl_plugin_registry_get_registrar_for_plugin(registry, "IsarFlutterLibsPlugin"); 15 | isar_flutter_libs_plugin_register_with_registrar(isar_flutter_libs_registrar); 16 | g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = 17 | fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); 18 | url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); 19 | } 20 | -------------------------------------------------------------------------------- /lib/core/domain/failure.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | sealed class Failure extends Equatable { 4 | const Failure(this.message, {this.code, this.stackTrace, this.errorObject}); 5 | 6 | final String message; 7 | final int? code; 8 | final Object? errorObject; 9 | final StackTrace? stackTrace; 10 | } 11 | 12 | class ApiFailure extends Failure { 13 | const ApiFailure( 14 | super.message, { 15 | super.code, 16 | super.stackTrace, 17 | super.errorObject, 18 | }); 19 | 20 | @override 21 | List get props => [message, code, stackTrace, errorObject]; 22 | } 23 | 24 | class UriParserFailure extends Failure { 25 | const UriParserFailure(super.message, {super.errorObject, super.stackTrace}); 26 | 27 | @override 28 | List get props => [message, errorObject, stackTrace]; 29 | } 30 | -------------------------------------------------------------------------------- /lib/core/presentation/no_results_display.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class NoResultsDisplay extends StatelessWidget { 4 | const NoResultsDisplay({ 5 | required this.message, 6 | super.key, 7 | }); 8 | 9 | final String message; 10 | 11 | @override 12 | Widget build(BuildContext context) { 13 | return Container( 14 | padding: const EdgeInsets.all(8), 15 | alignment: Alignment.center, 16 | child: Column( 17 | mainAxisSize: MainAxisSize.min, 18 | children: [ 19 | const Icon( 20 | Icons.hourglass_empty, 21 | size: 96, 22 | ), 23 | Text( 24 | message, 25 | style: Theme.of(context).textTheme.headlineSmall, 26 | textAlign: TextAlign.center, 27 | ), 28 | ], 29 | ), 30 | ); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 11.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | isar_flutter_libs 7 | url_launcher_linux 8 | ) 9 | 10 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 11 | ) 12 | 13 | set(PLUGIN_BUNDLED_LIBRARIES) 14 | 15 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 16 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 17 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 20 | endforeach(plugin) 21 | 22 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 23 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 25 | endforeach(ffi_plugin) 26 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | isar_flutter_libs 7 | url_launcher_windows 8 | ) 9 | 10 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 11 | ) 12 | 13 | set(PLUGIN_BUNDLED_LIBRARIES) 14 | 15 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 16 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 17 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 20 | endforeach(plugin) 21 | 22 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 23 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 25 | endforeach(ffi_plugin) 26 | -------------------------------------------------------------------------------- /lib/features/detail/flutter_detail/data/flutter_detail_remote_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:now_in_dart_flutter/core/data/remote_response.dart'; 3 | import 'package:now_in_dart_flutter/core/domain/failure.dart'; 4 | import 'package:now_in_dart_flutter/features/detail/core/data/constants.dart'; 5 | import 'package:now_in_dart_flutter/features/detail/core/data/detail_remote_service.dart'; 6 | 7 | typedef _FlutterDetail = TaskEither>; 8 | 9 | class FlutterDetailRemoteService extends DetailRemoteService { 10 | FlutterDetailRemoteService({ 11 | super.dio, 12 | super.headerCache, 13 | }); 14 | 15 | _FlutterDetail getWhatsNewFlutterDetail(int id) { 16 | return super.getDetail(id, flutterWhatsNewPath); 17 | } 18 | 19 | _FlutterDetail getFlutterReleaseNotesDetail(int id) { 20 | return super.getDetail(id, flutterReleaseNotesPath); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | .vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Symbolication related 36 | app.*.symbols 37 | 38 | # Obfuscation related 39 | app.*.map.json 40 | 41 | # Android Studio will place build artifacts here 42 | /android/app/debug 43 | /android/app/profile 44 | /android/app/release 45 | 46 | # Isar specific 47 | libisar.so 48 | coverage -------------------------------------------------------------------------------- /lib/core/data/isar_database.dart: -------------------------------------------------------------------------------- 1 | import 'package:isar/isar.dart'; 2 | import 'package:now_in_dart_flutter/core/data/github_header.dart'; 3 | import 'package:now_in_dart_flutter/features/detail/core/data/detail_dto.dart'; 4 | import 'package:path_provider/path_provider.dart'; 5 | 6 | class IsarDatabase { 7 | factory IsarDatabase() => _isarDatabase; 8 | IsarDatabase._internal(); 9 | 10 | static final _isarDatabase = IsarDatabase._internal(); 11 | 12 | late Isar _instance; 13 | 14 | Isar get instance => _instance; 15 | 16 | /// Initializes the isar database. 17 | /// 18 | /// This method needs to be called before accessing any isar-specific APIs. 19 | Future init() async { 20 | final dir = await getApplicationDocumentsDirectory(); 21 | if (Isar.instanceNames.isNotEmpty) return; 22 | _instance = await Isar.open( 23 | [GithubHeaderSchema, DetailDTOSchema], 24 | directory: dir.path, 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/core/presentation/no_connection_toast.dart: -------------------------------------------------------------------------------- 1 | import 'package:flash/flash.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | Future showNoConnectionToast( 5 | String message, 6 | BuildContext context, 7 | ) async { 8 | await showFlash( 9 | context: context, 10 | duration: const Duration(seconds: 2), 11 | builder: (context, controller) { 12 | return FlashBar( 13 | controller: controller, 14 | backgroundColor: Colors.black.withOpacity(0.7), 15 | shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), 16 | margin: const EdgeInsets.all(8), 17 | content: Padding( 18 | padding: const EdgeInsets.all(8), 19 | child: Text( 20 | message, 21 | style: const TextStyle( 22 | color: Colors.white, 23 | fontSize: 16, 24 | ), 25 | ), 26 | ), 27 | ); 28 | }, 29 | ); 30 | } 31 | -------------------------------------------------------------------------------- /windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /lib/features/detail/flutter_detail/application/flutter_detail_event.dart: -------------------------------------------------------------------------------- 1 | part of 'flutter_detail_bloc.dart'; 2 | 3 | sealed class FlutterDetailEvent { 4 | const FlutterDetailEvent(); 5 | } 6 | 7 | class FlutterWhatsNewDetailRequested extends FlutterDetailEvent { 8 | const FlutterWhatsNewDetailRequested(this.id); 9 | 10 | final int id; 11 | } 12 | 13 | class FlutterReleaseNotesDetailRequested extends FlutterDetailEvent { 14 | const FlutterReleaseNotesDetailRequested(this.id); 15 | 16 | final int id; 17 | } 18 | 19 | extension FlutterDetailEventExt on FlutterDetailEvent { 20 | A when({ 21 | required A Function(int) flutterWhatsNewDetailRequested, 22 | required A Function(int) flutterReleaseNotesDetailRequested, 23 | }) { 24 | return switch (this) { 25 | FlutterWhatsNewDetailRequested(:final id) => 26 | flutterWhatsNewDetailRequested(id), 27 | FlutterReleaseNotesDetailRequested(:final id) => 28 | flutterReleaseNotesDetailRequested(id), 29 | }; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: now_in_dart_flutter 2 | description: A simple app that uses WebView under the hood to display all the news and updates regarding Dart and Flutter. The information is retrieved using GitHub's API and the github repository used as source is that of Flutter and Dart's. 3 | 4 | publish_to: "none" 5 | 6 | version: 2.0.1 7 | 8 | environment: 9 | sdk: ">=3.1.0 <4.0.0" 10 | 11 | dependencies: 12 | flutter: 13 | sdk: flutter 14 | 15 | dio: ^5.4.0 16 | equatable: ^2.0.5 17 | flash: ^3.0.5+1 18 | flutter_bloc: ^8.1.3 19 | flutter_svg: ^2.0.9 20 | fpdart: ^1.1.0 21 | isar: ^3.1.0+1 22 | isar_flutter_libs: ^3.1.0+1 23 | meta: ^1.10.0 24 | url_launcher: ^6.2.2 25 | webview_flutter: ^4.4.2 26 | path_provider: ^2.1.1 27 | vector_graphics: ^1.1.9+1 28 | 29 | dev_dependencies: 30 | build_runner: ^2.4.7 31 | flutter_lints: ^3.0.1 32 | mocktail: ^1.0.2 33 | test: ^1.25.0 34 | very_good_analysis: ^5.1.0 35 | 36 | flutter: 37 | uses-material-design: true 38 | assets: 39 | - assets/ 40 | -------------------------------------------------------------------------------- /lib/features/detail/dart_detail/application/dart_detail_state.dart: -------------------------------------------------------------------------------- 1 | part of 'dart_detail_bloc.dart'; 2 | 3 | enum DartDetailStatus { initial, loading, success, failure } 4 | 5 | class DartDetailState extends Equatable { 6 | const DartDetailState({ 7 | this.status = DartDetailStatus.initial, 8 | this.detail = const Fresh.yes(entity: Detail.empty), 9 | this.failureMessage, 10 | }); 11 | 12 | final DartDetailStatus status; 13 | final Fresh detail; 14 | final String? failureMessage; 15 | 16 | DartDetailState copyWith({ 17 | DartDetailStatus Function()? status, 18 | Fresh Function()? detail, 19 | String? Function()? failureMessage, 20 | }) { 21 | return DartDetailState( 22 | status: status != null ? status() : this.status, 23 | detail: detail != null ? detail() : this.detail, 24 | failureMessage: 25 | failureMessage != null ? failureMessage() : this.failureMessage, 26 | ); 27 | } 28 | 29 | @override 30 | List get props => [status, detail, failureMessage]; 31 | } 32 | -------------------------------------------------------------------------------- /lib/features/detail/flutter_detail/presentation/view/flutter_whats_new_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:now_in_dart_flutter/core/data/id.dart'; 3 | import 'package:now_in_dart_flutter/features/detail/flutter_detail/application/flutter_detail_bloc.dart'; 4 | import 'package:now_in_dart_flutter/features/detail/flutter_detail/presentation/view/flutter_detail_common.dart'; 5 | 6 | class FlutterWhatsNewPage extends StatefulWidget { 7 | const FlutterWhatsNewPage({super.key}); 8 | 9 | @override 10 | State createState() => _FlutterWhatsNewPageState(); 11 | } 12 | 13 | class _FlutterWhatsNewPageState extends State 14 | with AutomaticKeepAliveClientMixin { 15 | @override 16 | Widget build(BuildContext context) { 17 | super.build(context); 18 | return const FlutterDetailCommonPage( 19 | event: FlutterWhatsNewDetailRequested( 20 | EntityId.flutterWhatsNewDetail, 21 | ), 22 | ); 23 | } 24 | 25 | @override 26 | bool get wantKeepAlive => true; 27 | } 28 | -------------------------------------------------------------------------------- /lib/core/data/github_header.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | import 'package:equatable/equatable.dart'; 3 | import 'package:isar/isar.dart'; 4 | 5 | part 'github_header.g.dart'; 6 | 7 | @Collection(inheritance: false) 8 | class GithubHeader extends Equatable { 9 | const GithubHeader({ 10 | required this.id, 11 | required this.eTag, 12 | required this.path, 13 | }); 14 | 15 | factory GithubHeader.parse(int id, Response response, String path) { 16 | return GithubHeader( 17 | id: id, 18 | eTag: response.headers.map['ETag']![0], 19 | path: path, 20 | ); 21 | } 22 | 23 | final String eTag; 24 | 25 | // We are only making `path` a property of this class because we want to make 26 | // a query using path value. If Isar supports key-value storage mechanism too 27 | // in the future, then the `path` property can be removed from this file. 28 | 29 | @Index(unique: true) 30 | final String path; 31 | 32 | final Id id; 33 | 34 | @ignore 35 | @override 36 | List get props => [id, eTag, path]; 37 | } 38 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:now_in_dart_flutter/app/app.dart'; 2 | import 'package:now_in_dart_flutter/bootstrap.dart'; 3 | import 'package:now_in_dart_flutter/features/detail/dart_detail/data/dart_detail_remote_service.dart'; 4 | import 'package:now_in_dart_flutter/features/detail/dart_detail/data/dart_detail_repository.dart'; 5 | import 'package:now_in_dart_flutter/features/detail/flutter_detail/data/flutter_detail_remote_service.dart'; 6 | import 'package:now_in_dart_flutter/features/detail/flutter_detail/data/flutter_detail_repository.dart'; 7 | 8 | void main() { 9 | bootstrap( 10 | (dio) { 11 | final dartDetailRepository = DartDetailRepository( 12 | remoteService: DartDetailRemoteService(dio: dio), 13 | ); 14 | 15 | final flutterDetailRepository = FlutterDetailRepository( 16 | remoteService: FlutterDetailRemoteService(dio: dio), 17 | ); 18 | 19 | return App( 20 | dartDetailRepository: dartDetailRepository, 21 | flutterDetailRepository: flutterDetailRepository, 22 | ); 23 | }, 24 | ); 25 | } 26 | -------------------------------------------------------------------------------- /lib/features/detail/core/data/detail_local_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:isar/isar.dart'; 3 | import 'package:meta/meta.dart'; 4 | import 'package:now_in_dart_flutter/core/data/data.dart'; 5 | import 'package:now_in_dart_flutter/features/detail/core/data/detail_dto.dart'; 6 | 7 | abstract class DetailLocalService { 8 | DetailLocalService({ 9 | IsarDatabase? isarDb, 10 | }) : _isarDb = isarDb ?? IsarDatabase(); 11 | 12 | final IsarDatabase _isarDb; 13 | 14 | Isar get _isar => _isarDb.instance; 15 | 16 | @protected 17 | @visibleForTesting 18 | Task upsertDetail(DetailDTO detailDTO) { 19 | return Task( 20 | () { 21 | return _isar.writeTxn( 22 | () async { 23 | await _isar.detailDTOs.put(detailDTO); 24 | return unit; 25 | }, 26 | silent: true, 27 | ); 28 | }, 29 | ); 30 | } 31 | 32 | @protected 33 | @visibleForTesting 34 | Task getDetail(int id) { 35 | return Task(() => _isar.detailDTOs.get(id)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/features/detail/flutter_detail/application/flutter_detail_state.dart: -------------------------------------------------------------------------------- 1 | part of 'flutter_detail_bloc.dart'; 2 | 3 | enum FlutterDetailStatus { initial, loading, success, failure } 4 | 5 | class FlutterDetailState extends Equatable { 6 | const FlutterDetailState({ 7 | this.status = FlutterDetailStatus.initial, 8 | this.detail = const Fresh.yes(entity: Detail.empty), 9 | this.failureMessage, 10 | }); 11 | 12 | final FlutterDetailStatus status; 13 | final Fresh detail; 14 | final String? failureMessage; 15 | 16 | FlutterDetailState copyWith({ 17 | FlutterDetailStatus Function()? status, 18 | Fresh Function()? detail, 19 | String? Function()? failureMessage, 20 | }) { 21 | return FlutterDetailState( 22 | status: status != null ? status() : this.status, 23 | detail: detail != null ? detail() : this.detail, 24 | failureMessage: 25 | failureMessage != null ? failureMessage() : this.failureMessage, 26 | ); 27 | } 28 | 29 | @override 30 | List get props => [status, detail, failureMessage]; 31 | } 32 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "now_in_dart_flutter", 3 | "short_name": "now_in_dart_flutter", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /lib/features/detail/flutter_detail/presentation/view/flutter_release_notes_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:now_in_dart_flutter/core/data/id.dart'; 3 | import 'package:now_in_dart_flutter/features/detail/flutter_detail/application/flutter_detail_bloc.dart'; 4 | import 'package:now_in_dart_flutter/features/detail/flutter_detail/presentation/view/flutter_detail_common.dart'; 5 | 6 | class FlutterReleaseNotesPage extends StatefulWidget { 7 | const FlutterReleaseNotesPage({super.key}); 8 | 9 | @override 10 | State createState() => 11 | _FlutterReleaseNotesPageState(); 12 | } 13 | 14 | class _FlutterReleaseNotesPageState extends State 15 | with AutomaticKeepAliveClientMixin { 16 | @override 17 | Widget build(BuildContext context) { 18 | super.build(context); 19 | return const FlutterDetailCommonPage( 20 | event: FlutterReleaseNotesDetailRequested( 21 | EntityId.flutterReleaseNotesDetail, 22 | ), 23 | ); 24 | } 25 | 26 | @override 27 | bool get wantKeepAlive => true; 28 | } 29 | -------------------------------------------------------------------------------- /lib/features/detail/flutter_detail/presentation/view/flutter_detail_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:now_in_dart_flutter/features/detail/flutter_detail/presentation/view/flutter_release_notes_page.dart'; 3 | import 'package:now_in_dart_flutter/features/detail/flutter_detail/presentation/view/flutter_whats_new_page.dart'; 4 | 5 | class FlutterDetailPage extends StatelessWidget { 6 | const FlutterDetailPage({super.key}); 7 | 8 | @override 9 | Widget build(BuildContext context) { 10 | const tabs = [ 11 | Tab(text: "What's new 🆕"), 12 | Tab(text: 'Release Notes 🗒️'), 13 | ]; 14 | return DefaultTabController( 15 | length: tabs.length, 16 | child: Scaffold( 17 | appBar: AppBar( 18 | title: const Text('Flutter'), 19 | bottom: const TabBar( 20 | tabs: tabs, 21 | ), 22 | ), 23 | body: const TabBarView( 24 | children: [ 25 | FlutterWhatsNewPage(), 26 | FlutterReleaseNotesPage(), 27 | ], 28 | ), 29 | ), 30 | ); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/helpers/mocks.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | import 'package:isar/isar.dart'; 3 | import 'package:mocktail/mocktail.dart'; 4 | import 'package:now_in_dart_flutter/core/data/data.dart'; 5 | import 'package:now_in_dart_flutter/features/detail/core/data/detail_local_service.dart'; 6 | import 'package:now_in_dart_flutter/features/detail/core/data/detail_remote_service.dart'; 7 | 8 | part 'fakes.dart'; 9 | 10 | class MockDio extends Mock implements Dio {} 11 | 12 | class MockResponse extends Mock implements Response {} 13 | 14 | class MockHeaders extends Mock implements Headers {} 15 | 16 | class MockHeaderCache extends Mock implements HeaderCache {} 17 | 18 | class MockDetailRemoteService extends DetailRemoteService { 19 | MockDetailRemoteService({super.dio, super.headerCache}); 20 | } 21 | 22 | class MockDetailLocalService extends DetailLocalService { 23 | MockDetailLocalService({super.isarDb}); 24 | } 25 | 26 | class MockIsarDatabase extends Mock implements IsarDatabase {} 27 | 28 | class MockIsar extends Mock implements Isar {} 29 | 30 | class MockIsarCollection extends Mock implements IsarCollection {} 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Biplab Dutta 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /lib/core/data/remote_response.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | sealed class RemoteResponse extends Equatable { 4 | const RemoteResponse(); 5 | 6 | @override 7 | List get props => []; 8 | } 9 | 10 | class NoConnectionRemoteResponse extends RemoteResponse { 11 | const NoConnectionRemoteResponse(); 12 | } 13 | 14 | class UnModifiedRemoteResponse extends RemoteResponse { 15 | const UnModifiedRemoteResponse(); 16 | } 17 | 18 | class ModifiedRemoteResponse extends RemoteResponse { 19 | const ModifiedRemoteResponse(this.data); 20 | 21 | final T data; 22 | 23 | @override 24 | List get props => [data]; 25 | } 26 | 27 | extension RemoteResponseExt on RemoteResponse { 28 | A when({ 29 | required A Function() noConnection, 30 | required A Function() unmodified, 31 | required A Function(T data) modified, 32 | }) { 33 | return switch (this) { 34 | NoConnectionRemoteResponse() => noConnection(), 35 | UnModifiedRemoteResponse() => unmodified(), 36 | ModifiedRemoteResponse(:final data) => modified(data), 37 | }; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/core/data/github_header_cache.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:isar/isar.dart'; 3 | import 'package:now_in_dart_flutter/core/data/github_header.dart'; 4 | import 'package:now_in_dart_flutter/core/data/isar_database.dart'; 5 | 6 | abstract class HeaderCache { 7 | Task saveHeader(GithubHeader header); 8 | Task getHeader(String path); 9 | } 10 | 11 | class GithubHeaderCache implements HeaderCache { 12 | GithubHeaderCache({ 13 | IsarDatabase? isarDb, 14 | }) : _isarDb = isarDb ?? IsarDatabase(); 15 | 16 | final IsarDatabase _isarDb; 17 | 18 | Isar get _isar => _isarDb.instance; 19 | 20 | IsarCollection get _githubHeaders => _isar.githubHeaders; 21 | 22 | @override 23 | Task saveHeader(GithubHeader header) { 24 | final txn = _isar.writeTxn( 25 | () async { 26 | await _githubHeaders.put(header); 27 | return unit; 28 | }, 29 | silent: true, 30 | ); 31 | return Task(() => txn); 32 | } 33 | 34 | @override 35 | Task getHeader(String path) { 36 | return Task(() => _githubHeaders.getByPath(path)); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Flutter (1.0.0) 3 | - isar_flutter_libs (1.0.0): 4 | - Flutter 5 | - url_launcher_ios (0.0.1): 6 | - Flutter 7 | - webview_flutter_wkwebview (0.0.1): 8 | - Flutter 9 | 10 | DEPENDENCIES: 11 | - Flutter (from `Flutter`) 12 | - isar_flutter_libs (from `.symlinks/plugins/isar_flutter_libs/ios`) 13 | - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) 14 | - webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`) 15 | 16 | EXTERNAL SOURCES: 17 | Flutter: 18 | :path: Flutter 19 | isar_flutter_libs: 20 | :path: ".symlinks/plugins/isar_flutter_libs/ios" 21 | url_launcher_ios: 22 | :path: ".symlinks/plugins/url_launcher_ios/ios" 23 | webview_flutter_wkwebview: 24 | :path: ".symlinks/plugins/webview_flutter_wkwebview/ios" 25 | 26 | SPEC CHECKSUMS: 27 | Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 28 | isar_flutter_libs: bfb66f35a1fa9db9ec96b93539a03329ce147738 29 | url_launcher_ios: 839c58cdb4279282219f5e248c3321761ff3c4de 30 | webview_flutter_wkwebview: b7e70ef1ddded7e69c796c7390ee74180182971f 31 | 32 | PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 33 | 34 | COCOAPODS: 1.11.3 35 | -------------------------------------------------------------------------------- /lib/app/app.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:now_in_dart_flutter/features/detail/dart_detail/data/dart_detail_repository.dart'; 4 | import 'package:now_in_dart_flutter/features/detail/flutter_detail/data/flutter_detail_repository.dart'; 5 | import 'package:now_in_dart_flutter/features/home/home.dart'; 6 | 7 | class App extends StatelessWidget { 8 | const App({ 9 | required DartDetailRepository dartDetailRepository, 10 | required FlutterDetailRepository flutterDetailRepository, 11 | super.key, 12 | }) : _dartDetailRepository = dartDetailRepository, 13 | _flutterDetailRepository = flutterDetailRepository; 14 | 15 | final DartDetailRepository _dartDetailRepository; 16 | final FlutterDetailRepository _flutterDetailRepository; 17 | 18 | @override 19 | Widget build(BuildContext context) { 20 | return MultiRepositoryProvider( 21 | providers: [ 22 | RepositoryProvider.value(value: _dartDetailRepository), 23 | RepositoryProvider.value(value: _flutterDetailRepository), 24 | ], 25 | child: MaterialApp( 26 | darkTheme: ThemeData.dark(), 27 | home: const HomePage(), 28 | ), 29 | ); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/core/domain/fresh.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | class Fresh extends Equatable { 4 | const Fresh._({this.entity, this.isFresh}); 5 | 6 | /// Factory for [WhenFresh] 7 | const factory Fresh.yes({ 8 | required T entity, 9 | }) = WhenFresh._; 10 | 11 | /// Factory for [WhenNotFresh] 12 | const factory Fresh.no({ 13 | required T entity, 14 | }) = WhenNotFresh._; 15 | 16 | /// Entity whose freshness is to be checked. 17 | final T? entity; 18 | 19 | /// Determines if the entity is fresh or not. 20 | final bool? isFresh; 21 | 22 | @override 23 | List get props => [entity, isFresh]; 24 | } 25 | 26 | /// Represents that the entity is fresh. 27 | class WhenFresh extends Fresh { 28 | const WhenFresh._({ 29 | required T super.entity, 30 | }) : super._(isFresh: true); 31 | 32 | @override 33 | String toString() { 34 | return 'WhenFresh(entity: $entity, isFresh: true)'; 35 | } 36 | } 37 | 38 | /// Represents that the entity is not fresh. 39 | class WhenNotFresh extends Fresh { 40 | const WhenNotFresh._({ 41 | required T super.entity, 42 | }) : super._(isFresh: false); 43 | 44 | @override 45 | String toString() { 46 | return 'WhenNotFresh(entity: $entity, isFresh: false)'; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lib/bootstrap.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:developer' as dev show log; 3 | 4 | import 'package:dio/dio.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter_bloc/flutter_bloc.dart'; 7 | import 'package:now_in_dart_flutter/app/app_bloc_observer.dart'; 8 | import 'package:now_in_dart_flutter/core/data/data.dart'; 9 | 10 | typedef _BootstrapBuilder = Widget Function(Dio dio); 11 | 12 | void bootstrap(_BootstrapBuilder builder) { 13 | Bloc.observer = AppBlocObserver(); 14 | 15 | FlutterError.onError = (details) { 16 | dev.log( 17 | details.exceptionAsString(), 18 | stackTrace: details.stack, 19 | ); 20 | }; 21 | 22 | runZonedGuarded( 23 | () async { 24 | WidgetsFlutterBinding.ensureInitialized(); 25 | await IsarDatabase().init(); 26 | final dio = Dio() 27 | ..options = BaseOptions( 28 | baseUrl: 'https://api.github.com/', 29 | headers: {'Accept': 'application/vnd.github.html+json'}, 30 | responseType: ResponseType.plain, 31 | validateStatus: (status) { 32 | return status != null && status >= 200 && status < 400; 33 | }, 34 | ); 35 | 36 | runApp(builder(dio)); 37 | }, 38 | (error, stackTrace) => dev.log( 39 | error.toString(), 40 | stackTrace: stackTrace, 41 | ), 42 | ); 43 | } 44 | -------------------------------------------------------------------------------- /windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.CreateAndShow(L"now_in_dart_flutter", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.11' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | end 35 | 36 | post_install do |installer| 37 | installer.pods_project.targets.each do |target| 38 | flutter_additional_macos_build_settings(target) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '11.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /lib/core/presentation/lazy_indexed_stack.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// IndexedStack but lazy. 4 | /// 5 | /// Source code credit: [marcossevilla](https://github.com/marcossevilla/lazy_indexed_stack/blob/main/lib/src/flutter_lazy_indexed_stack.dart) 6 | class LazyIndexedStack extends StatefulWidget { 7 | const LazyIndexedStack({ 8 | super.key, 9 | this.index = 0, 10 | this.children = const [], 11 | }); 12 | 13 | final int index; 14 | 15 | final List children; 16 | 17 | @override 18 | State createState() => _LazyIndexedStackState(); 19 | } 20 | 21 | class _LazyIndexedStackState extends State { 22 | late final List _activatedChildren; 23 | 24 | @override 25 | void initState() { 26 | super.initState(); 27 | _activatedChildren = List.generate( 28 | widget.children.length, 29 | (i) => i == widget.index, 30 | ); 31 | } 32 | 33 | @override 34 | void didUpdateWidget(LazyIndexedStack oldWidget) { 35 | super.didUpdateWidget(oldWidget); 36 | if (oldWidget.index != widget.index) _activateChild(widget.index); 37 | } 38 | 39 | void _activateChild(int? index) { 40 | if (index == null) return; 41 | 42 | if (!_activatedChildren[index]) _activatedChildren[index] = true; 43 | } 44 | 45 | List get children { 46 | return List.generate( 47 | widget.children.length, 48 | (i) { 49 | return _activatedChildren[i] 50 | ? widget.children[i] 51 | : const SizedBox.shrink(); 52 | }, 53 | ); 54 | } 55 | 56 | @override 57 | Widget build(BuildContext context) { 58 | return IndexedStack( 59 | index: widget.index, 60 | children: children, 61 | ); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled. 5 | 6 | version: 7 | revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 8 | channel: stable 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 17 | base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 18 | - platform: android 19 | create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 20 | base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 21 | - platform: ios 22 | create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 23 | base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 24 | - platform: linux 25 | create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 26 | base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 27 | - platform: macos 28 | create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 29 | base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 30 | - platform: web 31 | create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 32 | base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 33 | - platform: windows 34 | create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 35 | base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 37 | 38 | # Run the Flutter tool portions of the build. This must not be removed. 39 | add_dependencies(${BINARY_NAME} flutter_assemble) 40 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Now In Dart Flutter 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | now_in_dart_flutter 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | UIApplicationSupportsIndirectInputEvents 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | std::string utf8_string; 52 | if (target_length == 0 || target_length > utf8_string.max_size()) { 53 | return utf8_string; 54 | } 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | return true; 30 | } 31 | 32 | void FlutterWindow::OnDestroy() { 33 | if (flutter_controller_) { 34 | flutter_controller_ = nullptr; 35 | } 36 | 37 | Win32Window::OnDestroy(); 38 | } 39 | 40 | LRESULT 41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 42 | WPARAM const wparam, 43 | LPARAM const lparam) noexcept { 44 | // Give Flutter, including plugins, an opportunity to handle window messages. 45 | if (flutter_controller_) { 46 | std::optional result = 47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 48 | lparam); 49 | if (result) { 50 | return *result; 51 | } 52 | } 53 | 54 | switch (message) { 55 | case WM_FONTCHANGE: 56 | flutter_controller_->engine()->ReloadSystemFonts(); 57 | break; 58 | } 59 | 60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 61 | } 62 | -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | now_in_dart_flutter 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /lib/features/detail/dart_detail/data/dart_detail_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:now_in_dart_flutter/core/data/data.dart'; 3 | import 'package:now_in_dart_flutter/core/domain/failure.dart'; 4 | import 'package:now_in_dart_flutter/core/domain/fresh.dart'; 5 | import 'package:now_in_dart_flutter/features/detail/core/data/detail_dto.dart'; 6 | import 'package:now_in_dart_flutter/features/detail/core/domain/detail.dart'; 7 | import 'package:now_in_dart_flutter/features/detail/dart_detail/data/dart_detail_local_service.dart'; 8 | import 'package:now_in_dart_flutter/features/detail/dart_detail/data/dart_detail_remote_service.dart'; 9 | 10 | typedef _DartDetailOrFailure = TaskEither>; 11 | 12 | class DartDetailRepository { 13 | DartDetailRepository({ 14 | DartDetailLocalService? localService, 15 | DartDetailRemoteService? remoteService, 16 | }) : _localService = localService ?? DartDetailLocalService(), 17 | _remoteService = remoteService ?? DartDetailRemoteService(); 18 | 19 | final DartDetailLocalService _localService; 20 | final DartDetailRemoteService _remoteService; 21 | 22 | _DartDetailOrFailure getDartDetail(int id) { 23 | return TaskEither.Do( 24 | (_) async { 25 | final remoteResponse = await _( 26 | _remoteService.getDartChangelogDetail(id), 27 | ); 28 | 29 | return remoteResponse.when( 30 | noConnection: () async { 31 | final dto = await _(_localService.getDartDetail(id).toTaskEither()); 32 | return Fresh.no(entity: dto?.toDomain() ?? Detail.empty); 33 | }, 34 | unmodified: () async { 35 | final cachedData = await _( 36 | _localService.getDartDetail(id).toTaskEither(), 37 | ); 38 | return Fresh.yes(entity: cachedData?.toDomain() ?? Detail.empty); 39 | }, 40 | modified: (data) async { 41 | final dto = DetailDTO.parseHtml(id, data); 42 | await _(_localService.upsertDartDetail(dto).toTaskEither()); 43 | return Fresh.yes(entity: dto.toDomain()); 44 | }, 45 | ); 46 | }, 47 | ); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /lib/features/detail/dart_detail/application/dart_detail_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:fpdart/fpdart.dart'; 4 | import 'package:now_in_dart_flutter/core/domain/failure.dart'; 5 | import 'package:now_in_dart_flutter/core/domain/fresh.dart'; 6 | import 'package:now_in_dart_flutter/features/detail/core/domain/detail.dart'; 7 | import 'package:now_in_dart_flutter/features/detail/dart_detail/data/dart_detail_repository.dart'; 8 | 9 | part 'dart_detail_event.dart'; 10 | part 'dart_detail_state.dart'; 11 | 12 | class DartDetailBloc extends Bloc { 13 | DartDetailBloc({ 14 | required DartDetailRepository repository, 15 | }) : _repository = repository, 16 | super(const DartDetailState()) { 17 | on( 18 | (event, emit) async { 19 | await event.when( 20 | changelogDetailRequested: (id) { 21 | return _onDartChangelogDetailRequested(emit, id); 22 | }, 23 | ); 24 | }, 25 | ); 26 | } 27 | 28 | final DartDetailRepository _repository; 29 | 30 | Future _onDartChangelogDetailRequested( 31 | Emitter emit, 32 | int id, 33 | ) async { 34 | emit(state.copyWith(status: () => DartDetailStatus.loading)); 35 | final failureOrSuccessDetail = await _repository.getDartDetail(id).run(); 36 | return failureOrSuccessDetail.match( 37 | (failure) { 38 | emit( 39 | state.copyWith( 40 | status: () => DartDetailStatus.failure, 41 | failureMessage: () { 42 | return switch (failure) { 43 | ApiFailure() => failure.message, 44 | UriParserFailure() => failure.message, 45 | }; 46 | }, 47 | ), 48 | ); 49 | return unit; 50 | }, 51 | (detail) { 52 | emit( 53 | state.copyWith( 54 | status: () => DartDetailStatus.success, 55 | detail: () => detail, 56 | failureMessage: () => null, 57 | ), 58 | ); 59 | return unit; 60 | }, 61 | ); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /lib/features/detail/core/data/detail_dto.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:isar/isar.dart'; 3 | import 'package:now_in_dart_flutter/features/detail/core/domain/detail.dart'; 4 | 5 | part 'detail_dto.g.dart'; 6 | 7 | @Collection(inheritance: false) 8 | class DetailDTO extends Equatable { 9 | const DetailDTO({required this.id, required this.html}); 10 | 11 | /// The parser that parses the received html data. 12 | /// 13 | /// The markdowns in the flutter's github repo has some data in the format 14 | /// `%7B%7Bsite.url%7D%7D` which actually is `{{site.url}}`. But WebView will 15 | /// not be able to take us to relevant web page if `%7B%7Bsite.url%7D%7D` 16 | /// isn't parsed. So, we need to convert `%7B%7Bsite.url%7D%7D` to 17 | /// `https://docs.flutter.dev` because that's what `{{site.url}}` points to. 18 | /// 19 | /// The mappings will have to be done in accordance to [_mappings]. 20 | factory DetailDTO.parseHtml(int id, String html) { 21 | final parsedHtml = _mappings.entries.fold( 22 | html, 23 | (str, map) => str.replaceAll(map.key, map.value), 24 | ); 25 | return DetailDTO(id: id, html: parsedHtml); 26 | } 27 | 28 | final Id id; 29 | final String html; 30 | 31 | Detail toDomain() => Detail(html: html); 32 | 33 | static const _mappings = { 34 | '%7B%7Bsite.url%7D%7D': 'https://docs.flutter.dev', 35 | '%7B%7Bsite.medium%7D%7D': 'https://medium.com', 36 | '%7B%7Bsite.github%7D%7D': 'https://github.com', 37 | '%7B%7Bsite.groups%7D%7D': 'https://groups.google.com', 38 | '%7B%7Bsite.dart-site%7D%7D': 'https://dart.dev', 39 | '%7B%7Bsite.main-url%7D%7D': 'https://flutter.dev', 40 | '%7B%7Bsite.codelabs%7D%7D': 'https://codelabs.developers.google.com', 41 | '%7B%7Bsite.youtube-site%7D%7D': 'https://youtube.com', 42 | '%7B%7Bsite.flutter-medium%7D%7D': 'https://medium.com/flutter', 43 | '%7B%7Bsite.repo.this%7D%7D': 'https://github.com/flutter/website', 44 | '%7B%7Bsite.firebase%7D%7D': 'https://firebase.google.com', 45 | '%7B%7Bsite.google-blog%7D%7D': 'https://developers.googleblog.com', 46 | '%7B%7Bsite.pub%7D%7D': 'https://pub.dev', 47 | '%7B%7Bsite.api%7D%7D': 'https://api.flutter.dev', 48 | '%7B%7Bsite.repo.flutter%7D%7D': 'https://github.com/flutter/flutter', 49 | }; 50 | 51 | @ignore 52 | @override 53 | List get props => [id, html]; 54 | } 55 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 33 30 | ndkVersion flutter.ndkVersion 31 | 32 | compileOptions { 33 | sourceCompatibility JavaVersion.VERSION_1_8 34 | targetCompatibility JavaVersion.VERSION_1_8 35 | } 36 | 37 | kotlinOptions { 38 | jvmTarget = '1.8' 39 | } 40 | 41 | sourceSets { 42 | main.java.srcDirs += 'src/main/kotlin' 43 | } 44 | 45 | defaultConfig { 46 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 47 | applicationId "com.example.now_in_dart_flutter" 48 | // You can update the following values to match your application needs. 49 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. 50 | minSdkVersion 19 51 | targetSdkVersion flutter.targetSdkVersion 52 | versionCode flutterVersionCode.toInteger() 53 | versionName flutterVersionName 54 | } 55 | 56 | buildTypes { 57 | release { 58 | // TODO: Add your own signing config for the release build. 59 | // Signing with the debug keys for now, so `flutter run --release` works. 60 | signingConfig signingConfigs.debug 61 | } 62 | } 63 | namespace 'com.example.now_in_dart_flutter' 64 | } 65 | 66 | flutter { 67 | source '../..' 68 | } 69 | 70 | dependencies { 71 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 72 | } 73 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /test/features/detail/core/data/detail_local_service_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:mocktail/mocktail.dart'; 3 | import 'package:now_in_dart_flutter/features/detail/core/data/detail_dto.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import '../../../../helpers/mocks.dart'; 7 | 8 | void main() { 9 | final isar = MockIsar(); 10 | final isarDb = MockIsarDatabase(); 11 | final isarCollection = MockIsarCollection(); 12 | final detailLocalService = MockDetailLocalService(isarDb: isarDb); 13 | 14 | group( 15 | 'DetailLocalService |', 16 | () { 17 | const fakeDetailDTO = DetailDTO(id: 1, html: 'html'); 18 | 19 | setUpAll(() => when(() => isarDb.instance).thenReturn(isar)); 20 | 21 | test( 22 | 'should instantiate IsarDatabase() when not injected', 23 | () => expect(MockDetailLocalService(), isNotNull), 24 | ); 25 | 26 | test( 27 | 'The method `upsertDetail` should either update or insert the passed ' 28 | 'DetailDTO', 29 | () async { 30 | when( 31 | () => isar.writeTxn( 32 | any(that: isA()), 33 | silent: any(named: 'silent', that: isA()), 34 | ), 35 | ).thenAnswer((_) async => unit); 36 | 37 | final result = 38 | await detailLocalService.upsertDetail(fakeDetailDTO).run(); 39 | 40 | expect(result, isA()); 41 | }, 42 | ); 43 | 44 | group( 45 | 'The method `getDetail`', 46 | () { 47 | setUpAll( 48 | () => when(() => isar.detailDTOs).thenReturn(isarCollection), 49 | ); 50 | test( 51 | 'should return DetailDTO object for the passed id', 52 | () async { 53 | when(() => isarCollection.get(any(that: isA()))) 54 | .thenAnswer((_) async => fakeDetailDTO); 55 | 56 | final result = await detailLocalService.getDetail(1).run(); 57 | 58 | expect(result, fakeDetailDTO); 59 | }, 60 | ); 61 | 62 | test( 63 | 'should return null if invalid id is passed', 64 | () async { 65 | when(() => isarCollection.get(any(that: isA()))) 66 | .thenAnswer((_) async => null); 67 | 68 | final result = await detailLocalService.getDetail(1).run(); 69 | 70 | expect(result, isNull); 71 | }, 72 | ); 73 | }, 74 | ); 75 | }, 76 | ); 77 | } 78 | -------------------------------------------------------------------------------- /lib/features/detail/flutter_detail/data/flutter_detail_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:fpdart/fpdart.dart'; 2 | import 'package:now_in_dart_flutter/core/data/remote_response.dart'; 3 | import 'package:now_in_dart_flutter/core/domain/failure.dart'; 4 | import 'package:now_in_dart_flutter/core/domain/fresh.dart'; 5 | import 'package:now_in_dart_flutter/features/detail/core/data/detail_dto.dart'; 6 | import 'package:now_in_dart_flutter/features/detail/core/domain/detail.dart'; 7 | import 'package:now_in_dart_flutter/features/detail/flutter_detail/data/flutter_detail_local_service.dart'; 8 | import 'package:now_in_dart_flutter/features/detail/flutter_detail/data/flutter_detail_remote_service.dart'; 9 | 10 | typedef _FlutterDetailOrFailure = TaskEither>; 11 | 12 | class FlutterDetailRepository { 13 | FlutterDetailRepository({ 14 | FlutterDetailLocalService? localService, 15 | FlutterDetailRemoteService? remoteService, 16 | }) : _localService = localService ?? FlutterDetailLocalService(), 17 | _remoteService = remoteService ?? FlutterDetailRemoteService(); 18 | 19 | final FlutterDetailLocalService _localService; 20 | final FlutterDetailRemoteService _remoteService; 21 | 22 | _FlutterDetailOrFailure getWhatsNewFlutterDetail(int id) { 23 | return _getFlutterDetail(id, _remoteService.getWhatsNewFlutterDetail); 24 | } 25 | 26 | _FlutterDetailOrFailure getFlutterReleaseNotesDetail(int id) { 27 | return _getFlutterDetail(id, _remoteService.getFlutterReleaseNotesDetail); 28 | } 29 | 30 | _FlutterDetailOrFailure _getFlutterDetail( 31 | int id, 32 | TaskEither> Function(int) caller, 33 | ) { 34 | return TaskEither.Do( 35 | (_) async { 36 | final remoteResponse = await _(caller(id)); 37 | 38 | return remoteResponse.when( 39 | noConnection: () async { 40 | final dto = await _( 41 | _localService.getFlutterDetail(id).toTaskEither(), 42 | ); 43 | return Fresh.no(entity: dto?.toDomain() ?? Detail.empty); 44 | }, 45 | unmodified: () async { 46 | final cachedData = await _( 47 | _localService.getFlutterDetail(id).toTaskEither(), 48 | ); 49 | return Fresh.yes(entity: cachedData?.toDomain() ?? Detail.empty); 50 | }, 51 | modified: (data) async { 52 | final dto = DetailDTO.parseHtml(id, data); 53 | await _(_localService.upsertFlutterDetail(dto).toTaskEither()); 54 | return Fresh.yes(entity: dto.toDomain()); 55 | }, 56 | ); 57 | }, 58 | ); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /lib/features/detail/flutter_detail/presentation/view/flutter_detail_common.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:now_in_dart_flutter/core/presentation/no_connection_toast.dart'; 4 | import 'package:now_in_dart_flutter/core/presentation/no_results_display.dart'; 5 | import 'package:now_in_dart_flutter/features/detail/core/presentation/widget/detail_webview.dart'; 6 | import 'package:now_in_dart_flutter/features/detail/flutter_detail/application/flutter_detail_bloc.dart'; 7 | import 'package:now_in_dart_flutter/features/detail/flutter_detail/data/flutter_detail_repository.dart'; 8 | 9 | class FlutterDetailCommonPage extends StatelessWidget { 10 | const FlutterDetailCommonPage({ 11 | required FlutterDetailEvent event, 12 | super.key, 13 | }) : _event = event; 14 | 15 | final FlutterDetailEvent _event; 16 | 17 | @override 18 | Widget build(BuildContext context) { 19 | return BlocProvider( 20 | create: (context) { 21 | return FlutterDetailBloc( 22 | repository: context.read(), 23 | )..add(_event); 24 | }, 25 | child: const FlutterDetailCommonView(), 26 | ); 27 | } 28 | } 29 | 30 | class FlutterDetailCommonView extends StatefulWidget { 31 | const FlutterDetailCommonView({super.key}); 32 | 33 | @override 34 | State createState() => 35 | _FlutterDetailCommonViewState(); 36 | } 37 | 38 | class _FlutterDetailCommonViewState extends State { 39 | bool _hasAlreadyShownNoConnectionToast = false; 40 | 41 | @override 42 | Widget build(BuildContext context) { 43 | return BlocConsumer( 44 | listener: (context, state) { 45 | if (!state.detail.isFresh! && !_hasAlreadyShownNoConnectionToast) { 46 | _hasAlreadyShownNoConnectionToast = true; 47 | showNoConnectionToast('No Internet Connection!!!', context); 48 | } 49 | }, 50 | builder: (context, state) { 51 | switch (state.status) { 52 | case FlutterDetailStatus.initial: 53 | return const SizedBox.shrink(); 54 | 55 | case FlutterDetailStatus.loading: 56 | return const Center( 57 | child: CircularProgressIndicator.adaptive(), 58 | ); 59 | 60 | case FlutterDetailStatus.success: 61 | final receivedDetail = state.detail; 62 | if (receivedDetail.entity!.isEmpty) { 63 | return const NoResultsDisplay( 64 | message: "Sorry. There's nothing to display ☹️", 65 | ); 66 | } 67 | return DetailWebView(html: receivedDetail.entity!.html); 68 | 69 | case FlutterDetailStatus.failure: 70 | return NoResultsDisplay(message: state.failureMessage!); 71 | } 72 | }, 73 | ); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /lib/features/detail/core/data/detail_remote_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | import 'package:fpdart/fpdart.dart'; 3 | import 'package:meta/meta.dart'; 4 | import 'package:now_in_dart_flutter/core/data/data.dart'; 5 | import 'package:now_in_dart_flutter/core/domain/failure.dart'; 6 | 7 | typedef _FailureOrRemoteResponse = TaskEither>; 8 | 9 | abstract class DetailRemoteService { 10 | DetailRemoteService({ 11 | Dio? dio, 12 | HeaderCache? headerCache, 13 | }) : _dio = dio ?? Dio(), 14 | _headerCache = headerCache ?? GithubHeaderCache(); 15 | 16 | final Dio _dio; 17 | final HeaderCache _headerCache; 18 | 19 | @protected 20 | @visibleForTesting 21 | _FailureOrRemoteResponse getDetail( 22 | int id, 23 | String fullPathToMarkdownFile, 24 | ) { 25 | return TaskEither.Do( 26 | (_) async { 27 | final requestUri = await _( 28 | uriParser(fullPathToMarkdownFile).toTaskEither(), 29 | ); 30 | 31 | final cachedHeader = await _( 32 | _headerCache.getHeader(fullPathToMarkdownFile).toTaskEither(), 33 | ); 34 | 35 | return _( 36 | TaskEither>.tryCatch( 37 | () => _dio.getUri( 38 | requestUri, 39 | options: Options( 40 | headers: { 41 | 'If-None-Match': cachedHeader?.eTag ?? '', 42 | }, 43 | ), 44 | ), 45 | (e, stackTrace) { 46 | return ApiFailure( 47 | 'Error on network request', 48 | errorObject: e, 49 | stackTrace: stackTrace, 50 | ); 51 | }, 52 | ).flatMap( 53 | (response) { 54 | return TaskEither>( 55 | () async { 56 | if (response.statusCode == 200) { 57 | final header = GithubHeader.parse( 58 | id, 59 | response, 60 | fullPathToMarkdownFile, 61 | ); 62 | 63 | await _(_headerCache.saveHeader(header).toTaskEither()); 64 | 65 | final html = response.data ?? ''; 66 | return right(ModifiedRemoteResponse(html)); 67 | } 68 | 69 | return right(const UnModifiedRemoteResponse()); 70 | }, 71 | ); 72 | }, 73 | ).orElse( 74 | (failure) { 75 | final error = failure.errorObject; 76 | if (error is DioException && error.isNoConnectionError) { 77 | return TaskEither.right(const NoConnectionRemoteResponse()); 78 | } 79 | return TaskEither.left(failure); 80 | }, 81 | ), 82 | ); 83 | }, 84 | ); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /lib/features/detail/dart_detail/presentation/view/dart_changelog_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:now_in_dart_flutter/core/data/id.dart'; 4 | import 'package:now_in_dart_flutter/core/presentation/no_connection_toast.dart'; 5 | import 'package:now_in_dart_flutter/core/presentation/no_results_display.dart'; 6 | import 'package:now_in_dart_flutter/features/detail/core/presentation/widget/detail_webview.dart'; 7 | import 'package:now_in_dart_flutter/features/detail/dart_detail/application/dart_detail_bloc.dart'; 8 | import 'package:now_in_dart_flutter/features/detail/dart_detail/data/dart_detail_repository.dart'; 9 | 10 | class DartChangelogPage extends StatelessWidget { 11 | const DartChangelogPage({super.key}); 12 | 13 | @override 14 | Widget build(BuildContext context) { 15 | return Scaffold( 16 | appBar: AppBar(title: const Text('Dart')), 17 | body: BlocProvider( 18 | create: (context) { 19 | const id = EntityId.dartChangelogDetail; 20 | return DartDetailBloc( 21 | repository: context.read(), 22 | )..add(const DartChangelogDetailRequested(id)); 23 | }, 24 | child: const DartChangelogView(), 25 | ), 26 | ); 27 | } 28 | } 29 | 30 | class DartChangelogView extends StatefulWidget { 31 | const DartChangelogView({super.key}); 32 | 33 | @override 34 | State createState() => _DartChangelogViewState(); 35 | } 36 | 37 | class _DartChangelogViewState extends State { 38 | bool _hasAlreadyShownNoConnectionToast = false; 39 | 40 | @override 41 | Widget build(BuildContext context) { 42 | return BlocConsumer( 43 | listener: (context, state) { 44 | if (!state.detail.isFresh! && !_hasAlreadyShownNoConnectionToast) { 45 | _hasAlreadyShownNoConnectionToast = true; 46 | showNoConnectionToast('No Internet Connection!!!', context); 47 | } 48 | }, 49 | builder: (context, state) { 50 | switch (state.status) { 51 | case DartDetailStatus.initial: 52 | return const SizedBox.shrink(); 53 | 54 | case DartDetailStatus.loading: 55 | return const Center( 56 | child: CircularProgressIndicator.adaptive(), 57 | ); 58 | 59 | case DartDetailStatus.success: 60 | final receivedDetail = state.detail; 61 | if (receivedDetail.entity!.isEmpty) { 62 | return const NoResultsDisplay( 63 | message: "Sorry. There's nothing to display ☹️", 64 | ); 65 | } 66 | return DetailWebView( 67 | html: receivedDetail.entity!.html, 68 | ); 69 | 70 | case DartDetailStatus.failure: 71 | return NoResultsDisplay(message: state.failureMessage!); 72 | } 73 | }, 74 | ); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /lib/features/detail/flutter_detail/application/flutter_detail_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:fpdart/fpdart.dart'; 4 | import 'package:now_in_dart_flutter/core/domain/failure.dart'; 5 | import 'package:now_in_dart_flutter/core/domain/fresh.dart'; 6 | import 'package:now_in_dart_flutter/features/detail/core/domain/detail.dart'; 7 | import 'package:now_in_dart_flutter/features/detail/flutter_detail/data/flutter_detail_repository.dart'; 8 | 9 | part 'flutter_detail_event.dart'; 10 | part 'flutter_detail_state.dart'; 11 | 12 | typedef _DetailFailureOrSuccess = TaskEither>; 13 | 14 | class FlutterDetailBloc extends Bloc { 15 | FlutterDetailBloc({ 16 | required FlutterDetailRepository repository, 17 | }) : _repository = repository, 18 | super(const FlutterDetailState()) { 19 | on( 20 | (event, emit) async { 21 | await event.when( 22 | flutterWhatsNewDetailRequested: (id) { 23 | return _onFlutterWhatsNewDetailRequested(emit, id); 24 | }, 25 | flutterReleaseNotesDetailRequested: (id) { 26 | return _onFlutterReleaseNotesDetailRequested(emit, id); 27 | }, 28 | ); 29 | }, 30 | ); 31 | } 32 | 33 | final FlutterDetailRepository _repository; 34 | 35 | Future _onFlutterWhatsNewDetailRequested( 36 | Emitter emit, 37 | int id, 38 | ) { 39 | return _onFlutterDetailRequested( 40 | _repository.getWhatsNewFlutterDetail, 41 | emit, 42 | id, 43 | ); 44 | } 45 | 46 | Future _onFlutterReleaseNotesDetailRequested( 47 | Emitter emit, 48 | int id, 49 | ) { 50 | return _onFlutterDetailRequested( 51 | _repository.getFlutterReleaseNotesDetail, 52 | emit, 53 | id, 54 | ); 55 | } 56 | 57 | Future _onFlutterDetailRequested( 58 | _DetailFailureOrSuccess Function(int) caller, 59 | Emitter emit, 60 | int id, 61 | ) async { 62 | emit(state.copyWith(status: () => FlutterDetailStatus.loading)); 63 | final failureOrSuccessDetail = await caller(id).run(); 64 | return failureOrSuccessDetail.match( 65 | (failure) { 66 | emit( 67 | state.copyWith( 68 | status: () => FlutterDetailStatus.failure, 69 | failureMessage: () { 70 | return switch (failure) { 71 | ApiFailure() => failure.message, 72 | UriParserFailure() => failure.message, 73 | }; 74 | }, 75 | ), 76 | ); 77 | return unit; 78 | }, 79 | (detail) { 80 | emit( 81 | state.copyWith( 82 | status: () => FlutterDetailStatus.success, 83 | detail: () => detail, 84 | failureMessage: () => null, 85 | ), 86 | ); 87 | return unit; 88 | }, 89 | ); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.example" "\0" 93 | VALUE "FileDescription", "now_in_dart_flutter" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "now_in_dart_flutter" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2022 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "now_in_dart_flutter.exe" "\0" 98 | VALUE "ProductName", "now_in_dart_flutter" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates and shows a win32 window with |title| and position and size using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size to will treat the width height passed in to this function 35 | // as logical pixels and scale to appropriate for the default monitor. Returns 36 | // true if the window was created successfully. 37 | bool CreateAndShow(const std::wstring& title, 38 | const Point& origin, 39 | const Size& size); 40 | 41 | // Release OS resources associated with window. 42 | void Destroy(); 43 | 44 | // Inserts |content| into the window tree. 45 | void SetChildContent(HWND content); 46 | 47 | // Returns the backing Window handle to enable clients to set icon and other 48 | // window properties. Returns nullptr if the window has been destroyed. 49 | HWND GetHandle(); 50 | 51 | // If true, closing this window will quit the application. 52 | void SetQuitOnClose(bool quit_on_close); 53 | 54 | // Return a RECT representing the bounds of the current client area. 55 | RECT GetClientArea(); 56 | 57 | protected: 58 | // Processes and route salient window messages for mouse handling, 59 | // size change and DPI. Delegates handling of these to member overloads that 60 | // inheriting classes can handle. 61 | virtual LRESULT MessageHandler(HWND window, 62 | UINT const message, 63 | WPARAM const wparam, 64 | LPARAM const lparam) noexcept; 65 | 66 | // Called when CreateAndShow is called, allowing subclass window-related 67 | // setup. Subclasses should return false if setup fails. 68 | virtual bool OnCreate(); 69 | 70 | // Called when Destroy is called. 71 | virtual void OnDestroy(); 72 | 73 | private: 74 | friend class WindowClassRegistrar; 75 | 76 | // OS callback called by message pump. Handles the WM_NCCREATE message which 77 | // is passed when the non-client area is being created and enables automatic 78 | // non-client DPI scaling so that the non-client area automatically 79 | // responsponds to changes in DPI. All other messages are handled by 80 | // MessageHandler. 81 | static LRESULT CALLBACK WndProc(HWND const window, 82 | UINT const message, 83 | WPARAM const wparam, 84 | LPARAM const lparam) noexcept; 85 | 86 | // Retrieves a class instance pointer for |window| 87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 88 | 89 | bool quit_on_close_ = false; 90 | 91 | // window handle for top level window. 92 | HWND window_handle_ = nullptr; 93 | 94 | // window handle for hosted content. 95 | HWND child_content_ = nullptr; 96 | }; 97 | 98 | #endif // RUNNER_WIN32_WINDOW_H_ 99 | -------------------------------------------------------------------------------- /windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # === Flutter Library === 14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 15 | 16 | # Published to parent scope for install step. 17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 21 | 22 | list(APPEND FLUTTER_LIBRARY_HEADERS 23 | "flutter_export.h" 24 | "flutter_windows.h" 25 | "flutter_messenger.h" 26 | "flutter_plugin_registrar.h" 27 | "flutter_texture_registrar.h" 28 | ) 29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 30 | add_library(flutter INTERFACE) 31 | target_include_directories(flutter INTERFACE 32 | "${EPHEMERAL_DIR}" 33 | ) 34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 35 | add_dependencies(flutter flutter_assemble) 36 | 37 | # === Wrapper === 38 | list(APPEND CPP_WRAPPER_SOURCES_CORE 39 | "core_implementations.cc" 40 | "standard_codec.cc" 41 | ) 42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 44 | "plugin_registrar.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_APP 48 | "flutter_engine.cc" 49 | "flutter_view_controller.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 52 | 53 | # Wrapper sources needed for a plugin. 54 | add_library(flutter_wrapper_plugin STATIC 55 | ${CPP_WRAPPER_SOURCES_CORE} 56 | ${CPP_WRAPPER_SOURCES_PLUGIN} 57 | ) 58 | apply_standard_settings(flutter_wrapper_plugin) 59 | set_target_properties(flutter_wrapper_plugin PROPERTIES 60 | POSITION_INDEPENDENT_CODE ON) 61 | set_target_properties(flutter_wrapper_plugin PROPERTIES 62 | CXX_VISIBILITY_PRESET hidden) 63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 64 | target_include_directories(flutter_wrapper_plugin PUBLIC 65 | "${WRAPPER_ROOT}/include" 66 | ) 67 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 68 | 69 | # Wrapper sources needed for the runner. 70 | add_library(flutter_wrapper_app STATIC 71 | ${CPP_WRAPPER_SOURCES_CORE} 72 | ${CPP_WRAPPER_SOURCES_APP} 73 | ) 74 | apply_standard_settings(flutter_wrapper_app) 75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 76 | target_include_directories(flutter_wrapper_app PUBLIC 77 | "${WRAPPER_ROOT}/include" 78 | ) 79 | add_dependencies(flutter_wrapper_app flutter_assemble) 80 | 81 | # === Flutter tool backend === 82 | # _phony_ is a non-existent file to force this command to run every time, 83 | # since currently there's no way to get a full input/output list from the 84 | # flutter tool. 85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 87 | add_custom_command( 88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 90 | ${CPP_WRAPPER_SOURCES_APP} 91 | ${PHONY_OUTPUT} 92 | COMMAND ${CMAKE_COMMAND} -E env 93 | ${FLUTTER_TOOL_ENVIRONMENT} 94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 95 | windows-x64 $ 96 | VERBATIM 97 | ) 98 | add_custom_target(flutter_assemble DEPENDS 99 | "${FLUTTER_LIBRARY}" 100 | ${FLUTTER_LIBRARY_HEADERS} 101 | ${CPP_WRAPPER_SOURCES_CORE} 102 | ${CPP_WRAPPER_SOURCES_PLUGIN} 103 | ${CPP_WRAPPER_SOURCES_APP} 104 | ) 105 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # now_in_dart_flutter 2 | 3 | This app serves the purpose of staying up-to-date with the latest changes across Dart and Flutter ecosystem. The way this app works is by fetching markdowns from Dart and Flutter's official Github repo via REST API and rendering the information in a `WebView` widget. 4 | 5 | ## Features 6 | 7 | - Display Dart CHANGELOG 8 | - Display Flutter What's New 9 | - Display Flutter Release Notes 10 | - Offline Support 11 | 12 | ## Application Demo 13 | 14 |
15 | 16 | 17 | 22 | 27 | 28 |
18 | 21 | 23 | 26 |
29 |
30 | 31 | ## Architecture 32 | 33 | The app follows a simple but effective architecture. It relies on a feature-driven architecture with some sub-features. 34 | 35 | Inside [lib/features/](./lib/features/) directory, you can find two sub-features: `detail` and `home`. 36 | 37 | The [home](./lib/features/home/) sub-feature is responsible for showing a scaffold with a bottom navigation bar. It also contains logic for maintaining bottom navigation bar's state. 38 | 39 | The [detail](./lib/features/detail/) feature is divided into two sub-features: [dart_detail](./lib/features/detail/dart_detail/) and [flutter_detail](./lib/features/detail/flutter_detail/). Each of these sub-features has similar structure and is divided into three layers. 40 | 41 | - **Application Layer**: Contains state management logic and acts as a mediator between the presentation and the data layer. 42 | - **Data Layer**: Responsible for making all the necessary API calls and local cache operations. 43 | - **Presentation Layer**: Associated with the UI 44 | 45 | To check the `fpdart` implementation, consider taking a look at the `data` layer of each of the sub-features. 46 | 47 | ## State Management 48 | The project uses [flutter_bloc](https://pub.dev/packages/flutter_bloc) for managing the app's state. 49 | 50 | ## Storage 51 | The app stores fetched data locally on user's device for offline support. The project uses the latest [isar](https://pub.dev/packages/isar) plugin for local storage. 52 | 53 | ## Test 54 | The unit test has been written based on the `fpdart` refactoring and can be found in the [test](./test/) directory. 55 | - [detail_local_service_test.dart](./test/features/detail/core/data/detail_local_service_test.dart) 56 | - [detail_remote_service_test.dart](./test/features/detail/core/data/detail_remote_service_test.dart) 57 | 58 | ## Dependencies 59 | The project makes use of few third-party packages for rapid development. Some of them are listed below: 60 | - [dio](https://pub.dev/packages/dio) (To perform network calls) 61 | - [equatable](https://pub.dev/packages/equatable) (To achieve value equality) 62 | - [flash](https://pub.dev/packages/flash) (To display customizable toast) 63 | - [flutter_bloc](https://pub.dev/packages/flutter_bloc) (State Management) 64 | - [fpdart](https://pub.dev/packages/fpdart) (Functional Programming) 65 | - [isar](https://pub.dev/packages/isar) (Local Storage) 66 | - [url_launcher](https://pub.dev/packages/url_launcher) (To display information from hyperlinks in a browser interface within the app) 67 | - [webview_flutter](https://pub.dev/packages/webview_flutter) (To display markdowns) 68 | - [mocktail](https://pub.dev/packages/mocktail) (As a mocking library) 69 | 70 | ## Types used from `fpdart` 71 | - `TaskEither`: Used instead of `Future` to make async request that may fail 72 | - `IOEither`: Used to represent a synchronous computation that may fail 73 | - `Do` Notation: Used to write functional code that looks like normal imperative code and to avoid methods chaining -------------------------------------------------------------------------------- /linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "now_in_dart_flutter"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "now_in_dart_flutter"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(now_in_dart_flutter LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "now_in_dart_flutter") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(SET CMP0063 NEW) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | # Generated plugin build rules, which manage building the plugins and adding 56 | # them to the application. 57 | include(flutter/generated_plugins.cmake) 58 | 59 | 60 | # === Installation === 61 | # Support files are copied into place next to the executable, so that it can 62 | # run in place. This is done instead of making a separate bundle (as on Linux) 63 | # so that building and running from within Visual Studio will work. 64 | set(BUILD_BUNDLE_DIR "$") 65 | # Make the "install" step default, as it's required to run. 66 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 67 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 68 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 69 | endif() 70 | 71 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 72 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 73 | 74 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 75 | COMPONENT Runtime) 76 | 77 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 78 | COMPONENT Runtime) 79 | 80 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 81 | COMPONENT Runtime) 82 | 83 | if(PLUGIN_BUNDLED_LIBRARIES) 84 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 85 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 86 | COMPONENT Runtime) 87 | endif() 88 | 89 | # Fully re-copy the assets directory on each build to avoid having stale files 90 | # from a previous install. 91 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 92 | install(CODE " 93 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 94 | " COMPONENT Runtime) 95 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 96 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 97 | 98 | # Install the AOT library on non-Debug builds only. 99 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 100 | CONFIGURATIONS Profile;Release 101 | COMPONENT Runtime) 102 | -------------------------------------------------------------------------------- /lib/features/home/view/home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/services.dart'; 3 | import 'package:flutter_bloc/flutter_bloc.dart'; 4 | import 'package:flutter_svg/flutter_svg.dart'; 5 | import 'package:now_in_dart_flutter/core/presentation/assets_path.dart'; 6 | import 'package:now_in_dart_flutter/core/presentation/lazy_indexed_stack.dart'; 7 | import 'package:now_in_dart_flutter/core/presentation/responsive.dart'; 8 | import 'package:now_in_dart_flutter/features/detail/dart_detail/presentation/view/dart_changelog_page.dart'; 9 | import 'package:now_in_dart_flutter/features/detail/flutter_detail/presentation/view/flutter_detail_page.dart'; 10 | import 'package:now_in_dart_flutter/features/home/cubit/home_cubit.dart'; 11 | import 'package:vector_graphics/vector_graphics.dart'; 12 | 13 | class HomePage extends StatelessWidget { 14 | const HomePage({super.key}); 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | return BlocProvider( 19 | create: (context) => HomeCubit(), 20 | child: const HomeView(), 21 | ); 22 | } 23 | } 24 | 25 | class HomeView extends StatelessWidget { 26 | const HomeView({super.key}); 27 | 28 | @override 29 | Widget build(BuildContext context) { 30 | return const Responsive( 31 | mobile: MobileView(), 32 | tabletOrDesktop: TabletOrDesktopView(), 33 | ); 34 | } 35 | } 36 | 37 | class MobileView extends StatelessWidget { 38 | const MobileView({super.key}); 39 | 40 | @override 41 | Widget build(BuildContext context) { 42 | SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); 43 | const pages = [DartChangelogPage(), FlutterDetailPage()]; 44 | 45 | final selectedTabIndex = context.select( 46 | (HomeCubit cubit) => cubit.state.index, 47 | ); 48 | return Scaffold( 49 | body: LazyIndexedStack( 50 | index: selectedTabIndex, 51 | children: pages, 52 | ), 53 | bottomNavigationBar: NavigationBar( 54 | destinations: _destinations, 55 | selectedIndex: selectedTabIndex, 56 | onDestinationSelected: context.read().setTab, 57 | ), 58 | ); 59 | } 60 | } 61 | 62 | class TabletOrDesktopView extends StatelessWidget { 63 | const TabletOrDesktopView({super.key}); 64 | 65 | @override 66 | Widget build(BuildContext context) { 67 | SystemChrome.setPreferredOrientations([ 68 | DeviceOrientation.landscapeLeft, 69 | DeviceOrientation.landscapeRight, 70 | ]); 71 | 72 | const pages = [DartChangelogPage(), FlutterDetailPage()]; 73 | 74 | final selectedTabIndex = context.select( 75 | (HomeCubit cubit) => cubit.state.index, 76 | ); 77 | return Scaffold( 78 | body: Row( 79 | children: [ 80 | NavigationRail( 81 | destinations: _railDestinations, 82 | selectedIndex: selectedTabIndex, 83 | useIndicator: true, 84 | labelType: NavigationRailLabelType.selected, 85 | groupAlignment: 0, 86 | onDestinationSelected: context.read().setTab, 87 | ), 88 | const VerticalDivider(thickness: 1, width: 1), 89 | Expanded( 90 | child: LazyIndexedStack( 91 | index: selectedTabIndex, 92 | children: pages, 93 | ), 94 | ), 95 | ], 96 | ), 97 | ); 98 | } 99 | } 100 | 101 | final _destinations = [ 102 | const NavigationDestination( 103 | icon: SvgPicture( 104 | AssetBytesLoader(AssetsPath.dartIcon), 105 | width: 24, 106 | height: 24, 107 | ), 108 | label: 'Dart', 109 | ), 110 | const NavigationDestination( 111 | icon: SvgPicture( 112 | AssetBytesLoader(AssetsPath.flutterIcon), 113 | width: 24, 114 | height: 24, 115 | ), 116 | label: 'Flutter', 117 | ), 118 | ]; 119 | 120 | final _railDestinations = [ 121 | NavigationRailDestination( 122 | icon: SvgPicture.asset( 123 | AssetsPath.dartIcon, 124 | width: 24, 125 | height: 24, 126 | ), 127 | label: const Text('Dart'), 128 | ), 129 | NavigationRailDestination( 130 | icon: SvgPicture.asset( 131 | AssetsPath.flutterIcon, 132 | width: 24, 133 | height: 24, 134 | ), 135 | label: const Text('Flutter'), 136 | ), 137 | ]; 138 | -------------------------------------------------------------------------------- /linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.10) 3 | project(runner LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "now_in_dart_flutter") 8 | # The unique GTK application identifier for this application. See: 9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID 10 | set(APPLICATION_ID "com.example.now_in_dart_flutter") 11 | 12 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 13 | # versions of CMake. 14 | cmake_policy(SET CMP0063 NEW) 15 | 16 | # Load bundled libraries from the lib/ directory relative to the binary. 17 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 18 | 19 | # Root filesystem for cross-building. 20 | if(FLUTTER_TARGET_PLATFORM_SYSROOT) 21 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 22 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 23 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 24 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 27 | endif() 28 | 29 | # Define build configuration options. 30 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 31 | set(CMAKE_BUILD_TYPE "Debug" CACHE 32 | STRING "Flutter build mode" FORCE) 33 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 34 | "Debug" "Profile" "Release") 35 | endif() 36 | 37 | # Compilation settings that should be applied to most targets. 38 | # 39 | # Be cautious about adding new options here, as plugins use this function by 40 | # default. In most cases, you should add new options to specific targets instead 41 | # of modifying this function. 42 | function(APPLY_STANDARD_SETTINGS TARGET) 43 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 44 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 45 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 46 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 47 | endfunction() 48 | 49 | # Flutter library and tool build rules. 50 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 51 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 52 | 53 | # System-level dependencies. 54 | find_package(PkgConfig REQUIRED) 55 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 56 | 57 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 58 | 59 | # Define the application target. To change its name, change BINARY_NAME above, 60 | # not the value here, or `flutter run` will no longer work. 61 | # 62 | # Any new source files that you add to the application should be added here. 63 | add_executable(${BINARY_NAME} 64 | "main.cc" 65 | "my_application.cc" 66 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 67 | ) 68 | 69 | # Apply the standard set of build settings. This can be removed for applications 70 | # that need different build settings. 71 | apply_standard_settings(${BINARY_NAME}) 72 | 73 | # Add dependency libraries. Add any application-specific dependencies here. 74 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 75 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 76 | 77 | # Run the Flutter tool portions of the build. This must not be removed. 78 | add_dependencies(${BINARY_NAME} flutter_assemble) 79 | 80 | # Only the install-generated bundle's copy of the executable will launch 81 | # correctly, since the resources must in the right relative locations. To avoid 82 | # people trying to run the unbundled copy, put it in a subdirectory instead of 83 | # the default top-level location. 84 | set_target_properties(${BINARY_NAME} 85 | PROPERTIES 86 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 87 | ) 88 | 89 | # Generated plugin build rules, which manage building the plugins and adding 90 | # them to the application. 91 | include(flutter/generated_plugins.cmake) 92 | 93 | 94 | # === Installation === 95 | # By default, "installing" just makes a relocatable bundle in the build 96 | # directory. 97 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 98 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 99 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 100 | endif() 101 | 102 | # Start with a clean build bundle directory every time. 103 | install(CODE " 104 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 105 | " COMPONENT Runtime) 106 | 107 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 108 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 109 | 110 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 111 | COMPONENT Runtime) 112 | 113 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 114 | COMPONENT Runtime) 115 | 116 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 117 | COMPONENT Runtime) 118 | 119 | foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) 120 | install(FILES "${bundled_library}" 121 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 122 | COMPONENT Runtime) 123 | endforeach(bundled_library) 124 | 125 | # Fully re-copy the assets directory on each build to avoid having stale files 126 | # from a previous install. 127 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 128 | install(CODE " 129 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 130 | " COMPONENT Runtime) 131 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 132 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 133 | 134 | # Install the AOT library on non-Debug builds only. 135 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 136 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 137 | COMPONENT Runtime) 138 | endif() 139 | -------------------------------------------------------------------------------- /test/features/detail/core/data/detail_remote_service_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | import 'package:fpdart/fpdart.dart'; 3 | import 'package:mocktail/mocktail.dart'; 4 | import 'package:now_in_dart_flutter/core/data/github_header.dart'; 5 | import 'package:now_in_dart_flutter/core/data/remote_response.dart'; 6 | import 'package:now_in_dart_flutter/core/domain/failure.dart'; 7 | import 'package:test/test.dart'; 8 | 9 | import '../../../../helpers/mocks.dart'; 10 | import '../../../../helpers/register_multiple_fallback_values.dart'; 11 | 12 | void main() { 13 | final dio = MockDio(); 14 | final response = MockResponse(); 15 | final headers = MockHeaders(); 16 | final headerCache = MockHeaderCache(); 17 | final detailRemoteService = MockDetailRemoteService( 18 | dio: dio, 19 | headerCache: headerCache, 20 | ); 21 | 22 | setUpAll(() { 23 | registerMultipleFallbackValues([ 24 | FakeUri(), 25 | FakeOptions(), 26 | FakeGithubHeader(), 27 | ]); 28 | }); 29 | 30 | group( 31 | 'DetailRemoteService |', 32 | () { 33 | const fakeGithubHeader = GithubHeader( 34 | id: 1, 35 | eTag: '12345', 36 | path: '/path', 37 | ); 38 | 39 | test( 40 | 'should instantiate Dio() and HeaderCache() when not injected', 41 | () => expect(MockDetailRemoteService(), isNotNull), 42 | ); 43 | group( 44 | 'The method `getDetail`', 45 | () { 46 | setUpAll( 47 | () => when( 48 | () => headerCache.getHeader(any(that: isA())), 49 | ).thenReturn(Task(() async => fakeGithubHeader)), 50 | ); 51 | test( 52 | 'should return right of TaskEither>' 53 | ' i.e. ModifiedRemoteResponse if the status code is 200', 54 | () async { 55 | when(() => headers.map).thenReturn( 56 | { 57 | 'ETag': ['12345'], 58 | }, 59 | ); 60 | 61 | when(() => response.statusCode).thenReturn(200); 62 | when(() => response.data).thenReturn('html'); 63 | when(() => response.headers).thenReturn(headers); 64 | 65 | when( 66 | () => dio.getUri( 67 | any(that: isA()), 68 | options: any(named: 'options', that: isA()), 69 | ), 70 | ).thenAnswer((_) async => response); 71 | 72 | when( 73 | () => headerCache.saveHeader(any(that: isA())), 74 | ).thenReturn(Task(() async => unit)); 75 | 76 | final result = 77 | await detailRemoteService.getDetail(1, '/path').run(); 78 | 79 | expect( 80 | result, 81 | right>( 82 | const ModifiedRemoteResponse('html'), 83 | ), 84 | ); 85 | }, 86 | ); 87 | 88 | test( 89 | 'should return right of TaskEither>' 90 | ' i.e. UnModifiedRemoteResponse if the status code is 304', 91 | () async { 92 | when(() => response.statusCode).thenReturn(304); 93 | 94 | when( 95 | () => dio.getUri( 96 | any(that: isA()), 97 | options: any(named: 'options', that: isA()), 98 | ), 99 | ).thenAnswer((_) async => response); 100 | 101 | final result = 102 | await detailRemoteService.getDetail(1, '/path').run(); 103 | 104 | expect( 105 | result, 106 | right>( 107 | const UnModifiedRemoteResponse(), 108 | ), 109 | ); 110 | }, 111 | ); 112 | 113 | test( 114 | 'should return right of TaskEither>' 115 | ' i.e. NoConnectionRemoteResponse if DioException.connectionError ' 116 | 'is thrown', 117 | () async { 118 | when( 119 | () => dio.getUri( 120 | any(that: isA()), 121 | options: any(named: 'options', that: isA()), 122 | ), 123 | ).thenThrow( 124 | DioException.connectionError( 125 | requestOptions: RequestOptions(), 126 | reason: '', 127 | ), 128 | ); 129 | 130 | final result = 131 | await detailRemoteService.getDetail(1, '/path').run(); 132 | 133 | expect( 134 | result, 135 | right>( 136 | const NoConnectionRemoteResponse(), 137 | ), 138 | ); 139 | }, 140 | ); 141 | 142 | test( 143 | 'should return left of TaskEither>' 144 | ' i.e. ApiFailure if network request is unsuccessful', 145 | () async { 146 | const errorMessage = 'Error on network request'; 147 | 148 | when( 149 | () => dio.getUri( 150 | any(that: isA()), 151 | options: any(named: 'options', that: isA()), 152 | ), 153 | ).thenThrow(Exception()); 154 | 155 | final result = 156 | await detailRemoteService.getDetail(1, '/path').run(); 157 | 158 | expect( 159 | result.match( 160 | (failure) { 161 | final isApiFailure = failure is ApiFailure; 162 | return isApiFailure && failure.message == errorMessage; 163 | }, 164 | (_) => false, 165 | ), 166 | isTrue, 167 | ); 168 | }, 169 | ); 170 | }, 171 | ); 172 | }, 173 | ); 174 | } 175 | -------------------------------------------------------------------------------- /windows/runner/win32_window.cpp: -------------------------------------------------------------------------------- 1 | #include "win32_window.h" 2 | 3 | #include 4 | 5 | #include "resource.h" 6 | 7 | namespace { 8 | 9 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 10 | 11 | // The number of Win32Window objects that currently exist. 12 | static int g_active_window_count = 0; 13 | 14 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 15 | 16 | // Scale helper to convert logical scaler values to physical using passed in 17 | // scale factor 18 | int Scale(int source, double scale_factor) { 19 | return static_cast(source * scale_factor); 20 | } 21 | 22 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 23 | // This API is only needed for PerMonitor V1 awareness mode. 24 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 25 | HMODULE user32_module = LoadLibraryA("User32.dll"); 26 | if (!user32_module) { 27 | return; 28 | } 29 | auto enable_non_client_dpi_scaling = 30 | reinterpret_cast( 31 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 32 | if (enable_non_client_dpi_scaling != nullptr) { 33 | enable_non_client_dpi_scaling(hwnd); 34 | FreeLibrary(user32_module); 35 | } 36 | } 37 | 38 | } // namespace 39 | 40 | // Manages the Win32Window's window class registration. 41 | class WindowClassRegistrar { 42 | public: 43 | ~WindowClassRegistrar() = default; 44 | 45 | // Returns the singleton registar instance. 46 | static WindowClassRegistrar* GetInstance() { 47 | if (!instance_) { 48 | instance_ = new WindowClassRegistrar(); 49 | } 50 | return instance_; 51 | } 52 | 53 | // Returns the name of the window class, registering the class if it hasn't 54 | // previously been registered. 55 | const wchar_t* GetWindowClass(); 56 | 57 | // Unregisters the window class. Should only be called if there are no 58 | // instances of the window. 59 | void UnregisterWindowClass(); 60 | 61 | private: 62 | WindowClassRegistrar() = default; 63 | 64 | static WindowClassRegistrar* instance_; 65 | 66 | bool class_registered_ = false; 67 | }; 68 | 69 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 70 | 71 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 72 | if (!class_registered_) { 73 | WNDCLASS window_class{}; 74 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 75 | window_class.lpszClassName = kWindowClassName; 76 | window_class.style = CS_HREDRAW | CS_VREDRAW; 77 | window_class.cbClsExtra = 0; 78 | window_class.cbWndExtra = 0; 79 | window_class.hInstance = GetModuleHandle(nullptr); 80 | window_class.hIcon = 81 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 82 | window_class.hbrBackground = 0; 83 | window_class.lpszMenuName = nullptr; 84 | window_class.lpfnWndProc = Win32Window::WndProc; 85 | RegisterClass(&window_class); 86 | class_registered_ = true; 87 | } 88 | return kWindowClassName; 89 | } 90 | 91 | void WindowClassRegistrar::UnregisterWindowClass() { 92 | UnregisterClass(kWindowClassName, nullptr); 93 | class_registered_ = false; 94 | } 95 | 96 | Win32Window::Win32Window() { 97 | ++g_active_window_count; 98 | } 99 | 100 | Win32Window::~Win32Window() { 101 | --g_active_window_count; 102 | Destroy(); 103 | } 104 | 105 | bool Win32Window::CreateAndShow(const std::wstring& title, 106 | const Point& origin, 107 | const Size& size) { 108 | Destroy(); 109 | 110 | const wchar_t* window_class = 111 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 112 | 113 | const POINT target_point = {static_cast(origin.x), 114 | static_cast(origin.y)}; 115 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 116 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 117 | double scale_factor = dpi / 96.0; 118 | 119 | HWND window = CreateWindow( 120 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, 121 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 122 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 123 | nullptr, nullptr, GetModuleHandle(nullptr), this); 124 | 125 | if (!window) { 126 | return false; 127 | } 128 | 129 | return OnCreate(); 130 | } 131 | 132 | // static 133 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 134 | UINT const message, 135 | WPARAM const wparam, 136 | LPARAM const lparam) noexcept { 137 | if (message == WM_NCCREATE) { 138 | auto window_struct = reinterpret_cast(lparam); 139 | SetWindowLongPtr(window, GWLP_USERDATA, 140 | reinterpret_cast(window_struct->lpCreateParams)); 141 | 142 | auto that = static_cast(window_struct->lpCreateParams); 143 | EnableFullDpiSupportIfAvailable(window); 144 | that->window_handle_ = window; 145 | } else if (Win32Window* that = GetThisFromHandle(window)) { 146 | return that->MessageHandler(window, message, wparam, lparam); 147 | } 148 | 149 | return DefWindowProc(window, message, wparam, lparam); 150 | } 151 | 152 | LRESULT 153 | Win32Window::MessageHandler(HWND hwnd, 154 | UINT const message, 155 | WPARAM const wparam, 156 | LPARAM const lparam) noexcept { 157 | switch (message) { 158 | case WM_DESTROY: 159 | window_handle_ = nullptr; 160 | Destroy(); 161 | if (quit_on_close_) { 162 | PostQuitMessage(0); 163 | } 164 | return 0; 165 | 166 | case WM_DPICHANGED: { 167 | auto newRectSize = reinterpret_cast(lparam); 168 | LONG newWidth = newRectSize->right - newRectSize->left; 169 | LONG newHeight = newRectSize->bottom - newRectSize->top; 170 | 171 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 172 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 173 | 174 | return 0; 175 | } 176 | case WM_SIZE: { 177 | RECT rect = GetClientArea(); 178 | if (child_content_ != nullptr) { 179 | // Size and position the child window. 180 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 181 | rect.bottom - rect.top, TRUE); 182 | } 183 | return 0; 184 | } 185 | 186 | case WM_ACTIVATE: 187 | if (child_content_ != nullptr) { 188 | SetFocus(child_content_); 189 | } 190 | return 0; 191 | } 192 | 193 | return DefWindowProc(window_handle_, message, wparam, lparam); 194 | } 195 | 196 | void Win32Window::Destroy() { 197 | OnDestroy(); 198 | 199 | if (window_handle_) { 200 | DestroyWindow(window_handle_); 201 | window_handle_ = nullptr; 202 | } 203 | if (g_active_window_count == 0) { 204 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 205 | } 206 | } 207 | 208 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 209 | return reinterpret_cast( 210 | GetWindowLongPtr(window, GWLP_USERDATA)); 211 | } 212 | 213 | void Win32Window::SetChildContent(HWND content) { 214 | child_content_ = content; 215 | SetParent(content, window_handle_); 216 | RECT frame = GetClientArea(); 217 | 218 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 219 | frame.bottom - frame.top, true); 220 | 221 | SetFocus(child_content_); 222 | } 223 | 224 | RECT Win32Window::GetClientArea() { 225 | RECT frame; 226 | GetClientRect(window_handle_, &frame); 227 | return frame; 228 | } 229 | 230 | HWND Win32Window::GetHandle() { 231 | return window_handle_; 232 | } 233 | 234 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 235 | quit_on_close_ = quit_on_close; 236 | } 237 | 238 | bool Win32Window::OnCreate() { 239 | // No-op; provided for subclasses. 240 | return true; 241 | } 242 | 243 | void Win32Window::OnDestroy() { 244 | // No-op; provided for subclasses. 245 | } 246 | -------------------------------------------------------------------------------- /lib/features/detail/core/data/detail_dto.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'detail_dto.dart'; 4 | 5 | // ************************************************************************** 6 | // IsarCollectionGenerator 7 | // ************************************************************************** 8 | 9 | // coverage:ignore-file 10 | // ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types 11 | 12 | extension GetDetailDTOCollection on Isar { 13 | IsarCollection get detailDTOs => this.collection(); 14 | } 15 | 16 | const DetailDTOSchema = CollectionSchema( 17 | name: r'DetailDTO', 18 | id: -2968836428816848386, 19 | properties: { 20 | r'html': PropertySchema( 21 | id: 0, 22 | name: r'html', 23 | type: IsarType.string, 24 | ) 25 | }, 26 | estimateSize: _detailDTOEstimateSize, 27 | serialize: _detailDTOSerialize, 28 | deserialize: _detailDTODeserialize, 29 | deserializeProp: _detailDTODeserializeProp, 30 | idName: r'id', 31 | indexes: {}, 32 | links: {}, 33 | embeddedSchemas: {}, 34 | getId: _detailDTOGetId, 35 | getLinks: _detailDTOGetLinks, 36 | attach: _detailDTOAttach, 37 | version: '3.1.0+1', 38 | ); 39 | 40 | int _detailDTOEstimateSize( 41 | DetailDTO object, 42 | List offsets, 43 | Map> allOffsets, 44 | ) { 45 | var bytesCount = offsets.last; 46 | bytesCount += 3 + object.html.length * 3; 47 | return bytesCount; 48 | } 49 | 50 | void _detailDTOSerialize( 51 | DetailDTO object, 52 | IsarWriter writer, 53 | List offsets, 54 | Map> allOffsets, 55 | ) { 56 | writer.writeString(offsets[0], object.html); 57 | } 58 | 59 | DetailDTO _detailDTODeserialize( 60 | Id id, 61 | IsarReader reader, 62 | List offsets, 63 | Map> allOffsets, 64 | ) { 65 | final object = DetailDTO( 66 | html: reader.readString(offsets[0]), 67 | id: id, 68 | ); 69 | return object; 70 | } 71 | 72 | P _detailDTODeserializeProp

( 73 | IsarReader reader, 74 | int propertyId, 75 | int offset, 76 | Map> allOffsets, 77 | ) { 78 | switch (propertyId) { 79 | case 0: 80 | return (reader.readString(offset)) as P; 81 | default: 82 | throw IsarError('Unknown property with id $propertyId'); 83 | } 84 | } 85 | 86 | Id _detailDTOGetId(DetailDTO object) { 87 | return object.id; 88 | } 89 | 90 | List> _detailDTOGetLinks(DetailDTO object) { 91 | return []; 92 | } 93 | 94 | void _detailDTOAttach(IsarCollection col, Id id, DetailDTO object) {} 95 | 96 | extension DetailDTOQueryWhereSort 97 | on QueryBuilder { 98 | QueryBuilder anyId() { 99 | return QueryBuilder.apply(this, (query) { 100 | return query.addWhereClause(const IdWhereClause.any()); 101 | }); 102 | } 103 | } 104 | 105 | extension DetailDTOQueryWhere 106 | on QueryBuilder { 107 | QueryBuilder idEqualTo(Id id) { 108 | return QueryBuilder.apply(this, (query) { 109 | return query.addWhereClause(IdWhereClause.between( 110 | lower: id, 111 | upper: id, 112 | )); 113 | }); 114 | } 115 | 116 | QueryBuilder idNotEqualTo(Id id) { 117 | return QueryBuilder.apply(this, (query) { 118 | if (query.whereSort == Sort.asc) { 119 | return query 120 | .addWhereClause( 121 | IdWhereClause.lessThan(upper: id, includeUpper: false), 122 | ) 123 | .addWhereClause( 124 | IdWhereClause.greaterThan(lower: id, includeLower: false), 125 | ); 126 | } else { 127 | return query 128 | .addWhereClause( 129 | IdWhereClause.greaterThan(lower: id, includeLower: false), 130 | ) 131 | .addWhereClause( 132 | IdWhereClause.lessThan(upper: id, includeUpper: false), 133 | ); 134 | } 135 | }); 136 | } 137 | 138 | QueryBuilder idGreaterThan(Id id, 139 | {bool include = false}) { 140 | return QueryBuilder.apply(this, (query) { 141 | return query.addWhereClause( 142 | IdWhereClause.greaterThan(lower: id, includeLower: include), 143 | ); 144 | }); 145 | } 146 | 147 | QueryBuilder idLessThan(Id id, 148 | {bool include = false}) { 149 | return QueryBuilder.apply(this, (query) { 150 | return query.addWhereClause( 151 | IdWhereClause.lessThan(upper: id, includeUpper: include), 152 | ); 153 | }); 154 | } 155 | 156 | QueryBuilder idBetween( 157 | Id lowerId, 158 | Id upperId, { 159 | bool includeLower = true, 160 | bool includeUpper = true, 161 | }) { 162 | return QueryBuilder.apply(this, (query) { 163 | return query.addWhereClause(IdWhereClause.between( 164 | lower: lowerId, 165 | includeLower: includeLower, 166 | upper: upperId, 167 | includeUpper: includeUpper, 168 | )); 169 | }); 170 | } 171 | } 172 | 173 | extension DetailDTOQueryFilter 174 | on QueryBuilder { 175 | QueryBuilder htmlEqualTo( 176 | String value, { 177 | bool caseSensitive = true, 178 | }) { 179 | return QueryBuilder.apply(this, (query) { 180 | return query.addFilterCondition(FilterCondition.equalTo( 181 | property: r'html', 182 | value: value, 183 | caseSensitive: caseSensitive, 184 | )); 185 | }); 186 | } 187 | 188 | QueryBuilder htmlGreaterThan( 189 | String value, { 190 | bool include = false, 191 | bool caseSensitive = true, 192 | }) { 193 | return QueryBuilder.apply(this, (query) { 194 | return query.addFilterCondition(FilterCondition.greaterThan( 195 | include: include, 196 | property: r'html', 197 | value: value, 198 | caseSensitive: caseSensitive, 199 | )); 200 | }); 201 | } 202 | 203 | QueryBuilder htmlLessThan( 204 | String value, { 205 | bool include = false, 206 | bool caseSensitive = true, 207 | }) { 208 | return QueryBuilder.apply(this, (query) { 209 | return query.addFilterCondition(FilterCondition.lessThan( 210 | include: include, 211 | property: r'html', 212 | value: value, 213 | caseSensitive: caseSensitive, 214 | )); 215 | }); 216 | } 217 | 218 | QueryBuilder htmlBetween( 219 | String lower, 220 | String upper, { 221 | bool includeLower = true, 222 | bool includeUpper = true, 223 | bool caseSensitive = true, 224 | }) { 225 | return QueryBuilder.apply(this, (query) { 226 | return query.addFilterCondition(FilterCondition.between( 227 | property: r'html', 228 | lower: lower, 229 | includeLower: includeLower, 230 | upper: upper, 231 | includeUpper: includeUpper, 232 | caseSensitive: caseSensitive, 233 | )); 234 | }); 235 | } 236 | 237 | QueryBuilder htmlStartsWith( 238 | String value, { 239 | bool caseSensitive = true, 240 | }) { 241 | return QueryBuilder.apply(this, (query) { 242 | return query.addFilterCondition(FilterCondition.startsWith( 243 | property: r'html', 244 | value: value, 245 | caseSensitive: caseSensitive, 246 | )); 247 | }); 248 | } 249 | 250 | QueryBuilder htmlEndsWith( 251 | String value, { 252 | bool caseSensitive = true, 253 | }) { 254 | return QueryBuilder.apply(this, (query) { 255 | return query.addFilterCondition(FilterCondition.endsWith( 256 | property: r'html', 257 | value: value, 258 | caseSensitive: caseSensitive, 259 | )); 260 | }); 261 | } 262 | 263 | QueryBuilder htmlContains( 264 | String value, 265 | {bool caseSensitive = true}) { 266 | return QueryBuilder.apply(this, (query) { 267 | return query.addFilterCondition(FilterCondition.contains( 268 | property: r'html', 269 | value: value, 270 | caseSensitive: caseSensitive, 271 | )); 272 | }); 273 | } 274 | 275 | QueryBuilder htmlMatches( 276 | String pattern, 277 | {bool caseSensitive = true}) { 278 | return QueryBuilder.apply(this, (query) { 279 | return query.addFilterCondition(FilterCondition.matches( 280 | property: r'html', 281 | wildcard: pattern, 282 | caseSensitive: caseSensitive, 283 | )); 284 | }); 285 | } 286 | 287 | QueryBuilder htmlIsEmpty() { 288 | return QueryBuilder.apply(this, (query) { 289 | return query.addFilterCondition(FilterCondition.equalTo( 290 | property: r'html', 291 | value: '', 292 | )); 293 | }); 294 | } 295 | 296 | QueryBuilder htmlIsNotEmpty() { 297 | return QueryBuilder.apply(this, (query) { 298 | return query.addFilterCondition(FilterCondition.greaterThan( 299 | property: r'html', 300 | value: '', 301 | )); 302 | }); 303 | } 304 | 305 | QueryBuilder idEqualTo( 306 | Id value) { 307 | return QueryBuilder.apply(this, (query) { 308 | return query.addFilterCondition(FilterCondition.equalTo( 309 | property: r'id', 310 | value: value, 311 | )); 312 | }); 313 | } 314 | 315 | QueryBuilder idGreaterThan( 316 | Id value, { 317 | bool include = false, 318 | }) { 319 | return QueryBuilder.apply(this, (query) { 320 | return query.addFilterCondition(FilterCondition.greaterThan( 321 | include: include, 322 | property: r'id', 323 | value: value, 324 | )); 325 | }); 326 | } 327 | 328 | QueryBuilder idLessThan( 329 | Id value, { 330 | bool include = false, 331 | }) { 332 | return QueryBuilder.apply(this, (query) { 333 | return query.addFilterCondition(FilterCondition.lessThan( 334 | include: include, 335 | property: r'id', 336 | value: value, 337 | )); 338 | }); 339 | } 340 | 341 | QueryBuilder idBetween( 342 | Id lower, 343 | Id upper, { 344 | bool includeLower = true, 345 | bool includeUpper = true, 346 | }) { 347 | return QueryBuilder.apply(this, (query) { 348 | return query.addFilterCondition(FilterCondition.between( 349 | property: r'id', 350 | lower: lower, 351 | includeLower: includeLower, 352 | upper: upper, 353 | includeUpper: includeUpper, 354 | )); 355 | }); 356 | } 357 | } 358 | 359 | extension DetailDTOQueryObject 360 | on QueryBuilder {} 361 | 362 | extension DetailDTOQueryLinks 363 | on QueryBuilder {} 364 | 365 | extension DetailDTOQuerySortBy on QueryBuilder { 366 | QueryBuilder sortByHtml() { 367 | return QueryBuilder.apply(this, (query) { 368 | return query.addSortBy(r'html', Sort.asc); 369 | }); 370 | } 371 | 372 | QueryBuilder sortByHtmlDesc() { 373 | return QueryBuilder.apply(this, (query) { 374 | return query.addSortBy(r'html', Sort.desc); 375 | }); 376 | } 377 | } 378 | 379 | extension DetailDTOQuerySortThenBy 380 | on QueryBuilder { 381 | QueryBuilder thenByHtml() { 382 | return QueryBuilder.apply(this, (query) { 383 | return query.addSortBy(r'html', Sort.asc); 384 | }); 385 | } 386 | 387 | QueryBuilder thenByHtmlDesc() { 388 | return QueryBuilder.apply(this, (query) { 389 | return query.addSortBy(r'html', Sort.desc); 390 | }); 391 | } 392 | 393 | QueryBuilder thenById() { 394 | return QueryBuilder.apply(this, (query) { 395 | return query.addSortBy(r'id', Sort.asc); 396 | }); 397 | } 398 | 399 | QueryBuilder thenByIdDesc() { 400 | return QueryBuilder.apply(this, (query) { 401 | return query.addSortBy(r'id', Sort.desc); 402 | }); 403 | } 404 | } 405 | 406 | extension DetailDTOQueryWhereDistinct 407 | on QueryBuilder { 408 | QueryBuilder distinctByHtml( 409 | {bool caseSensitive = true}) { 410 | return QueryBuilder.apply(this, (query) { 411 | return query.addDistinctBy(r'html', caseSensitive: caseSensitive); 412 | }); 413 | } 414 | } 415 | 416 | extension DetailDTOQueryProperty 417 | on QueryBuilder { 418 | QueryBuilder idProperty() { 419 | return QueryBuilder.apply(this, (query) { 420 | return query.addPropertyName(r'id'); 421 | }); 422 | } 423 | 424 | QueryBuilder htmlProperty() { 425 | return QueryBuilder.apply(this, (query) { 426 | return query.addPropertyName(r'html'); 427 | }); 428 | } 429 | } 430 | --------------------------------------------------------------------------------