├── .firebaserc ├── .github └── FUNDING.yml ├── .gitignore ├── .metadata ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── build.gradle ├── settings.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── kotlin │ └── com │ └── mono0926 │ └── mono_kit │ └── MonoKitPlugin.kt ├── devtools_options.yaml ├── example ├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle.kts │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── mono0926 │ │ │ │ │ └── example │ │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ │ ├── drawable-v21 │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── 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 │ │ │ │ ├── values-night │ │ │ │ └── styles.xml │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle.kts │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle.kts ├── assets │ └── images │ │ └── love.png ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Podfile │ ├── Podfile.lock │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── 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-83.5x83.5@2x.png │ │ │ └── LaunchImage.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ └── README.md │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h │ └── RunnerTests │ │ └── RunnerTests.swift ├── lib │ ├── app.dart │ ├── main.dart │ ├── pages │ │ ├── app_bottom_area_page.dart │ │ ├── banner_visibility_page.dart │ │ ├── barrier_page.dart │ │ ├── better_placeholder_page.dart │ │ ├── color_ex_page.dart │ │ ├── debug_padding_page.dart │ │ ├── delayed_pop_scope_page.dart │ │ ├── home_page.dart │ │ ├── lifecycle_observer_page.dart │ │ ├── list_tile_selected_background_colored_box_page.dart │ │ ├── loading_switcher_page.dart │ │ ├── max_width_padding_builder_page.dart │ │ ├── not_found.page.dart │ │ ├── overflow_detectable_text_page │ │ │ ├── cell.dart │ │ │ ├── data.dart │ │ │ └── overflow_detectable_text_page.dart │ │ ├── pages.dart │ │ ├── paging_scroll_page.dart │ │ ├── snack_bar_page.dart │ │ ├── unfocus_on_tap_page.dart │ │ └── vertical_center_scroll_view_page.dart │ ├── router │ │ ├── router.dart │ │ └── router.g.dart │ └── util │ │ ├── logger.dart │ │ └── util.dart ├── macos │ ├── .gitignore │ ├── Flutter │ │ ├── Flutter-Debug.xcconfig │ │ ├── Flutter-Release.xcconfig │ │ └── GeneratedPluginRegistrant.swift │ ├── Podfile │ ├── Podfile.lock │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── 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 │ │ ├── Base.lproj │ │ │ └── MainMenu.xib │ │ ├── Configs │ │ │ ├── AppInfo.xcconfig │ │ │ ├── Debug.xcconfig │ │ │ ├── Release.xcconfig │ │ │ └── Warnings.xcconfig │ │ ├── DebugProfile.entitlements │ │ ├── Info.plist │ │ ├── MainFlutterWindow.swift │ │ └── Release.entitlements │ └── RunnerTests │ │ └── RunnerTests.swift ├── pubspec.lock ├── pubspec.yaml ├── test │ └── widget_test.dart ├── web │ ├── favicon.png │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ ├── index.html │ └── manifest.json └── windows │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake │ └── runner │ ├── CMakeLists.txt │ ├── Runner.rc │ ├── flutter_window.cpp │ ├── flutter_window.h │ ├── main.cpp │ ├── resource.h │ ├── resources │ └── app_icon.ico │ ├── runner.exe.manifest │ ├── utils.cpp │ ├── utils.h │ ├── win32_window.cpp │ └── win32_window.h ├── firebase.json ├── ios ├── .gitignore ├── Assets │ └── .gitkeep ├── Classes │ ├── MonoKitPlugin.h │ ├── MonoKitPlugin.m │ └── SwiftMonoKitPlugin.swift └── mono_kit.podspec ├── lib ├── errors │ ├── errors.dart │ └── unexpected_error.dart ├── extensions │ ├── color.dart │ ├── enum.dart │ ├── extensions.dart │ ├── iterable.dart │ ├── navigator_state.dart │ ├── scaffold_messenger_state.dart │ ├── state_notifier.dart │ ├── string.dart │ └── theme_data.dart ├── functions │ ├── functions.dart │ ├── show_error_dialog.dart │ └── show_photo_selection_sheet.dart ├── mono_kit.dart ├── plugins │ ├── app_installation_checker.dart │ ├── ios_info_plist_reader.dart │ └── plugins.dart ├── routes │ ├── bottom_popup_route.dart │ ├── fade_page_route.dart │ ├── modal_page_route.dart │ └── routes.dart ├── utils │ ├── build_mode.dart │ ├── hud.dart │ ├── lifecycle_observer.dart │ ├── logger.dart │ ├── paging_scroll_controller.dart │ └── utils.dart └── widgets │ ├── animated_expansion_visibility.dart │ ├── app_asset_image.dart │ ├── app_bottom_area.dart │ ├── barrier.dart │ ├── better_animated_opacity.dart │ ├── better_fade_transition.dart │ ├── better_placeholder.dart │ ├── better_stream_builder.dart │ ├── centered_max_width.dart │ ├── debug_padding.dart │ ├── delayed_pop_scope.dart │ ├── device_frame.dart │ ├── go_router_location_button.dart │ ├── itemized_text.dart │ ├── link_text_span.dart │ ├── list_section.dart │ ├── list_section_header.dart │ ├── list_tile_selected_background_colored_box.dart │ ├── listener │ ├── listener.dart │ ├── listener_text.dart │ └── listener_visibility.dart │ ├── loading_switcher.dart │ ├── max_width_padding_builder.dart │ ├── overflow_detectable_text.dart │ ├── ripple_effect_button.dart │ ├── scroll_keyboard_shortcut.dart │ ├── size_listener.dart │ ├── text_scale_factor.dart │ ├── tile_padding.dart │ ├── timeout_switcher.dart │ ├── unfocus_on_tap.dart │ ├── value_observable_builder.dart │ ├── vertical_center_scroll_view.dart │ ├── widgets.dart │ └── wip.dart ├── macos ├── Classes │ └── MonoKitPlugin.swift └── mono_kit.podspec ├── packages └── subscription_holder │ ├── .gitignore │ ├── .metadata │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── lib │ ├── src │ │ ├── subscription_holder.dart │ │ └── subscription_holder_mixin.dart │ └── subscription_holder.dart │ ├── pubspec.lock │ ├── pubspec.yaml │ └── test │ └── subscription_holder_test.dart ├── pubspec.lock ├── pubspec.yaml ├── test ├── extensions │ └── iterable_test.dart ├── mono_kit_test.dart └── utils │ └── functions_test.dart └── tool └── deploy_web.sh /.firebaserc: -------------------------------------------------------------------------------- 1 | { 2 | "projects": { 3 | "default": "mono-firebase" 4 | }, 5 | "targets": { 6 | "mono-firebase": { 7 | "hosting": { 8 | "mono-kit": [ 9 | "mono-kit" 10 | ] 11 | } 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: 2 | - mono0926 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # Visual Studio Code related 19 | .vscode/ 20 | 21 | # Flutter/Dart/Pub related 22 | **/doc/api/ 23 | .dart_tool/ 24 | .flutter-plugins 25 | .packages 26 | .pub-cache/ 27 | .pub/ 28 | build/ 29 | 30 | # Android related 31 | **/android/**/gradle-wrapper.jar 32 | **/android/.gradle 33 | **/android/captures/ 34 | **/android/gradlew 35 | **/android/gradlew.bat 36 | **/android/local.properties 37 | **/android/**/GeneratedPluginRegistrant.java 38 | 39 | # iOS/XCode related 40 | **/ios/**/*.mode1v3 41 | **/ios/**/*.mode2v3 42 | **/ios/**/*.moved-aside 43 | **/ios/**/*.pbxuser 44 | **/ios/**/*.perspectivev3 45 | **/ios/**/*sync/ 46 | **/ios/**/.sconsign.dblite 47 | **/ios/**/.tags* 48 | **/ios/**/.vagrant/ 49 | **/ios/**/DerivedData/ 50 | **/ios/**/Icon? 51 | **/ios/**/Pods/ 52 | **/ios/**/.symlinks/ 53 | **/ios/**/profile 54 | **/ios/**/xcuserdata 55 | **/ios/.generated/ 56 | **/ios/Flutter/App.framework 57 | **/ios/Flutter/Flutter.framework 58 | **/ios/Flutter/Generated.xcconfig 59 | **/ios/Flutter/app.flx 60 | **/ios/Flutter/app.zip 61 | **/ios/Flutter/flutter_assets/ 62 | **/ios/Flutter/flutter_export_environment.sh 63 | **/ios/ServiceDefinitions.json 64 | **/ios/Runner/GeneratedPluginRegistrant.* 65 | 66 | # Exceptions to above rules. 67 | !**/ios/**/default.mode1v3 68 | !**/ios/**/default.mode2v3 69 | !**/ios/**/default.pbxuser 70 | !**/ios/**/default.perspectivev3 71 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 72 | **/ios/Flutter/Flutter.podspec 73 | 74 | generated_plugin_registrant.dart 75 | .flutter-plugins-dependencies 76 | .firebase/ 77 | -------------------------------------------------------------------------------- /.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 and should not be manually edited. 5 | 6 | version: 7 | revision: "603104015dd692ea3403755b55d07813d5cf8965" 8 | channel: "stable" 9 | 10 | project_type: plugin 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 603104015dd692ea3403755b55d07813d5cf8965 17 | base_revision: 603104015dd692ea3403755b55d07813d5cf8965 18 | - platform: android 19 | create_revision: 603104015dd692ea3403755b55d07813d5cf8965 20 | base_revision: 603104015dd692ea3403755b55d07813d5cf8965 21 | - platform: ios 22 | create_revision: 603104015dd692ea3403755b55d07813d5cf8965 23 | base_revision: 603104015dd692ea3403755b55d07813d5cf8965 24 | 25 | # User provided section 26 | 27 | # List of Local paths (relative to this file) that should be 28 | # ignored by the migrate tool. 29 | # 30 | # Files that are not part of the templates will be ignored by default. 31 | unmanaged_files: 32 | - 'lib/main.dart' 33 | - 'ios/Runner.xcodeproj/project.pbxproj' 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Masayuki Ono 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mono_kit 2 | 3 | A collection of convenient widgets and utils made by mono. 4 | 5 | - Demo: https://mono-kit.web.app 6 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # https://pub.dev/packages/pedantic_mono 2 | include: package:pedantic_mono/analysis_options.yaml 3 | analyzer: 4 | exclude: 5 | - lib/generated_*.dart 6 | - lib/**/*.g.dart 7 | - lib/**/*.freezed.dart 8 | linter: 9 | rules: 10 | use_build_context_synchronously: false 11 | specify_nonobvious_property_types: false 12 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .cxx 10 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | group = "com.mono0926.mono_kit" 2 | version = "1.0-SNAPSHOT" 3 | 4 | buildscript { 5 | ext.kotlin_version = "1.8.22" 6 | repositories { 7 | google() 8 | mavenCentral() 9 | } 10 | 11 | dependencies { 12 | classpath("com.android.tools.build:gradle:8.1.0") 13 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version") 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | google() 20 | mavenCentral() 21 | } 22 | } 23 | 24 | apply plugin: "com.android.library" 25 | apply plugin: "kotlin-android" 26 | 27 | android { 28 | if (project.android.hasProperty("namespace")) { 29 | namespace = "com.mono0926.mono_kit" 30 | } 31 | 32 | compileSdk = 34 33 | 34 | compileOptions { 35 | sourceCompatibility = JavaVersion.VERSION_1_8 36 | targetCompatibility = JavaVersion.VERSION_1_8 37 | } 38 | 39 | kotlinOptions { 40 | jvmTarget = JavaVersion.VERSION_1_8 41 | } 42 | 43 | sourceSets { 44 | main.java.srcDirs += "src/main/kotlin" 45 | test.java.srcDirs += "src/test/kotlin" 46 | } 47 | 48 | defaultConfig { 49 | minSdk = 21 50 | } 51 | 52 | dependencies { 53 | testImplementation("org.jetbrains.kotlin:kotlin-test") 54 | testImplementation("org.mockito:mockito-core:5.0.0") 55 | } 56 | 57 | testOptions { 58 | unitTests.all { 59 | useJUnitPlatform() 60 | 61 | testLogging { 62 | events "passed", "skipped", "failed", "standardOut", "standardError" 63 | outputs.upToDateWhen {false} 64 | showStandardStreams = true 65 | } 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'mono_kit' 2 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/mono0926/mono_kit/MonoKitPlugin.kt: -------------------------------------------------------------------------------- 1 | package com.mono0926.mono_kit 2 | 3 | import io.flutter.plugin.common.MethodCall 4 | import io.flutter.plugin.common.MethodChannel 5 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler 6 | import io.flutter.plugin.common.MethodChannel.Result 7 | import android.content.pm.PackageManager 8 | import android.app.Activity 9 | import androidx.annotation.NonNull 10 | import io.flutter.embedding.engine.plugins.FlutterPlugin 11 | import io.flutter.embedding.engine.plugins.activity.ActivityAware 12 | import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding 13 | 14 | class MonoKitPlugin: FlutterPlugin, MethodCallHandler, ActivityAware { 15 | 16 | private lateinit var channel : MethodChannel 17 | private lateinit var activity: Activity 18 | 19 | override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { 20 | channel = MethodChannel(flutterPluginBinding.binaryMessenger, "mono_kit") 21 | channel.setMethodCallHandler(this) 22 | } 23 | 24 | override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { 25 | val method = call.method 26 | val info = method.split('/') 27 | val group = info[0] 28 | val path = info[1] 29 | @Suppress("UNCHECKED_CAST") 30 | val arguments = call.arguments as Map 31 | when (group) { 32 | "installation_checker" -> when (path) { 33 | "is_installed" -> { 34 | val packageName = arguments.getValue("package_name") 35 | val isInstalled = isInstalled(packageName, activity.packageManager) 36 | result.success(isInstalled) 37 | } 38 | else -> result.notImplemented() 39 | } 40 | else -> result.notImplemented() 41 | } 42 | } 43 | 44 | override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {} 45 | 46 | override fun onDetachedFromActivity() {} 47 | override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {} 48 | override fun onAttachedToActivity(binding: ActivityPluginBinding) { 49 | activity = binding.activity 50 | } 51 | override fun onDetachedFromActivityForConfigChanges() {} 52 | } 53 | 54 | private fun isInstalled(packageName: String, packageManager: PackageManager): Boolean { 55 | return try { 56 | packageManager.getPackageInfo(packageName, 0) 57 | true 58 | } catch (e: PackageManager.NameNotFoundException) { 59 | false 60 | } 61 | } -------------------------------------------------------------------------------- /devtools_options.yaml: -------------------------------------------------------------------------------- 1 | description: This file stores settings for Dart & Flutter DevTools. 2 | documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states 3 | extensions: 4 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .packages 28 | .pub-cache/ 29 | .pub/ 30 | /build/ 31 | 32 | # Android related 33 | **/android/**/gradle-wrapper.jar 34 | **/android/.gradle 35 | **/android/captures/ 36 | **/android/gradlew 37 | **/android/gradlew.bat 38 | **/android/local.properties 39 | **/android/**/GeneratedPluginRegistrant.java 40 | 41 | # iOS/XCode related 42 | **/ios/**/*.mode1v3 43 | **/ios/**/*.mode2v3 44 | **/ios/**/*.moved-aside 45 | **/ios/**/*.pbxuser 46 | **/ios/**/*.perspectivev3 47 | **/ios/**/*sync/ 48 | **/ios/**/.sconsign.dblite 49 | **/ios/**/.tags* 50 | **/ios/**/.vagrant/ 51 | **/ios/**/DerivedData/ 52 | **/ios/**/Icon? 53 | **/ios/**/Pods/ 54 | **/ios/**/.symlinks/ 55 | **/ios/**/profile 56 | **/ios/**/xcuserdata 57 | **/ios/.generated/ 58 | **/ios/Flutter/App.framework 59 | **/ios/Flutter/Flutter.framework 60 | **/ios/Flutter/Generated.xcconfig 61 | **/ios/Flutter/app.flx 62 | **/ios/Flutter/app.zip 63 | **/ios/Flutter/flutter_assets/ 64 | **/ios/ServiceDefinitions.json 65 | **/ios/Runner/GeneratedPluginRegistrant.* 66 | 67 | # Exceptions to above rules. 68 | !**/ios/**/default.mode1v3 69 | !**/ios/**/default.mode2v3 70 | !**/ios/**/default.pbxuser 71 | !**/ios/**/default.perspectivev3 72 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 73 | -------------------------------------------------------------------------------- /example/.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 and should not be manually edited. 5 | 6 | version: 7 | revision: "c23637390482d4cf9598c3ce3f2be31aa7332daf" 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: c23637390482d4cf9598c3ce3f2be31aa7332daf 17 | base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf 18 | - platform: android 19 | create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf 20 | base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf 21 | 22 | # User provided section 23 | 24 | # List of Local paths (relative to this file) that should be 25 | # ignored by the migrate tool. 26 | # 27 | # Files that are not part of the templates will be ignored by default. 28 | unmanaged_files: 29 | - 'lib/main.dart' 30 | - 'ios/Runner.xcodeproj/project.pbxproj' 31 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # mono_kit_example 2 | 3 | Demonstrates how to use the mono_kit plugin. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # https://pub.dev/packages/pedantic_mono 2 | include: package:pedantic_mono/analysis_options.yaml 3 | analyzer: 4 | exclude: 5 | - lib/generated_*.dart 6 | - lib/**/*.g.dart 7 | - lib/**/*.freezed.dart 8 | linter: 9 | rules: 10 | use_build_context_synchronously: false 11 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | .cxx/ 9 | 10 | # Remember to never publicly share your keystore. 11 | # See https://flutter.dev/to/reference-keystore 12 | key.properties 13 | **/*.keystore 14 | **/*.jks 15 | -------------------------------------------------------------------------------- /example/android/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. 5 | id("dev.flutter.flutter-gradle-plugin") 6 | } 7 | 8 | android { 9 | namespace = "com.mono0926.example" 10 | compileSdk = flutter.compileSdkVersion 11 | ndkVersion = flutter.ndkVersion 12 | 13 | compileOptions { 14 | sourceCompatibility = JavaVersion.VERSION_11 15 | targetCompatibility = JavaVersion.VERSION_11 16 | } 17 | 18 | kotlinOptions { 19 | jvmTarget = JavaVersion.VERSION_11.toString() 20 | } 21 | 22 | defaultConfig { 23 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 24 | applicationId = "com.mono0926.example" 25 | // You can update the following values to match your application needs. 26 | // For more information, see: https://flutter.dev/to/review-gradle-config. 27 | minSdk = flutter.minSdkVersion 28 | targetSdk = flutter.targetSdkVersion 29 | versionCode = flutter.versionCode 30 | versionName = flutter.versionName 31 | } 32 | 33 | buildTypes { 34 | release { 35 | // TODO: Add your own signing config for the release build. 36 | // Signing with the debug keys for now, so `flutter run --release` works. 37 | signingConfig = signingConfigs.getByName("debug") 38 | } 39 | } 40 | } 41 | 42 | flutter { 43 | source = "../.." 44 | } 45 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/mono0926/example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.mono0926.example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity : FlutterActivity() 6 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/build.gradle.kts: -------------------------------------------------------------------------------- 1 | allprojects { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | } 6 | } 7 | 8 | val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get() 9 | rootProject.layout.buildDirectory.value(newBuildDir) 10 | 11 | subprojects { 12 | val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name) 13 | project.layout.buildDirectory.value(newSubprojectBuildDir) 14 | } 15 | subprojects { 16 | project.evaluationDependsOn(":app") 17 | } 18 | 19 | tasks.register("clean") { 20 | delete(rootProject.layout.buildDirectory) 21 | } 22 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /example/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-8.10.2-all.zip 6 | -------------------------------------------------------------------------------- /example/android/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | val flutterSdkPath = run { 3 | val properties = java.util.Properties() 4 | file("local.properties").inputStream().use { properties.load(it) } 5 | val flutterSdkPath = properties.getProperty("flutter.sdk") 6 | require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" } 7 | flutterSdkPath 8 | } 9 | 10 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") 11 | 12 | repositories { 13 | google() 14 | mavenCentral() 15 | gradlePluginPortal() 16 | } 17 | } 18 | 19 | plugins { 20 | id("dev.flutter.flutter-plugin-loader") version "1.0.0" 21 | id("com.android.application") version "8.7.0" apply false 22 | id("org.jetbrains.kotlin.android") version "1.8.22" apply false 23 | } 24 | 25 | include(":app") 26 | -------------------------------------------------------------------------------- /example/assets/images/love.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/assets/images/love.png -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | 12.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '12.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 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Flutter (1.0.0) 3 | - image_picker_ios (0.0.1): 4 | - Flutter 5 | - mono_kit (0.0.1): 6 | - Flutter 7 | - url_launcher_ios (0.0.1): 8 | - Flutter 9 | 10 | DEPENDENCIES: 11 | - Flutter (from `Flutter`) 12 | - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) 13 | - mono_kit (from `.symlinks/plugins/mono_kit/ios`) 14 | - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) 15 | 16 | EXTERNAL SOURCES: 17 | Flutter: 18 | :path: Flutter 19 | image_picker_ios: 20 | :path: ".symlinks/plugins/image_picker_ios/ios" 21 | mono_kit: 22 | :path: ".symlinks/plugins/mono_kit/ios" 23 | url_launcher_ios: 24 | :path: ".symlinks/plugins/url_launcher_ios/ios" 25 | 26 | SPEC CHECKSUMS: 27 | Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 28 | image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1 29 | mono_kit: 67c15c1486e232d7f44ac47286933e80aa02f7a3 30 | url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe 31 | 32 | PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011 33 | 34 | COCOAPODS: 1.16.2 35 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @main 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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/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. -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | example 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | CADisableMinimumFrameDurationOnPhone 45 | 46 | UIApplicationSupportsIndirectInputEvents 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /example/ios/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /example/lib/app.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart' hide Router; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:mono_kit/mono_kit.dart'; 4 | import 'package:nested/nested.dart'; 5 | 6 | import 'router/router.dart'; 7 | 8 | class App extends ConsumerWidget { 9 | const App({super.key}); 10 | 11 | static const title = 'mono_kit Demo'; 12 | 13 | @override 14 | Widget build(BuildContext context, WidgetRef ref) { 15 | final router = ref.watch(routerProvider); 16 | return MaterialApp.router( 17 | title: title, 18 | builder: (context, child) => Nested( 19 | children: const [ 20 | // ignore: deprecated_member_use 21 | TextScaleFactor(), 22 | ], 23 | child: Barrier( 24 | child: child!, 25 | ), 26 | ), 27 | theme: lightTheme(), 28 | darkTheme: darkTheme(), 29 | routeInformationParser: router.routeInformationParser, 30 | routerDelegate: router.routerDelegate, 31 | routeInformationProvider: router.routeInformationProvider, 32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart' hide Router; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:flutter_web_plugins/url_strategy.dart'; 4 | 5 | import 'app.dart'; 6 | 7 | void main() { 8 | WidgetsFlutterBinding.ensureInitialized(); 9 | usePathUrlStrategy(); 10 | runApp( 11 | const ProviderScope( 12 | child: App(), 13 | ), 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /example/lib/pages/app_bottom_area_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/router/router.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:go_router/go_router.dart'; 4 | import 'package:mono_kit/mono_kit.dart'; 5 | 6 | class AppBottomAreaRoute extends GoRouteData { 7 | const AppBottomAreaRoute(); 8 | @override 9 | Widget build(BuildContext context, GoRouterState state) => 10 | const AppBottomAreaPage(); 11 | } 12 | 13 | class AppBottomAreaPage extends StatelessWidget { 14 | const AppBottomAreaPage({super.key}); 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | final theme = Theme.of(context); 19 | final colorScheme = theme.colorScheme; 20 | return AppBottomArea( 21 | bottom: Container( 22 | width: double.infinity, 23 | color: Colors.blueGrey, 24 | child: SafeArea( 25 | top: false, 26 | child: Padding( 27 | padding: const EdgeInsets.symmetric(vertical: 8), 28 | child: Text( 29 | 'AppBottomArea', 30 | textAlign: TextAlign.center, 31 | style: theme.textTheme.bodyMedium!.copyWith( 32 | color: Colors.white, 33 | ), 34 | ), 35 | ), 36 | ), 37 | ), 38 | child: DebugPadding( 39 | // showPadding: false, 40 | // showViewPadding: false, 41 | // showViewInsets: false, 42 | child: Scaffold( 43 | appBar: AppBar( 44 | title: Text(pascalCaseFromRouteUri(GoRouterState.of(context).uri)), 45 | ), 46 | body: UnfocusOnTap( 47 | child: ListView( 48 | padding: const EdgeInsets.only(bottom: 48), 49 | children: List.filled( 50 | 10, 51 | const Padding( 52 | padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8), 53 | child: TextField( 54 | decoration: InputDecoration( 55 | border: OutlineInputBorder(), 56 | ), 57 | ), 58 | ), 59 | ), 60 | ), 61 | ), 62 | floatingActionButton: FloatingActionButton( 63 | onPressed: () {}, 64 | ), 65 | bottomNavigationBar: BottomAppBar( 66 | color: colorScheme.secondaryContainer, 67 | child: Text( 68 | 'bottomNavigationBar', 69 | textAlign: TextAlign.center, 70 | style: theme.primaryTextTheme.bodyMedium, 71 | ), 72 | ), 73 | bottomSheet: Container( 74 | width: double.infinity, 75 | color: colorScheme.secondary, 76 | padding: const EdgeInsets.symmetric(vertical: 8), 77 | child: const Text( 78 | 'bottomSheet', 79 | textAlign: TextAlign.center, 80 | ), 81 | ), 82 | ), 83 | ), 84 | ); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /example/lib/pages/banner_visibility_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/router/router.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:go_router/go_router.dart'; 4 | import 'package:mono_kit/mono_kit.dart'; 5 | 6 | class BannerVisibilityRoute extends GoRouteData { 7 | const BannerVisibilityRoute(); 8 | @override 9 | Widget build(BuildContext context, GoRouterState state) => 10 | const BannerVisibilityPage(); 11 | } 12 | 13 | class BannerVisibilityPage extends StatefulWidget { 14 | const BannerVisibilityPage({super.key}); 15 | 16 | @override 17 | State createState() => _BannerVisibilityPageState(); 18 | } 19 | 20 | class _BannerVisibilityPageState extends State { 21 | final _isVisible = ValueNotifier(true); 22 | 23 | @override 24 | Widget build(BuildContext context) { 25 | return Scaffold( 26 | appBar: AppBar( 27 | title: Text(pascalCaseFromRouteUri(GoRouterState.of(context).uri)), 28 | ), 29 | body: Column( 30 | children: [ 31 | ValueListenableBuilder( 32 | valueListenable: _isVisible, 33 | builder: (context, isVisible, child) { 34 | return AnimatedExpansionVisibility( 35 | isVisible: isVisible, 36 | curve: Curves.ease, 37 | child: child, 38 | ); 39 | }, 40 | child: MaterialBanner( 41 | content: const Text('This is a banner. Dismiss me'), 42 | actions: [ 43 | TextButton( 44 | onPressed: () => _isVisible.value = false, 45 | child: const Text('DISMISS'), 46 | ), 47 | ], 48 | ), 49 | ), 50 | Container( 51 | height: 200, 52 | alignment: Alignment.center, 53 | color: Colors.blue, 54 | child: const Text('A Container'), 55 | ), 56 | ], 57 | ), 58 | floatingActionButton: FloatingActionButton( 59 | onPressed: () => _isVisible.value = !_isVisible.value, 60 | child: const Icon(Icons.refresh), 61 | ), 62 | ); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /example/lib/pages/barrier_page.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:example/router/router.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 6 | import 'package:go_router/go_router.dart'; 7 | import 'package:mono_kit/mono_kit.dart'; 8 | import 'package:mono_kit/widgets/widgets.dart'; 9 | 10 | class BarrierRoute extends GoRouteData { 11 | const BarrierRoute(); 12 | @override 13 | Widget build(BuildContext context, GoRouterState state) => 14 | const BarrierPage(); 15 | } 16 | 17 | class BarrierPage extends ConsumerStatefulWidget { 18 | const BarrierPage({super.key}); 19 | 20 | @override 21 | ConsumerState createState() => _BarrierPageState(); 22 | } 23 | 24 | class _BarrierPageState extends ConsumerState { 25 | var _count = 0; 26 | 27 | @override 28 | Widget build(BuildContext context) { 29 | return Scaffold( 30 | appBar: AppBar( 31 | title: Text(pascalCaseFromRouteUri(GoRouterState.of(context).uri)), 32 | ), 33 | floatingActionButton: FloatingActionButton( 34 | onPressed: () { 35 | // このブロックで囲まれている処理が終わるまでプログレス表示 36 | ref.read(barrierProvider.notifier).executeWithProgress(() async { 37 | // ダミー処理時間として1秒待つ 38 | await Future.delayed(const Duration(seconds: 1)); 39 | setState(() => _count++); 40 | }); 41 | }, 42 | child: const Icon(Icons.add), 43 | ), 44 | body: Center( 45 | child: Text( 46 | '$_count', 47 | style: Theme.of(context).textTheme.headlineMedium, 48 | ), 49 | ), 50 | ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /example/lib/pages/better_placeholder_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/router/router.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:go_router/go_router.dart'; 4 | import 'package:mono_kit/mono_kit.dart'; 5 | 6 | class BetterPlaceholderRoute extends GoRouteData { 7 | const BetterPlaceholderRoute(); 8 | @override 9 | Widget build(BuildContext context, GoRouterState state) => 10 | const BetterPlaceholderPage(); 11 | } 12 | 13 | class BetterPlaceholderPage extends StatelessWidget { 14 | const BetterPlaceholderPage({super.key}); 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | return Scaffold( 19 | appBar: AppBar( 20 | title: Text(pascalCaseFromRouteUri(GoRouterState.of(context).uri)), 21 | ), 22 | body: ListView( 23 | children: const [ 24 | BetterPlaceholder(), 25 | BetterPlaceholder( 26 | fallbackWidth: 100, 27 | fallbackHeight: 200, 28 | ), 29 | BetterPlaceholder( 30 | fallbackHeight: 30, 31 | ), 32 | ], 33 | ), 34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /example/lib/pages/color_ex_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/router/router.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:go_router/go_router.dart'; 4 | import 'package:mono_kit/mono_kit.dart'; 5 | 6 | final _swatch = const Color(0xFFF44336).materialColor; 7 | 8 | class ColorExRoute extends GoRouteData { 9 | const ColorExRoute(); 10 | @override 11 | Widget build(BuildContext context, GoRouterState state) => 12 | const ColorExPage(); 13 | } 14 | 15 | class ColorExPage extends StatelessWidget { 16 | const ColorExPage({super.key}); 17 | 18 | @override 19 | Widget build(BuildContext context) { 20 | return Theme( 21 | data: ThemeData( 22 | // primarySwatch: _swatch, 23 | brightness: Theme.of(context).brightness, 24 | ), 25 | child: Scaffold( 26 | appBar: AppBar( 27 | title: Text(pascalCaseFromRouteUri(GoRouterState.of(context).uri)), 28 | ), 29 | floatingActionButton: FloatingActionButton( 30 | onPressed: () {}, 31 | child: const Icon(Icons.add), 32 | ), 33 | floatingActionButtonLocation: FloatingActionButtonLocation.endDocked, 34 | bottomNavigationBar: BottomNavigationBar( 35 | items: List.generate( 36 | 2, 37 | (_) => const BottomNavigationBarItem( 38 | icon: Icon(Icons.home), 39 | label: '', 40 | ), 41 | ), 42 | ), 43 | body: Padding( 44 | padding: const EdgeInsets.all(44), 45 | child: Column( 46 | children: [50, 100, 200, 300, 400, 500, 600, 700, 800, 900] 47 | .map( 48 | (k) => Expanded( 49 | child: Container( 50 | color: _swatch[k], 51 | ), 52 | ), 53 | ) 54 | .toList(), 55 | ), 56 | ), 57 | ), 58 | ); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /example/lib/pages/debug_padding_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/router/router.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:go_router/go_router.dart'; 4 | import 'package:mono_kit/mono_kit.dart'; 5 | 6 | class DebugPaddingRoute extends GoRouteData { 7 | const DebugPaddingRoute(); 8 | @override 9 | Widget build(BuildContext context, GoRouterState state) => 10 | const DebugPaddingPage(); 11 | } 12 | 13 | class DebugPaddingPage extends StatelessWidget { 14 | const DebugPaddingPage({super.key}); 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | final theme = Theme.of(context); 19 | final colorScheme = theme.colorScheme; 20 | return DebugPadding( 21 | // showPadding: false, 22 | // showViewPadding: false, 23 | // showViewInsets: false, 24 | // showSize: false, 25 | child: Scaffold( 26 | appBar: AppBar( 27 | title: Text(pascalCaseFromRouteUri(GoRouterState.of(context).uri)), 28 | ), 29 | body: UnfocusOnTap( 30 | child: ListView( 31 | padding: const EdgeInsets.only(bottom: 48), 32 | children: List.filled( 33 | 10, 34 | const Padding( 35 | padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8), 36 | child: TextField( 37 | decoration: InputDecoration( 38 | border: OutlineInputBorder(), 39 | ), 40 | ), 41 | ), 42 | ), 43 | ), 44 | ), 45 | floatingActionButton: FloatingActionButton( 46 | onPressed: () {}, 47 | ), 48 | bottomNavigationBar: BottomAppBar( 49 | color: colorScheme.secondaryContainer, 50 | child: Text( 51 | 'bottomNavigationBar', 52 | textAlign: TextAlign.center, 53 | style: theme.primaryTextTheme.bodyMedium, 54 | ), 55 | ), 56 | bottomSheet: Container( 57 | width: double.infinity, 58 | color: colorScheme.secondary, 59 | padding: const EdgeInsets.symmetric(vertical: 8), 60 | child: const Text( 61 | 'bottomSheet', 62 | textAlign: TextAlign.center, 63 | ), 64 | ), 65 | ), 66 | ); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /example/lib/pages/delayed_pop_scope_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:adaptive_dialog/adaptive_dialog.dart'; 2 | import 'package:example/router/router.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:go_router/go_router.dart'; 5 | import 'package:mono_kit/mono_kit.dart'; 6 | 7 | class DelayedPopScopeRoute extends GoRouteData { 8 | const DelayedPopScopeRoute(); 9 | @override 10 | Widget build(BuildContext context, GoRouterState state) => 11 | const DelayedPopScopePage(); 12 | } 13 | 14 | class DelayedPopScopePage extends StatelessWidget { 15 | const DelayedPopScopePage({super.key}); 16 | 17 | @override 18 | Widget build(BuildContext context) { 19 | return DelayedPopScope( 20 | onShouldPop: (result) async { 21 | final confirmationResult = await showOkCancelAlertDialog( 22 | context: context, 23 | message: '前のページに戻りますか?', 24 | okLabel: '戻る', 25 | cancelLabel: '戻らないでとどまる', 26 | ); 27 | return confirmationResult == OkCancelResult.ok; 28 | }, 29 | child: Scaffold( 30 | appBar: AppBar( 31 | title: Text(pascalCaseFromRouteUri(GoRouterState.of(context).uri)), 32 | ), 33 | body: CenteredMaxWidth( 34 | width: 320, 35 | child: ListView( 36 | children: [ 37 | const Text( 38 | // ignore: lines_longer_than_80_chars 39 | 'AppBarの戻るボタン、あるいは下のボタンで`maybePop`実行すると、DelayedPopScopeが呼ばれて確認ダイアログが表示されます。', 40 | ), 41 | const SizedBox(height: 16), 42 | FilledButton( 43 | onPressed: () { 44 | Navigator.of(context).maybePop(); 45 | }, 46 | child: const Text('maybePop()'), 47 | ), 48 | ], 49 | ), 50 | ), 51 | ), 52 | ); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /example/lib/pages/home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:adaptive_dialog/adaptive_dialog.dart'; 2 | import 'package:example/app.dart'; 3 | import 'package:example/router/router.dart'; 4 | import 'package:example/util/util.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:go_router/go_router.dart'; 7 | import 'package:mono_kit/mono_kit.dart'; 8 | import 'package:mono_kit/plugins/plugins.dart'; 9 | 10 | class HomePage extends StatelessWidget { 11 | const HomePage({super.key}); 12 | 13 | @override 14 | Widget build(BuildContext context) { 15 | return Scaffold( 16 | appBar: AppBar(title: const Text(App.title)), 17 | body: ListView( 18 | children: [ 19 | const WIP( 20 | visible: true, 21 | child: ListTile(title: Text('Experimental Feature')), 22 | ), 23 | ...allRouteLocations.map((location) { 24 | return ListTile( 25 | title: Text(pascalCaseFromRouteName(location)), 26 | trailing: const Icon(Icons.chevron_right), 27 | onTap: () => context.go(location), 28 | ); 29 | }), 30 | ListTile( 31 | title: const Text('iGhost(Dev) installed?'), 32 | subtitle: FutureBuilder( 33 | future: AppInstallationChecker().isInstalled( 34 | 'com.aquatica.ghost.dev', 35 | ), 36 | builder: (context, snap) { 37 | if (!snap.hasData) { 38 | return const SizedBox(); 39 | } 40 | return Text(snap.data.toString()); 41 | }, 42 | ), 43 | ), 44 | ListTile( 45 | title: const Text('showPhotoSelectionSheet()'), 46 | trailing: const Icon(Icons.photo_library), 47 | onTap: () { 48 | showPhotoSelectionSheet( 49 | context: context, 50 | onSettingAppOpenRequested: () { 51 | logger.info('onSettingAppOpenRequested'); 52 | }, 53 | additionalActions: ( 54 | [ 55 | const SheetAction( 56 | label: 'Custom Action', 57 | icon: Icons.warning, 58 | key: 'custom_key', 59 | ), 60 | ], 61 | (key) { 62 | logger.info('Additional action selected: $key'); 63 | }, 64 | ), 65 | ); 66 | }, 67 | ), 68 | ], 69 | ), 70 | ); 71 | } 72 | } 73 | 74 | enum Hoge { a } 75 | -------------------------------------------------------------------------------- /example/lib/pages/lifecycle_observer_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/router/router.dart'; 2 | import 'package:example/util/util.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 5 | import 'package:go_router/go_router.dart'; 6 | import 'package:mono_kit/mono_kit.dart'; 7 | 8 | class LifecycleObserverRoute extends GoRouteData { 9 | const LifecycleObserverRoute(); 10 | @override 11 | Widget build(BuildContext context, GoRouterState state) => 12 | const LifecycleObserverPage(); 13 | } 14 | 15 | class LifecycleObserverPage extends ConsumerWidget { 16 | const LifecycleObserverPage({super.key}); 17 | 18 | @override 19 | Widget build(BuildContext context, WidgetRef ref) { 20 | ref.listen>(lifecycleObserver, (_, state) { 21 | logger.info(state.value); 22 | }); 23 | return Scaffold( 24 | appBar: AppBar( 25 | title: Text(pascalCaseFromRouteUri(GoRouterState.of(context).uri)), 26 | ), 27 | body: const Center( 28 | child: Text( 29 | 'Close and Open', 30 | style: TextStyle(fontSize: 28), 31 | ), 32 | ), 33 | ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /example/lib/pages/list_tile_selected_background_colored_box_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/router/router.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:go_router/go_router.dart'; 4 | import 'package:mono_kit/mono_kit.dart'; 5 | 6 | class ListTileSelectedBackgroundColoredBoxRoute extends GoRouteData { 7 | const ListTileSelectedBackgroundColoredBoxRoute(); 8 | @override 9 | Widget build(BuildContext context, GoRouterState state) => 10 | const ListTileSelectedBackgroundColoredBoxPage(); 11 | } 12 | 13 | class ListTileSelectedBackgroundColoredBoxPage extends StatefulWidget { 14 | const ListTileSelectedBackgroundColoredBoxPage({super.key}); 15 | 16 | @override 17 | State createState() => 18 | _ListTileSelectedBackgroundColoredBoxPageState(); 19 | } 20 | 21 | class _ListTileSelectedBackgroundColoredBoxPageState 22 | extends State { 23 | static const _listTileTexts = [ 24 | 'Hello', 25 | 'Animals', 26 | 'Dog', 27 | 'Cat', 28 | ]; 29 | 30 | var _selectedText = _listTileTexts.first; 31 | 32 | @override 33 | Widget build(BuildContext context) { 34 | final theme = Theme.of(context); 35 | final colorScheme = theme.colorScheme; 36 | return Scaffold( 37 | appBar: AppBar( 38 | title: Text(pascalCaseFromRouteUri(GoRouterState.of(context).uri)), 39 | ), 40 | body: Center( 41 | child: FilledButton.tonal( 42 | onPressed: () => Navigator.of(context).pop(), 43 | child: const Text('BACK'), 44 | ), 45 | ), 46 | drawer: Drawer( 47 | child: ListView( 48 | children: [ 49 | DrawerHeader( 50 | decoration: BoxDecoration( 51 | color: colorScheme.primary, 52 | ), 53 | child: Text( 54 | 'Header', 55 | style: theme.primaryTextTheme.headlineMedium, 56 | ), 57 | ), 58 | ..._listTileTexts.map( 59 | (text) => ListTileSelectedBackgroundColoredBox( 60 | listTile: ListTile( 61 | title: Text(text), 62 | selected: _selectedText == text, 63 | onTap: () { 64 | setState(() { 65 | _selectedText = text; 66 | }); 67 | }, 68 | ), 69 | ), 70 | ), 71 | ], 72 | ), 73 | ), 74 | ); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /example/lib/pages/max_width_padding_builder_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/router/router.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:go_router/go_router.dart'; 4 | import 'package:mono_kit/mono_kit.dart'; 5 | 6 | class MaxWidthPaddingBuilderRoute extends GoRouteData { 7 | const MaxWidthPaddingBuilderRoute(); 8 | @override 9 | Widget build(BuildContext context, GoRouterState state) => 10 | const MaxWidthPaddingBuilderPage(); 11 | } 12 | 13 | class MaxWidthPaddingBuilderPage extends StatelessWidget { 14 | const MaxWidthPaddingBuilderPage({super.key}); 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | return Scaffold( 19 | appBar: AppBar( 20 | title: Text(pascalCaseFromRouteUri(GoRouterState.of(context).uri)), 21 | ), 22 | body: MaxWidthPaddingBuilder( 23 | width: 300, 24 | builder: (context, padding) => ListView( 25 | padding: padding, 26 | children: List.filled( 27 | 3, 28 | const Placeholder(), 29 | ), 30 | ), 31 | ), 32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /example/lib/pages/not_found.page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class NotFoundPage extends StatelessWidget { 4 | const NotFoundPage({super.key}); 5 | 6 | @override 7 | Widget build(BuildContext context) { 8 | return Scaffold( 9 | appBar: AppBar( 10 | title: const Text('404 Not Found'), 11 | ), 12 | body: Center( 13 | child: Image.network( 14 | 'https://i0.wp.com/hokanko.mond.jp/wordpress341/wp-content/uploads/images/istock_hannah.jpg', 15 | ), 16 | ), 17 | ); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /example/lib/pages/overflow_detectable_text_page/data.dart: -------------------------------------------------------------------------------- 1 | class Data { 2 | Data._({ 3 | required this.desc, 4 | }); 5 | 6 | Data.small() 7 | : this._( 8 | desc: 'Flutter最高!', 9 | ); 10 | Data.medium() 11 | : this._( 12 | desc: 'むかしむかし、あるところにFlutterという素晴らしいフレームワークがありました。', 13 | ); 14 | 15 | // Copied from https://ja.wikipedia.org/wiki/Flutter 16 | Data.large() 17 | : this._( 18 | desc: 'Flutter(フラッター)は、Googleによって開発されたフリーかつ' 19 | 'オープンソースのモバイルアプリケーションフレームワークである。' * 20 | 2,); 21 | 22 | factory Data.index(int index) { 23 | switch (index % 3) { 24 | case 0: 25 | return Data.small(); 26 | case 1: 27 | return Data.medium(); 28 | case 2: 29 | return Data.large(); 30 | } 31 | assert(false); 32 | return Data._(desc: ''); 33 | } 34 | 35 | final String desc; 36 | } 37 | -------------------------------------------------------------------------------- /example/lib/pages/overflow_detectable_text_page/overflow_detectable_text_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/router/router.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:go_router/go_router.dart'; 5 | 6 | import 'cell.dart'; 7 | import 'data.dart'; 8 | 9 | class OverflowDetectableTextRoute extends GoRouteData { 10 | const OverflowDetectableTextRoute(); 11 | @override 12 | Widget build(BuildContext context, GoRouterState state) => 13 | const OverflowDetectableTextPage(); 14 | } 15 | 16 | class OverflowDetectableTextPage extends StatelessWidget { 17 | const OverflowDetectableTextPage({super.key}); 18 | 19 | @override 20 | Widget build(BuildContext context) { 21 | return Theme( 22 | data: _buildTheme(), 23 | child: Scaffold( 24 | appBar: AppBar( 25 | title: Text(pascalCaseFromRouteUri(GoRouterState.of(context).uri)), 26 | ), 27 | body: ListView.separated( 28 | padding: EdgeInsets.only( 29 | left: 20, 30 | right: 20, 31 | bottom: MediaQuery.of(context).padding.bottom, 32 | ), 33 | itemCount: 10, 34 | separatorBuilder: (context, index) => const Divider(height: 0), 35 | itemBuilder: (context, index) => Cell(Data.index(index)), 36 | ), 37 | ), 38 | ); 39 | } 40 | 41 | ThemeData _buildTheme() { 42 | final base = ThemeData.light(); 43 | const accentColor = Color(0xFF007AFF); 44 | const buttonColor = Color(0xFFF0F0F7); 45 | final highlightColor = accentColor.withValues(alpha: 0.04); 46 | return base.copyWith( 47 | cupertinoOverrideTheme: const CupertinoThemeData( 48 | primaryColor: accentColor, 49 | ), 50 | primaryColor: Colors.white, 51 | scaffoldBackgroundColor: Colors.white, 52 | highlightColor: highlightColor, 53 | // splashColor: splashColor, 54 | primaryTextTheme: base.primaryTextTheme.apply( 55 | bodyColor: Colors.black87, 56 | ), 57 | appBarTheme: base.appBarTheme.copyWith( 58 | elevation: 1, 59 | ), 60 | dividerColor: Colors.black26, 61 | textTheme: base.textTheme.copyWith( 62 | bodyMedium: base.textTheme.bodyMedium!.copyWith(fontSize: 13), 63 | labelLarge: base.textTheme.labelLarge!.copyWith( 64 | fontWeight: FontWeight.w600, 65 | ), 66 | ), 67 | elevatedButtonTheme: ElevatedButtonThemeData( 68 | style: ElevatedButton.styleFrom( 69 | foregroundColor: accentColor, shape: const StadiumBorder(), 70 | backgroundColor: buttonColor, 71 | // shadowColor: highlightColor, 72 | minimumSize: Size.zero, 73 | padding: const EdgeInsets.symmetric( 74 | horizontal: 18, 75 | vertical: 7, 76 | ), 77 | ).copyWith( 78 | elevation: WidgetStateProperty.all(0), 79 | overlayColor: WidgetStateProperty.all( 80 | Color.lerp( 81 | buttonColor, 82 | Colors.black, 83 | 0.3, 84 | ), 85 | ), 86 | ), 87 | ), 88 | primaryIconTheme: base.primaryIconTheme.copyWith( 89 | color: accentColor, 90 | ), 91 | ); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /example/lib/pages/pages.dart: -------------------------------------------------------------------------------- 1 | export 'home_page.dart'; 2 | export 'not_found.page.dart'; 3 | //export 'overflow_detectable_text_page/overflow_detectable_text_page.dart'; 4 | -------------------------------------------------------------------------------- /example/lib/pages/snack_bar_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/router/router.dart'; 2 | import 'package:example/util/util.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:go_router/go_router.dart'; 5 | import 'package:mono_kit/mono_kit.dart'; 6 | 7 | class SnackBarRoute extends GoRouteData { 8 | const SnackBarRoute(); 9 | @override 10 | Widget build(BuildContext context, GoRouterState state) => 11 | const SnackBarPage(); 12 | } 13 | 14 | class SnackBarPage extends StatelessWidget { 15 | const SnackBarPage({super.key}); 16 | 17 | @override 18 | Widget build(BuildContext context) { 19 | final messenger = ScaffoldMessenger.of(context); 20 | final theme = Theme.of(context); 21 | final colorScheme = theme.colorScheme; 22 | return Scaffold( 23 | appBar: AppBar( 24 | title: Text(pascalCaseFromRouteUri(GoRouterState.of(context).uri)), 25 | ), 26 | body: ListView( 27 | children: [ 28 | ListTile( 29 | title: const Text('Plain Text'), 30 | onTap: () => messenger.showMessage('( ´・‿・`)'), 31 | ), 32 | ListTile( 33 | title: Text( 34 | 'Error', 35 | style: TextStyle( 36 | color: colorScheme.error, 37 | ), 38 | ), 39 | onTap: () => messenger.showError( 40 | '(´・︵・`)', 41 | theme: theme, 42 | ), 43 | ), 44 | ListTile( 45 | title: const Text('UNDO'), 46 | onTap: () => messenger.showUndo( 47 | 'Dog 🐶', 48 | onUndo: () => logger.info('UNDO'), 49 | theme: theme, 50 | ), 51 | ), 52 | ], 53 | ), 54 | ); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /example/lib/pages/unfocus_on_tap_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/router/router.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:go_router/go_router.dart'; 4 | import 'package:mono_kit/mono_kit.dart'; 5 | import 'package:quiver/iterables.dart'; 6 | 7 | class UnfocusOnTapRoute extends GoRouteData { 8 | const UnfocusOnTapRoute(); 9 | @override 10 | Widget build(BuildContext context, GoRouterState state) => 11 | const UnfocusOnTapPage(); 12 | } 13 | 14 | class UnfocusOnTapPage extends StatelessWidget { 15 | const UnfocusOnTapPage({super.key}); 16 | 17 | @override 18 | Widget build(BuildContext context) { 19 | return Scaffold( 20 | appBar: AppBar( 21 | title: Text(pascalCaseFromRouteUri(GoRouterState.of(context).uri)), 22 | ), 23 | body: CenteredMaxWidth( 24 | width: 560, 25 | child: UnfocusOnTap( 26 | child: Column( 27 | children: range(0, 3) 28 | .map( 29 | (_) => const Padding( 30 | padding: EdgeInsets.symmetric( 31 | vertical: 8, 32 | horizontal: 16, 33 | ), 34 | child: TextField( 35 | decoration: InputDecoration( 36 | border: OutlineInputBorder(), 37 | ), 38 | ), 39 | ), 40 | ) 41 | .toList(), 42 | ), 43 | ), 44 | ), 45 | ); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /example/lib/pages/vertical_center_scroll_view_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/router/router.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:go_router/go_router.dart'; 4 | import 'package:mono_kit/mono_kit.dart'; 5 | 6 | class VerticalCenterScrollViewRoute extends GoRouteData { 7 | const VerticalCenterScrollViewRoute(); 8 | @override 9 | Widget build(BuildContext context, GoRouterState state) => 10 | const VerticalCenterScrollViewPage(); 11 | } 12 | 13 | class VerticalCenterScrollViewPage extends StatelessWidget { 14 | const VerticalCenterScrollViewPage({super.key}); 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | return Scaffold( 19 | appBar: AppBar( 20 | title: Text(pascalCaseFromRouteUri(GoRouterState.of(context).uri)), 21 | ), 22 | body: const VerticalCenterScrollView( 23 | padding: EdgeInsets.symmetric(vertical: 16), 24 | child: UnfocusOnTap( 25 | child: Text('Vertical Center Scroll View'), 26 | ), 27 | ), 28 | ); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /example/lib/util/logger.dart: -------------------------------------------------------------------------------- 1 | import 'package:simple_logger/simple_logger.dart'; 2 | 3 | final logger = SimpleLogger() 4 | ..mode = LoggerMode.print 5 | ..setLevel( 6 | Level.FINEST, 7 | includeCallerInfo: true, 8 | ); 9 | -------------------------------------------------------------------------------- /example/lib/util/util.dart: -------------------------------------------------------------------------------- 1 | export 'logger.dart'; 2 | -------------------------------------------------------------------------------- /example/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/xcuserdata/ 7 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 3 | #include "ephemeral/Flutter-Generated.xcconfig" 4 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 3 | #include "ephemeral/Flutter-Generated.xcconfig" 4 | -------------------------------------------------------------------------------- /example/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import appkit_ui_element_colors 9 | import dynamic_color 10 | import file_selector_macos 11 | import macos_ui 12 | import macos_window_utils 13 | import url_launcher_macos 14 | 15 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 16 | AppkitUiElementColorsPlugin.register(with: registry.registrar(forPlugin: "AppkitUiElementColorsPlugin")) 17 | DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin")) 18 | FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) 19 | MacOSUiPlugin.register(with: registry.registrar(forPlugin: "MacOSUiPlugin")) 20 | MacOSWindowUtilsPlugin.register(with: registry.registrar(forPlugin: "MacOSWindowUtilsPlugin")) 21 | UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) 22 | } 23 | -------------------------------------------------------------------------------- /example/macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.15' 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 | -------------------------------------------------------------------------------- /example/macos/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - appkit_ui_element_colors (1.0.0): 3 | - FlutterMacOS 4 | - dynamic_color (0.0.2): 5 | - FlutterMacOS 6 | - file_selector_macos (0.0.1): 7 | - FlutterMacOS 8 | - FlutterMacOS (1.0.0) 9 | - macos_ui (0.1.0): 10 | - FlutterMacOS 11 | - macos_window_utils (1.0.0): 12 | - FlutterMacOS 13 | - url_launcher_macos (0.0.1): 14 | - FlutterMacOS 15 | 16 | DEPENDENCIES: 17 | - appkit_ui_element_colors (from `Flutter/ephemeral/.symlinks/plugins/appkit_ui_element_colors/macos`) 18 | - dynamic_color (from `Flutter/ephemeral/.symlinks/plugins/dynamic_color/macos`) 19 | - file_selector_macos (from `Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos`) 20 | - FlutterMacOS (from `Flutter/ephemeral`) 21 | - macos_ui (from `Flutter/ephemeral/.symlinks/plugins/macos_ui/macos`) 22 | - macos_window_utils (from `Flutter/ephemeral/.symlinks/plugins/macos_window_utils/macos`) 23 | - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) 24 | 25 | EXTERNAL SOURCES: 26 | appkit_ui_element_colors: 27 | :path: Flutter/ephemeral/.symlinks/plugins/appkit_ui_element_colors/macos 28 | dynamic_color: 29 | :path: Flutter/ephemeral/.symlinks/plugins/dynamic_color/macos 30 | file_selector_macos: 31 | :path: Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos 32 | FlutterMacOS: 33 | :path: Flutter/ephemeral 34 | macos_ui: 35 | :path: Flutter/ephemeral/.symlinks/plugins/macos_ui/macos 36 | macos_window_utils: 37 | :path: Flutter/ephemeral/.symlinks/plugins/macos_window_utils/macos 38 | url_launcher_macos: 39 | :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos 40 | 41 | SPEC CHECKSUMS: 42 | appkit_ui_element_colors: 39bb2d80be3f19b152ccf4c70d5bbe6cba43d74a 43 | dynamic_color: 2eaa27267de1ca20d879fbd6e01259773fb1670f 44 | file_selector_macos: 54fdab7caa3ac3fc43c9fac4d7d8d231277f8cf2 45 | FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 46 | macos_ui: 6229a8922cd97bafb7d9636c8eb8dfb0744183ca 47 | macos_window_utils: 933f91f64805e2eb91a5bd057cf97cd097276663 48 | url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399 49 | 50 | PODFILE CHECKSUM: 0d3963a09fc94f580682bd88480486da345dc3f0 51 | 52 | COCOAPODS: 1.15.2 53 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @main 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /example/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 = example 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.mono0926.example 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2020 com.mono0926. All rights reserved. 15 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import FlutterMacOS 2 | import Cocoa 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: example 2 | description: A example of mono_kit. 3 | version: 1.0.0+1 4 | publish_to: none 5 | environment: 6 | sdk: ^3.7.0 7 | dependencies: 8 | adaptive_dialog: 9 | cupertino_icons: 10 | flutter: 11 | sdk: flutter 12 | flutter_riverpod: 13 | flutter_web_plugins: 14 | sdk: flutter 15 | go_router: 16 | mono_kit: 17 | path: .. 18 | nested: 19 | quiver: 20 | recase: 21 | simple_logger: 22 | dev_dependencies: 23 | build_runner: 24 | flutter_test: 25 | sdk: flutter 26 | go_router_builder: 27 | pedantic_mono: 28 | flutter: 29 | uses-material-design: true 30 | assets: 31 | - assets/images/ 32 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | 3 | void main() { 4 | testWidgets('', (tester) async {}); 5 | } 6 | -------------------------------------------------------------------------------- /example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/web/favicon.png -------------------------------------------------------------------------------- /example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /example/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "short_name": "example", 4 | "start_url": ".", 5 | "display": "minimal-ui", 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 | } 24 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | #include 12 | 13 | void RegisterPlugins(flutter::PluginRegistry* registry) { 14 | DynamicColorPluginCApiRegisterWithRegistrar( 15 | registry->GetRegistrarForPlugin("DynamicColorPluginCApi")); 16 | FileSelectorWindowsRegisterWithRegistrar( 17 | registry->GetRegistrarForPlugin("FileSelectorWindows")); 18 | UrlLauncherWindowsRegisterWithRegistrar( 19 | registry->GetRegistrarForPlugin("UrlLauncherWindows")); 20 | } 21 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | dynamic_color 7 | file_selector_windows 8 | url_launcher_windows 9 | ) 10 | 11 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 12 | ) 13 | 14 | set(PLUGIN_BUNDLED_LIBRARIES) 15 | 16 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 17 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 18 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 20 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 21 | endforeach(plugin) 22 | 23 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 24 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 25 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 26 | endforeach(ffi_plugin) 27 | -------------------------------------------------------------------------------- /example/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | add_executable(${BINARY_NAME} WIN32 5 | "flutter_window.cpp" 6 | "main.cpp" 7 | "utils.cpp" 8 | "win32_window.cpp" 9 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 10 | "Runner.rc" 11 | "runner.exe.manifest" 12 | ) 13 | apply_standard_settings(${BINARY_NAME}) 14 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 15 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 16 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 17 | add_dependencies(${BINARY_NAME} flutter_assemble) 18 | -------------------------------------------------------------------------------- /example/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 | #ifdef FLUTTER_BUILD_NUMBER 64 | #define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0 67 | #endif 68 | 69 | #ifdef FLUTTER_BUILD_NAME 70 | #define VERSION_AS_STRING #FLUTTER_BUILD_NAME 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.mono0926" "\0" 93 | VALUE "FileDescription", "example" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "example" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2022 com.mono0926. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "example.exe" "\0" 98 | VALUE "ProductName", "example" "\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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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"example", 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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/example/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | if (target_length == 0) { 52 | return std::string(); 53 | } 54 | std::string utf8_string; 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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /firebase.json: -------------------------------------------------------------------------------- 1 | { 2 | "hosting": [ 3 | { 4 | "target": "mono-kit", 5 | "public": "example/build/web", 6 | "rewrites": [ 7 | { 8 | "source": "**", 9 | "destination": "/index.html" 10 | } 11 | ] 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/Generated.xcconfig 37 | -------------------------------------------------------------------------------- /ios/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mono0926/flutter_mono_kit/eb41505420d5ffa8dcd04048a9a3dad6c9eae3ab/ios/Assets/.gitkeep -------------------------------------------------------------------------------- /ios/Classes/MonoKitPlugin.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface MonoKitPlugin : NSObject 4 | @end 5 | -------------------------------------------------------------------------------- /ios/Classes/MonoKitPlugin.m: -------------------------------------------------------------------------------- 1 | #import "MonoKitPlugin.h" 2 | #import 3 | 4 | @implementation MonoKitPlugin 5 | + (void)registerWithRegistrar:(NSObject*)registrar { 6 | [SwiftMonoKitPlugin registerWithRegistrar:registrar]; 7 | } 8 | @end 9 | -------------------------------------------------------------------------------- /ios/Classes/SwiftMonoKitPlugin.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | 4 | public class SwiftMonoKitPlugin: NSObject, FlutterPlugin { 5 | public static func register(with registrar: FlutterPluginRegistrar) { 6 | let channel = FlutterMethodChannel(name: "mono_kit", binaryMessenger: registrar.messenger()) 7 | let instance = SwiftMonoKitPlugin() 8 | registrar.addMethodCallDelegate(instance, channel: channel) 9 | } 10 | 11 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 12 | let method = call.method 13 | let info = method.split(separator: ("/")) 14 | let group = info[0] 15 | let path = info[1] 16 | let arguments = call.arguments! as! [String: String] 17 | switch group { 18 | case "info_plist": 19 | let key = arguments["key"]! 20 | switch path { 21 | case "read_string": 22 | let value = Bundle.main.object(forInfoDictionaryKey: key) as! String 23 | result(value) 24 | default: 25 | result(FlutterMethodNotImplemented) 26 | } 27 | 28 | default: 29 | result(FlutterMethodNotImplemented) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ios/mono_kit.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 3 | # 4 | Pod::Spec.new do |s| 5 | s.name = 'mono_kit' 6 | s.version = '0.0.1' 7 | s.summary = 'A new Flutter plugin.' 8 | s.description = <<-DESC 9 | A new Flutter plugin. 10 | DESC 11 | s.homepage = 'https://mono0926.com' 12 | s.license = { :file => '../LICENSE' } 13 | s.author = { 'Masayuki Ono' => 'mono0926@gmail.com' } 14 | s.source = { :path => '.' } 15 | s.source_files = 'Classes/**/*' 16 | s.public_header_files = 'Classes/**/*.h' 17 | s.dependency 'Flutter' 18 | 19 | s.ios.deployment_target = '8.0' 20 | end 21 | 22 | -------------------------------------------------------------------------------- /lib/errors/errors.dart: -------------------------------------------------------------------------------- 1 | export 'unexpected_error.dart'; 2 | -------------------------------------------------------------------------------- /lib/errors/unexpected_error.dart: -------------------------------------------------------------------------------- 1 | /// https://zenn.dev/mono/articles/082dde5601ab4de858a1 2 | class UnexpectedError extends AssertionError { 3 | UnexpectedError(Object value) : super('Unexpected value: $value'); 4 | } 5 | -------------------------------------------------------------------------------- /lib/extensions/color.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:tinycolor2/tinycolor2.dart'; 3 | 4 | extension ColorEx on Color { 5 | MaterialColor get materialColor { 6 | final tiny = TinyColor.fromColor(this); 7 | return MaterialColor( 8 | // ignore: deprecated_member_use 9 | value, 10 | Map.fromIterables( 11 | [50, 100, 200, 300, 400, 500, 600, 700, 800, 900], 12 | List.generate( 13 | 10, 14 | (i) => (i * 100 - 500) ~/ 15, 15 | // TODO(mono): broken 16 | ).map((v) => (v.isNegative ? tiny.brighten(-v) : tiny.darken(v)).color), 17 | ), 18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/extensions/enum.dart: -------------------------------------------------------------------------------- 1 | extension EnumByName on Iterable { 2 | T? byNameOrNull(String? name) { 3 | for (final value in this) { 4 | if (value.name == name) { 5 | return value; 6 | } 7 | } 8 | return null; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /lib/extensions/extensions.dart: -------------------------------------------------------------------------------- 1 | export 'color.dart'; 2 | export 'enum.dart'; 3 | export 'iterable.dart'; 4 | export 'navigator_state.dart'; 5 | export 'scaffold_messenger_state.dart'; 6 | export 'state_notifier.dart'; 7 | export 'string.dart'; 8 | export 'theme_data.dart'; 9 | -------------------------------------------------------------------------------- /lib/extensions/iterable.dart: -------------------------------------------------------------------------------- 1 | extension IterableEx on Iterable { 2 | bool containsAll(Iterable list) => !list.any((x) => !contains(x)); 3 | } 4 | -------------------------------------------------------------------------------- /lib/extensions/navigator_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | 3 | extension NavigatorStateEx on NavigatorState { 4 | void popToRouteName(String name) { 5 | popUntil(ModalRoute.withName(name)); 6 | } 7 | 8 | void popToRoot() { 9 | popUntil((r) => r.isFirst); 10 | } 11 | 12 | void popToFirstFullscreenDialog() { 13 | popUntil((r) => (r is PageRoute) && r.fullscreenDialog); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/extensions/scaffold_messenger_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | extension SnackBarPresenterEx on ScaffoldMessengerState { 4 | ScaffoldFeatureController showMessage( 5 | String text, 6 | ) { 7 | return _show( 8 | SnackBar( 9 | content: Text(text), 10 | ), 11 | ); 12 | } 13 | 14 | ScaffoldFeatureController showUndo( 15 | String text, { 16 | required VoidCallback onUndo, 17 | required ThemeData theme, 18 | Color? undoButtonColor, 19 | SnackBarL10n l10n = const SnackBarL10n(), 20 | }) { 21 | return showMessageWithAction( 22 | text, 23 | onAction: onUndo, 24 | actionLabel: l10n.undo, 25 | actionColor: undoButtonColor, 26 | theme: theme, 27 | ); 28 | } 29 | 30 | ScaffoldFeatureController 31 | showMessageWithAction( 32 | String text, { 33 | required VoidCallback onAction, 34 | required String actionLabel, 35 | required ThemeData theme, 36 | Color? actionColor, 37 | }) { 38 | return _show( 39 | SnackBar( 40 | content: Text(text), 41 | action: SnackBarAction( 42 | textColor: actionColor ?? theme.colorScheme.inversePrimary, 43 | label: actionLabel, 44 | onPressed: onAction, 45 | ), 46 | ), 47 | ); 48 | } 49 | 50 | ScaffoldFeatureController showError( 51 | dynamic error, { 52 | required ThemeData theme, 53 | SnackBarL10n l10n = const SnackBarL10n(), 54 | Color? backgroundColor, 55 | Color? textColor, 56 | }) { 57 | final colorScheme = theme.colorScheme; 58 | return _show( 59 | SnackBar( 60 | backgroundColor: backgroundColor ?? colorScheme.error, 61 | content: Text( 62 | l10n.localizeError(error), 63 | style: TextStyle( 64 | color: textColor ?? colorScheme.onError, 65 | ), 66 | ), 67 | ), 68 | ); 69 | } 70 | 71 | ScaffoldFeatureController _show( 72 | SnackBar snackBar, 73 | ) { 74 | removeCurrentSnackBar(); 75 | return showSnackBar(snackBar); 76 | } 77 | } 78 | 79 | @immutable 80 | class SnackBarL10n { 81 | const SnackBarL10n(); 82 | String get undo => 'UNDO'; 83 | String localizeError(dynamic error) => '$error'; 84 | } 85 | -------------------------------------------------------------------------------- /lib/extensions/state_notifier.dart: -------------------------------------------------------------------------------- 1 | import 'package:rxdart/rxdart.dart'; 2 | import 'package:state_notifier/state_notifier.dart'; 3 | 4 | extension StateNotifierEx on StateNotifier { 5 | // stream.shareValueSeeded(state)してValueStream にしたいものの、 6 | // shareValueSeededの購読数がゼロになるとそれ以降の購読に反応しなくなる挙動が 7 | // 罠になりがちなので避けた(同期的に現在の値を取りたい場合は普通にstateアクセスで済む)。 8 | Stream get streamWithCurrent => 9 | // ignore: invalid_use_of_protected_member, invalid_use_of_visible_for_testing_member 10 | Rx.concatEager([Stream.value(state), stream]); 11 | } 12 | -------------------------------------------------------------------------------- /lib/extensions/string.dart: -------------------------------------------------------------------------------- 1 | extension StringEx on String? { 2 | bool get isNullOrEmpty { 3 | final string = this; 4 | return string == null || string.isEmpty; 5 | } 6 | 7 | String? get nullIfEmpty => isNullOrEmpty ? null : this; 8 | } 9 | -------------------------------------------------------------------------------- /lib/extensions/theme_data.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | extension ThemeDataEx on ThemeData { 5 | ThemeData unifyToMobileApp() { 6 | return copyWith( 7 | visualDensity: VisualDensity.standard, 8 | materialTapTargetSize: MaterialTapTargetSize.padded, 9 | ); 10 | } 11 | 12 | /// Create ThemeData which follows latest Material Design Spec. 13 | ThemeData followLatestSpec() { 14 | return copyWith( 15 | snackBarTheme: snackBarTheme.copyWith( 16 | behavior: SnackBarBehavior.floating, 17 | ), 18 | splashFactory: InkSparkle.splashFactory, 19 | pageTransitionsTheme: const PageTransitionsTheme( 20 | builders: { 21 | TargetPlatform.android: FadeForwardsPageTransitionsBuilder(), 22 | TargetPlatform.iOS: CupertinoPageTransitionsBuilder(), 23 | TargetPlatform.macOS: CupertinoPageTransitionsBuilder(), 24 | }, 25 | ), 26 | progressIndicatorTheme: progressIndicatorTheme.copyWith(year2023: false), 27 | sliderTheme: sliderTheme.copyWith(year2023: false), 28 | ); 29 | } 30 | } 31 | 32 | ThemeData lightTheme() => ThemeData.from( 33 | colorScheme: ColorScheme.fromSeed( 34 | seedColor: Colors.green, 35 | ), 36 | useMaterial3: true, 37 | ).followLatestSpec(); 38 | ThemeData darkTheme() => ThemeData.from( 39 | colorScheme: ColorScheme.fromSeed( 40 | seedColor: Colors.green, 41 | brightness: Brightness.dark, 42 | ), 43 | useMaterial3: true, 44 | ).followLatestSpec().copyWith( 45 | cupertinoOverrideTheme: const CupertinoThemeData( 46 | // Needed for correct CupertinoTextField color (bug?) 47 | textTheme: CupertinoTextThemeData(), 48 | ), 49 | ); 50 | -------------------------------------------------------------------------------- /lib/functions/functions.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:flutter/widgets.dart'; 3 | 4 | export 'show_error_dialog.dart'; 5 | export 'show_photo_selection_sheet.dart'; 6 | 7 | String convertToHalfWidth(String text) { 8 | return text.replaceAllMapped( 9 | RegExp(r'[0-9a-zA-Z]'), 10 | (m) => String.fromCharCode(m[0]!.codeUnitAt(0) - 65248), 11 | ); 12 | } 13 | 14 | /// Show error unless ReleaseMode and isProduction is true. 15 | /// 16 | /// Modified from this: 17 | /// https://github.com/flutter/flutter/blob/62621507966463f9fe678b3e249a64f1be11c9a1/packages/flutter/lib/src/widgets/framework.dart#L4376 18 | void configureErrorWidgetBuilder({ 19 | required bool isProduction, 20 | ErrorWidgetBuilder? productionBuilder, 21 | }) { 22 | ErrorWidget.builder = (details) { 23 | final message = kReleaseMode && isProduction 24 | ? '' 25 | : '${_stringifyException(details.exception)}\n' 26 | 'See also: https://flutter.dev/docs/testing/errors'; 27 | final dynamic exception = details.exception; 28 | if (isProduction && productionBuilder != null) { 29 | return productionBuilder(details); 30 | } 31 | return ErrorWidget.withDetails( 32 | message: message, 33 | error: exception is FlutterError ? exception : null, 34 | ); 35 | }; 36 | } 37 | 38 | String _stringifyException(Object exception) { 39 | try { 40 | return exception.toString(); 41 | // ignore: avoid_catches_without_on_clauses 42 | } catch (e) { 43 | // intentionally left empty. 44 | } 45 | return 'Error'; 46 | } 47 | -------------------------------------------------------------------------------- /lib/functions/show_error_dialog.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | void showErrorDialog({ 4 | required BuildContext context, 5 | @required dynamic error, 6 | ErrorDialogL10n l10n = const ErrorDialogL10n(), 7 | }) { 8 | showDialog( 9 | context: context, 10 | builder: (context) => AlertDialog( 11 | title: Text( 12 | l10n.errorTitle, 13 | style: TextStyle( 14 | color: Theme.of(context).colorScheme.error, 15 | ), 16 | ), 17 | content: Text( 18 | l10n.localizeError(error), 19 | ), 20 | actions: [ 21 | ElevatedButton( 22 | onPressed: () { 23 | Navigator.of(context).pop(); 24 | }, 25 | child: Text(MaterialLocalizations.of(context).okButtonLabel), 26 | ), 27 | ], 28 | ), 29 | ); 30 | } 31 | 32 | @immutable 33 | class ErrorDialogL10n { 34 | const ErrorDialogL10n(); 35 | String get errorTitle => 'エラーが発生しました'; 36 | String localizeError(dynamic error) => '$error'; 37 | } 38 | -------------------------------------------------------------------------------- /lib/functions/show_photo_selection_sheet.dart: -------------------------------------------------------------------------------- 1 | import 'package:adaptive_dialog/adaptive_dialog.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter/services.dart'; 4 | import 'package:image_picker/image_picker.dart'; 5 | import 'package:mono_kit/utils/logger.dart'; 6 | import 'package:mono_kit/utils/utils.dart'; 7 | 8 | Future> showPhotoSelectionSheet({ 9 | required BuildContext context, 10 | PhotoSelectionL10n l10n = const PhotoSelectionL10n(), 11 | VoidCallback? onSettingAppOpenRequested, 12 | bool requestFullMetadata = false, 13 | bool allowMultiple = false, 14 | (List>, ValueSetter)? additionalActions, 15 | }) async { 16 | final source = await showModalActionSheet( 17 | context: context, 18 | title: l10n.title, 19 | actions: [ 20 | SheetAction( 21 | icon: Icons.perm_media, 22 | label: l10n.chooseFromLibrary, 23 | key: ImageSource.gallery, 24 | ), 25 | SheetAction( 26 | icon: Icons.camera_alt, 27 | label: l10n.takePicture, 28 | key: ImageSource.camera, 29 | ), 30 | if (additionalActions != null) ...additionalActions.$1, 31 | ], 32 | ); 33 | 34 | if (source == null) { 35 | return []; 36 | } 37 | 38 | final picker = ImagePicker(); 39 | try { 40 | if (source == ImageSource.gallery && allowMultiple) { 41 | return await picker.pickMultiImage( 42 | requestFullMetadata: requestFullMetadata, 43 | ); 44 | } else if (source is ImageSource) { 45 | final file = await picker.pickImage( 46 | source: source, 47 | requestFullMetadata: requestFullMetadata, 48 | ); 49 | return file == null ? [] : [file]; 50 | } else if (source is T) { 51 | additionalActions!.$2(source); 52 | } else { 53 | logger.warning('Invalid source type: $source'); 54 | } 55 | } on PlatformException catch (e) { 56 | logger.warning(e); 57 | if (![ 58 | ImagePickerErrorCodes.cameraAccessRestricted, 59 | ImagePickerErrorCodes.cameraAccessDenied, 60 | ImagePickerErrorCodes.photoAccessRestricted, 61 | ImagePickerErrorCodes.photoAccessDenied, 62 | ].contains(e.code)) { 63 | // ignore: use_build_context_synchronously 64 | showErrorDialog(context: context, error: e); 65 | return []; 66 | } 67 | 68 | if (onSettingAppOpenRequested == null) { 69 | return []; 70 | } 71 | 72 | const okKey = 'ok'; 73 | // ignore: use_build_context_synchronously 74 | final result = await showModalActionSheet( 75 | context: context, 76 | title: l10n.accessRestrictedTitle, 77 | message: l10n.accessRestrictedMessage, 78 | actions: [SheetAction(label: l10n.accessRestrictedOk, key: okKey)], 79 | ); 80 | if (result == okKey) { 81 | onSettingAppOpenRequested(); 82 | } 83 | } 84 | return []; 85 | } 86 | 87 | @immutable 88 | class PhotoSelectionL10n { 89 | const PhotoSelectionL10n(); 90 | String get title => '画像の選択'; 91 | String get chooseFromLibrary => 'ライブラリから選択'; 92 | String get takePicture => '写真を撮る'; 93 | String get accessRestrictedTitle => '設定画面での許可が必要です'; 94 | String get accessRestrictedMessage => '設定アプリで写真アクセスの許可をお願いします。'; 95 | String get accessRestrictedOk => '設定アプリで許可'; 96 | } 97 | 98 | class ImagePickerErrorCodes { 99 | static const cameraAccessRestricted = 'camera_access_restricted'; 100 | static const cameraAccessDenied = 'camera_access_denied'; 101 | static const photoAccessRestricted = 'photo_access_restricted'; 102 | static const photoAccessDenied = 'photo_access_denied'; 103 | } 104 | -------------------------------------------------------------------------------- /lib/mono_kit.dart: -------------------------------------------------------------------------------- 1 | export 'errors/errors.dart'; 2 | export 'extensions/extensions.dart'; 3 | export 'functions/functions.dart'; 4 | export 'routes/routes.dart'; 5 | export 'utils/utils.dart'; 6 | export 'widgets/widgets.dart'; 7 | -------------------------------------------------------------------------------- /lib/plugins/app_installation_checker.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:flutter/foundation.dart'; 4 | import 'package:flutter/services.dart'; 5 | import 'package:url_launcher/url_launcher.dart'; 6 | 7 | import 'plugins.dart'; 8 | 9 | class AppInstallationChecker { 10 | static const _platform = MethodChannel(kMethodChannelName); 11 | 12 | Future isInstalled(String packageName) async { 13 | if (kIsWeb) { 14 | return null; 15 | } 16 | if (Platform.isIOS) { 17 | return canLaunchUrl(Uri.parse('$packageName://')); 18 | } 19 | if (Platform.isAndroid) { 20 | return _platform.invokeMethod( 21 | 'installation_checker/is_installed', 22 | { 23 | 'package_name': packageName, 24 | }, 25 | ); 26 | } 27 | return null; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/plugins/ios_info_plist_reader.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:flutter/services.dart'; 4 | 5 | import 'plugins.dart'; 6 | 7 | class IosInfoPlistReader { 8 | static const _platform = MethodChannel(kMethodChannelName); 9 | 10 | Future readString(String key) { 11 | assert(Platform.isIOS); 12 | return _platform.invokeMethod( 13 | 'info_plist/read_string', 14 | { 15 | 'key': key, 16 | }, 17 | ); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/plugins/plugins.dart: -------------------------------------------------------------------------------- 1 | export 'app_installation_checker.dart'; 2 | export 'ios_info_plist_reader.dart'; 3 | 4 | const kMethodChannelName = 'mono_kit'; 5 | -------------------------------------------------------------------------------- /lib/routes/fade_page_route.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'modal_page_route.dart'; 4 | 5 | class FadePageRoute extends ModalPageRoute { 6 | FadePageRoute({ 7 | required super.builder, 8 | super.settings, 9 | }); 10 | 11 | @override 12 | Widget buildTransitions( 13 | BuildContext context, 14 | Animation animation, 15 | Animation secondaryAnimation, 16 | Widget child, 17 | ) { 18 | return FadeTransition(opacity: animation, child: child); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/routes/modal_page_route.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class ModalPageRoute extends MaterialPageRoute { 4 | ModalPageRoute({ 5 | required WidgetBuilder builder, 6 | @required super.settings, 7 | }) : super( 8 | builder: (context) => builder(context), 9 | fullscreenDialog: true, 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /lib/routes/routes.dart: -------------------------------------------------------------------------------- 1 | export 'bottom_popup_route.dart'; 2 | export 'fade_page_route.dart'; 3 | export 'modal_page_route.dart'; 4 | -------------------------------------------------------------------------------- /lib/utils/build_mode.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | 3 | enum BuildMode { profile, debug, release } 4 | 5 | BuildMode buildMode = () { 6 | if (kReleaseMode) { 7 | return BuildMode.release; 8 | } 9 | if (kProfileMode) { 10 | return BuildMode.profile; 11 | } 12 | if (kDebugMode) { 13 | return BuildMode.debug; 14 | } 15 | assert(false, 'Cannot determined Build Mode'); 16 | // ignore: null_check_always_fails 17 | return null!; 18 | }(); 19 | -------------------------------------------------------------------------------- /lib/utils/hud.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class HUD { 4 | BuildContext? hudContext; 5 | void show(BuildContext context) { 6 | showGeneralDialog( 7 | context: context, 8 | pageBuilder: (hudContext, a1, a2) { 9 | this.hudContext = hudContext; 10 | return const Center(child: CircularProgressIndicator()); 11 | }, 12 | barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel, 13 | barrierColor: Colors.black26, 14 | transitionDuration: const Duration(milliseconds: 150), 15 | transitionBuilder: (c, animation, sa, child) => FadeTransition( 16 | opacity: CurvedAnimation( 17 | parent: animation, 18 | curve: Curves.easeOut, 19 | ), 20 | child: child, 21 | ), 22 | ); 23 | } 24 | 25 | void dismiss() { 26 | if (hudContext == null) { 27 | assert(false, 'hudContext should not be null.'); 28 | return; 29 | } 30 | Navigator.of(hudContext!).pop(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/utils/lifecycle_observer.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | 4 | final lifecycleObserver = StreamProvider((ref) async* { 5 | final observer = AppLifecycleStateObserver( 6 | (state) { 7 | ref.state = AsyncData(state); 8 | }, 9 | ); 10 | final binding = WidgetsBinding.instance..addObserver(observer); 11 | ref.onDispose(() => binding.removeObserver(observer)); 12 | }); 13 | 14 | class AppLifecycleStateObserver extends WidgetsBindingObserver { 15 | AppLifecycleStateObserver(this._didChange); 16 | 17 | final ValueChanged _didChange; 18 | 19 | @override 20 | void didChangeAppLifecycleState(AppLifecycleState state) { 21 | _didChange(state); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/utils/logger.dart: -------------------------------------------------------------------------------- 1 | import 'package:simple_logger/simple_logger.dart'; 2 | 3 | final logger = SimpleLogger() 4 | ..mode = LoggerMode.print 5 | ..setLevel( 6 | Level.FINEST, 7 | includeCallerInfo: true, 8 | ); 9 | -------------------------------------------------------------------------------- /lib/utils/paging_scroll_controller.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:mono_kit/utils/logger.dart'; 5 | 6 | const kPagingScrollDuration = Duration(milliseconds: 200); 7 | const _curve = Curves.easeInOut; 8 | const kPagingScrollOffset = 44.0; 9 | 10 | class PagingScrollController extends ScrollController 11 | with PagingScrollControllerMixin {} 12 | 13 | mixin PagingScrollControllerMixin on ScrollController { 14 | BuildContext get _context => position.context.notificationContext!; 15 | RenderBox? get _renderBox => _context.findRenderObject()! as RenderBox; 16 | 17 | double get _height => _renderBox?.size.height ?? 0; 18 | double get _minScrollExtent => position.minScrollExtent; 19 | double get _maxScrollExtent => position.maxScrollExtent; 20 | bool get _reachedToTop => offset <= _minScrollExtent; 21 | bool get _reachedToBottom => offset >= _maxScrollExtent; 22 | 23 | void scrollToTop() { 24 | if (_reachedToTop) { 25 | logger.fine('Reached to top'); 26 | return; 27 | } 28 | animateTo( 29 | _minScrollExtent, 30 | duration: kPagingScrollDuration, 31 | curve: _curve, 32 | ); 33 | } 34 | 35 | void scrollToPreviousPage() { 36 | scrollUp(offset: _height); 37 | } 38 | 39 | void scrollUp({double offset = kPagingScrollOffset}) { 40 | if (_reachedToTop) { 41 | logger.fine('Reached to top'); 42 | return; 43 | } 44 | animateTo( 45 | max(_minScrollExtent, this.offset - offset), 46 | duration: kPagingScrollDuration, 47 | curve: _curve, 48 | ); 49 | } 50 | 51 | void scrollToNextPage() { 52 | scrollDown(offset: _height); 53 | } 54 | 55 | void scrollDown({double offset = kPagingScrollOffset}) { 56 | if (_reachedToBottom) { 57 | logger.fine('Reached to bottom'); 58 | return; 59 | } 60 | animateTo( 61 | min(_maxScrollExtent, this.offset + offset), 62 | duration: kPagingScrollDuration, 63 | curve: _curve, 64 | ); 65 | } 66 | 67 | void scrollToBottom() { 68 | if (_reachedToBottom) { 69 | logger.fine('Reached to bottom'); 70 | return; 71 | } 72 | animateTo( 73 | _maxScrollExtent, 74 | duration: kPagingScrollDuration, 75 | curve: _curve, 76 | ); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /lib/utils/utils.dart: -------------------------------------------------------------------------------- 1 | export 'package:mono_kit/functions/functions.dart'; 2 | export 'package:subscription_holder/subscription_holder.dart'; 3 | 4 | export 'build_mode.dart'; 5 | export 'hud.dart'; 6 | export 'lifecycle_observer.dart'; 7 | export 'paging_scroll_controller.dart'; 8 | -------------------------------------------------------------------------------- /lib/widgets/animated_expansion_visibility.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class AnimatedExpansionVisibility extends ImplicitlyAnimatedWidget { 4 | const AnimatedExpansionVisibility({ 5 | super.key, 6 | this.child, 7 | required this.isVisible, 8 | this.axisAlignment = 1, 9 | Duration? duration, 10 | Curve? curve, 11 | }) : super( 12 | duration: duration ?? const Duration(milliseconds: 200), 13 | curve: curve ?? Curves.linear, 14 | ); 15 | 16 | final Widget? child; 17 | final bool isVisible; 18 | final double axisAlignment; 19 | 20 | @override 21 | AnimatedWidgetBaseState createState() => 22 | _AnimatedExpansionVisibilityState(); 23 | } 24 | 25 | class _AnimatedExpansionVisibilityState 26 | extends AnimatedWidgetBaseState { 27 | Tween? _heightFactorTween; 28 | 29 | @override 30 | Widget build(BuildContext context) { 31 | return SizeTransition( 32 | sizeFactor: _heightFactorTween!.animate(animation), 33 | axisAlignment: widget.axisAlignment, 34 | child: widget.child, 35 | ); 36 | } 37 | 38 | @override 39 | void forEachTween(TweenVisitor visitor) { 40 | _heightFactorTween = visitor( 41 | _heightFactorTween, 42 | widget.isVisible ? 1.0 : 0.0, 43 | (dynamic heightFactor) => Tween(begin: heightFactor as double), 44 | )! as Tween; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /lib/widgets/app_asset_image.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_svg/flutter_svg.dart'; 3 | 4 | enum AppAssetImageType { 5 | png, 6 | svg, 7 | } 8 | 9 | abstract class AppAssetImage extends StatelessWidget { 10 | const factory AppAssetImage.png({ 11 | Key? key, 12 | required String name, 13 | BoxFit? fit, 14 | double scale, 15 | Color? color, 16 | }) = _PngImage; 17 | const factory AppAssetImage.svg({ 18 | required String name, 19 | BoxFit fit, 20 | Color? color, 21 | }) = _SvgImage; 22 | 23 | const AppAssetImage._({ 24 | super.key, 25 | required this.name, 26 | @required this.fit, 27 | required this.scale, 28 | required this.type, 29 | required this.color, 30 | }); 31 | 32 | final String name; 33 | final BoxFit? fit; 34 | final double? scale; 35 | final AppAssetImageType? type; 36 | final Color? color; 37 | 38 | ImageProvider? get image => 39 | this is _PngImage ? (this as _PngImage)._image : null; 40 | } 41 | 42 | class _PngImage extends AppAssetImage { 43 | const _PngImage({ 44 | super.key, 45 | required super.name, 46 | super.fit, 47 | double super.scale = 3, 48 | super.color, 49 | }) : super._( 50 | type: AppAssetImageType.png, 51 | ); 52 | 53 | Image get _widget => Image.asset( 54 | 'assets/images/$name.png', 55 | scale: scale, 56 | fit: fit, 57 | color: color, 58 | ); 59 | 60 | ImageProvider get _image => _widget.image; 61 | 62 | @override 63 | Widget build(BuildContext context) => _widget; 64 | } 65 | 66 | class _SvgImage extends AppAssetImage { 67 | const _SvgImage({ 68 | required super.name, 69 | BoxFit super.fit = BoxFit.contain, 70 | super.color, 71 | }) : super._( 72 | scale: null, 73 | type: AppAssetImageType.svg, 74 | ); 75 | 76 | @override 77 | Widget build(BuildContext context) { 78 | final color = this.color; 79 | return SvgPicture.asset( 80 | 'assets/images/$name.svg', 81 | fit: fit ?? BoxFit.contain, 82 | colorFilter: 83 | color == null ? null : ColorFilter.mode(color, BlendMode.srcIn), 84 | ); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /lib/widgets/app_bottom_area.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:mono_kit/mono_kit.dart'; 5 | import 'package:nested/nested.dart'; 6 | 7 | class AppBottomArea extends SingleChildStatefulWidget { 8 | const AppBottomArea({ 9 | super.key, 10 | required Widget super.child, 11 | this.bottom, 12 | }); 13 | 14 | final Widget? bottom; 15 | 16 | @override 17 | SingleChildState createState() => _AppBottomAreaState(); 18 | } 19 | 20 | class _AppBottomAreaState extends SingleChildState { 21 | var _bottomHeight = 0.0; 22 | 23 | @override 24 | Widget buildWithChild(BuildContext context, Widget? child) { 25 | final mediaQuery = MediaQuery.of(context); 26 | final bottom = widget.bottom; 27 | return Column( 28 | children: [ 29 | Expanded( 30 | child: LayoutBuilder( 31 | builder: (context, constraints) { 32 | final bottomDiff = mediaQuery.size.height - constraints.maxHeight; 33 | final paddingBottom = max( 34 | 0, 35 | mediaQuery.padding.bottom - _bottomHeight, 36 | ); 37 | return MediaQuery( 38 | data: mediaQuery.copyWith( 39 | size: Size(constraints.maxWidth, constraints.maxHeight), 40 | padding: mediaQuery.padding.copyWith( 41 | bottom: paddingBottom, 42 | ), 43 | viewPadding: mediaQuery.viewPadding.copyWith( 44 | bottom: paddingBottom, 45 | ), 46 | viewInsets: mediaQuery.viewInsets.copyWith( 47 | bottom: max( 48 | 0, 49 | mediaQuery.viewInsets.bottom - bottomDiff, 50 | ), 51 | ), 52 | ), 53 | child: child!, 54 | ); 55 | }, 56 | ), 57 | ), 58 | if (bottom != null) 59 | SizeListener( 60 | onSizeChanged: (size) { 61 | final bottomHeight = size.height; 62 | if (bottomHeight != _bottomHeight) { 63 | setState(() { 64 | _bottomHeight = bottomHeight; 65 | }); 66 | } 67 | }, 68 | child: bottom, 69 | ), 70 | ], 71 | ); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /lib/widgets/barrier.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:mono_kit/mono_kit.dart'; 4 | 5 | final barrierProvider = StateNotifierProvider( 6 | (ref) => BarrierController(), 7 | ); 8 | 9 | class Barrier extends ConsumerWidget { 10 | const Barrier({ 11 | super.key, 12 | required this.child, 13 | this.valueColor, 14 | this.backgroundColor, 15 | this.timeout = const Duration(milliseconds: 200), 16 | this.switchDuration = const Duration(milliseconds: 100), 17 | }); 18 | 19 | final Widget child; 20 | final Color? valueColor; 21 | final Color? backgroundColor; 22 | final Duration timeout; 23 | final Duration switchDuration; 24 | 25 | @override 26 | Widget build(BuildContext context, WidgetRef ref) { 27 | final theme = Theme.of(context); 28 | final visible = ref.watch(barrierProvider); 29 | return Stack( 30 | fit: StackFit.passthrough, 31 | children: [ 32 | child, 33 | Positioned.fill( 34 | child: Visibility( 35 | visible: visible, 36 | child: TimeoutSwitcher( 37 | timeout: timeout, 38 | switchDuration: switchDuration, 39 | initialChild: const SizedBox.expand(child: AbsorbPointer()), 40 | timedOutChild: ColoredBox( 41 | color: 42 | backgroundColor ?? 43 | theme.scaffoldBackgroundColor.withValues(alpha: 0.6), 44 | child: Center( 45 | child: CircularProgressIndicator( 46 | valueColor: AlwaysStoppedAnimation(valueColor), 47 | ), 48 | ), 49 | ), 50 | ), 51 | ), 52 | ), 53 | ], 54 | ); 55 | } 56 | } 57 | 58 | class BarrierController extends StateNotifier { 59 | BarrierController() : super(false); 60 | 61 | void startProgress() => state = true; 62 | 63 | void stopProgress() => state = false; 64 | 65 | void toggleProgress() => state = !state; 66 | 67 | /// Execute f() with showing progress. 68 | Future executeWithProgress(Future Function() f) async { 69 | try { 70 | startProgress(); 71 | return await f(); 72 | } finally { 73 | stopProgress(); 74 | } 75 | } 76 | } 77 | 78 | class PopBarrier extends ConsumerWidget { 79 | const PopBarrier({super.key, required this.child}); 80 | 81 | final Widget child; 82 | 83 | @override 84 | Widget build(BuildContext context, WidgetRef ref) { 85 | return PopScope(canPop: !ref.watch(barrierProvider), child: child); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /lib/widgets/better_animated_opacity.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | 3 | import 'widgets.dart'; 4 | 5 | class BetterAnimatedOpacity extends ImplicitlyAnimatedWidget { 6 | const BetterAnimatedOpacity({ 7 | super.key, 8 | required this.child, 9 | required this.opacity, 10 | super.curve, 11 | required super.duration, 12 | }) : assert(opacity >= 0.0 && opacity <= 1.0); 13 | 14 | final Widget child; 15 | final double opacity; 16 | 17 | @override 18 | ImplicitlyAnimatedWidgetState createState() => 19 | _AnimatedOpacityState(); 20 | } 21 | 22 | class _AnimatedOpacityState 23 | extends ImplicitlyAnimatedWidgetState { 24 | Tween? _opacity; 25 | late Animation _opacityAnimation; 26 | 27 | @override 28 | void forEachTween(TweenVisitor visitor) { 29 | _opacity = visitor( 30 | _opacity, 31 | widget.opacity, 32 | (dynamic value) => Tween(begin: value as double), 33 | )! as Tween; 34 | } 35 | 36 | @override 37 | void didUpdateTweens() { 38 | _opacityAnimation = animation.drive(_opacity!); 39 | } 40 | 41 | @override 42 | Widget build(BuildContext context) { 43 | return BetterFadeTransition( 44 | opacity: _opacityAnimation, 45 | child: widget.child, 46 | ); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lib/widgets/better_fade_transition.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | 3 | class BetterFadeTransition extends AnimatedWidget { 4 | const BetterFadeTransition({ 5 | super.key, 6 | required this.child, 7 | required Animation opacity, 8 | this.alwaysIncludeSemantics = false, 9 | }) : super( 10 | listenable: opacity, 11 | ); 12 | 13 | final Widget child; 14 | final bool alwaysIncludeSemantics; 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | final animation = listenable as Animation; 19 | return Visibility( 20 | visible: animation.value != 0, 21 | child: FadeTransition( 22 | opacity: animation, 23 | alwaysIncludeSemantics: alwaysIncludeSemantics, 24 | child: child, 25 | ), 26 | ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/widgets/better_placeholder.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class BetterPlaceholder extends StatelessWidget { 4 | const BetterPlaceholder({ 5 | super.key, 6 | this.color = const Color(0xFF455A64), // Blue Grey 700 7 | this.strokeWidth = 2.0, 8 | this.fallbackWidth = 400.0, 9 | this.fallbackHeight = 400.0, 10 | }); 11 | 12 | final Color color; 13 | final double strokeWidth; 14 | final double fallbackWidth; 15 | final double fallbackHeight; 16 | 17 | String _sizeDesc(BoxConstraints constraints) { 18 | final fallbackSize = 'Fallback Size: $fallbackWidth x $fallbackHeight'; 19 | return '$fallbackSize\nReal Size: ${_fallbackIfInfinity( 20 | value: constraints.maxWidth, 21 | fallback: fallbackWidth, 22 | )} x ${_fallbackIfInfinity( 23 | value: constraints.maxHeight, 24 | fallback: fallbackHeight, 25 | )}'; 26 | } 27 | 28 | double _fallbackIfInfinity({ 29 | required double value, 30 | required double fallback, 31 | }) => 32 | value == double.infinity ? fallback : value; 33 | 34 | @override 35 | Widget build(BuildContext context) { 36 | return LayoutBuilder( 37 | builder: (context, constraints) => Stack( 38 | alignment: Alignment.center, 39 | children: [ 40 | Placeholder( 41 | color: color, 42 | strokeWidth: strokeWidth, 43 | fallbackWidth: fallbackWidth, 44 | fallbackHeight: fallbackHeight, 45 | ), 46 | Positioned.fill( 47 | child: Center( 48 | child: Card( 49 | child: FittedBox( 50 | child: Padding( 51 | padding: const EdgeInsets.all(4), 52 | child: Text(_sizeDesc(constraints)), 53 | ), 54 | ), 55 | ), 56 | ), 57 | ), 58 | ], 59 | ), 60 | ); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /lib/widgets/better_stream_builder.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | 3 | class BetterStreamBuilder extends StatefulWidget { 4 | const BetterStreamBuilder({ 5 | super.key, 6 | this.initialData, 7 | required this.stream, 8 | required this.builder, 9 | this.child, 10 | }); 11 | 12 | final Stream stream; 13 | // ignore: unsafe_variance 14 | final AsyncChildWidgetBuilder builder; 15 | final T? initialData; 16 | final Widget? child; 17 | 18 | @override 19 | State> createState() => _BetterStreamBuilderState(); 20 | } 21 | 22 | class _BetterStreamBuilderState extends State> { 23 | @override 24 | Widget build(BuildContext context) { 25 | return StreamBuilder( 26 | initialData: widget.initialData, 27 | stream: widget.stream, 28 | builder: (context, snapshot) { 29 | return widget.builder(context, snapshot, widget.child); 30 | }, 31 | ); 32 | } 33 | } 34 | 35 | typedef AsyncChildWidgetBuilder = Widget Function( 36 | BuildContext context, 37 | AsyncSnapshot snap, 38 | Widget? child, 39 | ); 40 | -------------------------------------------------------------------------------- /lib/widgets/centered_max_width.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class CenteredMaxWidth extends StatelessWidget { 4 | const CenteredMaxWidth({ 5 | super.key, 6 | required this.child, 7 | this.width = 768, 8 | }); 9 | 10 | final double width; 11 | final Widget child; 12 | 13 | @override 14 | Widget build(BuildContext context) { 15 | return Center( 16 | child: SizedBox( 17 | width: width, 18 | child: child, 19 | ), 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/widgets/debug_padding.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:mono_kit/utils/logger.dart'; 3 | import 'package:nested/nested.dart'; 4 | 5 | class DebugPadding extends SingleChildStatelessWidget { 6 | const DebugPadding({ 7 | super.key, 8 | super.child, 9 | this.showPadding = true, 10 | this.showViewPadding = true, 11 | this.showViewInsets = true, 12 | this.showSize = true, 13 | }); 14 | 15 | final bool showPadding; 16 | final bool showViewPadding; 17 | final bool showViewInsets; 18 | final bool showSize; 19 | 20 | @override 21 | Widget buildWithChild(BuildContext context, Widget? child) { 22 | final mediaQuery = MediaQuery.of(context); 23 | return Stack( 24 | children: [ 25 | child!, 26 | if (showPadding) 27 | _Padding( 28 | label: 'padding', 29 | color: Colors.red, 30 | padding: mediaQuery.padding, 31 | alignment: Alignment.topLeft, 32 | ), 33 | if (showViewPadding) 34 | _Padding( 35 | label: 'viewPadding', 36 | color: Colors.blue, 37 | padding: mediaQuery.viewPadding, 38 | alignment: Alignment.topRight, 39 | ), 40 | if (showViewInsets) 41 | _Padding( 42 | label: 'viewInsets', 43 | color: Colors.green, 44 | padding: mediaQuery.viewInsets, 45 | alignment: Alignment.center, 46 | ), 47 | if (showSize) const _Size(), 48 | ], 49 | ); 50 | } 51 | } 52 | 53 | class _Size extends StatelessWidget { 54 | const _Size(); 55 | @override 56 | Widget build(BuildContext context) { 57 | final mediaQuery = MediaQuery.of(context); 58 | final theme = Theme.of(context); 59 | final colorScheme = theme.colorScheme; 60 | return Positioned( 61 | right: 0, 62 | bottom: mediaQuery.viewInsets.bottom, 63 | child: ColoredBox( 64 | color: colorScheme.surface, 65 | child: Text( 66 | 'size\n${mediaQuery.size}', 67 | style: theme.textTheme.bodyMedium, 68 | ), 69 | ), 70 | ); 71 | } 72 | } 73 | 74 | class _Padding extends StatelessWidget { 75 | const _Padding({ 76 | required this.label, 77 | required this.color, 78 | required this.padding, 79 | required this.alignment, 80 | }); 81 | 82 | final String label; 83 | final Color color; 84 | final EdgeInsets padding; 85 | final Alignment alignment; 86 | 87 | @override 88 | Widget build(BuildContext context) { 89 | logger.fine('${label.padRight(12)}: $padding'); 90 | final theme = Theme.of(context); 91 | final colorScheme = theme.colorScheme; 92 | return IgnorePointer( 93 | child: Container( 94 | decoration: BoxDecoration( 95 | border: Border.all( 96 | color: color.withValues(alpha: 0.8), 97 | width: 4, 98 | ), 99 | color: color.withValues(alpha: 0.2), 100 | ), 101 | margin: padding, 102 | child: Align( 103 | alignment: alignment, 104 | child: ColoredBox( 105 | color: colorScheme.surface, 106 | child: Text( 107 | '$label\n${padding.toString().replaceAll('EdgeInsets', '')}', 108 | style: theme.textTheme.bodyMedium, 109 | ), 110 | ), 111 | ), 112 | ), 113 | ); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /lib/widgets/delayed_pop_scope.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/services.dart'; 3 | 4 | typedef DelayedPopInvokedWithResultCallback = Future Function( 5 | T? result, 6 | ); 7 | 8 | class DelayedPopScope extends StatelessWidget { 9 | const DelayedPopScope({ 10 | super.key, 11 | required this.onShouldPop, 12 | required this.child, 13 | this.canPop = false, 14 | }); 15 | 16 | final DelayedPopInvokedWithResultCallback onShouldPop; 17 | final bool canPop; 18 | final Widget child; 19 | 20 | @override 21 | Widget build(BuildContext context) { 22 | return PopScope( 23 | canPop: canPop, 24 | onPopInvokedWithResult: (didPop, result) async { 25 | if (didPop) { 26 | return; 27 | } 28 | final navigator = Navigator.of(context); 29 | final shouldPop = await onShouldPop(result); 30 | if (shouldPop) { 31 | if (navigator.canPop()) { 32 | navigator.pop(); 33 | } else { 34 | await SystemNavigator.pop(); 35 | } 36 | } 37 | }, 38 | child: child, 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/widgets/device_frame.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:nested/nested.dart'; 3 | 4 | class DeviceFrame extends SingleChildStatelessWidget { 5 | const DeviceFrame({ 6 | super.key, 7 | required this.builder, 8 | super.child, 9 | this.enabled = false, 10 | }); 11 | 12 | final TransitionBuilder builder; 13 | final bool enabled; 14 | 15 | @override 16 | Widget buildWithChild(BuildContext context, Widget? child) { 17 | if (!enabled) { 18 | return child!; 19 | } 20 | return builder( 21 | context, 22 | LayoutBuilder( 23 | builder: (context, constraints) { 24 | return MediaQuery( 25 | data: MediaQuery.of(context).copyWith( 26 | size: Size( 27 | constraints.maxWidth, 28 | constraints.maxHeight, 29 | ), 30 | ), 31 | child: child!, 32 | ); 33 | }, 34 | ), 35 | ); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/widgets/go_router_location_button.dart: -------------------------------------------------------------------------------- 1 | import 'package:adaptive_dialog/adaptive_dialog.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:go_router/go_router.dart'; 5 | 6 | Widget goRouteLocationButtonNavigationBuilder( 7 | BuildContext context, 8 | GoRouterState state, 9 | Widget child, { 10 | bool visible = kDebugMode, 11 | }) => 12 | GoRouterLocationButton( 13 | visible: visible, 14 | child: child, 15 | ); 16 | 17 | class GoRouterLocationButton extends StatelessWidget { 18 | const GoRouterLocationButton({ 19 | super.key, 20 | required this.child, 21 | this.visible = true, 22 | }); 23 | 24 | final Widget child; 25 | final bool visible; 26 | 27 | @override 28 | Widget build(BuildContext context) { 29 | if (!visible) { 30 | return child; 31 | } 32 | final router = GoRouter.of(context); 33 | final routerState = GoRouterState.of(context); 34 | final location = routerState.uri.toString(); 35 | return Stack( 36 | children: [ 37 | child, 38 | Positioned( 39 | right: 0, 40 | bottom: 0, 41 | child: SafeArea( 42 | child: ElevatedButton( 43 | style: ElevatedButton.styleFrom( 44 | foregroundColor: Theme.of(context).colorScheme.onSecondary, 45 | backgroundColor: Theme.of(context).colorScheme.secondary, 46 | ), 47 | onPressed: () async { 48 | final next = (await showTextInputDialog( 49 | context: context, 50 | textFields: [ 51 | DialogTextField(initialText: location), 52 | ], 53 | )) 54 | ?.first; 55 | if (next != null) { 56 | router.go(next); 57 | } 58 | }, 59 | child: Text(location), 60 | ), 61 | ), 62 | ), 63 | ], 64 | ); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /lib/widgets/itemized_text.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | export 'link_text_span.dart'; 4 | 5 | class ItemizedText extends StatelessWidget { 6 | const ItemizedText( 7 | this.texts, { 8 | super.key, 9 | this.bullet = '・', 10 | }); 11 | 12 | final List texts; 13 | final String bullet; 14 | 15 | @override 16 | Widget build(BuildContext context) { 17 | return Column( 18 | children: texts 19 | .map( 20 | (text) => _ItemizedTextRow( 21 | text, 22 | bullet: bullet, 23 | ), 24 | ) 25 | .toList(), 26 | ); 27 | } 28 | } 29 | 30 | class _ItemizedTextRow extends StatelessWidget { 31 | const _ItemizedTextRow( 32 | this.text, { 33 | required this.bullet, 34 | }); 35 | 36 | final Text text; 37 | final String bullet; 38 | 39 | @override 40 | Widget build(BuildContext context) { 41 | return Row( 42 | textBaseline: TextBaseline.alphabetic, 43 | crossAxisAlignment: CrossAxisAlignment.baseline, 44 | children: [ 45 | Text( 46 | bullet, 47 | style: text.style, 48 | ), 49 | Expanded(child: text), 50 | ], 51 | ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /lib/widgets/link_text_span.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/gestures.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:url_launcher/url_launcher.dart'; 4 | 5 | class LinkTextSpan extends TextSpan { 6 | LinkTextSpan({ 7 | required TextStyle style, 8 | required Uri url, 9 | String? text, 10 | }) : super( 11 | style: style, 12 | text: '${text ?? url}', 13 | recognizer: TapGestureRecognizer()..onTap = () => launchUrl(url), 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /lib/widgets/list_section.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'list_section_header.dart'; 4 | 5 | class ListSection extends StatelessWidget { 6 | const ListSection({ 7 | super.key, 8 | required this.label, 9 | this.children = const [], 10 | this.hasTopBorder = true, 11 | }); 12 | 13 | final List children; 14 | final String label; 15 | final bool hasTopBorder; 16 | 17 | @override 18 | Widget build(BuildContext context) { 19 | return Column( 20 | crossAxisAlignment: CrossAxisAlignment.stretch, 21 | children: [ 22 | ListSectionHeader( 23 | label: label, 24 | hasTopBorder: hasTopBorder, 25 | ), 26 | ...children, 27 | ], 28 | ); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/widgets/list_section_header.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class ListSectionHeader extends StatelessWidget { 4 | const ListSectionHeader({ 5 | super.key, 6 | required this.label, 7 | this.hasTopBorder = true, 8 | }); 9 | 10 | final String label; 11 | final bool hasTopBorder; 12 | 13 | @override 14 | Widget build(BuildContext context) { 15 | final theme = Theme.of(context); 16 | final colorScheme = theme.colorScheme; 17 | // ignore: use_decorated_box 18 | return Container( 19 | decoration: hasTopBorder 20 | ? BoxDecoration( 21 | border: Border( 22 | top: BorderSide( 23 | color: theme.dividerColor, 24 | width: 0, // = 1pixel 25 | ), 26 | ), 27 | ) 28 | : null, 29 | child: ListTile( 30 | title: Text( 31 | label, 32 | style: TextStyle( 33 | color: colorScheme.primary, 34 | ), 35 | ), 36 | ), 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/widgets/list_tile_selected_background_colored_box.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class ListTileSelectedBackgroundColoredBox extends StatelessWidget { 4 | const ListTileSelectedBackgroundColoredBox({ 5 | super.key, 6 | required this.listTile, 7 | this.color, 8 | this.padding, 9 | this.borderRadius, 10 | }); 11 | 12 | final ListTile listTile; 13 | final Color? color; 14 | final EdgeInsetsGeometry? padding; 15 | final BorderRadius? borderRadius; 16 | 17 | @override 18 | Widget build(BuildContext context) { 19 | final theme = Theme.of(context); 20 | final colorScheme = theme.colorScheme; 21 | return Padding( 22 | padding: padding ?? const EdgeInsets.only(right: 8), 23 | child: ClipRRect( 24 | borderRadius: 25 | borderRadius ?? 26 | const BorderRadius.horizontal(right: Radius.circular(1000)), 27 | // Needed for ripple effect clipping 28 | child: Material( 29 | type: MaterialType.transparency, 30 | child: ColoredBox( 31 | color: 32 | listTile.selected 33 | ? color ?? colorScheme.primary.withValues(alpha: 0.1) 34 | : Colors.transparent, 35 | child: listTile, 36 | ), 37 | ), 38 | ), 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/widgets/listener/listener.dart: -------------------------------------------------------------------------------- 1 | export 'listener_text.dart'; 2 | export 'listener_visibility.dart'; 3 | -------------------------------------------------------------------------------- /lib/widgets/listener/listener_text.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:flutter/widgets.dart'; 3 | 4 | class ListenerText extends StatelessWidget { 5 | const ListenerText( 6 | this.data, { 7 | super.key, 8 | this.style, 9 | this.nullValue = '', 10 | }); 11 | 12 | final ValueListenable data; 13 | final TextStyle? style; 14 | final String nullValue; 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | return ValueListenableBuilder( 19 | valueListenable: data, 20 | builder: (context, data, child) { 21 | return Text( 22 | data ?? nullValue, 23 | style: style, 24 | ); 25 | }, 26 | ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/widgets/listener/listener_visibility.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:flutter/widgets.dart'; 3 | 4 | class ListenerVisibility extends StatelessWidget { 5 | const ListenerVisibility({ 6 | super.key, 7 | required this.visible, 8 | required this.child, 9 | }); 10 | 11 | final ValueListenable visible; 12 | final Widget child; 13 | 14 | @override 15 | Widget build(BuildContext context) { 16 | return ValueListenableBuilder( 17 | valueListenable: visible, 18 | builder: (context, visible, child) { 19 | return Visibility( 20 | visible: visible, 21 | child: child!, 22 | ); 23 | }, 24 | child: child, 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/widgets/loading_switcher.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:mono_kit/mono_kit.dart'; 3 | 4 | class LoadingSwitcher extends StatelessWidget { 5 | const LoadingSwitcher({ 6 | super.key, 7 | this.child, 8 | this.timedOutChild = const Center( 9 | child: CircularProgressIndicator(), 10 | ), 11 | this.initialChild = const SizedBox(), 12 | this.timeout = const Duration(milliseconds: 200), 13 | this.switchDuration = const Duration(milliseconds: 100), 14 | }); 15 | 16 | final Widget timedOutChild; 17 | final Widget initialChild; 18 | final Widget? child; 19 | final Duration timeout; 20 | final Duration switchDuration; 21 | 22 | @override 23 | Widget build(BuildContext context) { 24 | return AnimatedSwitcher( 25 | duration: switchDuration, 26 | child: child ?? 27 | TimeoutSwitcher( 28 | timedOutChild: timedOutChild, 29 | initialChild: initialChild, 30 | timeout: timeout, 31 | switchDuration: switchDuration, 32 | ), 33 | ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/widgets/max_width_padding_builder.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/material.dart'; 4 | 5 | typedef PaddingWidgetBuilder = Widget Function( 6 | BuildContext context, 7 | EdgeInsets padding, 8 | ); 9 | 10 | class MaxWidthPaddingBuilder extends StatelessWidget { 11 | const MaxWidthPaddingBuilder({ 12 | super.key, 13 | this.width = 768, 14 | required this.builder, 15 | }); 16 | 17 | final double width; 18 | final PaddingWidgetBuilder builder; 19 | 20 | @override 21 | Widget build(BuildContext context) { 22 | return LayoutBuilder( 23 | builder: (context, constraints) { 24 | return builder( 25 | context, 26 | EdgeInsets.symmetric( 27 | horizontal: max(0, constraints.maxWidth - width) / 2, 28 | ), 29 | ); 30 | }, 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/widgets/overflow_detectable_text.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math' show max; 2 | 3 | import 'package:flutter/widgets.dart'; 4 | 5 | typedef OverflowDetector = void Function(double overflowHeight); 6 | 7 | class OverflowDetectableText extends StatelessWidget { 8 | const OverflowDetectableText( 9 | this.data, { 10 | super.key, 11 | required this.style, 12 | required this.detector, 13 | this.overflow = TextOverflow.clip, 14 | }); 15 | 16 | final String data; 17 | final TextStyle style; 18 | final TextOverflow overflow; 19 | final OverflowDetector detector; 20 | 21 | @override 22 | Widget build(BuildContext context) { 23 | return LayoutBuilder( 24 | builder: (context, constraints) { 25 | final span = TextSpan( 26 | text: data, 27 | style: style, 28 | ); 29 | 30 | final painter = TextPainter( 31 | maxLines: 100000000, // big enough 32 | textDirection: Directionality.of(context), 33 | text: span, 34 | )..layout(maxWidth: constraints.maxWidth); 35 | 36 | final overflowHeight = max( 37 | 0.0, // ignore: prefer_int_literals 38 | painter.height - constraints.maxHeight, 39 | ); 40 | WidgetsBinding.instance 41 | .addPostFrameCallback((_) => detector(overflowHeight)); 42 | return Text.rich( 43 | span, 44 | overflow: overflow, 45 | ); 46 | }, 47 | ); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /lib/widgets/ripple_effect_button.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:nested/nested.dart'; 3 | 4 | class RippleEffectButton extends SingleChildStatelessWidget { 5 | const RippleEffectButton({ 6 | super.key, 7 | super.child, 8 | required this.onTap, 9 | required this.borderRadius, 10 | }); 11 | 12 | final VoidCallback onTap; 13 | final BorderRadius borderRadius; 14 | 15 | @override 16 | Widget buildWithChild(BuildContext context, Widget? child) { 17 | return Stack( 18 | fit: StackFit.passthrough, 19 | children: [ 20 | child!, 21 | Positioned.fill( 22 | child: Material( 23 | type: MaterialType.transparency, 24 | child: InkWell( 25 | borderRadius: borderRadius, 26 | onTap: onTap, 27 | ), 28 | ), 29 | ), 30 | ], 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/widgets/scroll_keyboard_shortcut.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/services.dart'; 3 | import 'package:mono_kit/mono_kit.dart'; 4 | import 'package:mono_kit/utils/logger.dart'; 5 | import 'package:rxdart/rxdart.dart'; 6 | 7 | class ScrollKeyboardShortcut extends StatefulWidget { 8 | const ScrollKeyboardShortcut({ 9 | super.key, 10 | required this.scrollController, 11 | required this.child, 12 | this.stepOffset = kPagingScrollOffset, 13 | }); 14 | 15 | final Widget child; 16 | final PagingScrollController scrollController; 17 | final double stepOffset; 18 | 19 | @override 20 | State createState() => _ScrollKeyboardShortcutState(); 21 | } 22 | 23 | class _ScrollKeyboardShortcutState extends State { 24 | final _focusNode = FocusNode(); 25 | final _onKeySubject = PublishSubject(); 26 | final _subscriptionHolder = SubscriptionHolder(); 27 | PagingScrollController get _scrollController => widget.scrollController; 28 | double get _stepOffset => widget.stepOffset; 29 | 30 | @override 31 | void initState() { 32 | super.initState(); 33 | 34 | _subscriptionHolder.add( 35 | _onKeySubject.throttleTime(kPagingScrollDuration).listen(_onKey), 36 | ); 37 | } 38 | 39 | @override 40 | void dispose() { 41 | _focusNode.dispose(); 42 | _onKeySubject.close(); 43 | 44 | super.dispose(); 45 | } 46 | 47 | @override 48 | void didChangeDependencies() { 49 | super.didChangeDependencies(); 50 | 51 | if (ModalRoute.of(context)!.isCurrent) { 52 | FocusScope.of(context).requestFocus(_focusNode); 53 | } 54 | } 55 | 56 | @override 57 | Widget build(BuildContext context) { 58 | return Shortcuts( 59 | shortcuts: _disabledNavigationKeys, 60 | child: KeyboardListener( 61 | focusNode: _focusNode, 62 | onKeyEvent: _onKeySubject.add, 63 | child: widget.child, 64 | ), 65 | ); 66 | } 67 | 68 | void _onKey(KeyEvent event) { 69 | if (event is! KeyDownEvent) { 70 | return; 71 | } 72 | final logicalKey = event.logicalKey; 73 | logger.fine('keyId: $logicalKey'); 74 | if (logicalKey == LogicalKeyboardKey.arrowUp) { 75 | _scrollController.scrollUp(offset: _stepOffset); 76 | } else if (logicalKey == LogicalKeyboardKey.arrowDown) { 77 | _scrollController.scrollDown(offset: _stepOffset); 78 | } else if (logicalKey == LogicalKeyboardKey.pageUp) { 79 | _scrollController.scrollToPreviousPage(); 80 | } else if (logicalKey == LogicalKeyboardKey.pageDown) { 81 | _scrollController.scrollToNextPage(); 82 | } else if (logicalKey == LogicalKeyboardKey.home) { 83 | _scrollController.scrollToTop(); 84 | } else if (logicalKey == LogicalKeyboardKey.end) { 85 | _scrollController.scrollToBottom(); 86 | } else if (logicalKey == LogicalKeyboardKey.space) { 87 | HardwareKeyboard.instance.isShiftPressed 88 | ? _scrollController.scrollToPreviousPage() 89 | : _scrollController.scrollToNextPage(); 90 | } 91 | } 92 | 93 | final _disabledNavigationKeys = 94 | { 95 | LogicalKeySet(LogicalKeyboardKey.arrowUp): Intent.doNothing, 96 | LogicalKeySet(LogicalKeyboardKey.arrowDown): Intent.doNothing, 97 | LogicalKeySet(LogicalKeyboardKey.arrowLeft): Intent.doNothing, 98 | LogicalKeySet(LogicalKeyboardKey.arrowRight): Intent.doNothing, 99 | }; 100 | } 101 | -------------------------------------------------------------------------------- /lib/widgets/size_listener.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/rendering.dart'; 2 | import 'package:flutter/widgets.dart'; 3 | 4 | typedef SizeChangedCallback = void Function(Size size); 5 | 6 | class SizeListener extends SingleChildRenderObjectWidget { 7 | const SizeListener({ 8 | super.key, 9 | super.child, 10 | required this.onSizeChanged, 11 | }); 12 | final SizeChangedCallback onSizeChanged; 13 | 14 | @override 15 | RenderObject createRenderObject(BuildContext context) => 16 | _SizeListenerRenderObject(onSizeChanged: onSizeChanged); 17 | } 18 | 19 | class _SizeListenerRenderObject extends RenderProxyBox { 20 | _SizeListenerRenderObject({ 21 | RenderBox? child, 22 | required this.onSizeChanged, 23 | }) : super(child); 24 | final SizeChangedCallback onSizeChanged; 25 | 26 | Size? _size; 27 | 28 | @override 29 | void performLayout() { 30 | super.performLayout(); 31 | 32 | final size = this.size; 33 | if (size != _size) { 34 | _size = size; 35 | WidgetsBinding.instance.addPostFrameCallback((_) => onSizeChanged(size)); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/widgets/text_scale_factor.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | import 'package:nested/nested.dart'; 3 | 4 | class TextScaleFactor extends SingleChildStatelessWidget { 5 | @Deprecated('Use `MediaQuery.withClampedTextScaling()` directly instead.') 6 | const TextScaleFactor({ 7 | super.key, 8 | super.child, 9 | this.min = 1, 10 | this.max, 11 | }); 12 | 13 | final double? min; 14 | final double? max; 15 | 16 | @override 17 | Widget buildWithChild(BuildContext context, Widget? child) { 18 | return MediaQuery.withClampedTextScaling( 19 | minScaleFactor: min ?? 0, 20 | maxScaleFactor: max ?? double.infinity, 21 | child: child!, 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/widgets/tile_padding.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:nested/nested.dart'; 3 | 4 | class TilePadding extends SingleChildStatelessWidget { 5 | const TilePadding({ 6 | super.key, 7 | super.child, 8 | this.horizontal, 9 | }); 10 | 11 | final double? horizontal; 12 | 13 | @override 14 | Widget buildWithChild(BuildContext context, Widget? child) { 15 | return SafeArea( 16 | top: false, 17 | bottom: false, 18 | minimum: EdgeInsets.symmetric( 19 | horizontal: horizontal ?? 16, 20 | ), 21 | child: child!, 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/widgets/timeout_switcher.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/material.dart'; 4 | 5 | class TimeoutSwitcher extends StatefulWidget { 6 | const TimeoutSwitcher({ 7 | super.key, 8 | required this.timedOutChild, 9 | this.initialChild = const SizedBox(), 10 | this.timeout = const Duration(milliseconds: 200), 11 | this.switchDuration = const Duration(milliseconds: 100), 12 | }); 13 | 14 | final Widget timedOutChild; 15 | final Widget initialChild; 16 | final Duration timeout; 17 | final Duration switchDuration; 18 | 19 | @override 20 | State createState() => _TimeoutSwitcherState(); 21 | } 22 | 23 | class _TimeoutSwitcherState extends State { 24 | var _timedOut = false; 25 | late final Timer _timer; 26 | 27 | @override 28 | void initState() { 29 | super.initState(); 30 | 31 | _timer = Timer( 32 | widget.timeout, 33 | () { 34 | if (mounted) { 35 | setState( 36 | () => _timedOut = true, 37 | ); 38 | } 39 | }, 40 | ); 41 | } 42 | 43 | @override 44 | void dispose() { 45 | _timer.cancel(); 46 | super.dispose(); 47 | } 48 | 49 | @override 50 | Widget build(BuildContext context) { 51 | return AnimatedSwitcher( 52 | duration: widget.switchDuration, 53 | child: _timedOut ? widget.timedOutChild : widget.initialChild, 54 | ); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/widgets/unfocus_on_tap.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:nested/nested.dart'; 3 | 4 | class UnfocusOnTap extends SingleChildStatelessWidget { 5 | const UnfocusOnTap({ 6 | super.key, 7 | required Widget super.child, 8 | }); 9 | 10 | @override 11 | Widget buildWithChild(BuildContext context, Widget? child) { 12 | return GestureDetector( 13 | behavior: HitTestBehavior.opaque, 14 | onTap: () => FocusScope.of(context).unfocus(), 15 | child: child, 16 | ); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/widgets/value_observable_builder.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | import 'package:nested/nested.dart'; 3 | import 'package:rxdart/rxdart.dart'; 4 | 5 | import 'better_stream_builder.dart'; 6 | 7 | class ValueObservableBuilder extends SingleChildStatefulWidget { 8 | const ValueObservableBuilder({ 9 | super.key, 10 | required this.builder, 11 | required this.stream, 12 | super.child, 13 | }); 14 | 15 | final ValueStream stream; 16 | final AsyncChildWidgetBuilder builder; 17 | 18 | @override 19 | SingleChildState> createState() => 20 | _ValueObservableBuilderState(); 21 | } 22 | 23 | class _ValueObservableBuilderState 24 | extends SingleChildState> { 25 | @override 26 | Widget buildWithChild(BuildContext context, Widget? child) { 27 | return StreamBuilder( 28 | initialData: widget.stream.valueOrNull, 29 | stream: widget.stream, 30 | builder: (context, snapshot) { 31 | // ValueObservableの場合、初期値があったらwaitingでは無いとみなす方が自然。 32 | // また、この加工をすることで初回の無駄な2回のリビルドが解消される。 33 | if (snapshot.connectionState == ConnectionState.waiting && 34 | snapshot.hasData) { 35 | snapshot = AsyncSnapshot.withData( 36 | ConnectionState.active, 37 | snapshot.data as T, 38 | ); 39 | } 40 | return widget.builder(context, snapshot, child); 41 | }, 42 | ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /lib/widgets/vertical_center_scroll_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class VerticalCenterScrollView extends StatefulWidget { 4 | const VerticalCenterScrollView({ 5 | super.key, 6 | required this.child, 7 | this.padding, 8 | this.autoPop = false, 9 | this.hasCloseButton = false, 10 | }); 11 | 12 | final Widget child; 13 | final bool autoPop; 14 | final bool hasCloseButton; 15 | final EdgeInsets? padding; 16 | 17 | @override 18 | State createState() => 19 | _VerticalCenterScrollViewState(); 20 | } 21 | 22 | class _VerticalCenterScrollViewState extends State { 23 | late final ScrollController _controller; 24 | var _isPopping = false; 25 | 26 | @override 27 | void initState() { 28 | super.initState(); 29 | _controller = ScrollController() 30 | ..addListener(() { 31 | if (!widget.autoPop || _isPopping) { 32 | return; 33 | } 34 | final query = MediaQuery.of(context); 35 | if (-_controller.offset > query.size.height * 0.18) { 36 | _isPopping = true; 37 | Navigator.of(context).pop(); 38 | } 39 | }); 40 | } 41 | 42 | @override 43 | Widget build(BuildContext context) { 44 | return Stack( 45 | children: [ 46 | LayoutBuilder( 47 | builder: (context, constraints) { 48 | final verticalPadding = 49 | (widget.padding?.top ?? 0) + (widget.padding?.bottom ?? 0); 50 | return SingleChildScrollView( 51 | padding: widget.padding, 52 | controller: _controller, 53 | // 中身の高さによらず常にバウンスさせる 54 | physics: const AlwaysScrollableScrollPhysics(), 55 | child: ConstrainedBox( 56 | // 最小高さを親の高さと一緒にする 57 | constraints: BoxConstraints( 58 | minHeight: constraints.maxHeight - verticalPadding, 59 | ), 60 | child: Center( 61 | child: widget.child, 62 | ), 63 | ), 64 | ); 65 | }, 66 | ), 67 | Visibility( 68 | visible: widget.hasCloseButton, 69 | child: Positioned( 70 | top: -6, 71 | left: -6, 72 | child: Material( 73 | color: Colors.transparent, 74 | child: SafeArea( 75 | bottom: false, 76 | child: SizedBox( 77 | width: Material.defaultSplashRadius * 2, 78 | height: Material.defaultSplashRadius * 2, 79 | child: IconTheme( 80 | data: Theme.of(context).primaryIconTheme, 81 | child: const CloseButton(), 82 | ), 83 | ), 84 | ), 85 | ), 86 | ), 87 | ), 88 | ], 89 | ); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /lib/widgets/widgets.dart: -------------------------------------------------------------------------------- 1 | export 'animated_expansion_visibility.dart'; 2 | export 'app_asset_image.dart'; 3 | export 'app_bottom_area.dart'; 4 | export 'barrier.dart'; 5 | export 'better_animated_opacity.dart'; 6 | export 'better_fade_transition.dart'; 7 | export 'better_placeholder.dart'; 8 | export 'better_stream_builder.dart'; 9 | export 'centered_max_width.dart'; 10 | export 'debug_padding.dart'; 11 | export 'delayed_pop_scope.dart'; 12 | export 'go_router_location_button.dart'; 13 | export 'itemized_text.dart'; 14 | export 'list_section.dart'; 15 | export 'list_section_header.dart'; 16 | export 'list_tile_selected_background_colored_box.dart'; 17 | export 'listener/listener.dart'; 18 | export 'loading_switcher.dart'; 19 | export 'max_width_padding_builder.dart'; 20 | export 'overflow_detectable_text.dart'; 21 | export 'ripple_effect_button.dart'; 22 | export 'scroll_keyboard_shortcut.dart'; 23 | export 'size_listener.dart'; 24 | export 'text_scale_factor.dart'; 25 | export 'tile_padding.dart'; 26 | export 'timeout_switcher.dart'; 27 | export 'unfocus_on_tap.dart'; 28 | export 'value_observable_builder.dart'; 29 | export 'vertical_center_scroll_view.dart'; 30 | export 'wip.dart'; 31 | -------------------------------------------------------------------------------- /lib/widgets/wip.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:nested/nested.dart'; 3 | 4 | const double _kHeight = 12; 5 | const _kColor = Color(0xFFF57F17); 6 | const _kTextStyle = TextStyle( 7 | color: Color(0xFFFFFFFF), 8 | fontSize: _kHeight * 0.85, 9 | fontWeight: FontWeight.w900, 10 | height: 1, 11 | ); 12 | 13 | class WIP extends SingleChildStatelessWidget { 14 | const WIP({ 15 | super.key, 16 | required Widget super.child, 17 | this.location = BannerLocation.topEnd, 18 | this.color, 19 | this.textStyle, 20 | this.backgroundColor, 21 | this.visible = false, 22 | this.message, 23 | }); 24 | 25 | final bool visible; 26 | final BannerLocation location; 27 | final Color? color; 28 | final Color? backgroundColor; 29 | final TextStyle? textStyle; 30 | final String? message; 31 | 32 | @override 33 | Widget buildWithChild(BuildContext context, Widget? child) { 34 | if (!visible) { 35 | return const SizedBox.shrink(); 36 | } 37 | final color = this.color ?? _kColor; 38 | return ClipRRect( 39 | child: Banner( 40 | message: message ?? 'WIP', 41 | location: location, 42 | color: color, 43 | textStyle: textStyle ?? _kTextStyle, 44 | child: ColoredBox( 45 | color: backgroundColor ?? color.withValues(alpha: 0.1), 46 | child: child, 47 | ), 48 | ), 49 | ); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /macos/Classes/MonoKitPlugin.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | public class MonoKitPlugin: NSObject, FlutterPlugin { 5 | public static func register(with registrar: FlutterPluginRegistrar) { 6 | let channel = FlutterMethodChannel(name: "mono_kit", binaryMessenger: registrar.messenger) 7 | let instance = MonoKitPlugin() 8 | registrar.addMethodCallDelegate(instance, channel: channel) 9 | } 10 | 11 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 12 | switch call.method { 13 | case "getPlatformVersion": 14 | result("macOS " + ProcessInfo.processInfo.operatingSystemVersionString) 15 | default: 16 | result(FlutterMethodNotImplemented) 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /macos/mono_kit.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 3 | # 4 | Pod::Spec.new do |s| 5 | s.name = 'mono_kit' 6 | s.version = '0.0.1' 7 | s.summary = 'A new Flutter plugin.' 8 | s.description = <<-DESC 9 | A new Flutter plugin. 10 | DESC 11 | s.homepage = 'https://mono0926.com' 12 | s.license = { :file => '../LICENSE' } 13 | s.author = { 'Masayuki Ono' => 'mono0926@gmail.com' } 14 | s.source = { :path => '.' } 15 | s.source_files = 'Classes/**/*' 16 | s.dependency 'FlutterMacOS' 17 | 18 | s.platform = :osx, '10.11' 19 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } 20 | s.swift_version = '5.0' 21 | end 22 | 23 | -------------------------------------------------------------------------------- /packages/subscription_holder/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .packages 28 | .pub-cache/ 29 | .pub/ 30 | build/ 31 | 32 | # Android related 33 | **/android/**/gradle-wrapper.jar 34 | **/android/.gradle 35 | **/android/captures/ 36 | **/android/gradlew 37 | **/android/gradlew.bat 38 | **/android/local.properties 39 | **/android/**/GeneratedPluginRegistrant.java 40 | 41 | # iOS/XCode related 42 | **/ios/**/*.mode1v3 43 | **/ios/**/*.mode2v3 44 | **/ios/**/*.moved-aside 45 | **/ios/**/*.pbxuser 46 | **/ios/**/*.perspectivev3 47 | **/ios/**/*sync/ 48 | **/ios/**/.sconsign.dblite 49 | **/ios/**/.tags* 50 | **/ios/**/.vagrant/ 51 | **/ios/**/DerivedData/ 52 | **/ios/**/Icon? 53 | **/ios/**/Pods/ 54 | **/ios/**/.symlinks/ 55 | **/ios/**/profile 56 | **/ios/**/xcuserdata 57 | **/ios/.generated/ 58 | **/ios/Flutter/App.framework 59 | **/ios/Flutter/Flutter.framework 60 | **/ios/Flutter/Generated.xcconfig 61 | **/ios/Flutter/app.flx 62 | **/ios/Flutter/app.zip 63 | **/ios/Flutter/flutter_assets/ 64 | **/ios/Flutter/flutter_export_environment.sh 65 | **/ios/ServiceDefinitions.json 66 | **/ios/Runner/GeneratedPluginRegistrant.* 67 | 68 | # Exceptions to above rules. 69 | !**/ios/**/default.mode1v3 70 | !**/ios/**/default.mode2v3 71 | !**/ios/**/default.pbxuser 72 | !**/ios/**/default.perspectivev3 73 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 74 | -------------------------------------------------------------------------------- /packages/subscription_holder/.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 and should not be manually edited. 5 | 6 | version: 7 | revision: 97e00b2288938998f755c5262a118d9a0d6a915a 8 | channel: dev 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /packages/subscription_holder/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 2.2.0 2 | 3 | - Upgrade dependencies 4 | 5 | ## 2.1.1 6 | 7 | - Update to rxdart 0.27.0 8 | 9 | ## 2.1.0 10 | 11 | - Migrate to null safety 12 | 13 | ## 2.0.0 14 | 15 | - Change `SubscriptionHolderMixin` to `on StateNotifier` from `with Disposabe` 16 | - Previously, `dispose` can override the `dispose` of base class, so eliminate that situation by limiting usage. 17 | 18 | ## 1.2.0+1 19 | 20 | - Depends on subscription_holder 21 | 22 | ## 1.1.0 23 | 24 | - Upgrade dependencies 25 | 26 | ## 1.0.0 27 | 28 | - Initial release. 29 | -------------------------------------------------------------------------------- /packages/subscription_holder/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Masayuki Ono 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 | -------------------------------------------------------------------------------- /packages/subscription_holder/README.md: -------------------------------------------------------------------------------- 1 | # subscription_holder 2 | 3 | Subscription Holder 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Dart 8 | [package](https://flutter.dev/developing-packages/), 9 | a library module containing code that can be shared easily across 10 | multiple Flutter or Dart projects. 11 | 12 | For help getting started with Flutter, view our 13 | [online documentation](https://flutter.dev/docs), which offers tutorials, 14 | samples, guidance on mobile development, and a full API reference. 15 | -------------------------------------------------------------------------------- /packages/subscription_holder/lib/src/subscription_holder.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/foundation.dart'; 4 | import 'package:rxdart/rxdart.dart'; 5 | 6 | @immutable 7 | class SubscriptionHolder { 8 | final _subscriptions = >[]; 9 | 10 | void add(StreamSubscription subscription) { 11 | _subscriptions.add(subscription); 12 | } 13 | 14 | ValueStream publishValueConnecting( 15 | ValueStream observable, 16 | FutureOr Function(T? value) f, 17 | ) { 18 | final v = f(observable.valueOrNull); 19 | final valueObservable = observable 20 | .asyncMap(f) 21 | .distinct() 22 | .publishValueSeeded(v is Future ? null : v as S); 23 | _subscriptions.add(valueObservable.connect()); 24 | 25 | return valueObservable; 26 | } 27 | 28 | ValueListenable consumeAsListenable( 29 | ValueStream observable, 30 | FutureOr Function(T? value) f, 31 | ) { 32 | final v = f(observable.valueOrNull); 33 | final notifier = ValueNotifier(v is Future ? null : v as S); 34 | _subscriptions.add( 35 | observable.distinct().listen((x) async => notifier.value = await f(x)), 36 | ); 37 | return notifier; 38 | } 39 | 40 | void dispose() { 41 | for (final subscription in _subscriptions) { 42 | subscription.cancel(); 43 | } 44 | _subscriptions.clear(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /packages/subscription_holder/lib/src/subscription_holder_mixin.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:state_notifier/state_notifier.dart'; 3 | 4 | import 'subscription_holder.dart'; 5 | 6 | mixin SubscriptionHolderMixin on StateNotifier { 7 | @protected 8 | final subscriptionHolder = SubscriptionHolder(); 9 | 10 | @override 11 | @mustCallSuper 12 | void dispose() { 13 | subscriptionHolder.dispose(); 14 | 15 | super.dispose(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/subscription_holder/lib/subscription_holder.dart: -------------------------------------------------------------------------------- 1 | export 'src/subscription_holder.dart'; 2 | export 'src/subscription_holder_mixin.dart'; 3 | -------------------------------------------------------------------------------- /packages/subscription_holder/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: subscription_holder 2 | description: Subscription Holder holds StreamSubscriptions and dispose all conveniently. 3 | version: 2.2.0 4 | homepage: https://github.com/mono0926/flutter_mono_kit 5 | environment: 6 | sdk: ^3.0.0 7 | dependencies: 8 | flutter: 9 | sdk: flutter 10 | rxdart: '>=0.27.0 <1.0.0' 11 | state_notifier: ^1.0.0 12 | dev_dependencies: 13 | flutter_test: 14 | sdk: flutter 15 | pedantic_mono: 16 | flutter: 17 | -------------------------------------------------------------------------------- /packages/subscription_holder/test/subscription_holder_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | 3 | void main() { 4 | test('', () {}); 5 | } 6 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: mono_kit 2 | description: A collection of convenient widgets and utils made by mono. Under 3 | construction now. 4 | version: 0.44.0 5 | repository: https://github.com/mono0926/flutter_mono_kit 6 | environment: 7 | sdk: ^3.8.0 8 | flutter: '>=3.32.0' 9 | dependencies: 10 | adaptive_dialog: ^2.0.0 11 | collection: ^1.15.0 12 | disposable_provider: ^2.0.0 13 | flutter: 14 | sdk: flutter 15 | flutter_riverpod: ^2.0.0 16 | flutter_svg: ^2.0.0 17 | freezed_annotation: ^3.0.0 18 | go_router: ^15.0.0 19 | image_picker: ^1.0.0 20 | nested: ^1.0.0 21 | quiver: ^3.0.0 22 | rxdart: '>=0.27.0 <1.0.0' 23 | simple_logger: ^1.6.0 24 | state_notifier: ^1.0.0 25 | stream_transform: ^2.0.0 26 | subscription_holder: ^2.1.0 27 | tinycolor2: ^3.0.0 28 | url_launcher: ^6.1.0 29 | dev_dependencies: 30 | build_runner: 31 | flutter_test: 32 | sdk: flutter 33 | freezed: 34 | pedantic_mono: 35 | flutter: 36 | plugin: 37 | platforms: 38 | android: 39 | package: com.mono0926.mono_kit 40 | pluginClass: MonoKitPlugin 41 | ios: 42 | pluginClass: MonoKitPlugin 43 | # macos: 44 | # pluginClass: MonoKitPlugin 45 | -------------------------------------------------------------------------------- /test/extensions/iterable_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | import 'package:mono_kit/mono_kit.dart'; 3 | 4 | void main() { 5 | test('containsAll', () { 6 | expect( 7 | ['a', 'b'].containsAll(['a']), 8 | isTrue, 9 | ); 10 | expect( 11 | ['a', 'b'].containsAll(['a', 'b']), 12 | isTrue, 13 | ); 14 | expect( 15 | ['a', 'b'].containsAll(['a', 'b', 'c']), 16 | isFalse, 17 | ); 18 | expect( 19 | ['a', 'b'].containsAll(['a', 'c']), 20 | isFalse, 21 | ); 22 | }); 23 | } 24 | -------------------------------------------------------------------------------- /test/mono_kit_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | 3 | void main() { 4 | test('', () {}); 5 | } 6 | -------------------------------------------------------------------------------- /test/utils/functions_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | import 'package:mono_kit/mono_kit.dart'; 3 | 4 | void main() { 5 | test('convertToHalfWidth', () { 6 | expect(convertToHalfWidth('hello'), equals('hello')); 7 | expect(convertToHalfWidth('Hello'), equals('Hello')); 8 | expect(convertToHalfWidth('Hello1'), equals('Hello1')); 9 | expect(convertToHalfWidth('Hello1'), equals('Hello1')); 10 | expect(convertToHalfWidth('Hello1'), equals('Hello1')); 11 | expect(convertToHalfWidth('Hello1'), equals('Hello1')); 12 | expect(convertToHalfWidth('Hello1'), equals('Hello1')); 13 | }); 14 | } 15 | -------------------------------------------------------------------------------- /tool/deploy_web.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd example 4 | flutter build web --web-renderer canvaskit 5 | firebase deploy --only hosting:mono-kit 6 | --------------------------------------------------------------------------------