├── linux ├── .gitignore ├── main.cc ├── flutter │ ├── generated_plugin_registrant.h │ ├── generated_plugin_registrant.cc │ ├── generated_plugins.cmake │ └── CMakeLists.txt ├── my_application.h ├── my_application.cc └── CMakeLists.txt ├── ios ├── Runner │ ├── Runner-Bridging-Header.h │ ├── Assets.xcassets │ │ ├── LaunchImage.imageset │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ ├── README.md │ │ │ └── Contents.json │ │ └── AppIcon.appiconset │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ └── Contents.json │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard │ └── Info.plist ├── Flutter │ ├── Debug.xcconfig │ ├── Release.xcconfig │ └── AppFrameworkInfo.plist ├── Runner.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── WorkspaceSettings.xcsettings │ │ └── IDEWorkspaceChecks.plist ├── .gitignore └── Podfile ├── dev-deploy.sh ├── peanut.yaml ├── web ├── favicon.png ├── icons │ ├── Icon-192.png │ └── Icon-512.png ├── manifest.json ├── index.html └── 404.html ├── assets └── music.mp3 ├── fonts ├── WorkSans-Italic.ttf ├── WorkSans-Regular.ttf ├── WorkSans-SemiBold.ttf ├── WorkSans-ExtraLight.ttf ├── WorkSans-ExtraLightItalic.ttf └── WorkSans-SemiBoldItalic.ttf ├── android ├── gradle.properties ├── app │ ├── src │ │ ├── main │ │ │ ├── res │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── drawable │ │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable-v21 │ │ │ │ │ └── launch_background.xml │ │ │ │ ├── values │ │ │ │ │ └── styles.xml │ │ │ │ └── values-night │ │ │ │ │ └── styles.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── flutterplasma │ │ │ │ │ └── MainActivity.kt │ │ │ └── AndroidManifest.xml │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ └── profile │ │ │ └── AndroidManifest.xml │ └── build.gradle ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle └── build.gradle ├── macos ├── .gitignore ├── Runner │ ├── Configs │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ ├── Warnings.xcconfig │ │ └── AppInfo.xcconfig │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ ├── app_icon_1024.png │ │ │ ├── app_icon_128.png │ │ │ ├── app_icon_16.png │ │ │ ├── app_icon_256.png │ │ │ ├── app_icon_32.png │ │ │ ├── app_icon_512.png │ │ │ ├── app_icon_64.png │ │ │ └── Contents.json │ ├── AppDelegate.swift │ ├── Release.entitlements │ ├── DebugProfile.entitlements │ ├── MainFlutterWindow.swift │ └── Info.plist ├── Flutter │ ├── Flutter-Debug.xcconfig │ ├── Flutter-Release.xcconfig │ └── GeneratedPluginRegistrant.swift ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── Runner.xcodeproj │ ├── project.xcworkspace │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Podfile.lock └── Podfile ├── windows ├── runner │ ├── resources │ │ └── app_icon.ico │ ├── resource.h │ ├── CMakeLists.txt │ ├── utils.h │ ├── runner.exe.manifest │ ├── run_loop.h │ ├── flutter_window.h │ ├── main.cpp │ ├── utils.cpp │ ├── flutter_window.cpp │ ├── run_loop.cpp │ ├── Runner.rc │ └── win32_window.h ├── flutter │ ├── generated_plugin_registrant.h │ ├── generated_plugin_registrant.cc │ ├── generated_plugins.cmake │ └── CMakeLists.txt ├── .gitignore └── CMakeLists.txt ├── analysis_options.yaml ├── lib ├── demo │ ├── layout │ │ ├── colors.dart │ │ ├── layout_wall.dart │ │ ├── layout_a.dart │ │ └── layout_b.dart │ ├── audio.dart │ ├── audio_io.dart │ ├── audio_web.dart │ ├── intro │ │ ├── large_text.dart │ │ └── intro.dart │ ├── fancy_plasma1 │ │ ├── other_plasma1.dart │ │ ├── other_plasma2.dart │ │ ├── fancy_widgets1.dart │ │ └── fancy_plasma1.dart │ ├── caching_builder.dart │ ├── stars │ │ ├── particles.dart │ │ ├── static_stars.dart │ │ ├── flashes.dart │ │ ├── stars_background.dart │ │ └── stars.dart │ ├── sky │ │ ├── dash.dart │ │ └── sky.dart │ ├── demo_screen.dart │ ├── outro │ │ └── outro.dart │ ├── startpage │ │ └── start_page.dart │ ├── fancy_plasma2 │ │ └── fancy_plasma2.dart │ └── effects │ │ └── shatter.dart ├── showroom │ ├── gesture_detector_with_click_hover.dart │ ├── select.dart │ └── show_room.dart ├── widget_warmup.dart ├── main.dart └── routed_app.dart ├── .metadata ├── README.md ├── .gitignore ├── LICENSE └── pubspec.yaml /linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /dev-deploy.sh: -------------------------------------------------------------------------------- 1 | flutter build web --web-renderer canvaskit --release && firebase deploy 2 | -------------------------------------------------------------------------------- /peanut.yaml: -------------------------------------------------------------------------------- 1 | # Configuration for https://pub.dev/packages/peanut 2 | 3 | canvas-kit: true 4 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/web/favicon.png -------------------------------------------------------------------------------- /assets/music.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/assets/music.mp3 -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/web/icons/Icon-512.png -------------------------------------------------------------------------------- /fonts/WorkSans-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/fonts/WorkSans-Italic.ttf -------------------------------------------------------------------------------- /fonts/WorkSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/fonts/WorkSans-Regular.ttf -------------------------------------------------------------------------------- /fonts/WorkSans-SemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/fonts/WorkSans-SemiBold.ttf -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /fonts/WorkSans-ExtraLight.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/fonts/WorkSans-ExtraLight.ttf -------------------------------------------------------------------------------- /macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/xcuserdata/ 7 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /fonts/WorkSans-ExtraLightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/fonts/WorkSans-ExtraLightItalic.ttf -------------------------------------------------------------------------------- /fonts/WorkSans-SemiBoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/fonts/WorkSans-SemiBoldItalic.ttf -------------------------------------------------------------------------------- /windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:pedantic/analysis_options.1.11.0.yaml 2 | 3 | analyzer: 4 | exclude: [build/**] 5 | strong-mode: 6 | implicit-casts: false 7 | implicit-dynamic: false -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/felixblaschke/flutterplasma/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/flutterplasma/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.flutterplasma 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /lib/demo/layout/colors.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | final grey1 = Colors.grey.shade300; 4 | final grey2 = Colors.grey.shade400; 5 | final grey3 = Colors.grey.shade500; 6 | final grey4 = Colors.grey.shade600; 7 | -------------------------------------------------------------------------------- /macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip 7 | -------------------------------------------------------------------------------- /lib/demo/audio.dart: -------------------------------------------------------------------------------- 1 | import 'audio_io.dart' if (dart.library.html) 'audio_web.dart' as impl; 2 | 3 | abstract class AudioPlayer { 4 | factory AudioPlayer(String src) => impl.AudioPlayerImpl(src); 5 | 6 | Future play(); 7 | Future pause(); 8 | Duration get position; 9 | } 10 | -------------------------------------------------------------------------------- /macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.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: 7a8bbbd80747a7d797d016a938924d62d489f3fd 8 | channel: master 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import url_launcher_macos 9 | 10 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 11 | UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) 12 | } 13 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 6 | #define GENERATED_PLUGIN_REGISTRANT_ 7 | 8 | #include 9 | 10 | // Registers Flutter plugins. 11 | void fl_register_plugins(FlPluginRegistry* registry); 12 | 13 | #endif // GENERATED_PLUGIN_REGISTRANT_ 14 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 6 | #define GENERATED_PLUGIN_REGISTRANT_ 7 | 8 | #include 9 | 10 | // Registers Flutter plugins. 11 | void RegisterPlugins(flutter::PluginRegistry* registry); 12 | 13 | #endif // GENERATED_PLUGIN_REGISTRANT_ 14 | -------------------------------------------------------------------------------- /windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | #include "generated_plugin_registrant.h" 6 | 7 | #include 8 | 9 | void RegisterPlugins(flutter::PluginRegistry* registry) { 10 | UrlLauncherPluginRegisterWithRegistrar( 11 | registry->GetRegistrarForPlugin("UrlLauncherPlugin")); 12 | } 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flutter Plasma 2 | 3 | Flutter app demonstrating Flutter web rendering. 4 | 5 | ## Routes 6 | 7 | - `/`: Default demo 8 | - `/nocredits`: Demo stops before credits 9 | - `/showroom`: Enters Show Room 10 | - `/showroom/:index`: Jump to specific Show Room example 11 | 12 | Example: 13 | - https://hostname/nocredits 14 | - https://hostname/showroom 15 | - https://hostname/showroom/5 16 | -------------------------------------------------------------------------------- /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. -------------------------------------------------------------------------------- /lib/demo/audio_io.dart: -------------------------------------------------------------------------------- 1 | import 'audio.dart'; 2 | 3 | // TODO: mobile version not implemented 4 | class AudioPlayerImpl implements AudioPlayer { 5 | AudioPlayerImpl(this.src); 6 | 7 | final String src; 8 | 9 | @override 10 | Future pause() async { 11 | } 12 | 13 | @override 14 | Future play() async { 15 | } 16 | 17 | @override 18 | Duration get position => Duration.zero; 19 | } 20 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | #include "generated_plugin_registrant.h" 6 | 7 | #include 8 | 9 | void fl_register_plugins(FlPluginRegistry* registry) { 10 | g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = 11 | fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); 12 | url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); 13 | } 14 | -------------------------------------------------------------------------------- /windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | url_launcher_linux 7 | ) 8 | 9 | set(PLUGIN_BUNDLED_LIBRARIES) 10 | 11 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 12 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 13 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 14 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 15 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 16 | endforeach(plugin) 17 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | url_launcher_windows 7 | ) 8 | 9 | set(PLUGIN_BUNDLED_LIBRARIES) 10 | 11 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 12 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 13 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 14 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 15 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 16 | endforeach(plugin) 17 | -------------------------------------------------------------------------------- /lib/demo/audio_web.dart: -------------------------------------------------------------------------------- 1 | import 'dart:html' as html; 2 | 3 | import 'audio.dart'; 4 | 5 | class AudioPlayerImpl implements AudioPlayer { 6 | AudioPlayerImpl(this.src) : _audioElement = html.AudioElement(src); 7 | 8 | final html.AudioElement _audioElement; 9 | final String src; 10 | 11 | @override 12 | Future pause() async { 13 | _audioElement.pause(); 14 | } 15 | 16 | @override 17 | Future play() async { 18 | await _audioElement.play(); 19 | } 20 | 21 | @override 22 | Duration get position => Duration(milliseconds: (_audioElement.currentTime * 1000).toInt()); 23 | } 24 | -------------------------------------------------------------------------------- /lib/demo/intro/large_text.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class LargeText extends StatelessWidget { 4 | final String text; 5 | final bool bold; 6 | final double textSize; 7 | 8 | const LargeText(this.text, {required this.textSize, this.bold = false}); 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return Text( 13 | text, 14 | textAlign: TextAlign.center, 15 | style: TextStyle( 16 | fontFamily: 'Work Sans', 17 | color: Colors.white, 18 | fontSize: textSize, 19 | fontWeight: !bold ? FontWeight.w200 : FontWeight.w600), 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/showroom/gesture_detector_with_click_hover.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/rendering.dart'; 3 | 4 | class GestureDetectorWithClickHover extends StatelessWidget { 5 | final GestureTapCallback onTap; 6 | final Widget child; 7 | 8 | const GestureDetectorWithClickHover( 9 | {required this.onTap, required this.child}); 10 | 11 | @override 12 | Widget build(BuildContext context) { 13 | return MouseRegion( 14 | cursor: SystemMouseCursors.click, 15 | child: GestureDetector( 16 | behavior: HitTestBehavior.translucent, 17 | onTap: onTap, 18 | child: child, 19 | ), 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | project(runner LANGUAGES CXX) 3 | 4 | add_executable(${BINARY_NAME} WIN32 5 | "flutter_window.cpp" 6 | "main.cpp" 7 | "run_loop.cpp" 8 | "utils.cpp" 9 | "win32_window.cpp" 10 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 11 | "Runner.rc" 12 | "runner.exe.manifest" 13 | ) 14 | apply_standard_settings(${BINARY_NAME}) 15 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 16 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 17 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 18 | add_dependencies(${BINARY_NAME} flutter_assemble) 19 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.mode2v3 3 | *.moved-aside 4 | *.pbxuser 5 | *.perspectivev3 6 | **/*sync/ 7 | .sconsign.dblite 8 | .tags* 9 | **/.vagrant/ 10 | **/DerivedData/ 11 | Icon? 12 | **/Pods/ 13 | **/.symlinks/ 14 | profile 15 | xcuserdata 16 | **/.generated/ 17 | Flutter/App.framework 18 | Flutter/Flutter.framework 19 | Flutter/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/app.flx 22 | Flutter/app.zip 23 | Flutter/flutter_assets/ 24 | Flutter/flutter_export_environment.sh 25 | ServiceDefinitions.json 26 | Runner/GeneratedPluginRegistrant.* 27 | 28 | # Exceptions to above rules. 29 | !default.mode1v3 30 | !default.mode2v3 31 | !default.pbxuser 32 | !default.perspectivev3 33 | -------------------------------------------------------------------------------- /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 = flutterplasma 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterplasma 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2021 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /macos/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - FlutterMacOS (1.0.0) 3 | - url_launcher_macos (0.0.1): 4 | - FlutterMacOS 5 | 6 | DEPENDENCIES: 7 | - FlutterMacOS (from `Flutter/ephemeral`) 8 | - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) 9 | 10 | EXTERNAL SOURCES: 11 | FlutterMacOS: 12 | :path: Flutter/ephemeral 13 | url_launcher_macos: 14 | :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos 15 | 16 | SPEC CHECKSUMS: 17 | FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424 18 | url_launcher_macos: 45af3d61de06997666568a7149c1be98b41c95d4 19 | 20 | PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c 21 | 22 | COCOAPODS: 1.10.0 23 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Flutter Plasma", 3 | "short_name": "Flutter Plasma", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "Flutter app demonstrating Flutter web rendering", 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 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.3.50' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:4.1.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /lib/demo/fancy_plasma1/other_plasma1.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:simple_animations/simple_animations.dart'; 3 | 4 | class OtherPlasma1 extends StatelessWidget { 5 | @override 6 | Widget build(BuildContext context) { 7 | return Container( 8 | decoration: BoxDecoration( 9 | color: Color(0xff7b1d17), 10 | backgroundBlendMode: BlendMode.srcOver, 11 | ), 12 | child: PlasmaRenderer( 13 | type: PlasmaType.infinity, 14 | particles: 10, 15 | color: Color(0xd0110101), 16 | blur: 0.74, 17 | size: 0.87, 18 | speed: 10, 19 | offset: 0, 20 | blendMode: BlendMode.darken, 21 | variation1: 0, 22 | variation2: 0, 23 | variation3: 0, 24 | rotation: -3.14, 25 | ), 26 | ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /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 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /.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 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | lib/generated_plugin_registrant.dart 36 | 37 | # Symbolication related 38 | app.*.symbols 39 | 40 | # Obfuscation related 41 | app.*.map.json 42 | 43 | # Android Studio will place build artifacts here 44 | /android/app/debug 45 | /android/app/profile 46 | /android/app/release 47 | 48 | # Firebase 49 | .firebase/ 50 | firebase.json 51 | .firebaserc 52 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Felix Blaschke 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /lib/demo/caching_builder.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | 3 | /// Builds a widget by calling [builder]. Rebuilds the widget when [cacheKey] 4 | /// changes. 5 | /// 6 | /// Use this to prevent unnecessary rebuilds of expensive widgets by changing 7 | /// the [cacheKey] only when a rebuild is necessary. Typically, the cache key 8 | /// would consist of values used by [builder] to build the widget. 9 | class CachingBuilder extends StatefulWidget { 10 | const CachingBuilder({ 11 | required this.cacheKey, 12 | required this.builder, 13 | }); 14 | 15 | final V cacheKey; 16 | final WidgetBuilder builder; 17 | 18 | @override 19 | _CachingBuilderState createState() => _CachingBuilderState(); 20 | } 21 | 22 | class _CachingBuilderState extends State> { 23 | V? _lastCacheKey; 24 | Widget? _cachedWidget; 25 | 26 | @override 27 | Widget build(BuildContext context) { 28 | if (_cachedWidget != null && _lastCacheKey == widget.cacheKey) { 29 | return _cachedWidget!; 30 | } else { 31 | _cachedWidget = widget.builder(context); 32 | _lastCacheKey = widget.cacheKey; 33 | return _cachedWidget!; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /windows/runner/run_loop.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_RUN_LOOP_H_ 2 | #define RUNNER_RUN_LOOP_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | // A runloop that will service events for Flutter instances as well 10 | // as native messages. 11 | class RunLoop { 12 | public: 13 | RunLoop(); 14 | ~RunLoop(); 15 | 16 | // Prevent copying 17 | RunLoop(RunLoop const&) = delete; 18 | RunLoop& operator=(RunLoop const&) = delete; 19 | 20 | // Runs the run loop until the application quits. 21 | void Run(); 22 | 23 | // Registers the given Flutter instance for event servicing. 24 | void RegisterFlutterInstance( 25 | flutter::FlutterEngine* flutter_instance); 26 | 27 | // Unregisters the given Flutter instance from event servicing. 28 | void UnregisterFlutterInstance( 29 | flutter::FlutterEngine* flutter_instance); 30 | 31 | private: 32 | using TimePoint = std::chrono::steady_clock::time_point; 33 | 34 | // Processes all currently pending messages for registered Flutter instances. 35 | TimePoint ProcessFlutterMessages(); 36 | 37 | std::set flutter_instances_; 38 | }; 39 | 40 | #endif // RUNNER_RUN_LOOP_H_ 41 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutterplasma 2 | description: Flutter app demonstrating some examples of graphics rendering. 3 | 4 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 5 | 6 | version: 1.1.0 7 | 8 | environment: 9 | sdk: '>=2.12.0 <3.0.0' 10 | 11 | dependencies: 12 | flutter: 13 | sdk: flutter 14 | supercharged: ^2.0.0 15 | simple_animations: ^3.0.3 16 | pedantic: ^1.11.0 17 | url_strategy: ^0.2.0 18 | url_launcher: ^6.0.3 19 | 20 | dev_dependencies: 21 | flutter_test: 22 | sdk: flutter 23 | integration_test: 24 | sdk: flutter 25 | 26 | flutter: 27 | uses-material-design: true 28 | assets: 29 | - assets/music.mp3 30 | fonts: 31 | - family: Work Sans 32 | fonts: 33 | - asset: fonts/WorkSans-ExtraLight.ttf 34 | weight: 200 35 | - asset: fonts/WorkSans-ExtraLightItalic.ttf 36 | weight: 200 37 | style: italic 38 | - asset: fonts/WorkSans-Regular.ttf 39 | - asset: fonts/WorkSans-Italic.ttf 40 | style: italic 41 | - asset: fonts/WorkSans-SemiBold.ttf 42 | weight: 600 43 | - asset: fonts/WorkSans-SemiBoldItalic.ttf 44 | weight: 600 45 | style: italic 46 | -------------------------------------------------------------------------------- /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 "run_loop.h" 10 | #include "win32_window.h" 11 | 12 | // A window that does nothing but host a Flutter view. 13 | class FlutterWindow : public Win32Window { 14 | public: 15 | // Creates a new FlutterWindow driven by the |run_loop|, hosting a 16 | // Flutter view running |project|. 17 | explicit FlutterWindow(RunLoop* run_loop, 18 | const flutter::DartProject& project); 19 | virtual ~FlutterWindow(); 20 | 21 | protected: 22 | // Win32Window: 23 | bool OnCreate() override; 24 | void OnDestroy() override; 25 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 26 | LPARAM const lparam) noexcept override; 27 | 28 | private: 29 | // The run loop driving events for this window. 30 | RunLoop* run_loop_; 31 | 32 | // The project to run. 33 | flutter::DartProject project_; 34 | 35 | // The Flutter instance hosted by this window. 36 | std::unique_ptr flutter_controller_; 37 | }; 38 | 39 | #endif // RUNNER_FLUTTER_WINDOW_H_ 40 | -------------------------------------------------------------------------------- /lib/widget_warmup.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'showroom/show_room.dart'; 4 | 5 | /// Warms up renderer by rendering each widget for a single frame 6 | class WidgetWarmup extends StatefulWidget { 7 | final Widget child; 8 | 9 | const WidgetWarmup({required this.child}); 10 | 11 | @override 12 | _WidgetWarmupState createState() => _WidgetWarmupState(); 13 | } 14 | 15 | class _WidgetWarmupState extends State { 16 | var _widgetsPrecached = false; 17 | 18 | @override 19 | void initState() { 20 | super.initState(); 21 | WidgetsBinding.instance!.addPostFrameCallback((_) => _afterRender(context)); 22 | } 23 | 24 | @override 25 | Widget build(BuildContext context) { 26 | if (!_widgetsPrecached) { 27 | return Stack( 28 | children: [ 29 | ...WIDGETS.entries 30 | .map((entry) => entry.value()) 31 | .map((widget) => Positioned.fill(child: widget)), 32 | Positioned.fill(child: Container(color: Colors.white)), 33 | ], 34 | ); 35 | } 36 | 37 | return widget.child; 38 | } 39 | 40 | void _afterRender(BuildContext context) { 41 | if (!_widgetsPrecached) { 42 | setState(() { 43 | _widgetsPrecached = true; 44 | }); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lib/demo/stars/particles.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:supercharged/supercharged.dart'; 5 | 6 | class ParticlesPainter extends CustomPainter { 7 | final double value; 8 | 9 | ParticlesPainter({required this.value}); 10 | 11 | @override 12 | void paint(Canvas canvas, Size size) { 13 | final random = Random(1); 14 | 15 | 200.times(() { 16 | final start = random.nextDouble(); 17 | final p = (start + value) % 1.0; 18 | 19 | final target = random.nextBool() 20 | ? Offset( 21 | random.nextDouble(), 22 | random.nextBool() ? -0.0 : 1.0, 23 | ) 24 | : Offset( 25 | random.nextBool() ? -0.0 : 1.0, 26 | random.nextDouble(), 27 | ); 28 | 29 | final position = Offset( 30 | ((1 - p) * 0.5 + p * target.dx) * size.width, 31 | ((1 - p) * 0.5 + p * target.dy) * size.height, 32 | ); 33 | 34 | final paint = Paint()..color = Colors.white.withOpacity(0.3 + 0.4 * p); 35 | 36 | if (p > 0.1) { 37 | canvas.drawCircle(position, size.width * 0.002 * p, paint); 38 | } 39 | }); 40 | } 41 | 42 | @override 43 | bool shouldRepaint(covariant ParticlesPainter oldDelegate) { 44 | return value != oldDelegate.value; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "run_loop.h" 7 | #include "utils.h" 8 | 9 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 10 | _In_ wchar_t *command_line, _In_ int show_command) { 11 | // Attach to console when present (e.g., 'flutter run') or create a 12 | // new console when running with a debugger. 13 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 14 | CreateAndAttachConsole(); 15 | } 16 | 17 | // Initialize COM, so that it is available for use in the library and/or 18 | // plugins. 19 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 20 | 21 | RunLoop run_loop; 22 | 23 | flutter::DartProject project(L"data"); 24 | 25 | std::vector command_line_arguments = 26 | GetCommandLineArguments(); 27 | 28 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 29 | 30 | FlutterWindow window(&run_loop, project); 31 | Win32Window::Point origin(10, 10); 32 | Win32Window::Size size(1280, 720); 33 | if (!window.CreateAndShow(L"flutterplasma", origin, size)) { 34 | return EXIT_FAILURE; 35 | } 36 | window.SetQuitOnClose(true); 37 | 38 | run_loop.Run(); 39 | 40 | ::CoUninitialize(); 41 | return EXIT_SUCCESS; 42 | } 43 | -------------------------------------------------------------------------------- /lib/demo/stars/static_stars.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:supercharged/supercharged.dart'; 5 | 6 | class StaticStars extends StatelessWidget { 7 | @override 8 | Widget build(BuildContext context) { 9 | return LayoutBuilder(builder: (context, constraints) { 10 | final n = min( 11 | 1000, (constraints.maxWidth * constraints.maxHeight / 2000).round()); 12 | 13 | return CustomPaint( 14 | painter: _Painter(n: n), 15 | ); 16 | }); 17 | } 18 | } 19 | 20 | class _Painter extends CustomPainter { 21 | final int n; 22 | 23 | _Painter({required this.n}); 24 | 25 | @override 26 | void paint(Canvas canvas, Size size) { 27 | final random = Random(1); 28 | n.times(() { 29 | final position = Offset( 30 | random.nextDouble() * size.width, 31 | random.nextDouble() * size.height, 32 | ); 33 | final radius = 2 * random.nextDouble(); 34 | final paint = Paint() 35 | ..maskFilter = MaskFilter.blur(BlurStyle.normal, 1) 36 | ..color = colors.pickOne(random).withOpacity(0.7 * random.nextDouble()); 37 | canvas.drawCircle(position, radius, paint); 38 | }); 39 | } 40 | 41 | @override 42 | bool shouldRepaint(covariant _Painter oldDelegate) { 43 | return oldDelegate.n != n; 44 | } 45 | } 46 | 47 | var colors = [ 48 | '#DAB6BA'.toColor(), 49 | '#FFDFFF'.toColor(), 50 | '#878DEB'.toColor(), 51 | ]; 52 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:simple_animations/simple_animations.dart'; 4 | import 'package:url_strategy/url_strategy.dart'; 5 | 6 | import 'demo/intro/intro.dart'; 7 | import 'routed_app.dart'; 8 | 9 | import 'demo/sky/dash_painter.dart'; 10 | 11 | void main() async { 12 | await initializeDashPainter(); 13 | setPathUrlStrategy(); 14 | 15 | if (kReleaseMode || kProfileMode) { 16 | runApp(RoutedApp()); 17 | } else { 18 | runApp(RoutedApp()); 19 | } 20 | } 21 | 22 | /// Can be used instead of RoutedApp to develop and test 23 | /// a single part of the application. 24 | class DevApp extends StatelessWidget { 25 | @override 26 | Widget build(BuildContext context) { 27 | return MaterialApp( 28 | home: Scaffold( 29 | body: Container( 30 | color: Colors.black, 31 | child: SafeArea( 32 | child: AnimationDeveloperTools( 33 | // position: AnimationDeveloperToolsPosition.hidden, 34 | child: LayoutBuilder(builder: (context, constraints) { 35 | return Center( 36 | child: AspectRatio( 37 | //aspectRatio: 5/10, 38 | aspectRatio: constraints.maxWidth / constraints.maxHeight, 39 | child: Intro(), 40 | )); 41 | }), 42 | ), 43 | ), 44 | ), 45 | ), 46 | ); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.11' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | end 35 | 36 | post_install do |installer| 37 | installer.pods_project.targets.each do |target| 38 | flutter_additional_macos_build_settings(target) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '9.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 | -------------------------------------------------------------------------------- /lib/demo/stars/flashes.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:supercharged/supercharged.dart'; 5 | 6 | class Flashes extends StatelessWidget { 7 | @override 8 | Widget build(BuildContext context) { 9 | return LayoutBuilder(builder: (context, constraints) { 10 | return CustomPaint( 11 | painter: _Painter(), 12 | ); 13 | }); 14 | } 15 | } 16 | 17 | class _Painter extends CustomPainter { 18 | @override 19 | void paint(Canvas canvas, Size size) { 20 | final random = Random(7); 21 | 3.times(() { 22 | var position = Offset( 23 | (0.1 + 0.6 * random.nextDouble()) * size.width, 24 | (0.1 + 0.4 * random.nextDouble()) * size.height, 25 | ); 26 | 27 | final paint = Paint() 28 | ..strokeWidth = size.width * 0.1 * (1 + 0.1 * random.nextDouble()) 29 | ..blendMode = BlendMode.srcOver 30 | ..maskFilter = MaskFilter.blur(BlurStyle.normal, 20) 31 | ..color = Color(0xFFD987EB).withOpacity(0.3 * random.nextDouble()); 32 | 33 | (2 + random.nextInt(6)).times(() { 34 | final target = Offset( 35 | position.dx + random.nextDouble() * size.width * 0.07, 36 | position.dy + random.nextDouble() * size.height * 0.07, 37 | ); 38 | canvas.drawLine(position, target, paint); 39 | position = target; 40 | }); 41 | }); 42 | } 43 | 44 | @override 45 | bool shouldRepaint(covariant _Painter oldDelegate) { 46 | return false; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /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 | flutterplasma 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 | 45 | 46 | -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | Flutter Plasma 30 | 31 | 32 | 33 | 36 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /web/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | Flutter Plasma 30 | 31 | 32 | 33 | 36 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 30 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | defaultConfig { 36 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 37 | applicationId "com.example.flutterplasma" 38 | minSdkVersion 16 39 | targetSdkVersion 30 40 | versionCode flutterVersionCode.toInteger() 41 | versionName flutterVersionName 42 | } 43 | 44 | buildTypes { 45 | release { 46 | // TODO: Add your own signing config for the release build. 47 | // Signing with the debug keys for now, so `flutter run --release` works. 48 | signingConfig signingConfigs.debug 49 | } 50 | } 51 | } 52 | 53 | flutter { 54 | source '../..' 55 | } 56 | 57 | dependencies { 58 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 59 | } 60 | -------------------------------------------------------------------------------- /lib/demo/fancy_plasma1/other_plasma2.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:simple_animations/simple_animations.dart'; 3 | 4 | class OtherPlasma2 extends StatelessWidget { 5 | @override 6 | Widget build(BuildContext context) { 7 | return Container( 8 | decoration: BoxDecoration( 9 | gradient: LinearGradient( 10 | tileMode: TileMode.mirror, 11 | begin: Alignment.topLeft, 12 | end: Alignment.bottomRight, 13 | colors: [ 14 | Color(0xff6d1678), 15 | Color(0xff011c2c), 16 | ], 17 | stops: [ 18 | 0, 19 | 1, 20 | ], 21 | ), 22 | backgroundBlendMode: BlendMode.srcOver, 23 | ), 24 | child: PlasmaRenderer( 25 | type: PlasmaType.circle, 26 | particles: 10, 27 | color: Color(0x4423b9e4), 28 | blur: 0.4, 29 | size: 1, 30 | speed: 6, 31 | offset: 0, 32 | blendMode: BlendMode.plus, 33 | variation1: 0, 34 | variation2: 0, 35 | variation3: 0, 36 | rotation: 0, 37 | child: PlasmaRenderer( 38 | type: PlasmaType.circle, 39 | particles: 10, 40 | color: Color(0x44b623e4), 41 | blur: 0.4, 42 | size: 1, 43 | speed: 5.16, 44 | offset: 0, 45 | blendMode: BlendMode.plus, 46 | variation1: 0.38, 47 | variation2: 0.48, 48 | variation3: 0, 49 | rotation: 0, 50 | child: PlasmaRenderer( 51 | type: PlasmaType.circle, 52 | particles: 3, 53 | color: Color(0x4423c1e4), 54 | blur: 0.4, 55 | size: 1, 56 | speed: 6.48, 57 | offset: 0, 58 | blendMode: BlendMode.plus, 59 | variation1: 0.82, 60 | variation2: 0.88, 61 | variation3: 0, 62 | rotation: 0, 63 | ), 64 | ), 65 | ), 66 | ); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lib/demo/stars/stars_background.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:simple_animations/simple_animations.dart'; 3 | 4 | class StarsBackground extends StatelessWidget { 5 | @override 6 | Widget build(BuildContext context) { 7 | return Container( 8 | decoration: BoxDecoration( 9 | gradient: LinearGradient( 10 | tileMode: TileMode.mirror, 11 | begin: Alignment(-0.4, -1.0), 12 | end: Alignment(0.3, 1.0), 13 | colors: [ 14 | Color(0xff20317d), 15 | Color(0xff1a2452), 16 | ], 17 | stops: [ 18 | 0, 19 | 1, 20 | ], 21 | ), 22 | backgroundBlendMode: BlendMode.srcOver, 23 | ), 24 | child: PlasmaRenderer( 25 | type: PlasmaType.infinity, 26 | particles: 10, 27 | color: Color(0x18c537cf), 28 | blur: 0.34, 29 | size: 0.88, 30 | speed: 0, 31 | offset: 3.8, 32 | blendMode: BlendMode.srcOver, 33 | variation1: 0, 34 | variation2: 0.43, 35 | variation3: 0, 36 | rotation: 0, 37 | child: PlasmaRenderer( 38 | type: PlasmaType.infinity, 39 | particles: 10, 40 | color: Color(0x06bababa), 41 | blur: 0.4, 42 | size: 1, 43 | speed: 0, 44 | offset: 3.84, 45 | blendMode: BlendMode.srcOver, 46 | variation1: 0, 47 | variation2: 0, 48 | variation3: 0, 49 | rotation: 1.31, 50 | child: Container( 51 | decoration: BoxDecoration( 52 | gradient: RadialGradient( 53 | center: Alignment.center, 54 | radius: 0.95, 55 | colors: [ 56 | Color(0x00000000), 57 | Color(0x41000000), 58 | ], 59 | stops: [ 60 | 0, 61 | 1, 62 | ], 63 | ), 64 | backgroundBlendMode: BlendMode.srcOver, 65 | ), 66 | ), 67 | ), 68 | ), 69 | ); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /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(RunLoop* run_loop, 8 | const flutter::DartProject& project) 9 | : run_loop_(run_loop), project_(project) {} 10 | 11 | FlutterWindow::~FlutterWindow() {} 12 | 13 | bool FlutterWindow::OnCreate() { 14 | if (!Win32Window::OnCreate()) { 15 | return false; 16 | } 17 | 18 | RECT frame = GetClientArea(); 19 | 20 | // The size here must match the window dimensions to avoid unnecessary surface 21 | // creation / destruction in the startup path. 22 | flutter_controller_ = std::make_unique( 23 | frame.right - frame.left, frame.bottom - frame.top, project_); 24 | // Ensure that basic setup of the controller was successful. 25 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 26 | return false; 27 | } 28 | RegisterPlugins(flutter_controller_->engine()); 29 | run_loop_->RegisterFlutterInstance(flutter_controller_->engine()); 30 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 31 | return true; 32 | } 33 | 34 | void FlutterWindow::OnDestroy() { 35 | if (flutter_controller_) { 36 | run_loop_->UnregisterFlutterInstance(flutter_controller_->engine()); 37 | flutter_controller_ = nullptr; 38 | } 39 | 40 | Win32Window::OnDestroy(); 41 | } 42 | 43 | LRESULT 44 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 45 | WPARAM const wparam, 46 | LPARAM const lparam) noexcept { 47 | // Give Flutter, including plugins, an opportunity to handle window messages. 48 | if (flutter_controller_) { 49 | std::optional result = 50 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 51 | lparam); 52 | if (result) { 53 | return *result; 54 | } 55 | } 56 | 57 | switch (message) { 58 | case WM_FONTCHANGE: 59 | flutter_controller_->engine()->ReloadSystemFonts(); 60 | break; 61 | } 62 | 63 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 64 | } 65 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 13 | 17 | 21 | 26 | 30 | 31 | 32 | 33 | 34 | 35 | 37 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /lib/demo/stars/stars.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:simple_animations/simple_animations.dart'; 3 | import 'package:supercharged/supercharged.dart'; 4 | 5 | import '../demo_screen.dart'; 6 | import 'flashes.dart'; 7 | import 'particles.dart'; 8 | import 'stars_background.dart'; 9 | import 'static_stars.dart'; 10 | 11 | class Stars extends StatelessWidget { 12 | @override 13 | Widget build(BuildContext context) { 14 | final tween = _createTween(); 15 | 16 | return LayoutBuilder(builder: (context, constraints) { 17 | return LoopAnimation>( 18 | tween: tween, 19 | duration: tween.duration, 20 | builder: (context, child, value) { 21 | return Stack( 22 | children: [ 23 | Positioned.fill(child: StarsBackground()), 24 | Positioned.fill(child: StaticStars()), 25 | Positioned.fill(child: Flashes()), 26 | Positioned.fill( 27 | child: CustomPaint( 28 | painter: ParticlesPainter(value: value.get(_P.particles)), 29 | )), 30 | Positioned.fill( 31 | child: Center( 32 | child: Transform.scale( 33 | scale: value.get(_P.scale), 34 | child: Transform.rotate( 35 | angle: value.get(_P.rotate), 36 | child: FlutterLogo(size: constraints.maxWidth * 0.3), 37 | ), 38 | ), 39 | )) 40 | ], 41 | ); 42 | }); 43 | }); 44 | } 45 | } 46 | 47 | enum _P { scale, rotate, particles } 48 | 49 | TimelineTween<_P> _createTween() { 50 | final tween = TimelineTween<_P>(); 51 | 52 | tween 53 | .addScene( 54 | begin: (0.25 * MUSIC_UNIT_MS).round().milliseconds, 55 | end: (0.75 * MUSIC_UNIT_MS).round().milliseconds, 56 | curve: Curves.easeOutQuad, 57 | ) 58 | .animate(_P.scale, tween: (0.01).tweenTo(1.5)) 59 | .animate(_P.rotate, tween: (-70.6).tweenTo(0.0)); 60 | 61 | tween 62 | .addScene( 63 | begin: 0.seconds, 64 | end: (1 * MUSIC_UNIT_MS).round().milliseconds, 65 | ) 66 | .animate(_P.particles, tween: (0.0).tweenTo(3.0)); 67 | 68 | return tween; 69 | } 70 | -------------------------------------------------------------------------------- /lib/showroom/select.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:supercharged/supercharged.dart'; 3 | 4 | import 'gesture_detector_with_click_hover.dart'; 5 | 6 | class PropertySelect extends StatelessWidget { 7 | final Function(String?) onChanged; 8 | final String value; 9 | final List options; 10 | 11 | PropertySelect( 12 | {required this.onChanged, required this.value, required this.options}); 13 | 14 | @override 15 | Widget build(BuildContext context) { 16 | return Row( 17 | children: [ 18 | DropdownButton( 19 | value: value, 20 | style: whiteRegular, 21 | dropdownColor: '#555555'.toColor(), 22 | items: _buildDropdownEntries(), 23 | onChanged: onChanged, 24 | ), 25 | MyIconButton( 26 | icon: Icons.navigate_before, 27 | onPressed: () => _nextOption(-1), 28 | ), 29 | MyIconButton( 30 | icon: Icons.navigate_next, 31 | onPressed: () => _nextOption(1), 32 | ) 33 | ], 34 | ); 35 | } 36 | 37 | List> _buildDropdownEntries() { 38 | return options.map((option) { 39 | return DropdownMenuItem( 40 | value: option, 41 | child: Text(option), 42 | ); 43 | }).toList(); 44 | } 45 | 46 | void _nextOption(int delta) { 47 | var sortedOptions = options; 48 | var index = sortedOptions.indexWhere((entry) => entry == value) + delta; 49 | 50 | if (index == sortedOptions.length) { 51 | index = 0; 52 | } 53 | 54 | if (index == -1) { 55 | index = sortedOptions.length - 1; 56 | } 57 | 58 | onChanged(sortedOptions[index]); 59 | } 60 | } 61 | 62 | var whiteRegular = 63 | const TextStyle(fontFamily: 'Work Sans', color: Colors.white, fontSize: 16); 64 | 65 | class MyIconButton extends StatelessWidget { 66 | final IconData icon; 67 | final void Function() onPressed; 68 | 69 | const MyIconButton({required this.icon, required this.onPressed}); 70 | 71 | @override 72 | Widget build(BuildContext context) { 73 | return GestureDetectorWithClickHover( 74 | onTap: onPressed, 75 | child: Container( 76 | padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12), 77 | child: Icon(icon, size: 24, color: Colors.white), 78 | ), 79 | ); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /windows/runner/run_loop.cpp: -------------------------------------------------------------------------------- 1 | #include "run_loop.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | RunLoop::RunLoop() {} 8 | 9 | RunLoop::~RunLoop() {} 10 | 11 | void RunLoop::Run() { 12 | bool keep_running = true; 13 | TimePoint next_flutter_event_time = TimePoint::clock::now(); 14 | while (keep_running) { 15 | std::chrono::nanoseconds wait_duration = 16 | std::max(std::chrono::nanoseconds(0), 17 | next_flutter_event_time - TimePoint::clock::now()); 18 | ::MsgWaitForMultipleObjects( 19 | 0, nullptr, FALSE, static_cast(wait_duration.count() / 1000), 20 | QS_ALLINPUT); 21 | bool processed_events = false; 22 | MSG message; 23 | // All pending Windows messages must be processed; MsgWaitForMultipleObjects 24 | // won't return again for items left in the queue after PeekMessage. 25 | while (::PeekMessage(&message, nullptr, 0, 0, PM_REMOVE)) { 26 | processed_events = true; 27 | if (message.message == WM_QUIT) { 28 | keep_running = false; 29 | break; 30 | } 31 | ::TranslateMessage(&message); 32 | ::DispatchMessage(&message); 33 | // Allow Flutter to process messages each time a Windows message is 34 | // processed, to prevent starvation. 35 | next_flutter_event_time = 36 | std::min(next_flutter_event_time, ProcessFlutterMessages()); 37 | } 38 | // If the PeekMessage loop didn't run, process Flutter messages. 39 | if (!processed_events) { 40 | next_flutter_event_time = 41 | std::min(next_flutter_event_time, ProcessFlutterMessages()); 42 | } 43 | } 44 | } 45 | 46 | void RunLoop::RegisterFlutterInstance( 47 | flutter::FlutterEngine* flutter_instance) { 48 | flutter_instances_.insert(flutter_instance); 49 | } 50 | 51 | void RunLoop::UnregisterFlutterInstance( 52 | flutter::FlutterEngine* flutter_instance) { 53 | flutter_instances_.erase(flutter_instance); 54 | } 55 | 56 | RunLoop::TimePoint RunLoop::ProcessFlutterMessages() { 57 | TimePoint next_event_time = TimePoint::max(); 58 | for (auto instance : flutter_instances_) { 59 | std::chrono::nanoseconds wait_duration = instance->ProcessMessages(); 60 | if (wait_duration != std::chrono::nanoseconds::max()) { 61 | next_event_time = 62 | std::min(next_event_time, TimePoint::clock::now() + wait_duration); 63 | } 64 | } 65 | return next_event_time; 66 | } 67 | -------------------------------------------------------------------------------- /lib/demo/fancy_plasma1/fancy_widgets1.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:simple_animations/simple_animations.dart'; 3 | 4 | class FancyPlasmaWidget2 extends StatelessWidget { 5 | const FancyPlasmaWidget2({ 6 | Key? key, 7 | required this.color, 8 | }) : super(key: key); 9 | 10 | final Color color; 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return Container( 15 | decoration: BoxDecoration( 16 | gradient: LinearGradient( 17 | tileMode: TileMode.mirror, 18 | begin: Alignment(0.6, -1.0), 19 | end: Alignment(-0.3, 1.0), 20 | colors: [ 21 | color.withOpacity(1.0), 22 | color.withOpacity(1.0), 23 | ], 24 | stops: [ 25 | 0, 26 | 1, 27 | ], 28 | ), 29 | backgroundBlendMode: BlendMode.srcOver, 30 | ), 31 | child: PlasmaRenderer( 32 | type: PlasmaType.infinity, 33 | particles: 20, 34 | color: color, 35 | blur: 0.5, 36 | size: 0.5830834600660535, 37 | speed: 3.916667302449544, 38 | offset: 0, 39 | blendMode: BlendMode.plus, 40 | variation1: 0, 41 | variation2: 0, 42 | variation3: 0, 43 | rotation: 0, 44 | ), 45 | ); 46 | } 47 | } 48 | 49 | class FancyPlasmaWidget1 extends StatelessWidget { 50 | const FancyPlasmaWidget1({ 51 | Key? key, 52 | required this.color, 53 | }) : super(key: key); 54 | 55 | final Color color; 56 | 57 | @override 58 | Widget build(BuildContext context) { 59 | return Container( 60 | decoration: BoxDecoration( 61 | gradient: LinearGradient( 62 | tileMode: TileMode.mirror, 63 | begin: Alignment.topLeft, 64 | end: Alignment.bottomRight, 65 | colors: [ 66 | Color(0xfff44336), 67 | Color(0xff2196f3), 68 | ], 69 | stops: [ 70 | 0, 71 | 1, 72 | ], 73 | ), 74 | backgroundBlendMode: BlendMode.srcOver, 75 | ), 76 | child: PlasmaRenderer( 77 | type: PlasmaType.infinity, 78 | particles: 10, 79 | color: color, 80 | blur: 0.4, 81 | size: 1, 82 | speed: 6.35, 83 | offset: 0, 84 | blendMode: BlendMode.plus, 85 | variation1: 0, 86 | variation2: 0, 87 | variation3: 0, 88 | rotation: 0, 89 | ), 90 | ); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 4 | 5 | # Configuration provided via flutter tool. 6 | include(${EPHEMERAL_DIR}/generated_config.cmake) 7 | 8 | # TODO: Move the rest of this into files in ephemeral. See 9 | # https://github.com/flutter/flutter/issues/57146. 10 | 11 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 12 | # which isn't available in 3.10. 13 | function(list_prepend LIST_NAME PREFIX) 14 | set(NEW_LIST "") 15 | foreach(element ${${LIST_NAME}}) 16 | list(APPEND NEW_LIST "${PREFIX}${element}") 17 | endforeach(element) 18 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 19 | endfunction() 20 | 21 | # === Flutter Library === 22 | # System-level dependencies. 23 | find_package(PkgConfig REQUIRED) 24 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 25 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 26 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 27 | 28 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 29 | 30 | # Published to parent scope for install step. 31 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 32 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 33 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 34 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 35 | 36 | list(APPEND FLUTTER_LIBRARY_HEADERS 37 | "fl_basic_message_channel.h" 38 | "fl_binary_codec.h" 39 | "fl_binary_messenger.h" 40 | "fl_dart_project.h" 41 | "fl_engine.h" 42 | "fl_json_message_codec.h" 43 | "fl_json_method_codec.h" 44 | "fl_message_codec.h" 45 | "fl_method_call.h" 46 | "fl_method_channel.h" 47 | "fl_method_codec.h" 48 | "fl_method_response.h" 49 | "fl_plugin_registrar.h" 50 | "fl_plugin_registry.h" 51 | "fl_standard_message_codec.h" 52 | "fl_standard_method_codec.h" 53 | "fl_string_codec.h" 54 | "fl_value.h" 55 | "fl_view.h" 56 | "flutter_linux.h" 57 | ) 58 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 59 | add_library(flutter INTERFACE) 60 | target_include_directories(flutter INTERFACE 61 | "${EPHEMERAL_DIR}" 62 | ) 63 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 64 | target_link_libraries(flutter INTERFACE 65 | PkgConfig::GTK 66 | PkgConfig::GLIB 67 | PkgConfig::GIO 68 | ) 69 | add_dependencies(flutter flutter_assemble) 70 | 71 | # === Flutter tool backend === 72 | # _phony_ is a non-existent file to force this command to run every time, 73 | # since currently there's no way to get a full input/output list from the 74 | # flutter tool. 75 | add_custom_command( 76 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 77 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 78 | COMMAND ${CMAKE_COMMAND} -E env 79 | ${FLUTTER_TOOL_ENVIRONMENT} 80 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 81 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 82 | VERBATIM 83 | ) 84 | add_custom_target(flutter_assemble DEPENDS 85 | "${FLUTTER_LIBRARY}" 86 | ${FLUTTER_LIBRARY_HEADERS} 87 | ) 88 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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.example" "\0" 93 | VALUE "FileDescription", "A new Flutter project." "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "flutterplasma" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2021 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "flutterplasma.exe" "\0" 98 | VALUE "ProductName", "flutterplasma" "\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 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 73 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates and shows a win32 window with |title| and position and size using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size to will treat the width height passed in to this function 35 | // as logical pixels and scale to appropriate for the default monitor. Returns 36 | // true if the window was created successfully. 37 | bool CreateAndShow(const std::wstring& title, 38 | const Point& origin, 39 | const Size& size); 40 | 41 | // Release OS resources associated with window. 42 | void Destroy(); 43 | 44 | // Inserts |content| into the window tree. 45 | void SetChildContent(HWND content); 46 | 47 | // Returns the backing Window handle to enable clients to set icon and other 48 | // window properties. Returns nullptr if the window has been destroyed. 49 | HWND GetHandle(); 50 | 51 | // If true, closing this window will quit the application. 52 | void SetQuitOnClose(bool quit_on_close); 53 | 54 | // Return a RECT representing the bounds of the current client area. 55 | RECT GetClientArea(); 56 | 57 | protected: 58 | // Processes and route salient window messages for mouse handling, 59 | // size change and DPI. Delegates handling of these to member overloads that 60 | // inheriting classes can handle. 61 | virtual LRESULT MessageHandler(HWND window, 62 | UINT const message, 63 | WPARAM const wparam, 64 | LPARAM const lparam) noexcept; 65 | 66 | // Called when CreateAndShow is called, allowing subclass window-related 67 | // setup. Subclasses should return false if setup fails. 68 | virtual bool OnCreate(); 69 | 70 | // Called when Destroy is called. 71 | virtual void OnDestroy(); 72 | 73 | private: 74 | friend class WindowClassRegistrar; 75 | 76 | // OS callback called by message pump. Handles the WM_NCCREATE message which 77 | // is passed when the non-client area is being created and enables automatic 78 | // non-client DPI scaling so that the non-client area automatically 79 | // responsponds to changes in DPI. All other messages are handled by 80 | // MessageHandler. 81 | static LRESULT CALLBACK WndProc(HWND const window, 82 | UINT const message, 83 | WPARAM const wparam, 84 | LPARAM const lparam) noexcept; 85 | 86 | // Retrieves a class instance pointer for |window| 87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 88 | 89 | bool quit_on_close_ = false; 90 | 91 | // window handle for top level window. 92 | HWND window_handle_ = nullptr; 93 | 94 | // window handle for hosted content. 95 | HWND child_content_ = nullptr; 96 | }; 97 | 98 | #endif // RUNNER_WIN32_WINDOW_H_ 99 | -------------------------------------------------------------------------------- /windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | project(flutterplasma LANGUAGES CXX) 3 | 4 | set(BINARY_NAME "flutterplasma") 5 | 6 | cmake_policy(SET CMP0063 NEW) 7 | 8 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 9 | 10 | # Configure build options. 11 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 12 | if(IS_MULTICONFIG) 13 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 14 | CACHE STRING "" FORCE) 15 | else() 16 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 17 | set(CMAKE_BUILD_TYPE "Debug" CACHE 18 | STRING "Flutter build mode" FORCE) 19 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 20 | "Debug" "Profile" "Release") 21 | endif() 22 | endif() 23 | 24 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 25 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 26 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 27 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 28 | 29 | # Use Unicode for all projects. 30 | add_definitions(-DUNICODE -D_UNICODE) 31 | 32 | # Compilation settings that should be applied to most targets. 33 | function(APPLY_STANDARD_SETTINGS TARGET) 34 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 35 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 36 | target_compile_options(${TARGET} PRIVATE /EHsc) 37 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 38 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 39 | endfunction() 40 | 41 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 42 | 43 | # Flutter library and tool build rules. 44 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 45 | 46 | # Application build 47 | add_subdirectory("runner") 48 | 49 | # Generated plugin build rules, which manage building the plugins and adding 50 | # them to the application. 51 | include(flutter/generated_plugins.cmake) 52 | 53 | 54 | # === Installation === 55 | # Support files are copied into place next to the executable, so that it can 56 | # run in place. This is done instead of making a separate bundle (as on Linux) 57 | # so that building and running from within Visual Studio will work. 58 | set(BUILD_BUNDLE_DIR "$") 59 | # Make the "install" step default, as it's required to run. 60 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 61 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 62 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 63 | endif() 64 | 65 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 66 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 67 | 68 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 69 | COMPONENT Runtime) 70 | 71 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 72 | COMPONENT Runtime) 73 | 74 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 75 | COMPONENT Runtime) 76 | 77 | if(PLUGIN_BUNDLED_LIBRARIES) 78 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 79 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 80 | COMPONENT Runtime) 81 | endif() 82 | 83 | # Fully re-copy the assets directory on each build to avoid having stale files 84 | # from a previous install. 85 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 86 | install(CODE " 87 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 88 | " COMPONENT Runtime) 89 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 90 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 91 | 92 | # Install the AOT library on non-Debug builds only. 93 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 94 | CONFIGURATIONS Profile;Release 95 | COMPONENT Runtime) 96 | -------------------------------------------------------------------------------- /lib/demo/sky/dash.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | import 'dart:typed_data'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:simple_animations/simple_animations.dart'; 5 | import 'package:supercharged/supercharged.dart'; 6 | 7 | import 'dash_painter.dart'; 8 | 9 | class DashAnimation extends StatelessWidget { 10 | @override 11 | Widget build(BuildContext context) { 12 | return MirrorAnimation( 13 | tween: 0.0.tweenTo(1.0), 14 | duration: 300.milliseconds, 15 | builder: (context, child, value) { 16 | return Dash(value: value); 17 | }); 18 | } 19 | } 20 | 21 | class Dash extends StatelessWidget { 22 | final double value; 23 | 24 | const Dash({required this.value}); 25 | 26 | @override 27 | Widget build(BuildContext context) { 28 | return AspectRatio( 29 | aspectRatio: 1.0, 30 | child: Container( 31 | child: CustomPaint( 32 | painter: DashPainter(value: value), 33 | ), 34 | ), 35 | ); 36 | } 37 | } 38 | 39 | final Paint opaque = Paint()..filterQuality = FilterQuality.medium; 40 | 41 | class DashPainter extends CustomPainter { 42 | final double value; 43 | 44 | const DashPainter({required this.value}); 45 | 46 | @override 47 | void paint(Canvas canvas, Size size) { 48 | final dashFrame = paintDash(value); 49 | final scale = size.width / dashWidth; 50 | 51 | final rstTransforms = Float32List(4); 52 | rstTransforms[0] = scale; 53 | 54 | final rects = Float32List(4); 55 | rects[0] = 0; 56 | rects[1] = 0; 57 | rects[2] = dashWidth; 58 | rects[3] = dashHeight; 59 | 60 | canvas.drawRawAtlas( 61 | dashFrame, 62 | rstTransforms, 63 | rects, 64 | null, 65 | BlendMode.srcOver, 66 | null, 67 | opaque, 68 | ); 69 | } 70 | 71 | @override 72 | bool shouldRepaint(covariant CustomPainter oldDelegate) { 73 | return true; 74 | } 75 | } 76 | 77 | class MultiDashPainter extends CustomPainter { 78 | const MultiDashPainter(this.otherDashes, this.value); 79 | 80 | final double otherDashes; 81 | final double value; 82 | 83 | @override 84 | void paint(Canvas canvas, Size size) { 85 | final random = Random(18); 86 | final randomAngle = Random(16); 87 | 88 | const dashCount = 20; 89 | final rstTransforms = Float32List(4 * dashCount); 90 | final rects = Float32List(4 * dashCount); 91 | 92 | 0.until(dashCount).forEach((n) { 93 | final offset = 4 * n; 94 | rects[offset + 2] = dashWidth; 95 | rects[offset + 3] = dashHeight; 96 | 97 | var left = 0.0 + 1.0 * random.nextDouble() + (1 - otherDashes) * 0.3; 98 | left *= size.width; 99 | var top = 2.4 * (1 - otherDashes) - 1.2 + random.nextDouble(); 100 | top *= size.height; 101 | var length = 0.14 + 0.08 * random.nextDouble() - otherDashes * 0.1; 102 | length *= size.width; 103 | final scale = length / dashWidth; 104 | 105 | final anchorX = dashWidth / 2; 106 | final anchorY = dashHeight / 2; 107 | final rotation = 0.3 + 0.2 * randomAngle.nextDouble(); 108 | final scos = cos(rotation) * scale; 109 | final ssin = sin(rotation) * scale; 110 | final tx = left + -scos * anchorX + ssin * anchorY; 111 | final ty = top + -ssin * anchorX - scos * anchorY; 112 | 113 | rstTransforms[offset] = scos; 114 | rstTransforms[offset + 1] = ssin; 115 | rstTransforms[offset + 2] = tx; 116 | rstTransforms[offset + 3] = ty; 117 | }); 118 | 119 | final dashFrame = paintDash(value); 120 | canvas.clipRect(Offset.zero & size); 121 | canvas.drawRawAtlas( 122 | dashFrame, 123 | rstTransforms, 124 | rects, 125 | null, 126 | BlendMode.srcOver, 127 | null, 128 | opaque, 129 | ); 130 | } 131 | 132 | @override 133 | bool shouldRepaint(covariant CustomPainter oldDelegate) => true; 134 | } 135 | -------------------------------------------------------------------------------- /windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | 3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 4 | 5 | # Configuration provided via flutter tool. 6 | include(${EPHEMERAL_DIR}/generated_config.cmake) 7 | 8 | # TODO: Move the rest of this into files in ephemeral. See 9 | # https://github.com/flutter/flutter/issues/57146. 10 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 11 | 12 | # === Flutter Library === 13 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 14 | 15 | # Published to parent scope for install step. 16 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 17 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 18 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 19 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 20 | 21 | list(APPEND FLUTTER_LIBRARY_HEADERS 22 | "flutter_export.h" 23 | "flutter_windows.h" 24 | "flutter_messenger.h" 25 | "flutter_plugin_registrar.h" 26 | "flutter_texture_registrar.h" 27 | ) 28 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 29 | add_library(flutter INTERFACE) 30 | target_include_directories(flutter INTERFACE 31 | "${EPHEMERAL_DIR}" 32 | ) 33 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 34 | add_dependencies(flutter flutter_assemble) 35 | 36 | # === Wrapper === 37 | list(APPEND CPP_WRAPPER_SOURCES_CORE 38 | "core_implementations.cc" 39 | "standard_codec.cc" 40 | ) 41 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 42 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 43 | "plugin_registrar.cc" 44 | ) 45 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 46 | list(APPEND CPP_WRAPPER_SOURCES_APP 47 | "flutter_engine.cc" 48 | "flutter_view_controller.cc" 49 | ) 50 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 51 | 52 | # Wrapper sources needed for a plugin. 53 | add_library(flutter_wrapper_plugin STATIC 54 | ${CPP_WRAPPER_SOURCES_CORE} 55 | ${CPP_WRAPPER_SOURCES_PLUGIN} 56 | ) 57 | apply_standard_settings(flutter_wrapper_plugin) 58 | set_target_properties(flutter_wrapper_plugin PROPERTIES 59 | POSITION_INDEPENDENT_CODE ON) 60 | set_target_properties(flutter_wrapper_plugin PROPERTIES 61 | CXX_VISIBILITY_PRESET hidden) 62 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 63 | target_include_directories(flutter_wrapper_plugin PUBLIC 64 | "${WRAPPER_ROOT}/include" 65 | ) 66 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 67 | 68 | # Wrapper sources needed for the runner. 69 | add_library(flutter_wrapper_app STATIC 70 | ${CPP_WRAPPER_SOURCES_CORE} 71 | ${CPP_WRAPPER_SOURCES_APP} 72 | ) 73 | apply_standard_settings(flutter_wrapper_app) 74 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 75 | target_include_directories(flutter_wrapper_app PUBLIC 76 | "${WRAPPER_ROOT}/include" 77 | ) 78 | add_dependencies(flutter_wrapper_app flutter_assemble) 79 | 80 | # === Flutter tool backend === 81 | # _phony_ is a non-existent file to force this command to run every time, 82 | # since currently there's no way to get a full input/output list from the 83 | # flutter tool. 84 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 85 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 86 | add_custom_command( 87 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 88 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 89 | ${CPP_WRAPPER_SOURCES_APP} 90 | ${PHONY_OUTPUT} 91 | COMMAND ${CMAKE_COMMAND} -E env 92 | ${FLUTTER_TOOL_ENVIRONMENT} 93 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 94 | windows-x64 $ 95 | VERBATIM 96 | ) 97 | add_custom_target(flutter_assemble DEPENDS 98 | "${FLUTTER_LIBRARY}" 99 | ${FLUTTER_LIBRARY_HEADERS} 100 | ${CPP_WRAPPER_SOURCES_CORE} 101 | ${CPP_WRAPPER_SOURCES_PLUGIN} 102 | ${CPP_WRAPPER_SOURCES_APP} 103 | ) 104 | -------------------------------------------------------------------------------- /linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen *screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "flutterplasma"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } 47 | else { 48 | gtk_window_set_title(window, "flutterplasma"); 49 | } 50 | 51 | gtk_window_set_default_size(window, 1280, 720); 52 | gtk_widget_show(GTK_WIDGET(window)); 53 | 54 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 55 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 56 | 57 | FlView* view = fl_view_new(project); 58 | gtk_widget_show(GTK_WIDGET(view)); 59 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 60 | 61 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 62 | 63 | gtk_widget_grab_focus(GTK_WIDGET(view)); 64 | } 65 | 66 | // Implements GApplication::local_command_line. 67 | static gboolean my_application_local_command_line(GApplication* application, gchar ***arguments, int *exit_status) { 68 | MyApplication* self = MY_APPLICATION(application); 69 | // Strip out the first argument as it is the binary name. 70 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 71 | 72 | g_autoptr(GError) error = nullptr; 73 | if (!g_application_register(application, nullptr, &error)) { 74 | g_warning("Failed to register: %s", error->message); 75 | *exit_status = 1; 76 | return TRUE; 77 | } 78 | 79 | g_application_activate(application); 80 | *exit_status = 0; 81 | 82 | return TRUE; 83 | } 84 | 85 | // Implements GObject::dispose. 86 | static void my_application_dispose(GObject *object) { 87 | MyApplication* self = MY_APPLICATION(object); 88 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 89 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 90 | } 91 | 92 | static void my_application_class_init(MyApplicationClass* klass) { 93 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 94 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 95 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 96 | } 97 | 98 | static void my_application_init(MyApplication* self) {} 99 | 100 | MyApplication* my_application_new() { 101 | return MY_APPLICATION(g_object_new(my_application_get_type(), 102 | "application-id", APPLICATION_ID, 103 | "flags", G_APPLICATION_NON_UNIQUE, 104 | nullptr)); 105 | } 106 | -------------------------------------------------------------------------------- /linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | project(runner LANGUAGES CXX) 3 | 4 | set(BINARY_NAME "flutterplasma") 5 | set(APPLICATION_ID "com.example.flutterplasma") 6 | 7 | cmake_policy(SET CMP0063 NEW) 8 | 9 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 10 | 11 | # Root filesystem for cross-building. 12 | if(FLUTTER_TARGET_PLATFORM_SYSROOT) 13 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 14 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 15 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 16 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 17 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 18 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 19 | endif() 20 | 21 | # Configure build options. 22 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 23 | set(CMAKE_BUILD_TYPE "Debug" CACHE 24 | STRING "Flutter build mode" FORCE) 25 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 26 | "Debug" "Profile" "Release") 27 | endif() 28 | 29 | # Compilation settings that should be applied to most targets. 30 | function(APPLY_STANDARD_SETTINGS TARGET) 31 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 32 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 33 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 34 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 35 | endfunction() 36 | 37 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 38 | 39 | # Flutter library and tool build rules. 40 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 41 | 42 | # System-level dependencies. 43 | find_package(PkgConfig REQUIRED) 44 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 45 | 46 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 47 | 48 | # Application build 49 | add_executable(${BINARY_NAME} 50 | "main.cc" 51 | "my_application.cc" 52 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 53 | ) 54 | apply_standard_settings(${BINARY_NAME}) 55 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 56 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 57 | add_dependencies(${BINARY_NAME} flutter_assemble) 58 | # Only the install-generated bundle's copy of the executable will launch 59 | # correctly, since the resources must in the right relative locations. To avoid 60 | # people trying to run the unbundled copy, put it in a subdirectory instead of 61 | # the default top-level location. 62 | set_target_properties(${BINARY_NAME} 63 | PROPERTIES 64 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 65 | ) 66 | 67 | # Generated plugin build rules, which manage building the plugins and adding 68 | # them to the application. 69 | include(flutter/generated_plugins.cmake) 70 | 71 | 72 | # === Installation === 73 | # By default, "installing" just makes a relocatable bundle in the build 74 | # directory. 75 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 76 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 77 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 78 | endif() 79 | 80 | # Start with a clean build bundle directory every time. 81 | install(CODE " 82 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 83 | " COMPONENT Runtime) 84 | 85 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 86 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 87 | 88 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 89 | COMPONENT Runtime) 90 | 91 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 92 | COMPONENT Runtime) 93 | 94 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 95 | COMPONENT Runtime) 96 | 97 | if(PLUGIN_BUNDLED_LIBRARIES) 98 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 99 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 100 | COMPONENT Runtime) 101 | endif() 102 | 103 | # Fully re-copy the assets directory on each build to avoid having stale files 104 | # from a previous install. 105 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 106 | install(CODE " 107 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 108 | " COMPONENT Runtime) 109 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 110 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 111 | 112 | # Install the AOT library on non-Debug builds only. 113 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 114 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 115 | COMPONENT Runtime) 116 | endif() 117 | -------------------------------------------------------------------------------- /lib/demo/layout/layout_wall.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:simple_animations/simple_animations.dart'; 5 | import 'package:supercharged/supercharged.dart'; 6 | 7 | import '../demo_screen.dart'; 8 | import 'layout_a.dart'; 9 | import 'layout_b.dart'; 10 | import 'layout_c.dart'; 11 | import 'layout_d.dart'; 12 | 13 | class LayoutWall extends StatelessWidget { 14 | @override 15 | Widget build(BuildContext context) { 16 | return LayoutBuilder(builder: (context, constraints) { 17 | final size = Size(constraints.maxWidth, constraints.maxHeight); 18 | final tween = _createTween(size); 19 | 20 | return PlayAnimation>( 21 | tween: tween, 22 | duration: tween.duration, 23 | builder: (context, child, value) { 24 | return ClipRect( 25 | child: Container( 26 | color: Colors.white, 27 | child: Transform( 28 | transform: Matrix4.identity() 29 | ..setEntry(3, 2, 0.001) 30 | ..rotateX(value.get(_P.rotateX)) 31 | ..rotateY(value.get(_P.rotateY)), 32 | child: Transform.scale( 33 | scale: value.get(_P.scale), 34 | child: Transform.translate( 35 | offset: Offset( 36 | value.get(_P.translateX), value.get(_P.translateY)), 37 | child: OverflowBox( 38 | minWidth: constraints.maxWidth * 1.25, 39 | maxWidth: constraints.maxWidth * 1.25, 40 | minHeight: constraints.maxHeight * 1.25, 41 | maxHeight: constraints.maxHeight * 1.25, 42 | child: Stack( 43 | children: _createGrid(context, size), 44 | ), 45 | ), 46 | ), 47 | ), 48 | ), 49 | ), 50 | ); 51 | }); 52 | }); 53 | } 54 | 55 | List _createGrid(BuildContext context, Size size) { 56 | final random = Random(1); 57 | 58 | final grid = []; 59 | 60 | final itemSize = 61 | size.width > size.height ? size.width / 4 : size.height / 4; 62 | 63 | final itemsX = (size.width / itemSize).ceil(); 64 | final itemsY = (size.height / itemSize).ceil(); 65 | 66 | 0.until(itemsY).forEach((y) { 67 | 0.until(itemsX).forEach((x) { 68 | grid.add(Positioned( 69 | left: x * itemSize, 70 | top: y * itemSize, 71 | width: itemSize, 72 | height: itemSize, 73 | child: Padding( 74 | padding: EdgeInsets.all(itemSize * 0.1), 75 | child: AspectRatio( 76 | aspectRatio: 1, 77 | child: _randomLayout(random), 78 | ), 79 | ), 80 | )); 81 | }); 82 | }); 83 | 84 | return grid; 85 | } 86 | } 87 | 88 | enum _P { scale, translateX, translateY, rotateX, rotateY } 89 | 90 | TimelineTween<_P> _createTween(Size size) { 91 | final tween = TimelineTween<_P>(); 92 | 93 | final shift1 = size.width / 3 * 0.585; 94 | 95 | tween 96 | .addScene(begin: 0.milliseconds, duration: MUSIC_UNIT_MS.milliseconds) 97 | .animate(_P.scale, tween: 1.5.tweenTo(1.25)) 98 | .animate(_P.translateX, tween: (shift1).tweenTo(-shift1)) 99 | .animate(_P.translateY, tween: (0.0).tweenTo(shift1 / 2)) 100 | .animate(_P.rotateX, tween: (-1.4).tweenTo(-0.4)) 101 | .animate(_P.rotateY, tween: (0.0).tweenTo(0.0)); 102 | 103 | tween 104 | .addScene( 105 | begin: MUSIC_UNIT_MS.milliseconds, 106 | duration: MUSIC_UNIT_MS.milliseconds) 107 | .animate(_P.scale, tween: 1.3.tweenTo(0.8), curve: Curves.easeOut) 108 | .animate(_P.translateX, tween: (-shift1 * 1.2).tweenTo(0)) 109 | .animate(_P.rotateX, tween: (-0.0).tweenTo(-0.8)) 110 | .animate(_P.rotateY, tween: (1.0).tweenTo(0.0)); 111 | 112 | tween.addScene( 113 | end: (2 * MUSIC_UNIT_MS).milliseconds, duration: 1.milliseconds); 114 | 115 | return tween; 116 | } 117 | 118 | Widget _randomLayout(Random random) { 119 | return [ 120 | (r) => LayoutA(start: r.nextDouble()), 121 | (r) => LayoutB(start: r.nextDouble()), 122 | (r) => LayoutC(start: r.nextDouble()), 123 | (r) => LayoutD(start: r.nextDouble()), 124 | ].pickOne(random)(random); 125 | } 126 | -------------------------------------------------------------------------------- /lib/demo/layout/layout_a.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:simple_animations/simple_animations.dart'; 3 | import 'package:supercharged/supercharged.dart'; 4 | 5 | import 'colors.dart'; 6 | 7 | class LayoutA extends StatelessWidget { 8 | final double start; 9 | 10 | LayoutA({this.start = 0.0}); 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return LayoutBuilder(builder: (context, outerConstraints) { 15 | final gap = 0.025 * outerConstraints.maxWidth; 16 | 17 | return Container( 18 | padding: EdgeInsets.all(2 * gap), 19 | decoration: BoxDecoration( 20 | color: grey1, 21 | borderRadius: BorderRadius.all(Radius.circular(gap)), 22 | ), 23 | child: LayoutBuilder(builder: (context, constraints) { 24 | final tween = _createTween(constraints.maxWidth, gap); 25 | 26 | return CustomAnimation>( 27 | control: CustomAnimationControl.LOOP, 28 | startPosition: start, 29 | tween: tween, 30 | duration: tween.duration, 31 | builder: (context, child, value) { 32 | return Container( 33 | child: Stack( 34 | children: [ 35 | Positioned( 36 | left: value.get(_P.left1), 37 | top: value.get(_P.top1), 38 | width: value.get(_P.width1), 39 | height: value.get(_P.height1), 40 | child: Container( 41 | decoration: BoxDecoration( 42 | color: grey2, 43 | borderRadius: 44 | BorderRadius.all(Radius.circular(gap)), 45 | ), 46 | )), 47 | Positioned( 48 | left: value.get(_P.left2), 49 | top: value.get(_P.top2), 50 | width: value.get(_P.width2), 51 | height: value.get(_P.height2), 52 | child: Container( 53 | decoration: BoxDecoration( 54 | color: grey2, 55 | borderRadius: 56 | BorderRadius.all(Radius.circular(gap)), 57 | ), 58 | )) 59 | ], 60 | ), 61 | ); 62 | }); 63 | }), 64 | ); 65 | }); 66 | } 67 | } 68 | 69 | enum _P { 70 | top1, 71 | left1, 72 | width1, 73 | height1, 74 | top2, 75 | left2, 76 | width2, 77 | height2, 78 | } 79 | 80 | TimelineTween<_P> _createTween(double size, double gap) { 81 | final tween = TimelineTween<_P>(curve: Curves.easeInOut); 82 | tween 83 | .addScene(begin: 0.seconds, duration: 1.milliseconds) 84 | .animate(_P.top1, tween: ConstantTween(0.0)) 85 | .animate(_P.left1, tween: ConstantTween(0.0)); 86 | 87 | final step1 = tween 88 | .addScene(begin: 500.milliseconds, duration: 700.milliseconds) 89 | .animate(_P.width1, tween: (size * 0.5 - gap).tweenTo(size)); 90 | 91 | final step2 = step1 92 | .addSubsequentScene(delay: -300.milliseconds, duration: 700.milliseconds) 93 | .animate(_P.left2, tween: (0.5 * size + gap).tweenTo(0.0)); 94 | 95 | final step3 = step2 96 | .addSubsequentScene(delay: 800.milliseconds, duration: 500.milliseconds) 97 | .animate(_P.height1, tween: (size * 0.5 - gap).tweenTo(size * 0.2 - gap)) 98 | .animate(_P.top2, tween: (0.5 * size + gap).tweenTo(0.2 * size + gap)); 99 | 100 | final step4 = step3 101 | .addSubsequentScene(delay: 300.milliseconds, duration: 700.milliseconds) 102 | .animate(_P.height2, tween: (0.5 * size - gap).tweenTo(0.8 * size - gap)) 103 | .animate(_P.width2, tween: (0.5 * size - gap).tweenTo(size)); 104 | 105 | step4 106 | .addSubsequentScene(delay: 1000.milliseconds, duration: 700.milliseconds) 107 | .animate(_P.width1, tween: (size).tweenTo(size * 0.5 - gap)) 108 | .animate(_P.height1, tween: (size * 0.2 - gap).tweenTo(size * 0.5 - gap)) 109 | .animate(_P.top2, tween: (0.2 * size + gap).tweenTo(0.5 * size + gap)) 110 | .animate(_P.left2, tween: (0.0).tweenTo(0.5 * size + gap)) 111 | .animate(_P.height2, tween: (0.8 * size - gap).tweenTo(0.5 * size - gap)) 112 | .animate(_P.width2, tween: (size).tweenTo(0.5 * size - gap)); 113 | 114 | return tween; 115 | } 116 | -------------------------------------------------------------------------------- /lib/demo/demo_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:simple_animations/simple_animations.dart'; 4 | import 'package:supercharged/supercharged.dart'; 5 | 6 | import 'effects/shatter.dart'; 7 | import 'fancy_plasma1/fancy_plasma1.dart'; 8 | import 'fancy_plasma2/fancy_plasma2.dart'; 9 | import 'intro/intro.dart'; 10 | import 'layout/layout_wall.dart'; 11 | import 'outro/outro.dart'; 12 | import 'sky/sky.dart'; 13 | import 'stars/stars.dart'; 14 | import 'startpage/start_page.dart'; 15 | 16 | import 'audio.dart'; 17 | 18 | class DemoScreen extends StatefulWidget { 19 | final VoidCallback onComplete; 20 | final bool showCredits; 21 | 22 | const DemoScreen({required this.onComplete, required this.showCredits}); 23 | 24 | @override 25 | _DemoScreenState createState() => _DemoScreenState(); 26 | } 27 | 28 | class _DemoScreenState extends State { 29 | final AudioPlayer _audioPlayer = AudioPlayer('assets/assets/music.mp3'); 30 | 31 | var control = CustomAnimationControl.STOP; 32 | 33 | var widgets = []; 34 | 35 | @override 36 | void initState() { 37 | widgets = [ 38 | Container(), 39 | Intro(), 40 | FancyPlasma1(), 41 | LayoutWall(), 42 | FancyPlasma2(), 43 | Sky(), 44 | Stars(), 45 | Container(), 46 | Outro(onComplete: widget.onComplete), 47 | ]; 48 | 49 | super.initState(); 50 | } 51 | 52 | void _start(Function shatterFn) async { 53 | if (kIsWeb) { 54 | await _audioPlayer.play(); 55 | 56 | while (true) { 57 | final position = await _audioPlayer.position; 58 | if (position > 0.seconds) { 59 | setState(() => control = CustomAnimationControl.PLAY_FROM_START); 60 | shatterFn(); 61 | break; 62 | } 63 | await 1.milliseconds.delay; 64 | } 65 | } else { 66 | setState(() => control = CustomAnimationControl.PLAY_FROM_START); 67 | shatterFn(); 68 | } 69 | } 70 | 71 | @override 72 | Widget build(BuildContext context) { 73 | final tween = _createTween(widget.showCredits); 74 | 75 | return Scaffold( 76 | body: CustomAnimation>( 77 | control: control, 78 | tween: tween, 79 | duration: tween.duration, 80 | builder: (context, child, value) { 81 | var widgetIndex = value.get(_P.widgetIndex); 82 | return Container( 83 | color: Colors.black, 84 | child: Stack( 85 | children: [ 86 | Positioned.fill( 87 | child: widgets[widgetIndex], 88 | ), 89 | if (widgetIndex <= 1) 90 | Positioned.fill( 91 | child: ShatterScene( 92 | builder: (context, shatterFn) => 93 | StartPage(pressedStart: () => _start(shatterFn)), 94 | ), 95 | ), 96 | ], 97 | ), 98 | ); 99 | }, 100 | animationStatusListener: (status) { 101 | if (status == AnimationStatus.completed) { 102 | _audioPlayer.pause(); 103 | } 104 | }, 105 | ), 106 | ); 107 | } 108 | } 109 | 110 | enum _P { widgetIndex } 111 | 112 | TimelineTween<_P> _createTween(bool withCredits) { 113 | final tween = TimelineTween<_P>(); 114 | 115 | final intro = tween 116 | .addScene(begin: 0.milliseconds, duration: 605.milliseconds) 117 | .animate(_P.widgetIndex, tween: ConstantTween(0)); 118 | 119 | final message = intro 120 | .addSubsequentScene(duration: MUSIC_UNIT_MS.milliseconds) 121 | .animate(_P.widgetIndex, tween: ConstantTween(1)); 122 | 123 | final plasmas = tween 124 | .addScene( 125 | begin: 13068.milliseconds, 126 | duration: (2 * MUSIC_UNIT_MS).round().milliseconds) 127 | .animate(_P.widgetIndex, tween: ConstantTween(2)); 128 | 129 | final layoutWall = tween 130 | .addScene( 131 | begin: 25414.milliseconds, 132 | duration: (2 * MUSIC_UNIT_MS).round().milliseconds) 133 | .animate(_P.widgetIndex, tween: ConstantTween(3)); 134 | 135 | final plasmaComposition = tween 136 | .addScene( 137 | begin: 37728.milliseconds, 138 | duration: (2 * MUSIC_UNIT_MS).round().milliseconds) 139 | .animate(_P.widgetIndex, tween: ConstantTween(4)); 140 | 141 | final sky = plasmaComposition 142 | .addSubsequentScene(duration: MUSIC_UNIT_MS.milliseconds) 143 | .animate(_P.widgetIndex, tween: ConstantTween(5)); 144 | 145 | final space = sky 146 | .addSubsequentScene(duration: MUSIC_UNIT_MS.milliseconds) 147 | .animate(_P.widgetIndex, tween: ConstantTween(6)); 148 | 149 | final dark = space 150 | .addSubsequentScene(duration: 2000.milliseconds) 151 | .animate(_P.widgetIndex, tween: ConstantTween(7)); 152 | 153 | if (withCredits) { 154 | var outro = tween 155 | .addScene(begin: 66275.milliseconds, end: 91532.milliseconds) 156 | .animate(_P.widgetIndex, tween: ConstantTween(8)); 157 | 158 | var end = tween.addScene(begin: 94.seconds, duration: 1.milliseconds); 159 | } 160 | 161 | return tween; 162 | } 163 | 164 | const MUSIC_UNIT_MS = 6165; 165 | -------------------------------------------------------------------------------- /lib/routed_app.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:supercharged/supercharged.dart'; 3 | 4 | import 'demo/demo_screen.dart'; 5 | import 'showroom/show_room.dart'; 6 | import 'widget_warmup.dart'; 7 | 8 | class RoutedApp extends StatefulWidget { 9 | @override 10 | _RoutedAppState createState() => _RoutedAppState(); 11 | } 12 | 13 | class _RoutedAppState extends State { 14 | final _routerDelegate = AppRouterDelegate(); 15 | final _routeInformationParser = AppRouteInformationParser(); 16 | 17 | @override 18 | Widget build(BuildContext context) { 19 | return MaterialApp.router( 20 | title: 'Flutter Plasma', 21 | routerDelegate: _routerDelegate, 22 | routeInformationParser: _routeInformationParser, 23 | ); 24 | } 25 | } 26 | 27 | class AppRoutePath { 28 | final String _route; 29 | var showroomIndex = 0; 30 | var demoShowCredits = true; 31 | 32 | AppRoutePath.demo({bool credits = true}) 33 | : _route = 'demo', 34 | demoShowCredits = credits; 35 | 36 | AppRoutePath.showroom(int index) 37 | : _route = 'showroom', 38 | showroomIndex = index; 39 | 40 | AppRoutePath.unknown() : _route = 'unknown'; 41 | 42 | bool get isDemo => _route == 'demo'; 43 | 44 | bool get isShowroom => _route == 'showroom'; 45 | 46 | bool get isUnknown => _route == 'unknown'; 47 | } 48 | 49 | class AppRouteInformationParser extends RouteInformationParser { 50 | @override 51 | Future parseRouteInformation( 52 | RouteInformation routeInformation) async { 53 | final uri = Uri.parse(routeInformation.location!); 54 | 55 | if (uri.pathSegments.isEmpty) { 56 | return AppRoutePath.demo(); 57 | } 58 | 59 | if (uri.pathSegments[0] == 'nocredits') { 60 | return AppRoutePath.demo(credits: false); 61 | } 62 | 63 | if (uri.pathSegments[0] == 'showroom') { 64 | if (uri.pathSegments.length == 2) { 65 | var index = uri.pathSegments[1].toInt(); 66 | if (index != null) { 67 | return AppRoutePath.showroom(index); 68 | } 69 | } 70 | 71 | return AppRoutePath.showroom(0); 72 | } 73 | 74 | return AppRoutePath.unknown(); 75 | } 76 | 77 | @override 78 | RouteInformation restoreRouteInformation(AppRoutePath path) { 79 | if (path.isDemo) { 80 | if (path.demoShowCredits) { 81 | return RouteInformation(location: '/'); 82 | } else { 83 | return RouteInformation(location: '/nocredits'); 84 | } 85 | } 86 | if (path.isShowroom) { 87 | if (path.showroomIndex > 0) { 88 | return RouteInformation(location: '/showroom/${path.showroomIndex}'); 89 | } 90 | return RouteInformation(location: '/showroom'); 91 | } 92 | return RouteInformation(location: '/unknown'); 93 | } 94 | } 95 | 96 | class AppRouterDelegate extends RouterDelegate 97 | with ChangeNotifier, PopNavigatorRouterDelegateMixin { 98 | @override 99 | final GlobalKey navigatorKey; 100 | 101 | AppRouterDelegate() : navigatorKey = GlobalKey(); 102 | 103 | var showDemo = true; 104 | var demoShowCredits = true; 105 | var showShowroom = false; 106 | var showroomIndex = 0; 107 | var showUnknown = false; 108 | 109 | @override 110 | AppRoutePath get currentConfiguration { 111 | if (showDemo) { 112 | return AppRoutePath.demo(credits: demoShowCredits); 113 | } 114 | if (showShowroom) { 115 | return AppRoutePath.showroom(showroomIndex); 116 | } 117 | return AppRoutePath.unknown(); 118 | } 119 | 120 | @override 121 | Widget build(BuildContext context) { 122 | return WidgetWarmup( 123 | child: Navigator( 124 | key: navigatorKey, 125 | pages: [ 126 | if (showDemo) 127 | MaterialPage( 128 | key: ValueKey('Demo'), 129 | child: DemoScreen( 130 | showCredits: demoShowCredits, 131 | onComplete: _handleDemoCompleted, 132 | ), 133 | ), 134 | if (showShowroom) 135 | MaterialPage( 136 | key: ValueKey('ShowRoom'), 137 | child: Scaffold( 138 | body: ShowRoom( 139 | index: showroomIndex, 140 | onIndexChange: _handleShowroomIndexChange)), 141 | ), 142 | if (showUnknown) 143 | MaterialPage( 144 | key: ValueKey('Unknown'), 145 | child: Scaffold(body: Center(child: Text('404'))), 146 | ) 147 | ], 148 | onPopPage: (route, dynamic result) { 149 | if (!route.didPop(result)) { 150 | return false; 151 | } 152 | 153 | notifyListeners(); 154 | return true; 155 | }, 156 | ), 157 | ); 158 | } 159 | 160 | @override 161 | Future setNewRoutePath(AppRoutePath path) async { 162 | showDemo = path.isDemo; 163 | demoShowCredits = path.demoShowCredits; 164 | showShowroom = path.isShowroom; 165 | showUnknown = path.isUnknown; 166 | showroomIndex = path.showroomIndex; 167 | } 168 | 169 | void _handleDemoCompleted() { 170 | showDemo = false; 171 | showShowroom = true; 172 | notifyListeners(); 173 | } 174 | 175 | void _handleShowroomIndexChange(int newIndex) { 176 | showroomIndex = newIndex; 177 | notifyListeners(); 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /lib/showroom/show_room.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:supercharged/supercharged.dart'; 3 | 4 | import '../demo/fancy_plasma1/fancy_widgets1.dart'; 5 | import '../demo/fancy_plasma1/other_plasma1.dart'; 6 | import '../demo/fancy_plasma1/other_plasma2.dart'; 7 | import '../demo/fancy_plasma2/fancy_plasma2.dart'; 8 | import '../demo/intro/large_text.dart'; 9 | import '../demo/layout/layout_a.dart'; 10 | import '../demo/layout/layout_b.dart'; 11 | import '../demo/layout/layout_c.dart'; 12 | import '../demo/layout/layout_d.dart'; 13 | import '../demo/layout/layout_wall.dart'; 14 | import '../demo/outro/outro.dart'; 15 | import '../demo/sky/dash.dart'; 16 | import '../demo/sky/sky.dart'; 17 | import '../demo/stars/stars.dart'; 18 | import '../showroom/select.dart'; 19 | 20 | class ShowRoom extends StatefulWidget { 21 | final int index; 22 | final Function(int) onIndexChange; 23 | 24 | const ShowRoom({required this.index, required this.onIndexChange}); 25 | 26 | @override 27 | _ShowRoomState createState() => _ShowRoomState(); 28 | } 29 | 30 | class _ShowRoomState extends State { 31 | Widget displayedWidget = _introText(); 32 | String selectedItem = 'Pick a widget here...'; 33 | 34 | void changeWidgetFromOutside(int index) { 35 | setState(() { 36 | var allWidgets = WIDGETS.entries.toList(); 37 | try { 38 | selectedItem = allWidgets[widget.index].key; 39 | displayedWidget = allWidgets[widget.index].value(); 40 | } catch (e) { 41 | selectedItem = allWidgets[0].key; 42 | displayedWidget = allWidgets[0].value(); 43 | } 44 | }); 45 | } 46 | 47 | void changeWidgetInternally(String key) { 48 | var allWidgets = WIDGETS.entries.toList(); 49 | var index = allWidgets.indexWhere((element) => element.key == key); 50 | widget.onIndexChange(index); 51 | } 52 | 53 | @override 54 | void initState() { 55 | changeWidgetFromOutside(widget.index); 56 | super.initState(); 57 | } 58 | 59 | @override 60 | void didUpdateWidget(covariant ShowRoom oldWidget) { 61 | changeWidgetFromOutside(widget.index); 62 | super.didUpdateWidget(oldWidget); 63 | } 64 | 65 | @override 66 | Widget build(BuildContext context) { 67 | return LayoutBuilder(builder: (context, constraints) { 68 | var smallScreen = constraints.maxWidth < 700; 69 | var spacing = smallScreen ? 0.0 : 32.0; 70 | 71 | return Container( 72 | color: '#333333'.toColor(), 73 | child: Column( 74 | children: [ 75 | Container( 76 | height: 50.0, 77 | padding: EdgeInsets.symmetric(horizontal: spacing), 78 | color: Colors.black.withOpacity(0.3), 79 | child: Row( 80 | children: [ 81 | Padding( 82 | padding: EdgeInsets.only(left: smallScreen ? 16 : 0), 83 | child: LargeText( 84 | 'ShowRoom', 85 | bold: true, 86 | textSize: smallScreen ? 14 : 18, 87 | ), 88 | ), 89 | Spacer(), 90 | PropertySelect( 91 | value: selectedItem, 92 | onChanged: (newValue) { 93 | changeWidgetInternally(newValue!); 94 | }, 95 | options: WIDGETS.keys.toList(), 96 | ) 97 | ], 98 | ), 99 | ), 100 | Expanded( 101 | flex: 1, 102 | child: Center( 103 | child: Padding( 104 | padding: EdgeInsets.all(spacing), 105 | child: displayedWidget, 106 | ), 107 | )) 108 | ], 109 | ), 110 | ); 111 | }); 112 | } 113 | } 114 | 115 | var WIDGETS = { 116 | 'Pick a widget here...': () => _introText(), 117 | 'Layout A': () => _square(LayoutA()), 118 | 'Layout B': () => _square(LayoutB()), 119 | 'Layout C': () => _square(LayoutC()), 120 | 'Layout D': () => _square(LayoutD()), 121 | 'Layout Wall': () => LayoutWall(), 122 | 'Plasma 1 (blue)': () => 123 | FancyPlasmaWidget1(color: Colors.blue.withOpacity(0.4)), 124 | 'Plasma 1 (red)': () => 125 | FancyPlasmaWidget1(color: Colors.red.withOpacity(0.4)), 126 | 'Plasma 1 (yellow)': () => 127 | FancyPlasmaWidget1(color: Colors.yellow.withOpacity(0.4)), 128 | 'Plasma 1 (green)': () => 129 | FancyPlasmaWidget1(color: Colors.green.withOpacity(0.4)), 130 | 'Plasma 2 (blue)': () => 131 | FancyPlasmaWidget2(color: Colors.blue.withOpacity(0.4)), 132 | 'Plasma 2 (red)': () => 133 | FancyPlasmaWidget2(color: Colors.red.withOpacity(0.4)), 134 | 'Plasma 2 (yellow)': () => 135 | FancyPlasmaWidget2(color: Colors.yellow.withOpacity(0.4)), 136 | 'Plasma 2 (green)': () => 137 | FancyPlasmaWidget2(color: Colors.green.withOpacity(0.4)), 138 | 'Plasma 3': () => OtherPlasma1(), 139 | 'Plasma 4': () => OtherPlasma2(), 140 | 'Plasma 5': () => FancyPlasma2(), 141 | 'Sky': () => Sky(), 142 | 'Dash': () => DashAnimation(), 143 | 'Stars': () => Stars(), 144 | 'Outro': () => Outro(), 145 | }; 146 | 147 | Widget _square(Widget child) => AspectRatio( 148 | aspectRatio: 1, 149 | child: child, 150 | ); 151 | 152 | Widget _introText() { 153 | return Padding( 154 | padding: const EdgeInsets.all(16.0), 155 | child: LargeText( 156 | 'Use the select box on the top right to navigate between screens.', 157 | textSize: 16, 158 | ), 159 | ); 160 | } 161 | 162 | Widget Function() stringToWidgetBuilder(String string) { 163 | return WIDGETS.entries.firstWhere((w) => w.key == string).value; 164 | } 165 | -------------------------------------------------------------------------------- /lib/demo/outro/outro.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:simple_animations/simple_animations.dart'; 3 | import 'package:supercharged/supercharged.dart'; 4 | 5 | import '../caching_builder.dart'; 6 | import '../intro/large_text.dart'; 7 | 8 | class Outro extends StatelessWidget { 9 | final VoidCallback? onComplete; 10 | 11 | Outro({this.onComplete}); 12 | 13 | @override 14 | Widget build(BuildContext context) { 15 | return LayoutBuilder(builder: (context, constraints) { 16 | var fontSize = constraints.maxHeight * 0.04; 17 | var tween = _createTween(constraints); 18 | 19 | return CustomAnimation>( 20 | tween: tween, 21 | duration: tween.duration, 22 | builder: (context, child, value) { 23 | return Stack( 24 | children: [ 25 | /* // Background effect disabled to improve performance 26 | Positioned.fill( 27 | child: Opacity( 28 | opacity: value.get(_P.opacityBackground), 29 | child: _Background())), 30 | */ 31 | Positioned.fill(child: _buildScrollingText(value, fontSize)), 32 | ], 33 | ); 34 | }, 35 | animationStatusListener: (status) { 36 | if (status == AnimationStatus.completed) { 37 | onComplete!(); 38 | } 39 | }, 40 | ); 41 | }); 42 | } 43 | 44 | ClipRect _buildScrollingText(TimelineValue<_P> value, double fontSize) { 45 | return ClipRect( 46 | child: OverflowBox( 47 | maxHeight: double.infinity, 48 | alignment: Alignment.topCenter, 49 | child: Transform.translate( 50 | offset: Offset(0, value.get(_P.scroll)), 51 | child: Container( 52 | alignment: Alignment.topCenter, 53 | child: Column( 54 | mainAxisSize: MainAxisSize.min, 55 | children: _buildContent(fontSize, value), 56 | ), 57 | ), 58 | ), 59 | ), 60 | ); 61 | } 62 | 63 | List _buildContent(double fontSize, TimelineValue<_P> value) { 64 | return [ 65 | _buildText('created by', 'Felix Blaschke', fontSize), 66 | Opacity( 67 | opacity: value.get(_P.opacityOther), 68 | child: CachingBuilder( 69 | cacheKey: fontSize, 70 | builder: (context) { 71 | return RepaintBoundary( 72 | child: Column( 73 | mainAxisSize: MainAxisSize.min, 74 | children: [ 75 | _buildSpacer(fontSize), 76 | _buildText('directed by', 'Felix Blaschke\nMandy Blaschke', 77 | fontSize), 78 | _buildSpacer(fontSize), 79 | _buildText('Artwork by', 'Mandy Blaschke', fontSize), 80 | _buildSpacer(fontSize), 81 | _buildText('Made with', 'Flutter', fontSize), 82 | _buildSpacer(fontSize), 83 | _buildText( 84 | 'animation package used', 'simple_animations', fontSize), 85 | _buildSpacer(fontSize), 86 | _buildText('Special thanks to', 'The Flutter Team', fontSize), 87 | Container( 88 | height: fontSize * 0.2, 89 | ), 90 | LargeText('for creating this awesome technology.', 91 | textSize: fontSize * 0.43), 92 | ], 93 | ), 94 | ); 95 | }, 96 | ), 97 | ) 98 | ]; 99 | } 100 | 101 | Container _buildSpacer(double fontSize) { 102 | return Container( 103 | height: 6 * fontSize, 104 | ); 105 | } 106 | 107 | Widget _buildText(String title, String content, double fontSize) { 108 | return LayoutBuilder(builder: (context, constraints) { 109 | return Column( 110 | mainAxisSize: MainAxisSize.min, 111 | children: [ 112 | LargeText( 113 | title.toUpperCase(), 114 | textSize: fontSize * 0.5, 115 | bold: true, 116 | ), 117 | Container(height: fontSize * 0.5), 118 | LargeText(content, textSize: fontSize), 119 | ], 120 | ); 121 | }); 122 | } 123 | } 124 | 125 | enum _P { scroll, opacityOther, opacityBackground } 126 | 127 | TimelineTween<_P> _createTween(BoxConstraints constraints) { 128 | var tween = TimelineTween<_P>(); 129 | 130 | tween 131 | .addScene(begin: 2.seconds, duration: 700.milliseconds) 132 | .animate(_P.opacityOther, tween: (0.0).tweenTo(1.0)); 133 | 134 | tween 135 | .addScene(begin: 1.seconds, duration: 300.milliseconds) 136 | .animate(_P.opacityBackground, tween: (0.0).tweenTo(1.0)); 137 | 138 | tween.addScene(begin: 2.seconds, end: 25.seconds).animate(_P.scroll, 139 | tween: 140 | (constraints.maxHeight * 0.45).tweenTo(-constraints.maxHeight * 1.6)); 141 | 142 | tween 143 | .addScene(end: 25.seconds, duration: 700.milliseconds) 144 | .animate(_P.opacityBackground, tween: (1.0).tweenTo(0.0)) 145 | .animate(_P.opacityOther, tween: (1.0).tweenTo(0.0)); 146 | 147 | return tween; 148 | } 149 | 150 | class _Background extends StatelessWidget { 151 | @override 152 | Widget build(BuildContext context) { 153 | return Container( 154 | decoration: BoxDecoration( 155 | color: Color(0xff092452), 156 | backgroundBlendMode: BlendMode.srcOver, 157 | ), 158 | child: PlasmaRenderer( 159 | type: PlasmaType.infinity, 160 | particles: 10, 161 | color: Color(0xd0010101), 162 | blur: 0.74, 163 | size: 0.87, 164 | speed: 4, 165 | offset: 0, 166 | blendMode: BlendMode.darken, 167 | variation1: 0, 168 | variation2: 0, 169 | variation3: 0, 170 | rotation: -3.14, 171 | ), 172 | ); 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /lib/demo/fancy_plasma1/fancy_plasma1.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:simple_animations/simple_animations.dart'; 3 | import 'package:supercharged/supercharged.dart'; 4 | 5 | import '../demo_screen.dart'; 6 | import 'fancy_widgets1.dart'; 7 | import 'other_plasma1.dart'; 8 | import 'other_plasma2.dart'; 9 | 10 | class FancyPlasma1 extends StatelessWidget { 11 | @override 12 | Widget build(BuildContext context) { 13 | final tween = _createTween(); 14 | 15 | return LayoutBuilder(builder: (context, constraints) { 16 | final ratio = constraints.maxWidth / constraints.maxHeight; 17 | 18 | return PlayAnimation>( 19 | tween: tween, 20 | duration: tween.duration, 21 | builder: (context, child, value) { 22 | final p1Scale = value.get(_P.p1Scale); 23 | final p2Scale = value.get(_P.p2Scale); 24 | 25 | final p2 = Positioned.fill( 26 | key: Key('p2'), 27 | child: Transform.scale( 28 | alignment: Alignment.topLeft, 29 | scale: value.get(_P.p2Scale), 30 | child: AspectRatio( 31 | aspectRatio: ratio, 32 | child: _buildPlasma2(value), 33 | )), 34 | ); 35 | 36 | final stackWidgets = [ 37 | if (p1Scale < 1 || p2Scale < 1) 38 | Positioned.fill( 39 | key: Key('p3'), 40 | child: Transform.scale( 41 | alignment: Alignment.topRight, 42 | scale: 0.5, 43 | child: AspectRatio( 44 | aspectRatio: ratio, 45 | child: OtherPlasma1(), 46 | )), 47 | ), 48 | if (p1Scale < 1 || p2Scale < 1) 49 | Positioned.fill( 50 | key: Key('p4'), 51 | child: Transform.scale( 52 | alignment: Alignment.bottomLeft, 53 | scale: 0.5, 54 | child: AspectRatio( 55 | aspectRatio: ratio, 56 | child: OtherPlasma2(), 57 | )), 58 | ), 59 | Positioned.fill( 60 | key: Key('p1'), 61 | child: Transform.scale( 62 | alignment: Alignment.bottomRight, 63 | scale: value.get(_P.p1Scale), 64 | child: AspectRatio( 65 | aspectRatio: ratio, 66 | child: _buildPlasma1(value), 67 | )), 68 | ), 69 | ]; 70 | 71 | if (p1Scale < 1.0) { 72 | if (p2Scale > 0.5) { 73 | stackWidgets.add(p2); 74 | } else { 75 | stackWidgets.insert(0, p2); 76 | } 77 | } 78 | 79 | return Stack( 80 | children: stackWidgets, 81 | ); 82 | }); 83 | }); 84 | } 85 | 86 | Widget _buildPlasma1(TimelineValue<_P> value) { 87 | return FancyPlasmaWidget1(color: value.get(_P.p1Color)); 88 | } 89 | 90 | Widget _buildPlasma2(TimelineValue<_P> value) { 91 | return FancyPlasmaWidget2(color: value.get(_P.p2Color)); 92 | } 93 | } 94 | 95 | enum _P { p1Scale, p2Scale, p1Color, p2Color } 96 | 97 | TimelineTween<_P> _createTween() { 98 | final tween = TimelineTween<_P>(); 99 | 100 | final red = Colors.red.withOpacity(0.4); 101 | final blue = Colors.blue.withOpacity(0.4); 102 | final yellow = Colors.yellow.shade800.withOpacity(0.4); 103 | final green = Colors.green.shade500.withOpacity(0.4); 104 | 105 | // B1 -> B2 106 | tween 107 | .addScene( 108 | duration: 200.milliseconds, 109 | begin: (0.25 * MUSIC_UNIT_MS).round().milliseconds, 110 | curve: Curves.easeIn, 111 | ) 112 | .animate(_P.p1Color, tween: red.tweenTo(blue)); 113 | 114 | // B2 -> B3 115 | tween 116 | .addScene( 117 | duration: 200.milliseconds, 118 | begin: (0.5 * MUSIC_UNIT_MS).round().milliseconds, 119 | curve: Curves.easeIn, 120 | ) 121 | .animate(_P.p1Color, tween: blue.tweenTo(yellow)); 122 | 123 | // B3 -> B4 124 | tween 125 | .addScene( 126 | duration: 200.milliseconds, 127 | begin: (0.75 * MUSIC_UNIT_MS).round().milliseconds, 128 | curve: Curves.easeIn, 129 | ) 130 | .animate(_P.p1Color, tween: yellow.tweenTo(green)); 131 | 132 | // Unit swap 133 | tween 134 | .addScene( 135 | begin: (0.75 * MUSIC_UNIT_MS).round().milliseconds, 136 | duration: 500.milliseconds, 137 | curve: Curves.easeInOut, 138 | ) 139 | .animate(_P.p1Scale, tween: 1.0.tweenTo(0.5)); 140 | tween 141 | .addScene( 142 | duration: 500.milliseconds, 143 | begin: (1.0 * MUSIC_UNIT_MS).round().milliseconds, 144 | curve: Curves.easeInOut) 145 | .animate( 146 | _P.p2Scale, 147 | tween: 0.5.tweenTo(1.0), 148 | ); 149 | 150 | // B1 -> B2 (no gong) 151 | tween 152 | .addScene( 153 | begin: (1.2 * MUSIC_UNIT_MS).round().milliseconds, 154 | end: (1.3 * MUSIC_UNIT_MS).round().milliseconds, 155 | ) 156 | .animate(_P.p2Color, tween: green.tweenTo(red)); 157 | 158 | // B2 -> B3 159 | tween 160 | .addScene( 161 | duration: 200.milliseconds, 162 | begin: (1.5 * MUSIC_UNIT_MS).round().milliseconds, 163 | curve: Curves.easeIn, 164 | ) 165 | .animate(_P.p2Color, tween: red.tweenTo(blue)); 166 | 167 | // B3 -> B4 168 | tween 169 | .addScene( 170 | duration: 200.milliseconds, 171 | begin: (1.75 * MUSIC_UNIT_MS).round().milliseconds, 172 | curve: Curves.easeIn, 173 | ) 174 | .animate(_P.p2Color, tween: blue.tweenTo(yellow)); 175 | 176 | tween.addScene( 177 | end: (2 * MUSIC_UNIT_MS).milliseconds, duration: 1.milliseconds); 178 | 179 | return tween; 180 | } 181 | -------------------------------------------------------------------------------- /lib/demo/startpage/start_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:supercharged/supercharged.dart'; 3 | import 'package:url_launcher/url_launcher.dart'; 4 | 5 | import '../../showroom/gesture_detector_with_click_hover.dart'; 6 | import '../intro/large_text.dart'; 7 | 8 | class StartPage extends StatelessWidget { 9 | final Function() pressedStart; 10 | 11 | const StartPage({required this.pressedStart}); 12 | 13 | @override 14 | Widget build(BuildContext context) { 15 | return Stack( 16 | children: [ 17 | _buildPreload(), 18 | Positioned.fill( 19 | child: _Background( 20 | child: Padding( 21 | padding: const EdgeInsets.all(32.0), 22 | child: Center( 23 | child: Container( 24 | constraints: BoxConstraints.expand(width: 700), 25 | child: Center( 26 | child: _buildPageContent(), 27 | ), 28 | ), 29 | ), 30 | ), 31 | ), 32 | ), 33 | ], 34 | ); 35 | } 36 | 37 | Column _buildPageContent() { 38 | return Column( 39 | crossAxisAlignment: CrossAxisAlignment.stretch, 40 | children: [ 41 | SelectableText('Flutter Plasma', style: h1()), 42 | Container(height: 24), 43 | SelectableText( 44 | 'This demo shows the capabilities of Flutter in the web.', 45 | style: normal()), 46 | Container(height: 16), 47 | _Li( 48 | child: SelectableText.rich( 49 | TextSpan( 50 | children: [ 51 | TextSpan(text: 'This is ', style: normal()), 52 | TextSpan(text: 'not a video', style: bold()), 53 | TextSpan( 54 | text: '. No prebuilt visual assets are used.', 55 | style: normal()), 56 | ], 57 | ), 58 | )), 59 | Container(height: 16), 60 | _Li( 61 | child: SelectableText('Turn on your sound.', style: normal()), 62 | ), 63 | Container(height: 16), 64 | _Li( 65 | child: SelectableText('Enjoy the show.', style: normal()), 66 | ), 67 | Container(height: 32), 68 | SelectableText.rich( 69 | TextSpan( 70 | children: [ 71 | TextSpan(text: 'Seizure warning', style: bold()), 72 | TextSpan( 73 | text: 74 | ': Don\'t watch this demo if you suffer from photosensitive epilepsy.', 75 | style: normal()), 76 | ], 77 | ), 78 | ), 79 | Container(height: 32), 80 | Container( 81 | alignment: Alignment.center, 82 | child: GestureDetectorWithClickHover( 83 | onTap: pressedStart, 84 | child: Padding( 85 | padding: const EdgeInsets.all(16.0), 86 | child: Text('Play demo', style: link()), 87 | ), 88 | ), 89 | ), 90 | Spacer(), 91 | Container( 92 | alignment: Alignment.center, 93 | child: GestureDetectorWithClickHover( 94 | onTap: viewSourceCode, 95 | child: Padding( 96 | padding: const EdgeInsets.all(8.0), 97 | child: Text('View source code', style: link()), 98 | ), 99 | ), 100 | ) 101 | ], 102 | ); 103 | } 104 | 105 | TextStyle normal() => TextStyle(fontSize: 16, color: Colors.black); 106 | 107 | TextStyle link() => TextStyle( 108 | fontSize: 16, 109 | color: 'blue'.toColor(), 110 | decoration: TextDecoration.underline); 111 | 112 | TextStyle bold() => normal().copyWith(fontWeight: FontWeight.bold); 113 | 114 | TextStyle h1() => 115 | TextStyle(fontSize: 24, fontWeight: FontWeight.bold, color: Colors.black); 116 | 117 | Positioned _buildPreload() { 118 | return Positioned.fill( 119 | child: Opacity( 120 | opacity: 0.0, 121 | child: Row( 122 | mainAxisSize: MainAxisSize.min, 123 | children: [ 124 | LargeText( 125 | 'a', 126 | textSize: 16, 127 | bold: false, 128 | ), 129 | LargeText( 130 | 'b', 131 | textSize: 16, 132 | bold: true, 133 | ), 134 | ], 135 | ), 136 | )); 137 | } 138 | 139 | void viewSourceCode() async { 140 | var url = 'https://github.com/felixblaschke/flutterplasma/'; 141 | if (await canLaunch(url)) { 142 | await launch(url); 143 | } 144 | } 145 | } 146 | 147 | class _Li extends StatelessWidget { 148 | final Widget child; 149 | 150 | const _Li({required this.child}); 151 | 152 | @override 153 | Widget build(BuildContext context) { 154 | return Row( 155 | crossAxisAlignment: CrossAxisAlignment.start, 156 | children: [ 157 | Padding( 158 | padding: const EdgeInsets.only(top: 6.0), 159 | child: Container( 160 | decoration: BoxDecoration( 161 | color: Colors.black, 162 | borderRadius: BorderRadius.all(Radius.circular(3.5))), 163 | width: 7, 164 | height: 7, 165 | ), 166 | ), 167 | Expanded( 168 | flex: 1, 169 | child: Padding( 170 | padding: const EdgeInsets.only(left: 8.0), 171 | child: child, 172 | ), 173 | ) 174 | ], 175 | ); 176 | } 177 | } 178 | 179 | class _Background extends StatelessWidget { 180 | final Widget child; 181 | 182 | const _Background({required this.child}); 183 | 184 | @override 185 | Widget build(BuildContext context) { 186 | return Container( 187 | constraints: BoxConstraints.expand(), 188 | decoration: BoxDecoration( 189 | gradient: LinearGradient( 190 | tileMode: TileMode.mirror, 191 | begin: Alignment.topLeft, 192 | end: Alignment.bottomRight, 193 | colors: [ 194 | Color(0xffeeeeee), 195 | Color(0xff93b4cf), 196 | ], 197 | stops: [ 198 | 0, 199 | 1, 200 | ], 201 | ), 202 | ), 203 | child: child, 204 | ); 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /lib/demo/sky/sky.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:simple_animations/simple_animations.dart'; 3 | import 'package:supercharged/supercharged.dart'; 4 | 5 | import '../demo_screen.dart'; 6 | import 'dash.dart'; 7 | 8 | class Sky extends StatelessWidget { 9 | @override 10 | Widget build(BuildContext context) { 11 | final tween = _createTween(); 12 | 13 | return LayoutBuilder(builder: (context, constraints) { 14 | return LoopAnimation>( 15 | tween: tween, 16 | duration: tween.duration, 17 | builder: (context, child, value) { 18 | var otherDashes = value.get(_P.otherDashes); 19 | 20 | return Stack( 21 | children: [ 22 | Positioned.fill(child: SkyGradient()), 23 | Positioned.fill(child: CloudsPlasma()), 24 | if (otherDashes > 0) 25 | Positioned.fill(child: OtherDashes(otherDashes)), 26 | Positioned( 27 | left: value.get(_P.left1) * constraints.maxWidth, 28 | top: value.get(_P.top1) * constraints.maxHeight, 29 | width: value.get(_P.size1) * constraints.maxWidth, 30 | height: value.get(_P.size1) * constraints.maxWidth, 31 | child: Transform.rotate( 32 | angle: value.get(_P.rotate1), 33 | child: DashAnimation(), 34 | ), 35 | ), 36 | Positioned.fill(child: ForegroundCloudsPlasma()), 37 | ], 38 | ); 39 | }); 40 | }); 41 | } 42 | } 43 | 44 | class OtherDashes extends StatelessWidget { 45 | OtherDashes(this.otherDashes); 46 | 47 | final double otherDashes; 48 | 49 | @override 50 | Widget build(BuildContext context) { 51 | return MirrorAnimation( 52 | tween: 0.0.tweenTo(1.0), 53 | duration: 300.milliseconds, 54 | builder: (context, child, value) { 55 | return CustomPaint(painter: MultiDashPainter(otherDashes, value)); 56 | }); 57 | } 58 | } 59 | 60 | enum _P { left1, top1, size1, rotate1, otherDashes } 61 | 62 | TimelineTween<_P> _createTween() { 63 | final tween = TimelineTween<_P>(); 64 | 65 | tween 66 | .addScene( 67 | begin: (0.0 * MUSIC_UNIT_MS).round().milliseconds, 68 | end: (0.25 * MUSIC_UNIT_MS).round().milliseconds, 69 | curve: Curves.easeOut, 70 | ) 71 | .animate(_P.left1, tween: (1.05).tweenTo(0.2)) 72 | .animate(_P.top1, tween: (0.6).tweenTo(0.3)) 73 | .animate(_P.size1, tween: (0.4).tweenTo(0.3)); 74 | 75 | tween 76 | .addScene( 77 | begin: (0.25 * MUSIC_UNIT_MS).round().milliseconds, 78 | end: (0.5 * MUSIC_UNIT_MS).round().milliseconds, 79 | curve: Curves.easeInOut) 80 | .animate(_P.left1, tween: (0.2).tweenTo(0.3)) 81 | .animate(_P.top1, tween: (0.3).tweenTo(0.4)) 82 | .animate(_P.size1, tween: (0.3).tweenTo(0.35)); 83 | 84 | tween 85 | .addScene( 86 | begin: (0.5 * MUSIC_UNIT_MS).round().milliseconds, 87 | end: (0.75 * MUSIC_UNIT_MS).round().milliseconds, 88 | curve: Curves.easeInOut) 89 | .animate(_P.left1, tween: (0.3).tweenTo(0.2)) 90 | .animate(_P.top1, tween: (0.4).tweenTo(0.3)) 91 | .animate(_P.size1, tween: (0.35).tweenTo(0.3)); 92 | 93 | tween 94 | .addScene( 95 | begin: (0.50 * MUSIC_UNIT_MS).round().milliseconds, 96 | end: (1.0 * MUSIC_UNIT_MS).round().milliseconds, 97 | curve: Curves.easeOut, 98 | ) 99 | .animate(_P.otherDashes, tween: (0.0).tweenTo(1.0)); 100 | 101 | final fallIntoSwarm = tween 102 | .addScene( 103 | begin: (0.75 * MUSIC_UNIT_MS).round().milliseconds, 104 | end: (0.83 * MUSIC_UNIT_MS).round().milliseconds, 105 | curve: Curves.easeOut, 106 | ) 107 | .animate(_P.rotate1, 108 | tween: (0.1).tweenTo(0.35), 109 | shiftEnd: -400.milliseconds, 110 | curve: Curves.easeInOut) 111 | .animate(_P.left1, tween: (0.2).tweenTo(0.35)) 112 | .animate(_P.top1, tween: (0.3).tweenTo(0.4)) 113 | .animate(_P.size1, tween: (0.3).tweenTo(0.2)); 114 | 115 | fallIntoSwarm 116 | .addSubsequentScene(duration: (0.17 * MUSIC_UNIT_MS).round().milliseconds) 117 | .animate(_P.top1, tween: (0.4).tweenTo(-0.8)) 118 | .animate(_P.left1, tween: (0.35).tweenTo(0.25)); 119 | 120 | tween.addScene(end: (MUSIC_UNIT_MS).milliseconds, duration: 1.milliseconds); 121 | 122 | return tween; 123 | } 124 | 125 | class SkyGradient extends StatelessWidget { 126 | @override 127 | Widget build(BuildContext context) { 128 | return Container( 129 | decoration: BoxDecoration( 130 | gradient: LinearGradient( 131 | tileMode: TileMode.mirror, 132 | begin: Alignment.topCenter, 133 | end: Alignment.bottomCenter, 134 | colors: [ 135 | Color(0xff214c8f), 136 | Color(0xff4999d9), 137 | ], 138 | stops: [ 139 | 0, 140 | 1, 141 | ], 142 | ), 143 | backgroundBlendMode: BlendMode.srcOver, 144 | ), 145 | ); 146 | } 147 | } 148 | 149 | class CloudsPlasma extends StatelessWidget { 150 | @override 151 | Widget build(BuildContext context) { 152 | return PlasmaRenderer( 153 | type: PlasmaType.bubbles, 154 | particles: 39, 155 | color: Color(0x44ffffff), 156 | blur: 0.55, 157 | size: 1.44, 158 | speed: 3.88, 159 | offset: 0, 160 | blendMode: BlendMode.srcOver, 161 | variation1: 0, 162 | variation2: 0, 163 | variation3: 0, 164 | rotation: 1.63, 165 | ); 166 | } 167 | } 168 | 169 | class ForegroundCloudsPlasma extends StatelessWidget { 170 | @override 171 | Widget build(BuildContext context) { 172 | return PlasmaRenderer( 173 | type: PlasmaType.bubbles, 174 | particles: 10, 175 | color: Color(0x66ffffff), 176 | blur: 0.55, 177 | size: 2.44, 178 | speed: 3.88, 179 | offset: 0, 180 | blendMode: BlendMode.srcOver, 181 | variation1: 0, 182 | variation2: 0, 183 | variation3: 0, 184 | rotation: 1.63, 185 | ); 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /lib/demo/fancy_plasma2/fancy_plasma2.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:simple_animations/simple_animations.dart'; 3 | import 'package:supercharged/supercharged.dart'; 4 | 5 | import '../demo_screen.dart'; 6 | 7 | class FancyPlasma2 extends StatelessWidget { 8 | @override 9 | Widget build(BuildContext context) { 10 | final tween = _createTween(); 11 | 12 | return LayoutBuilder(builder: (context, constraints) { 13 | final ratio = constraints.maxWidth / constraints.maxHeight; 14 | 15 | return MirrorAnimation>( 16 | tween: tween, 17 | duration: tween.duration, 18 | builder: (context, child, value) { 19 | return _gradient( 20 | child: Stack( 21 | children: [ 22 | Positioned.fill( 23 | child: Transform.scale( 24 | alignment: Alignment.topLeft, 25 | scale: value.get(_P.scale), 26 | child: AspectRatio( 27 | aspectRatio: ratio, 28 | child: PlasmaPart1(), 29 | ), 30 | ), 31 | ), 32 | Positioned.fill( 33 | child: Transform.scale( 34 | alignment: Alignment.topRight, 35 | scale: value.get(_P.scale), 36 | child: AspectRatio( 37 | aspectRatio: ratio, 38 | child: PlasmaPart2(), 39 | ), 40 | ), 41 | ), 42 | Positioned.fill( 43 | child: Transform.scale( 44 | alignment: Alignment.bottomLeft, 45 | scale: value.get(_P.scale), 46 | child: AspectRatio( 47 | aspectRatio: ratio, 48 | child: PlasmaPart3(), 49 | ), 50 | ), 51 | ), 52 | Positioned.fill( 53 | child: Transform.scale( 54 | alignment: Alignment.bottomRight, 55 | scale: value.get(_P.scale), 56 | child: AspectRatio( 57 | aspectRatio: ratio, 58 | child: PlasmaPart4(), 59 | ), 60 | ), 61 | ), 62 | ], 63 | ), 64 | value: value); 65 | }); 66 | }); 67 | } 68 | 69 | Widget _gradient({Widget? child, required TimelineValue<_P> value}) { 70 | return Container( 71 | decoration: BoxDecoration( 72 | gradient: LinearGradient( 73 | tileMode: TileMode.mirror, 74 | begin: Alignment.topLeft, 75 | end: Alignment.bottomRight, 76 | colors: [ 77 | value.get(_P.gradient1), 78 | value.get(_P.gradient2), 79 | ], 80 | stops: [ 81 | 0, 82 | 1, 83 | ], 84 | ), 85 | backgroundBlendMode: BlendMode.srcOver, 86 | ), 87 | child: child, 88 | ); 89 | } 90 | } 91 | 92 | enum _P { scale, gradient1, gradient2 } 93 | 94 | TimelineTween<_P> _createTween() { 95 | // TODO change colors in 2nd unit on each beat (3 color changes) 96 | 97 | final tween = TimelineTween<_P>(); 98 | tween 99 | .addScene( 100 | begin: (0.5 * MUSIC_UNIT_MS).round().milliseconds, 101 | end: MUSIC_UNIT_MS.milliseconds, 102 | curve: Curves.easeInOut, 103 | ) 104 | .animate(_P.scale, tween: (0.5).tweenTo(1.0)); 105 | 106 | final purple1 = Color(0xff743496); 107 | final purple2 = Color(0xff31083b); 108 | final green1 = Color(0xff1CAB12); 109 | final green2 = Color(0xff095903); 110 | final red1 = Color(0xffCC2C08); 111 | final red2 = Color(0xff761802); 112 | final pink1 = Color(0xffC41091); 113 | final pink2 = Color(0xff760252); 114 | 115 | tween 116 | .addScene( 117 | begin: (1.25 * MUSIC_UNIT_MS).round().milliseconds, 118 | duration: 200.milliseconds, 119 | ) 120 | .animate(_P.gradient1, tween: purple1.tweenTo(green1)) 121 | .animate(_P.gradient2, tween: purple2.tweenTo(green2)); 122 | 123 | tween 124 | .addScene( 125 | begin: (1.5 * MUSIC_UNIT_MS).round().milliseconds, 126 | duration: 200.milliseconds, 127 | ) 128 | .animate(_P.gradient1, tween: green1.tweenTo(red1)) 129 | .animate(_P.gradient2, tween: green2.tweenTo(red2)); 130 | 131 | tween 132 | .addScene( 133 | begin: (1.75 * MUSIC_UNIT_MS).round().milliseconds, 134 | duration: 200.milliseconds, 135 | ) 136 | .animate(_P.gradient1, tween: red1.tweenTo(pink1)) 137 | .animate(_P.gradient2, tween: red2.tweenTo(pink2)); 138 | 139 | tween.addScene( 140 | end: (2 * MUSIC_UNIT_MS).round().milliseconds, duration: 1.milliseconds); 141 | 142 | return tween; 143 | } 144 | 145 | class PlasmaPart1 extends StatelessWidget { 146 | @override 147 | Widget build(BuildContext context) { 148 | return PlasmaRenderer( 149 | type: PlasmaType.infinity, 150 | particles: 6, 151 | color: Color(0x44e45a23), 152 | blur: 0.4, 153 | size: 1, 154 | speed: 7.18, 155 | offset: 0, 156 | blendMode: BlendMode.plus, 157 | variation1: 0, 158 | variation2: 0, 159 | variation3: 0, 160 | rotation: 0, 161 | ); 162 | } 163 | } 164 | 165 | class PlasmaPart2 extends StatelessWidget { 166 | @override 167 | Widget build(BuildContext context) { 168 | return PlasmaRenderer( 169 | type: PlasmaType.bubbles, 170 | particles: 23, 171 | color: Color(0x2963a6e1), 172 | blur: 0.16, 173 | size: 0.51, 174 | speed: 1.35, 175 | offset: 0, 176 | blendMode: BlendMode.screen, 177 | variation1: 0.31, 178 | variation2: 0.3, 179 | variation3: 0.13, 180 | rotation: 1.05, 181 | ); 182 | } 183 | } 184 | 185 | class PlasmaPart3 extends StatelessWidget { 186 | @override 187 | Widget build(BuildContext context) { 188 | return PlasmaRenderer( 189 | type: PlasmaType.infinity, 190 | particles: 10, 191 | color: Color(0x447be423), 192 | blur: 0.4, 193 | size: 1, 194 | speed: 1, 195 | offset: 0, 196 | blendMode: BlendMode.plus, 197 | variation1: 0.72, 198 | variation2: 0, 199 | variation3: 0, 200 | rotation: 0, 201 | ); 202 | } 203 | } 204 | 205 | class PlasmaPart4 extends StatelessWidget { 206 | @override 207 | Widget build(BuildContext context) { 208 | return PlasmaRenderer( 209 | type: PlasmaType.circle, 210 | particles: 10, 211 | color: Color(0x441290d5), 212 | blur: 0.4, 213 | size: 1, 214 | speed: 1, 215 | offset: 0, 216 | blendMode: BlendMode.plus, 217 | variation1: 0, 218 | variation2: 0, 219 | variation3: 0, 220 | rotation: 0, 221 | ); 222 | } 223 | } 224 | -------------------------------------------------------------------------------- /lib/demo/intro/intro.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:simple_animations/simple_animations.dart'; 5 | import 'package:supercharged/supercharged.dart'; 6 | 7 | import '../demo_screen.dart'; 8 | import 'large_text.dart'; 9 | 10 | class Intro extends StatelessWidget { 11 | @override 12 | Widget build(BuildContext context) { 13 | return LayoutBuilder(builder: (context, constraints) { 14 | final tween = _createTween(constraints); 15 | return PlayAnimation>( 16 | tween: tween, 17 | duration: tween.duration, 18 | builder: (context, child, value) { 19 | final textFadeOut = value.get(_P.textFadeOut); 20 | 21 | return Opacity( 22 | opacity: value.get(_P.sceneOpacity), 23 | child: Stack( 24 | children: [ 25 | Positioned.fill(child: _buildBackground(value)), 26 | if (textFadeOut < 1) 27 | Positioned.fill( 28 | child: Opacity( 29 | opacity: 1 - textFadeOut, 30 | child: Align( 31 | alignment: Alignment.center, 32 | child: _buildText(constraints, value), 33 | ), 34 | )) 35 | ], 36 | ), 37 | ); 38 | }); 39 | }); 40 | } 41 | 42 | Container _buildBackground(TimelineValue<_P> value) { 43 | return Container( 44 | decoration: BoxDecoration( 45 | gradient: LinearGradient( 46 | tileMode: TileMode.mirror, 47 | begin: Alignment.topCenter, 48 | end: Alignment.bottomCenter, 49 | colors: [ 50 | Color(0xff48066e), 51 | Color(0xff0c0117), 52 | ], 53 | stops: [ 54 | 0, 55 | 1, 56 | ], 57 | ), 58 | backgroundBlendMode: BlendMode.srcOver, 59 | ), 60 | child: PlasmaRenderer( 61 | type: PlasmaType.infinity, 62 | particles: 10, 63 | color: Color(0x0dec2f0a), 64 | blur: 0.4, 65 | size: 1, 66 | speed: value.get(_P.plasmaSpeed), 67 | offset: 0, 68 | blendMode: BlendMode.screen, 69 | variation1: 0, 70 | variation2: 0, 71 | variation3: 0, 72 | rotation: 0, 73 | ), 74 | ); 75 | } 76 | 77 | Container _buildText(BoxConstraints constraints, TimelineValue<_P> value) { 78 | final size = Size(constraints.maxWidth / 2, 79 | min(constraints.maxHeight / 3, constraints.maxWidth / 3)); 80 | final textSize = size.width * 0.1; 81 | 82 | final t1fade = value.get(_P.t1fade); 83 | final t2fade = value.get(_P.t2fade); 84 | final t3fade = value.get(_P.t3fade); 85 | 86 | return Container( 87 | width: size.width, 88 | height: size.height, 89 | child: Transform.rotate( 90 | angle: -value.get(_P.textRotate), 91 | child: Stack( 92 | children: [ 93 | Positioned( 94 | child: Opacity( 95 | opacity: t1fade, 96 | child: Transform.rotate( 97 | angle: t1fade * -0.12, 98 | child: LargeText('time to', textSize: textSize)), 99 | )), 100 | Positioned( 101 | left: 0, 102 | right: 0, 103 | top: size.height / 2.1 - textSize * 0.75, 104 | child: Center( 105 | child: Transform.scale( 106 | scale: t2fade, 107 | child: LargeText('reimagine', 108 | textSize: textSize * 1.5, bold: true))), 109 | ), 110 | Positioned( 111 | right: size.width * 0.05, 112 | bottom: 0, 113 | child: Opacity( 114 | opacity: t3fade, 115 | child: Transform.translate( 116 | offset: Offset(size.width * 0.1 * (1 - t3fade), 0), 117 | child: Transform.rotate( 118 | angle: t3fade * 0.05, 119 | child: LargeText('web graphics', textSize: textSize)), 120 | ), 121 | )), 122 | ], 123 | ), 124 | ), 125 | ); 126 | } 127 | } 128 | 129 | enum _P { 130 | sceneOpacity, 131 | textFadeOut, 132 | plasmaSpeed, 133 | textRotate, 134 | t1fade, 135 | t2fade, 136 | t3fade, 137 | } 138 | 139 | TimelineTween<_P> _createTween(BoxConstraints constraints) { 140 | final tween = TimelineTween<_P>(); 141 | 142 | final fadeIn = tween 143 | .addScene(begin: 0.milliseconds, end: 800.milliseconds) 144 | .animate(_P.sceneOpacity, tween: 0.0.tweenTo(1.0)); 145 | 146 | final t1 = tween 147 | .addScene( 148 | end: 1738.milliseconds, 149 | duration: 600.milliseconds, 150 | curve: Curves.easeOutCubic, 151 | ) 152 | .animate(_P.t1fade, tween: (0.0).tweenTo(1.0)); 153 | 154 | final t2 = t1 155 | .addSubsequentScene( 156 | delay: 300.milliseconds, 157 | duration: 600.milliseconds, 158 | curve: Curves.easeOutCubic, 159 | ) 160 | .animate(_P.t2fade, tween: (0.0).tweenTo(1.0)); 161 | 162 | final t3 = t2 163 | .addSubsequentScene( 164 | delay: 300.milliseconds, 165 | duration: 600.milliseconds, 166 | curve: Curves.easeOutCubic, 167 | ) 168 | .animate(_P.t3fade, tween: (0.0).tweenTo(1.0)); 169 | 170 | tween 171 | .addScene( 172 | begin: (0.75 * MUSIC_UNIT_MS).round().milliseconds, 173 | end: (1.75 * MUSIC_UNIT_MS).round().milliseconds) 174 | .animate( 175 | _P.textRotate, 176 | tween: 0.0.tweenTo(30 * 2 * pi), 177 | curve: _CustomExponentialCurve(), 178 | ); 179 | 180 | tween 181 | .addScene( 182 | begin: (1.25 * MUSIC_UNIT_MS).round().milliseconds, 183 | end: (1.75 * MUSIC_UNIT_MS).round().milliseconds, 184 | curve: Curves.easeIn) 185 | .animate(_P.textFadeOut, tween: 0.0.tweenTo(1.0)); 186 | 187 | tween 188 | .addScene( 189 | begin: MUSIC_UNIT_MS.milliseconds, 190 | duration: 3.seconds, 191 | curve: Curves.easeIn) 192 | .animate(_P.plasmaSpeed, tween: 0.0.tweenTo(50.0)); 193 | 194 | tween.addScene( 195 | begin: (2 * MUSIC_UNIT_MS).milliseconds, duration: 1.milliseconds); 196 | 197 | return tween; 198 | } 199 | 200 | /// A custom curve that combines [Curves.easeIn] and [Curves.easeInExpo]. 201 | /// This is to prevent the animation to "jump" to motion at the very start 202 | /// when the animation takes a long time. 203 | class _CustomExponentialCurve extends Curve { 204 | const _CustomExponentialCurve(); 205 | 206 | @override 207 | double transformInternal(double t) { 208 | var scale = 1.0; 209 | const easeInPortion = 0.6; 210 | if (t < easeInPortion) { 211 | scale = Curves.easeInOut.transform(t * (1 / easeInPortion)); 212 | } 213 | return Curves.easeInExpo.transformInternal(t) * scale; 214 | } 215 | } 216 | -------------------------------------------------------------------------------- /lib/demo/effects/shatter.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:math'; 3 | import 'dart:ui'; 4 | 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter/rendering.dart'; 7 | import 'package:flutter/services.dart'; 8 | import 'package:simple_animations/simple_animations.dart'; 9 | import 'package:supercharged/supercharged.dart'; 10 | 11 | class ShatterScene extends StatefulWidget { 12 | final Widget Function(BuildContext context, void Function() startScatter)? 13 | builder; 14 | 15 | ShatterScene({this.builder}); 16 | 17 | @override 18 | _ShatterSceneState createState() => _ShatterSceneState(); 19 | } 20 | 21 | class _ShatterSceneState extends State { 22 | var showAnimation = false; 23 | 24 | final _key = GlobalKey(); 25 | 26 | MemoryImage? memoryImage; 27 | 28 | var useFallback = false; 29 | 30 | late List> parts; 31 | 32 | @override 33 | void initState() { 34 | super.initState(); 35 | WidgetsBinding.instance!.addPostFrameCallback((_) => _recordImage()); 36 | } 37 | 38 | @override 39 | Widget build(BuildContext context) { 40 | if (!showAnimation) { 41 | return Stack( 42 | children: [ 43 | if (memoryImage != null) 44 | Positioned.fill( 45 | child: Opacity(opacity: 0.0, child: Image(image: memoryImage!)), 46 | ), 47 | Positioned.fill( 48 | child: RepaintBoundary( 49 | key: _key, 50 | child: widget.builder!(context, _startShatter), 51 | ), 52 | ), 53 | ], 54 | ); 55 | } 56 | 57 | return PlayAnimation( 58 | tween: 0.0.tweenTo(1.0), 59 | duration: 1200.milliseconds, 60 | curve: Curves.easeInSine, 61 | builder: (context, child, value) { 62 | return Stack( 63 | children: parts 64 | .map((part) => Positioned.fill( 65 | child: AnimatedShatter( 66 | points: part, 67 | progress: value, 68 | child: !useFallback 69 | ? Image(image: memoryImage!) 70 | : widget.builder!(context, () {}), 71 | ))) 72 | .toList(), 73 | ); 74 | }); 75 | } 76 | 77 | void _recordImage() async { 78 | try { 79 | final boundary = 80 | _key.currentContext!.findRenderObject() as RenderRepaintBoundary; 81 | final image = await boundary.toImage(); 82 | final byteData = await (image.toByteData(format: ImageByteFormat.png) 83 | as FutureOr); 84 | final imageBytes = byteData.buffer.asUint8List(); 85 | 86 | setState(() { 87 | parts = PolygonStripGenerator().generate(); 88 | memoryImage = MemoryImage(imageBytes); 89 | }); 90 | } catch (e) { 91 | setState(() { 92 | parts = PolygonStripGenerator().generate(complexity: 1); 93 | useFallback = true; 94 | }); 95 | } 96 | } 97 | 98 | void _startShatter() { 99 | setState(() { 100 | showAnimation = true; 101 | }); 102 | } 103 | } 104 | 105 | class AnimatedShatter extends StatelessWidget { 106 | final double progress; 107 | final List points; 108 | final Widget child; 109 | 110 | AnimatedShatter({ 111 | required this.progress, 112 | required this.points, 113 | required this.child, 114 | }); 115 | 116 | @override 117 | Widget build(BuildContext context) { 118 | final center = Offset( 119 | (points[0].dx + points[1].dx + points[2].dx) / 3.0, 120 | (points[0].dy + points[1].dy + points[2].dy) / 3.0, 121 | ); 122 | 123 | return LayoutBuilder(builder: (context, constraints) { 124 | final alignment = Alignment(-1 + center.dx * 2, -1 + center.dy * 2); 125 | return Transform.translate( 126 | offset: Offset(0, progress * constraints.maxHeight * 1.2), 127 | child: Transform( 128 | transform: Matrix4.identity() 129 | ..setEntry(3, 2, 0.01) 130 | ..rotateZ((alignment.x < 0 ? -1 : 1) * 0.4 * progress) 131 | ..rotateX((alignment.x < 0 ? -1 : 1) * 0.3 * progress) 132 | ..rotateY((alignment.x < 0 ? -1 : 1) * 0.2 * progress), 133 | alignment: alignment, 134 | child: Transform.scale( 135 | scale: 1 - 0.7 * progress, 136 | alignment: alignment, 137 | child: ClipPath( 138 | clipper: PolygonClipper(points: points), 139 | child: child, 140 | ), 141 | ), 142 | ), 143 | ); 144 | }); 145 | } 146 | } 147 | 148 | class PolygonClipper extends CustomClipper { 149 | final List points; 150 | 151 | PolygonClipper({required this.points}); 152 | 153 | @override 154 | Path getClip(Size size) { 155 | return Path() 156 | ..addPolygon( 157 | points 158 | .map((relativeOffset) => Offset( 159 | relativeOffset.dx * size.width, 160 | relativeOffset.dy * size.height, 161 | )) 162 | .toList(), 163 | true); 164 | } 165 | 166 | @override 167 | bool shouldReclip(covariant CustomClipper oldClipper) => true; 168 | } 169 | 170 | class PolygonStripGenerator { 171 | List> generate({int seed = 2, int complexity = 2}) { 172 | final random = Random(2); 173 | 174 | var triangles = [ 175 | Triangle(Offset(0, 0), Offset(0, 1), Offset(1, 0)), 176 | Triangle(Offset(1, 1), Offset(0, 1), Offset(1, 0)), 177 | ]; 178 | 179 | 0.until(complexity).forEach((_) { 180 | triangles = triangles.expand((t) => t.shatter(random)).toList(); 181 | }); 182 | 183 | return triangles.map((t) => [t.p1, t.p2, t.p3]).toList(); 184 | } 185 | } 186 | 187 | class Triangle { 188 | final Offset p1; 189 | final Offset p2; 190 | final Offset p3; 191 | 192 | const Triangle(this.p1, this.p2, this.p3); 193 | 194 | List shatter(Random random) { 195 | final m12 = _average2(p1, p2, 0.4 + 0.2 * random.nextDouble()); 196 | final m23 = _average2(p2, p3, 0.4 + 0.2 * random.nextDouble()); 197 | final m13 = _average2(p1, p3, 0.4 + 0.2 * random.nextDouble()); 198 | final center = _average3( 199 | p1, 200 | p2, 201 | p3, 202 | 0.3 * random.nextDouble(), 203 | 0.3 * random.nextDouble(), 204 | 0.3 * random.nextDouble(), 205 | ); 206 | 207 | return [ 208 | Triangle(p1, m12, center), 209 | Triangle(m12, p2, center), 210 | Triangle(p2, m23, center), 211 | Triangle(m23, p3, center), 212 | Triangle(p3, m13, center), 213 | Triangle(m13, p1, center), 214 | ]; 215 | } 216 | 217 | Offset _average2(Offset p1, Offset p2, double weight) { 218 | final vec = Offset( 219 | p2.dx - p1.dx, 220 | p2.dy - p1.dy, 221 | ); 222 | 223 | return Offset( 224 | p1.dx + vec.dx * weight, 225 | p1.dy + vec.dy * weight, 226 | ); 227 | } 228 | 229 | Offset _average3( 230 | Offset p1, Offset p2, Offset p3, double w1, double w2, double w3) { 231 | final center = Offset( 232 | (p1.dx + p2.dx + p3.dx) / 3.0, 233 | (p1.dy + p2.dy + p3.dy) / 3.0, 234 | ); 235 | 236 | final vec1 = Offset(p1.dx - center.dx, p1.dy - center.dy); 237 | final vec2 = Offset(p2.dx - center.dx, p2.dy - center.dy); 238 | final vec3 = Offset(p3.dx - center.dx, p3.dy - center.dy); 239 | 240 | return Offset( 241 | center.dx + vec1.dx * w1 + vec2.dx * w2 + vec3.dx * w3, 242 | center.dy + vec1.dy * w1 + vec2.dy * w2 + vec3.dy * w3, 243 | ); 244 | } 245 | } 246 | -------------------------------------------------------------------------------- /lib/demo/layout/layout_b.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:simple_animations/simple_animations.dart'; 3 | import 'package:supercharged/supercharged.dart'; 4 | 5 | import 'colors.dart'; 6 | 7 | class LayoutB extends StatelessWidget { 8 | final double start; 9 | 10 | const LayoutB({this.start = 0.0}); 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return LayoutBuilder(builder: (context, outerConstraints) { 15 | final gap = 0.025 * outerConstraints.maxWidth; 16 | 17 | return Container( 18 | decoration: BoxDecoration( 19 | color: grey1, 20 | borderRadius: BorderRadius.all(Radius.circular(gap)), 21 | ), 22 | child: LayoutBuilder(builder: (context, constraints) { 23 | final tween = _createTween(constraints.maxWidth, gap); 24 | 25 | return CustomAnimation>( 26 | control: CustomAnimationControl.LOOP, 27 | startPosition: start, 28 | tween: tween, 29 | duration: tween.duration, 30 | builder: (context, child, value) { 31 | return Container( 32 | child: Stack( 33 | children: [ 34 | Positioned( 35 | left: value.get(_P.left1), 36 | top: value.get(_P.top1), 37 | width: value.get(_P.width1), 38 | height: value.get(_P.height1), 39 | child: Container( 40 | decoration: BoxDecoration( 41 | color: grey2, 42 | borderRadius: BorderRadius.only( 43 | topLeft: Radius.circular(gap), 44 | topRight: Radius.circular( 45 | value.get(_P.rightBorderRadius1)), 46 | bottomLeft: Radius.circular(gap), 47 | bottomRight: Radius.circular( 48 | value.get(_P.rightBorderRadius1)), 49 | ), 50 | ), 51 | )), 52 | Positioned( 53 | left: value.get(_P.left1) + 54 | value.get(_P.width1) + 55 | 2 * gap, 56 | right: 2 * gap, 57 | height: constraints.maxHeight, 58 | child: ClipRect( 59 | child: OverflowBox( 60 | alignment: Alignment.topCenter, 61 | maxHeight: double.infinity, 62 | child: Transform.translate( 63 | offset: Offset( 64 | 0, -value.get(_P.pageScroll)), 65 | child: _buildContentColumn( 66 | gap, constraints, value), 67 | ), 68 | ), 69 | )) 70 | ], 71 | ), 72 | ); 73 | }); 74 | }), 75 | ); 76 | }); 77 | } 78 | 79 | Container _buildContentColumn( 80 | double gap, BoxConstraints constraints, TimelineValue<_P> value) { 81 | return Container( 82 | child: Column( 83 | mainAxisSize: MainAxisSize.min, 84 | crossAxisAlignment: CrossAxisAlignment.start, 85 | children: [ 86 | Container(height: 2 * gap), 87 | _buildHeadlineContainer(gap, constraints), 88 | _buildContentContainer(gap), 89 | _buildContentContainer(gap), 90 | _buildContentContainer(gap), 91 | _buildContentContainer(gap), 92 | Container(height: 6 * gap), 93 | _buildHeadlineContainer(gap, constraints), 94 | _buildContentContainer(gap), 95 | _buildContentContainer(gap), 96 | Container(height: 6 * gap), 97 | _buildHeadlineContainer(gap, constraints), 98 | _buildContentContainer(gap), 99 | _buildContentContainer(gap), 100 | _buildContentContainer(gap, 101 | color: value.get(_P.contentColor), 102 | heightScale: value.get(_P.contentHeight)), 103 | _buildContentContainer(gap), 104 | ], 105 | ), 106 | ); 107 | } 108 | 109 | Container _buildHeadlineContainer(double gap, BoxConstraints constraints) { 110 | return Container( 111 | margin: EdgeInsets.only(bottom: gap), 112 | width: constraints.maxWidth * 0.25, 113 | height: 1.5 * gap, 114 | decoration: BoxDecoration( 115 | color: grey3, 116 | borderRadius: BorderRadius.all(Radius.circular(0.5 * gap))), 117 | ); 118 | } 119 | 120 | Container _buildContentContainer(double gap, 121 | {Color? color, double heightScale = 1.0}) { 122 | return Container( 123 | margin: EdgeInsets.only(bottom: gap), 124 | constraints: BoxConstraints.expand(height: 3 * gap * heightScale), 125 | decoration: BoxDecoration( 126 | color: color ?? grey2, 127 | borderRadius: BorderRadius.all(Radius.circular(0.5 * gap))), 128 | ); 129 | } 130 | } 131 | 132 | enum _P { 133 | top1, 134 | left1, 135 | width1, 136 | height1, 137 | rightBorderRadius1, 138 | pageScroll, 139 | contentColor, 140 | contentHeight, 141 | } 142 | 143 | TimelineTween<_P> _createTween(double size, double gap) { 144 | final tween = TimelineTween<_P>(curve: Curves.easeInOut); 145 | 146 | final scroll1 = tween 147 | .addScene(begin: 500.milliseconds, duration: 900.milliseconds) 148 | .animate(_P.pageScroll, 149 | tween: 0.0 150 | .tweenTo(320.0) 151 | .curved(Curves.easeOut) 152 | .curved(Curves.easeOut) 153 | .curved(Curves.easeOut)); 154 | 155 | final scroll2 = scroll1 156 | .addSubsequentScene(duration: 600.milliseconds) 157 | .animate(_P.pageScroll, 158 | tween: 320.0 159 | .tweenTo(400.0) 160 | .curved(Curves.easeOut) 161 | .curved(Curves.easeOut) 162 | .curved(Curves.easeOut)); 163 | 164 | final clickIn = scroll2 165 | .addSubsequentScene(delay: 300.milliseconds, duration: 100.milliseconds) 166 | .animate(_P.contentColor, tween: grey2.tweenTo(grey3)); 167 | 168 | final clickOut = clickIn 169 | .addSubsequentScene(duration: 100.milliseconds) 170 | .animate(_P.contentColor, tween: grey3.tweenTo(grey2)); 171 | 172 | final focus = clickOut 173 | .addSubsequentScene(delay: 100.milliseconds, duration: 1200.milliseconds) 174 | .animate(_P.left1, tween: (2 * gap).tweenTo(0.0)) 175 | .animate(_P.top1, tween: (2 * gap).tweenTo(0.0)) 176 | .animate(_P.width1, tween: (size * 0.3).tweenTo(size * 0.35 - gap)) 177 | .animate(_P.height1, tween: (size * 0.3).tweenTo(size)) 178 | .animate(_P.rightBorderRadius1, tween: (gap).tweenTo(0)) 179 | .animate(_P.contentHeight, tween: 1.0.tweenTo(6.0)) 180 | .animate(_P.contentColor, tween: grey2.tweenTo(grey4)) 181 | .animate(_P.pageScroll, tween: 400.0.tweenTo(600.0)); 182 | 183 | final fadeBack = focus 184 | .addSubsequentScene(delay: 1.seconds, duration: 1200.milliseconds) 185 | .animate(_P.left1, tween: (0.0).tweenTo(2 * gap)) 186 | .animate(_P.top1, tween: (0.0).tweenTo(2 * gap)) 187 | .animate(_P.width1, tween: (size * 0.35 - gap).tweenTo(size * 0.3)) 188 | .animate(_P.height1, tween: (size).tweenTo(size * 0.3)) 189 | .animate(_P.rightBorderRadius1, tween: (0.0).tweenTo(gap)) 190 | .animate(_P.contentHeight, tween: 6.0.tweenTo(1.0)) 191 | .animate(_P.contentColor, tween: grey4.tweenTo(grey2)) 192 | .animate(_P.pageScroll, tween: 600.0.tweenTo(0.0)); 193 | 194 | fadeBack.addSubsequentScene(duration: 500.milliseconds); 195 | 196 | return tween; 197 | } 198 | --------------------------------------------------------------------------------