diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f5d1d0..daeabe5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [0.3.0] - (2021-Feb-10) + +* Added support for web. Closes [#30](https://github.com/jonbhanson/flutter_native_splash/issues/30). +* Updated the example app to include web. + ## [0.2.11] - (2021-Feb-09) * Fixed `remove` command which was leaving splash images in place. diff --git a/README.md b/README.md index 4c223fc..c65fa35 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![pub package](https://img.shields.io/pub/v/flutter_native_splash)](https://pub.dev/packages/flutter_native_splash) [![Build Status](https://img.shields.io/travis/jonbhanson/flutter_native_splash)](https://travis-ci.org/jonbhanson/flutter_native_splash) -When your app is opened, there is a brief time while the native app loads Flutter. By default, during this time the native app displays a white splash screen. This package automatically generates iOS and Android native code for customizing this native splash screen background color and splash image. Supports dark mode, full screen, and platform-specific options. +When your app is opened, there is a brief time while the native app loads Flutter. By default, during this time the native app displays a white splash screen. This package automatically generates iOS, Android, and Web native code for customizing this native splash screen background color and splash image. Supports dark mode, full screen, and platform-specific options.

@@ -13,7 +13,7 @@ First, add `flutter_native_splash` as a dev dependency in your pubspec.yaml file ```yaml dev_dependencies: - flutter_native_splash: ^0.2.11 + flutter_native_splash: ^0.3.0 ``` Don't forget to `flutter pub get`. @@ -51,9 +51,10 @@ flutter_native_splash: # platform. #android: false #ios: false + #web: false - # The position of the splash image can be set with android_gravity and ios_content_mode - # parameters. Both default to center. + # The position of the splash image can be set with android_gravity, ios_content_mode, and + # web_image_mode parameters. All default to center. # # android_gravity can be one of the following Android Gravity (see # https://developer.android.com/reference/android/view/Gravity): bottom, center, @@ -66,8 +67,12 @@ flutter_native_splash: # scaleAspectFit, scaleAspectFill, center, top, bottom, left, right, topLeft, topRight, # bottomLeft, or bottomRight. #ios_content_mode: center + # + # web_image_mode can be one of the following modes: center, contain, stretch, and cover. + #web_image_mode: center - # To hide the notification bar, use the fullscreen parameter. Defaults to false. + # To hide the notification bar, use the fullscreen parameter. Has no affect in web since web + # has no notification bar. Defaults to false. # NOTE: Unlike Android, iOS will not automatically show the notification bar when the app loads. # To show the notification bar, add the following code to your Flutter app: # WidgetsFlutterBinding.ensureInitialized(); @@ -145,9 +150,6 @@ The native splash screen is displayed while the native app loads the Flutter fra ## Are animations/lottie/GIF images supported? Not at this time. However, you may want to consider a secondary splash screen that supports animation. See the [secondary splash screen](#secondary-splash-screen) recommendation. -## Is there support for web? -Not yet, but this is a planned improvement. - # Notes * If splash screen was not updated properly on iOS or if you experience a white screen before splash screen, run `flutter clean` and recompile your app. If that does not solve the problem, delete your app from the device, power down the device, power up device, install and launch app as per [this stackoverflow thread](https://stackoverflow.com/questions/33002829/ios-keeping-old-launch-screen-and-app-icon-after-update). @@ -167,6 +169,11 @@ Not yet, but this is a planned improvement. * The background color is implemented by using a single pixel png file and stretching it to fit the screen. * Code for hidden status bar toggle will be added in `Info.plist`. +## Web +* A `web/splash` folder will be created for splash screen images and CSS files. +* Your splash image will be resized to `1x`, `2x`, and `3x` sizes and placed in `web/splash/img`. +* The splash style sheet will be added to the app's `web/index.html`, as well as the HTML for the splash pictures. + # Removing If you would like to restore Flutter's default white splash screen, run the following command in the terminal: diff --git a/example/.gitignore b/example/.gitignore index ac4a906..0fa6b67 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -22,51 +22,25 @@ # Flutter/Dart/Pub related **/doc/api/ +**/ios/Flutter/.last_build_id .dart_tool/ .flutter-plugins +.flutter-plugins-dependencies .packages .pub-cache/ .pub/ /build/ -# Android related -**/android/**/gradle-wrapper.jar -**/android/.gradle -**/android/captures/ -**/android/gradlew -**/android/gradlew.bat -**/android/local.properties -**/android/**/GeneratedPluginRegistrant.java +# Web related +lib/generated_plugin_registrant.dart -# iOS/XCode related -**/ios/**/*.mode1v3 -**/ios/**/*.mode2v3 -**/ios/**/*.moved-aside -**/ios/**/*.pbxuser -**/ios/**/*.perspectivev3 -**/ios/**/*sync/ -**/ios/**/.sconsign.dblite -**/ios/**/.tags* -**/ios/**/.vagrant/ -**/ios/**/DerivedData/ -**/ios/**/Icon? -**/ios/**/Pods/ -**/ios/**/.symlinks/ -**/ios/**/profile -**/ios/**/xcuserdata -**/ios/.generated/ -**/ios/Flutter/App.framework -**/ios/Flutter/Flutter.framework -**/ios/Flutter/Generated.xcconfig -**/ios/Flutter/app.flx -**/ios/Flutter/app.zip -**/ios/Flutter/flutter_assets/ -**/ios/ServiceDefinitions.json -**/ios/Runner/GeneratedPluginRegistrant.* +# Symbolication related +app.*.symbols -# Exceptions to above rules. -!**/ios/**/default.mode1v3 -!**/ios/**/default.mode2v3 -!**/ios/**/default.pbxuser -!**/ios/**/default.perspectivev3 -!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/example/.metadata b/example/.metadata index e023651..d65ac32 100644 --- a/example/.metadata +++ b/example/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled and should not be manually edited. version: - revision: 20e59316b8b8474554b38493b8ca888794b0234a - channel: stable + revision: 4b50ca7f7fbf56be72e54cd200825b760416a356 + channel: beta project_type: app diff --git a/example/README.md b/example/README.md index 2fd02e2..ce73bef 100644 --- a/example/README.md +++ b/example/README.md @@ -1,37 +1,25 @@ # Example for flutter_native_splash -This is a brand new Flutter project created with `flutter create`. +A new Flutter application for testing a splash screen. -`pubspec.yaml`: +## Getting Started -```yaml -name: example -description: A new Flutter project. -version: 1.0.0+1 +This is Flutter's example application. Run it now and you will see that it has Flutter's default white splash screen. -environment: - sdk: ">=2.1.0 <3.0.0" +The pubspec.yaml file has been modified to add a color and icon to the splash screen. To apply these modification, run the following command in the terminal: -dependencies: - flutter: - sdk: flutter - cupertino_icons: ^0.1.2 +``` +flutter pub get +flutter pub run flutter_native_splash:create +``` -dev_dependencies: - flutter_test: - sdk: flutter - flutter_native_splash: ^0.1.5 +The updated splash screen will now appear when you run the app. -flutter_native_splash: - image: assets/splash.png - color: "42a5f5" +A few resources to get you started if this is your first Flutter project: -flutter: - uses-material-design: true -``` +- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) -And then: -``` -flutter pub get -flutter pub pub run flutter_native_splash:create -``` +For help getting started with Flutter, view our +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/example/android/.gitignore b/example/android/.gitignore new file mode 100644 index 0000000..0a741cb --- /dev/null +++ b/example/android/.gitignore @@ -0,0 +1,11 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 4ed2e25..7fa85db 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -25,20 +25,15 @@ apply plugin: 'com.android.application' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 28 - - lintOptions { - disable 'InvalidPackage' - } + compileSdkVersion 30 defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.example" minSdkVersion 16 - targetSdkVersion 28 + targetSdkVersion 30 versionCode flutterVersionCode.toInteger() versionName flutterVersionName - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { @@ -53,9 +48,3 @@ android { flutter { source '../..' } - -dependencies { - testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' -} diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 2877140..34dd77e 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,33 +1,41 @@ - - - - + + android:name="io.flutter.embedding.android.NormalTheme" + android:resource="@style/NormalTheme" + /> + + + + diff --git a/example/android/app/src/main/java/com/example/example/MainActivity.java b/example/android/app/src/main/java/com/example/example/MainActivity.java index e3a339e..59f336d 100644 --- a/example/android/app/src/main/java/com/example/example/MainActivity.java +++ b/example/android/app/src/main/java/com/example/example/MainActivity.java @@ -1,28 +1,6 @@ package com.example.example; -import android.os.Bundle; -import io.flutter.app.FlutterActivity; -import io.flutter.plugins.GeneratedPluginRegistrant; - -import android.view.ViewTreeObserver; -import android.view.WindowManager; +import io.flutter.embedding.android.FlutterActivity; public class MainActivity extends FlutterActivity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - boolean flutter_native_splash = true; - getWindow().setStatusBarColor(0x00000000); - - GeneratedPluginRegistrant.registerWith(this); - ViewTreeObserver vto = getFlutterView().getViewTreeObserver(); - vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - getFlutterView().getViewTreeObserver().removeOnGlobalLayoutListener(this); - getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - } - }); - - } -} \ No newline at end of file +} diff --git a/example/android/app/src/main/res/drawable-hdpi/splash.png b/example/android/app/src/main/res/drawable-hdpi/splash.png deleted file mode 100644 index 2369e5f..0000000 Binary files a/example/android/app/src/main/res/drawable-hdpi/splash.png and /dev/null differ diff --git a/example/android/app/src/main/res/drawable-mdpi/splash.png b/example/android/app/src/main/res/drawable-mdpi/splash.png deleted file mode 100644 index 2e7b6e5..0000000 Binary files a/example/android/app/src/main/res/drawable-mdpi/splash.png and /dev/null differ diff --git a/example/android/app/src/main/res/drawable-v21/launch_background.xml b/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/example/android/app/src/main/res/drawable-xhdpi/splash.png b/example/android/app/src/main/res/drawable-xhdpi/splash.png deleted file mode 100644 index 4a4d719..0000000 Binary files a/example/android/app/src/main/res/drawable-xhdpi/splash.png and /dev/null differ diff --git a/example/android/app/src/main/res/drawable-xxhdpi/splash.png b/example/android/app/src/main/res/drawable-xxhdpi/splash.png deleted file mode 100644 index 77d050f..0000000 Binary files a/example/android/app/src/main/res/drawable-xxhdpi/splash.png and /dev/null differ diff --git a/example/android/app/src/main/res/drawable-xxxhdpi/splash.png b/example/android/app/src/main/res/drawable-xxxhdpi/splash.png deleted file mode 100644 index 1c84e78..0000000 Binary files a/example/android/app/src/main/res/drawable-xxxhdpi/splash.png and /dev/null differ diff --git a/example/android/app/src/main/res/drawable/launch_background.xml b/example/android/app/src/main/res/drawable/launch_background.xml index 8c09435..304732f 100644 --- a/example/android/app/src/main/res/drawable/launch_background.xml +++ b/example/android/app/src/main/res/drawable/launch_background.xml @@ -1,7 +1,7 @@ - + - - - - diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..449a9f9 --- /dev/null +++ b/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/example/android/app/src/main/res/values/colors.xml b/example/android/app/src/main/res/values/colors.xml deleted file mode 100644 index 3216a0d..0000000 --- a/example/android/app/src/main/res/values/colors.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - #42a5f5 - \ No newline at end of file diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml index a1ec9a1..d74aa35 100644 --- a/example/android/app/src/main/res/values/styles.xml +++ b/example/android/app/src/main/res/values/styles.xml @@ -1,10 +1,18 @@ - - \ No newline at end of file + + + diff --git a/example/android/build.gradle b/example/android/build.gradle index bb8a303..c9e3db0 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath 'com.android.tools.build:gradle:4.1.0' } } diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 2bd6f4f..94adc3a 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,2 +1,3 @@ org.gradle.jvmargs=-Xmx1536M - +android.useAndroidX=true +android.enableJetifier=true diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 2819f02..bc6a58a 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle index 5a2f14f..44e62bc 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -1,15 +1,11 @@ include ':app' -def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() -def plugins = new Properties() -def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') -if (pluginsFile.exists()) { - pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } -} +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } -plugins.each { name, path -> - def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() - include ":$name" - project(":$name").projectDir = pluginDirectory -} +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/example/assets/logo_lockup_flutter_vertical.png b/example/assets/logo_lockup_flutter_vertical.png new file mode 100644 index 0000000..3a9719e Binary files /dev/null and b/example/assets/logo_lockup_flutter_vertical.png differ diff --git a/example/assets/logo_lockup_flutter_vertical_wht.png b/example/assets/logo_lockup_flutter_vertical_wht.png new file mode 100644 index 0000000..11e0fb9 Binary files /dev/null and b/example/assets/logo_lockup_flutter_vertical_wht.png differ diff --git a/example/assets/splash.png b/example/assets/splash.png deleted file mode 100755 index 8d2dc1a..0000000 Binary files a/example/assets/splash.png and /dev/null differ diff --git a/example/ios/.gitignore b/example/ios/.gitignore new file mode 100644 index 0000000..e96ef60 --- /dev/null +++ b/example/ios/.gitignore @@ -0,0 +1,32 @@ +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 6b4c0f7..9367d48 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) + en CFBundleExecutable App CFBundleIdentifier diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 556383d..fd88861 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -9,11 +9,6 @@ /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; - 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; - 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; - 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; @@ -28,8 +23,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, - 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -40,13 +33,11 @@ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; - 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; - 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; @@ -60,8 +51,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, - 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -71,9 +60,7 @@ 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( - 3B80C3931E831B6300D905FE /* App.framework */, 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, - 9740EEBA1CF902C7004384FC /* Flutter.framework */, 9740EEB21CF90195004384FC /* Debug.xcconfig */, 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 9740EEB31CF90195004384FC /* Generated.xcconfig */, @@ -153,7 +140,7 @@ isa = PBXProject; attributes = { LastUpgradeCheck = 1020; - ORGANIZATIONNAME = "The Chromium Authors"; + ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { CreatedOnToolsVersion = 7.3.1; @@ -161,7 +148,7 @@ }; }; buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; - compatibilityVersion = "Xcode 3.2"; + compatibilityVersion = "Xcode 9.3"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( @@ -185,7 +172,6 @@ files = ( 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, - 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, ); @@ -206,7 +192,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; @@ -259,7 +245,6 @@ /* Begin XCBuildConfiguration section */ 249021D3217E4FDB00AE95B9 /* Profile */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -299,9 +284,10 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -313,18 +299,9 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = S8QB4VV633; ENABLE_BITCODE = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); PRODUCT_BUNDLE_IDENTIFIER = com.example.example; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; @@ -333,7 +310,6 @@ }; 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -379,7 +355,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -389,7 +365,6 @@ }; 97C147041CF9000F007C117D /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -429,9 +404,10 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -444,16 +420,8 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); PRODUCT_BUNDLE_IDENTIFIER = com.example.example; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; @@ -467,16 +435,8 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); PRODUCT_BUNDLE_IDENTIFIER = com.example.example; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a1..919434a 100644 --- a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/example/ios/Runner/AppDelegate.m b/example/ios/Runner/AppDelegate.m index 9e28738..70e8393 100644 --- a/example/ios/Runner/AppDelegate.m +++ b/example/ios/Runner/AppDelegate.m @@ -1,18 +1,13 @@ -#include "AppDelegate.h" -#include "GeneratedPluginRegistrant.h" +#import "AppDelegate.h" +#import "GeneratedPluginRegistrant.h" @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - UIApplication.sharedApplication.statusBarHidden = false; - - int flutter_native_splash = 1; - UIApplication.sharedApplication.statusBarHidden = false; - [GeneratedPluginRegistrant registerWithRegistry:self]; // Override point for customization after application launch. return [super application:application didFinishLaunchingWithOptions:launchOptions]; } -@end \ No newline at end of file +@end diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png index 3d43d11..dc9ada4 100644 Binary files a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png index 5ea841a..9da19ea 100644 Binary files a/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png and b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png index 2e7b6e5..9da19ea 100644 Binary files a/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png and b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png index 1c84e78..9da19ea 100644 Binary files a/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png and b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/example/ios/Runner/Base.lproj/LaunchScreen.storyboard b/example/ios/Runner/Base.lproj/LaunchScreen.storyboard index dd0834b..f2e259c 100644 --- a/example/ios/Runner/Base.lproj/LaunchScreen.storyboard +++ b/example/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -19,7 +19,7 @@ - + @@ -32,6 +32,6 @@ - + - \ No newline at end of file + diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index b11703f..a060db6 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -41,8 +41,5 @@ UIViewControllerBasedStatusBarAppearance - UIStatusBarHidden - - - \ No newline at end of file + diff --git a/example/lib/main.dart b/example/lib/main.dart index 06d74b4..7dba050 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,13 +1,29 @@ import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; -void main() => runApp(MyApp()); +void main() { + WidgetsFlutterBinding.ensureInitialized(); + SystemChrome.setEnabledSystemUIOverlays( + [SystemUiOverlay.bottom, SystemUiOverlay.top]); + runApp(MyApp()); +} class MyApp extends StatelessWidget { + // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( + // This is the theme of your application. + // + // Try running your application with "flutter run". You'll see the + // application has a blue toolbar. Then, without quitting the app, try + // changing the primarySwatch below to Colors.green and then invoke + // "hot reload" (press "r" in the console where you ran "flutter run", + // or simply save your changes to "hot reload" in a Flutter IDE). + // Notice that the counter didn't reset back to zero; the application + // is not restarted. primarySwatch: Colors.blue, ), home: MyHomePage(title: 'Flutter Demo Home Page'), @@ -18,6 +34,15 @@ class MyApp extends StatelessWidget { class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key); + // This widget is the home page of your application. It is stateful, meaning + // that it has a State object (defined below) that contains fields that affect + // how it looks. + + // This class is the configuration for the state. It holds the values (in this + // case the title) provided by the parent (in this case the App widget) and + // used by the build method of the State. Fields in a Widget subclass are + // always marked "final". + final String title; @override @@ -29,18 +54,47 @@ class _MyHomePageState extends State { void _incrementCounter() { setState(() { + // This call to setState tells the Flutter framework that something has + // changed in this State, which causes it to rerun the build method below + // so that the display can reflect the updated values. If we changed + // _counter without calling setState(), then the build method would not be + // called again, and so nothing would appear to happen. _counter++; }); } @override Widget build(BuildContext context) { + // This method is rerun every time setState is called, for instance as done + // by the _incrementCounter method above. + // + // The Flutter framework has been optimized to make rerunning build methods + // fast, so that you can just rebuild anything that needs updating rather + // than having to individually change instances of widgets. return Scaffold( appBar: AppBar( + // Here we take the value from the MyHomePage object that was created by + // the App.build method, and use it to set our appbar title. title: Text(widget.title), ), body: Center( + // Center is a layout widget. It takes a single child and positions it + // in the middle of the parent. child: Column( + // Column is also a layout widget. It takes a list of children and + // arranges them vertically. By default, it sizes itself to fit its + // children horizontally, and tries to be as tall as its parent. + // + // Invoke "debug painting" (press "p" in the console, choose the + // "Toggle Debug Paint" action from the Flutter Inspector in Android + // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) + // to see the wireframe for each widget. + // + // Column has various properties to control how it sizes itself and + // how it positions its children. Here we use mainAxisAlignment to + // center the children vertically; the main axis here is the vertical + // axis because Columns are vertical (the cross axis would be + // horizontal). mainAxisAlignment: MainAxisAlignment.center, children: [ Text( @@ -57,7 +111,7 @@ class _MyHomePageState extends State { onPressed: _incrementCounter, tooltip: 'Increment', child: Icon(Icons.add), - ), + ), // This trailing comma makes auto-formatting nicer for build methods. ); } } diff --git a/example/pubspec.lock b/example/pubspec.lock index d7f7065..57ec564 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,149 +1,93 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - archive: - dependency: transitive - description: - name: archive - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.11" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.5.2" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.5.0-nullsafety.3" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0-nullsafety.3" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0-nullsafety.5" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0-nullsafety.3" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0-nullsafety.3" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.3" - color: - dependency: transitive - description: - name: color - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" - crypto: - dependency: transitive - description: - name: crypto - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.3" + version: "1.15.0-nullsafety.5" cupertino_icons: dependency: "direct main" description: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.2" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0-nullsafety.3" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" - flutter_native_splash: - dependency: "direct dev" - description: - path: ".." - relative: true - source: path - version: "0.2.1" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" - image: - dependency: transitive - description: - name: image - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.19" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.10-nullsafety.3" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0-nullsafety.6" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.1" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.0" + version: "1.8.0-nullsafety.3" sky_engine: dependency: transitive description: flutter @@ -155,69 +99,55 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.0-nullsafety.4" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0-nullsafety.6" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0-nullsafety.3" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0-nullsafety.3" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0-nullsafety.3" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.2.19-nullsafety.6" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0-nullsafety.5" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.dartlang.org" - source: hosted - version: "4.5.1" - yaml: - dependency: transitive - description: - name: yaml - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.1" + version: "2.1.0-nullsafety.5" sdks: - dart: ">=2.10.0-110 <2.11.0" + dart: ">=2.12.0-0.0 <3.0.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 5fa3e26..bb01938 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,14 +1,33 @@ name: example -description: A new Flutter project. +description: A new Flutter application. + +# The following line prevents the package from being accidentally published to +# pub.dev using `pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html version: 1.0.0+1 environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.7.0 <3.0.0" dependencies: flutter: sdk: flutter - cupertino_icons: ^1.0.0 + + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 dev_dependencies: flutter_test: @@ -16,9 +35,108 @@ dev_dependencies: flutter_native_splash: path: .. -flutter_native_splash: - image: assets/splash.png - color: 42a5f5 +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec +# The following section is specific to Flutter. flutter: - uses-material-design: true \ No newline at end of file + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware. + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages + +flutter_native_splash: + + # This package generates native code to customize Flutter's default white native splash screen + # with background color and splash image. + # Customize the parameters below, and run the following command in the terminal: + # flutter pub run flutter_native_splash:create + # To restore Flutter's default white splash screen, run the following command in the terminal: + # flutter pub run flutter_native_splash:remove + + # color is the only required parameter. It sets the background color of your splash screen. + color: "#e1f5fe" + + # Optional parameters are listed below. To enable a parameter, uncomment the line by removing + # the leading # character. + + # The image parameter allows you to specify an image used in the splash screen. It must be a + # png file. + image: assets/logo_lockup_flutter_vertical.png + + # The color_dark and image_dark are parameters that set the color and image when the device is + # in dark mode. If they are not specified, the app will use the color and image above. + # If the image_dark parameter is specified, color_dark must be specified. + color_dark: "#042a49" + image_dark: assets/logo_lockup_flutter_vertical_wht.png + + # The android and ios parameters can be used to disable generating a splash screen on a given + # platform. + #android: false + #ios: false + #web: false + + # The position of the splash image can be set with android_gravity, ios_content_mode, and + # web_image_mode parameters. All default to center. + # + # android_gravity can be one of the following Android Gravity (see + # https://developer.android.com/reference/android/view/Gravity): bottom, center, + # center_horizontal, center_vertical, clip_horizontal, clip_vertical, end, fill, fill_horizontal, + # fill_vertical, left, right, start, or top. + #android_gravity: center + # + # ios_content_mode can be one of the following iOS UIView.ContentMode (see + # https://developer.apple.com/documentation/uikit/uiview/contentmode): scaleToFill, + # scaleAspectFit, scaleAspectFill, center, top, bottom, left, right, topLeft, topRight, + # bottomLeft, or bottomRight. + #ios_content_mode: center + # + # web_image_mode can be one of the following modes: center, contain, stretch, and cover. + #web_image_mode: center + + # To hide the notification bar, use the fullscreen parameter. Has no affect in web since web + # has no notification bar. Defaults to false. + # NOTE: Unlike Android, iOS will not automatically show the notification bar when the app loads. + # To show the notification bar, add the following code to your Flutter app: + # WidgetsFlutterBinding.ensureInitialized(); + # SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom, SystemUiOverlay.top]); + fullscreen: true + + # If you have changed the name(s) of your info.plist file(s), you can specify the filename(s) + # with the info_plist_files parameter. Remove only the # characters in the three lines below, + # do not remove any spaces: + #info_plist_files: + # - 'ios/Runner/Info-Debug.plist' + # - 'ios/Runner/Info-Release.plist' \ No newline at end of file diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart new file mode 100644 index 0000000..747db1d --- /dev/null +++ b/example/test/widget_test.dart @@ -0,0 +1,30 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility that Flutter provides. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:example/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} diff --git a/example/web/favicon.png b/example/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/example/web/favicon.png differ diff --git a/example/web/icons/Icon-192.png b/example/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/example/web/icons/Icon-192.png differ diff --git a/example/web/icons/Icon-512.png b/example/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/example/web/icons/Icon-512.png differ diff --git a/example/web/index.html b/example/web/index.html new file mode 100644 index 0000000..aaeb180 --- /dev/null +++ b/example/web/index.html @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + example + + + + + + + + diff --git a/example/web/manifest.json b/example/web/manifest.json new file mode 100644 index 0000000..3911621 --- /dev/null +++ b/example/web/manifest.json @@ -0,0 +1,23 @@ +{ + "name": "example", + "short_name": "example", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter application.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + } + ] +} diff --git a/lib/constants.dart b/lib/constants.dart index ebdf1d9..3c8f14e 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -26,3 +26,10 @@ const String _iOSLaunchScreenStoryboardFile = const String _iOSInfoPlistFile = 'ios/Runner/Info.plist'; const String _iOSAssetsLaunchImageBackgroundFolder = 'ios/Runner/Assets.xcassets/LaunchBackground.imageset/'; + +// Web-related constants +const String _webFolder = 'web/'; +const String _webSplashFolder = _webFolder + 'splash/'; +const String _webSplashImagesFolder = _webSplashFolder + 'img/'; +const String _webIndex = _webFolder + 'index.html'; +const String _webRelativeStyleFile = 'splash/style.css'; diff --git a/lib/supported_platform.dart b/lib/supported_platform.dart index 3e7d3db..8c0d5e3 100644 --- a/lib/supported_platform.dart +++ b/lib/supported_platform.dart @@ -19,6 +19,7 @@ part 'constants.dart'; part 'exceptions.dart'; part 'ios.dart'; part 'templates.dart'; +part 'web.dart'; /// Function that will be called on supported platforms to create the splash screens. Future tryCreateSplash() async { @@ -36,13 +37,14 @@ Future tryRemoveSplash() async { Future tryCreateSplashByConfig(Map config) async { String image = config['image'] ?? ''; String darkImage = config['image_dark'] ?? ''; - var color = parseColor(config['color']); - var darkColor = parseColor(config['color_dark']) ?? ''; + var color = _parseColor(config['color']); + var darkColor = _parseColor(config['color_dark']) ?? ''; var plistFiles = config['info_plist_files']; var gravity = (config['fill'] ?? false) ? 'fill' : 'center'; if (config['android_gravity'] != null) gravity = config['android_gravity']; bool fullscreen = config['fullscreen'] ?? false; String iosContentMode = config['ios_content_mode'] ?? 'center'; + final webImageMode = (config['web_image_mode'] ?? 'center'); if (!config.containsKey('android') || config['android']) { await _createAndroidSplash( @@ -66,9 +68,18 @@ Future tryCreateSplashByConfig(Map config) async { fullscreen: fullscreen, ); } + + if (!config.containsKey('web') || config['web']) { + await _createWebSplash( + imagePath: image, + darkImagePath: darkImage, + color: color, + darkColor: darkColor, + imageMode: webImageMode); + } } -String parseColor(var color) { +String _parseColor(var color) { if (color is int) color = color.toString().padLeft(6, '0'); if (color is String) { diff --git a/lib/templates.dart b/lib/templates.dart index 86bcb05..2eaa686 100644 --- a/lib/templates.dart +++ b/lib/templates.dart @@ -267,3 +267,52 @@ const String _iOSLaunchBackgroundConstraints = ''' '''; + +/// Web related templates +const String _webCss = ''' +body, html { + margin:0; + height:100%; + background: [LIGHTBACKGROUNDCOLOR]; +} + +.center { + margin: 0; + position: absolute; + top: 50%; + left: 50%; + -ms-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); +} + +.contain { + display:block; + width:100%; height:100%; + object-fit: contain; +} + +.stretch { + display:block; + width:100%; height:100%; +} + +.cover { + display:block; + width:100%; height:100%; + object-fit: cover; +} + +@media (prefers-color-scheme: dark) { + body { + background: [DARKBACKGROUNDCOLOR]; + } +} +'''; + +const List _indexHtmlPicture = [ + ' ', + ' ', + ' ', + ' ', + ' ', +]; diff --git a/lib/web.dart b/lib/web.dart new file mode 100644 index 0000000..6f0caae --- /dev/null +++ b/lib/web.dart @@ -0,0 +1,127 @@ +part of flutter_native_splash_supported_platform; + +// Image template +class _WebLaunchImageTemplate { + final String fileName; + final double divider; + _WebLaunchImageTemplate({this.fileName, this.divider}); +} + +/// Create Android splash screen +Future _createWebSplash({ + String imagePath, + String darkImagePath, + String color, + String darkColor, + String imageMode, +}) async { + if (!File(_webIndex).existsSync()) { + print('[Web] ' + _webIndex + ' not found. Skipping Web.'); + return; + } + + if (darkImagePath.isEmpty) darkImagePath = imagePath; + await createWebImages(imagePath: imagePath, webSplashImages: [ + _WebLaunchImageTemplate(fileName: 'light-1x.png', divider: 3.0), + _WebLaunchImageTemplate(fileName: 'light-2x.png', divider: 1.5), + _WebLaunchImageTemplate(fileName: 'light-3x.png', divider: 1.0), + ]); + await createWebImages(imagePath: darkImagePath, webSplashImages: [ + _WebLaunchImageTemplate(fileName: 'dark-1x.png', divider: 3.0), + _WebLaunchImageTemplate(fileName: 'dark-2x.png', divider: 1.5), + _WebLaunchImageTemplate(fileName: 'dark-3x.png', divider: 1.0), + ]); + await createSplashCss(color: color, darkColor: darkColor); + await updateIndex(imageMode: imageMode, showImages: imagePath.isNotEmpty); +} + +void createWebImages( + {String imagePath, List<_WebLaunchImageTemplate> webSplashImages}) async { + if (imagePath.isEmpty) { + for (var template in webSplashImages) { + final file = File(_webSplashImagesFolder + template.fileName); + if (file.existsSync()) file.deleteSync(); + } + } else { + final image = decodeImage(File(imagePath).readAsBytesSync()); + print('[Web] Creating images'); + for (var template in webSplashImages) { + await _saveImageWeb(template: template, image: image); + } + } +} + +dynamic _saveImageWeb({_WebLaunchImageTemplate template, Image image}) async { + var newFile = await copyResize( + image, + width: image.width ~/ template.divider, + height: image.height ~/ template.divider, + interpolation: Interpolation.linear, + ); + + var file = await File(_webSplashImagesFolder + template.fileName) + .create(recursive: true); + await file.writeAsBytes(encodePng(newFile)); +} + +void createSplashCss({String color, String darkColor}) { + print('[Web] Creating CSS'); + if (darkColor.isEmpty) darkColor = color; + var cssContent = _webCss + .replaceFirst('[LIGHTBACKGROUNDCOLOR]', '#' + color) + .replaceFirst('[DARKBACKGROUNDCOLOR]', '#' + darkColor); + File(_webFolder + _webRelativeStyleFile).writeAsStringSync(cssContent); +} + +void updateIndex({String imageMode, bool showImages}) async { + print('[Web] Updating index.html'); + final webIndex = File(_webIndex); + var lines = webIndex.readAsLinesSync(); + + var foundExistingStyleSheet = false; + var headCloseTagLine = 0; + var bodyCloseTagLine = 0; + var existingPictureLine = 0; + + final styleSheetLink = + ''; + for (var x = 0; x < lines.length; x++) { + var line = lines[x]; + + if (line.contains(styleSheetLink)) { + foundExistingStyleSheet = true; + } else if (line.contains('')) { + headCloseTagLine = x; + } else if (line.contains('')) { + bodyCloseTagLine = x; + } else if (line.contains('')) { + existingPictureLine = x; + } + } + + if (!foundExistingStyleSheet) { + lines[headCloseTagLine] = ' ' + styleSheetLink + '\n'; + } + + if (existingPictureLine == 0) { + if (showImages) { + for (var x = _indexHtmlPicture.length - 1; x >= 0; x--) { + lines[bodyCloseTagLine] = + _indexHtmlPicture[x].replaceFirst('[IMAGEMODE]', imageMode) + + '\n' + + lines[bodyCloseTagLine]; + } + } + } else { + if (showImages) { + for (var x = 0; x < _indexHtmlPicture.length; x++) { + lines[existingPictureLine + x] = + _indexHtmlPicture[x].replaceFirst('[IMAGEMODE]', imageMode); + } + } else { + lines.removeRange( + existingPictureLine, existingPictureLine + _indexHtmlPicture.length); + } + } + webIndex.writeAsStringSync(lines.join('\n')); +} diff --git a/pubspec.lock b/pubspec.lock index c202294..ff913ec 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -21,14 +21,14 @@ packages: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" + version: "1.2.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.13" + version: "1.15.0" convert: dependency: transitive description: @@ -56,21 +56,21 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.2.4" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" pedantic: dependency: "direct dev" description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.9.2" + version: "1.10.0" petitparser: dependency: transitive description: @@ -84,28 +84,28 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.1" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" xml: dependency: "direct main" description: @@ -121,4 +121,4 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.7.0 <3.0.0" + dart: ">=2.12.0-0.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 66f7e51..25dea8e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_native_splash description: Generates native code to customize Flutter's default white native splash screen with background color and splash image. Supports dark mode, full screen, and more. -version: 0.2.11 +version: 0.3.0 homepage: https://github.com/jonbhanson/flutter_native_splash environment: