diff --git a/.metadata b/.metadata index af84dae..0b5ddf0 100644 --- a/.metadata +++ b/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled and should not be manually edited. version: - revision: 77d935af4db863f6abd0b9c31c7e6df2a13de57b + revision: db747aa1331bd95bc9b3874c842261ca2d302cd5 channel: stable -project_type: package +project_type: plugin diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a6e524..d504848 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## [2.0.5] - (2022-Feb-20) +* Converted to a plugin since there is now platform specific code. ## [2.0.4] - (2022-Feb-15) * Fix Error: Not found: 'dart:js' error. Fixes [#292](https://github.com/jonbhanson/flutter_native_splash/issues/292). diff --git a/README.md b/README.md index 5b4b1f6..3f782ab 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ First, add `flutter_native_splash` as a dependency in your pubspec.yaml file. ```yaml dependencies: - flutter_native_splash: ^2.0.4 + flutter_native_splash: ^2.0.5 ``` Don't forget to `flutter pub get`. @@ -158,11 +158,11 @@ If you find this package useful, you can support it for free by giving it a thum # Android 12 Support -Android 12 has a [new method](https://developer.android.com/about/versions/12/features/splash-screen) of adding splash screens, which consists of a window background, icon, and the icon background. Currently, this package supports setting the background color and the icon is taken from the launcher icon. +Android 12 has a [new method](https://developer.android.com/about/versions/12/features/splash-screen) of adding splash screens, which consists of a window background, icon, and the icon background. This package supports setting the background color and the icon is taken from the launcher icon. -If you [enable Android 12 support](https://developer.android.com/about/versions/12/setup-sdk), the package will add a `styles.xml` in `values-v31` and `values-night-v31` resource folders, which will provide Android 12 support while maintaining the legacy splash screen for previous versions of Android. +The package will add a `styles.xml` in `values-v31` and `values-night-v31` resource folders, which will provide Android 12 support while maintaining the legacy splash screen for previous versions of Android. -NOTE: The splash screen may not appear when you launch the app from Android Studio. However, it should appear when you launch by clicking on the launch icon in Android. +***PLEASE NOTE:*** The splash screen may not appear when you launch the app from Android Studio. However, it should appear when you launch by clicking on the launch icon in Android. # FAQs ## I got the error "A splash screen was provided to Flutter, but this is deprecated." diff --git a/android/.gitignore b/android/.gitignore new file mode 100644 index 0000000..c6cbe56 --- /dev/null +++ b/android/.gitignore @@ -0,0 +1,8 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 0000000..9bdc8ca --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,35 @@ +group 'net.jonhanson.flutter_native_splash' +version '1.0' + +buildscript { + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:4.1.0' + } +} + +rootProject.allprojects { + repositories { + google() + mavenCentral() + } +} + +apply plugin: 'com.android.library' + +android { + compileSdkVersion 31 + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + defaultConfig { + minSdkVersion 16 + } +} diff --git a/android/settings.gradle b/android/settings.gradle new file mode 100644 index 0000000..c2f6ccf --- /dev/null +++ b/android/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'flutter_native_splash' diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml new file mode 100644 index 0000000..cb0686b --- /dev/null +++ b/android/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + diff --git a/android/src/main/java/net/jonhanson/flutter_native_splash/FlutterNativeSplashPlugin.java b/android/src/main/java/net/jonhanson/flutter_native_splash/FlutterNativeSplashPlugin.java new file mode 100644 index 0000000..a39913b --- /dev/null +++ b/android/src/main/java/net/jonhanson/flutter_native_splash/FlutterNativeSplashPlugin.java @@ -0,0 +1,38 @@ +package net.jonhanson.flutter_native_splash; + +import androidx.annotation.NonNull; + +import io.flutter.embedding.engine.plugins.FlutterPlugin; +import io.flutter.plugin.common.MethodCall; +import io.flutter.plugin.common.MethodChannel; +import io.flutter.plugin.common.MethodChannel.MethodCallHandler; +import io.flutter.plugin.common.MethodChannel.Result; + +/** FlutterNativeSplashPlugin */ +public class FlutterNativeSplashPlugin implements FlutterPlugin, MethodCallHandler { + /// The MethodChannel that will the communication between Flutter and native Android + /// + /// This local reference serves to register the plugin with the Flutter Engine and unregister it + /// when the Flutter Engine is detached from the Activity + private MethodChannel channel; + + @Override + public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) { + channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "flutter_native_splash"); + channel.setMethodCallHandler(this); + } + + @Override + public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { + if (call.method.equals("getPlatformVersion")) { + result.success("Android " + android.os.Build.VERSION.RELEASE); + } else { + result.notImplemented(); + } + } + + @Override + public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) { + channel.setMethodCallHandler(null); + } +} diff --git a/example/.metadata b/example/.metadata index fd70cab..0a999ee 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: 77d935af4db863f6abd0b9c31c7e6df2a13de57b + revision: db747aa1331bd95bc9b3874c842261ca2d302cd5 channel: stable project_type: app diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 4b5558f..7bc5693 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -22,6 +22,7 @@ if (flutterVersionName == null) { } apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { @@ -34,7 +35,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.example.example" + applicationId "net.jonhanson.flutter_native_splash_example" minSdkVersion flutter.minSdkVersion targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml index c208884..00cc4e7 100644 --- a/example/android/app/src/debug/AndroidManifest.xml +++ b/example/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="net.jonhanson.flutter_native_splash_example"> diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 3f41384..d43a94c 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,7 +1,7 @@ + package="net.jonhanson.flutter_native_splash_example"> + package="net.jonhanson.flutter_native_splash_example"> diff --git a/example/android/build.gradle b/example/android/build.gradle index 0b4cf53..4256f91 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,4 +1,5 @@ buildscript { + ext.kotlin_version = '1.6.10' repositories { google() mavenCentral() @@ -6,6 +7,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:4.1.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig index 592ceee..ec97fc6 100644 --- a/example/ios/Flutter/Debug.xcconfig +++ b/example/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig index 592ceee..c4855bf 100644 --- a/example/ios/Flutter/Release.xcconfig +++ b/example/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Podfile b/example/ios/Podfile new file mode 100644 index 0000000..f7d6a5e --- /dev/null +++ b/example/ios/Podfile @@ -0,0 +1,38 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '9.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 4b4242d..2d1c026 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -305,7 +305,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.example; + PRODUCT_BUNDLE_IDENTIFIER = net.jonhanson.flutterNativeSplashExample; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; @@ -429,7 +429,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.example; + PRODUCT_BUNDLE_IDENTIFIER = net.jonhanson.flutterNativeSplashExample; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; @@ -448,7 +448,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.example; + PRODUCT_BUNDLE_IDENTIFIER = net.jonhanson.flutterNativeSplashExample; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index 27491e8..df7dd60 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -5,7 +5,7 @@ CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName - Example + Flutter Native Splash CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier @@ -13,7 +13,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleName - example + flutter_native_splash_example CFBundlePackageType APPL CFBundleShortVersionString @@ -42,6 +42,6 @@ UIInterfaceOrientationLandscapeRight UIViewControllerBasedStatusBarAppearance - + diff --git a/example/lib/main.dart b/example/lib/main.dart index a342a19..d56c2aa 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -2,24 +2,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_native_splash/flutter_native_splash.dart'; void main() { - FlutterNativeSplash.removeAfter(initialization); + WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized(); + FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding); runApp(const MyApp()); } -void initialization(BuildContext context) async { - // This is where you can initialize the resources needed by your app while - // the splash screen is displayed. Remove the following example because - // delaying the user experience is a bad design practice! - // ignore_for_file: avoid_print - print('ready in 3...'); - await Future.delayed(const Duration(seconds: 1)); - print('ready in 2...'); - await Future.delayed(const Duration(seconds: 1)); - print('ready in 1...'); - await Future.delayed(const Duration(seconds: 1)); - print('go!'); -} - class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @@ -77,6 +64,27 @@ class _MyHomePageState extends State { }); } + @override + void initState() { + super.initState(); + initialization(); + } + + void initialization() async { + // This is where you can initialize the resources needed by your app while + // the splash screen is displayed. Remove the following example because + // delaying the user experience is a bad design practice! + // ignore_for_file: avoid_print + print('ready in 3...'); + await Future.delayed(const Duration(seconds: 1)); + print('ready in 2...'); + await Future.delayed(const Duration(seconds: 1)); + print('ready in 1...'); + await Future.delayed(const Duration(seconds: 1)); + print('go!'); + FlutterNativeSplash.remove(); + } + @override Widget build(BuildContext context) { // This method is rerun every time setState is called, for instance as done diff --git a/example/pubspec.lock b/example/pubspec.lock index 426fa5d..8a0c9d5 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -96,12 +96,17 @@ packages: path: ".." relative: true source: path - version: "2.0.3" + version: "2.0.5" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" image: dependency: transitive description: @@ -115,7 +120,7 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.4" + version: "0.6.3" lints: dependency: transitive description: @@ -241,5 +246,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.16.0-100.0.dev <3.0.0" + dart: ">=2.15.1 <3.0.0" flutter: ">=1.17.0" diff --git a/example/web/index.html b/example/web/index.html index b6b9dd2..3d9f3ed 100644 --- a/example/web/index.html +++ b/example/web/index.html @@ -23,13 +23,13 @@ - + - example + flutter_native_splash_example diff --git a/example/web/manifest.json b/example/web/manifest.json index 096edf8..dbcd93c 100644 --- a/example/web/manifest.json +++ b/example/web/manifest.json @@ -1,6 +1,6 @@ { - "name": "example", - "short_name": "example", + "name": "flutter_native_splash_example", + "short_name": "flutter_native_splash_example", "start_url": ".", "display": "standalone", "background_color": "#0175C2", diff --git a/ios/.gitignore b/ios/.gitignore new file mode 100644 index 0000000..0c88507 --- /dev/null +++ b/ios/.gitignore @@ -0,0 +1,38 @@ +.idea/ +.vagrant/ +.sconsign.dblite +.svn/ + +.DS_Store +*.swp +profile + +DerivedData/ +build/ +GeneratedPluginRegistrant.h +GeneratedPluginRegistrant.m + +.generated/ + +*.pbxuser +*.mode1v3 +*.mode2v3 +*.perspectivev3 + +!default.pbxuser +!default.mode1v3 +!default.mode2v3 +!default.perspectivev3 + +xcuserdata + +*.moved-aside + +*.pyc +*sync/ +Icon? +.tags* + +/Flutter/Generated.xcconfig +/Flutter/ephemeral/ +/Flutter/flutter_export_environment.sh \ No newline at end of file diff --git a/ios/Assets/.gitkeep b/ios/Assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/ios/Classes/FlutterNativeSplashPlugin.h b/ios/Classes/FlutterNativeSplashPlugin.h new file mode 100644 index 0000000..a1be446 --- /dev/null +++ b/ios/Classes/FlutterNativeSplashPlugin.h @@ -0,0 +1,4 @@ +#import + +@interface FlutterNativeSplashPlugin : NSObject +@end diff --git a/ios/Classes/FlutterNativeSplashPlugin.m b/ios/Classes/FlutterNativeSplashPlugin.m new file mode 100644 index 0000000..0aba6d2 --- /dev/null +++ b/ios/Classes/FlutterNativeSplashPlugin.m @@ -0,0 +1,20 @@ +#import "FlutterNativeSplashPlugin.h" + +@implementation FlutterNativeSplashPlugin ++ (void)registerWithRegistrar:(NSObject*)registrar { + FlutterMethodChannel* channel = [FlutterMethodChannel + methodChannelWithName:@"flutter_native_splash" + binaryMessenger:[registrar messenger]]; + FlutterNativeSplashPlugin* instance = [[FlutterNativeSplashPlugin alloc] init]; + [registrar addMethodCallDelegate:instance channel:channel]; +} + +- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { + if ([@"getPlatformVersion" isEqualToString:call.method]) { + result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]); + } else { + result(FlutterMethodNotImplemented); + } +} + +@end diff --git a/ios/flutter_native_splash.podspec b/ios/flutter_native_splash.podspec new file mode 100644 index 0000000..1eae6e5 --- /dev/null +++ b/ios/flutter_native_splash.podspec @@ -0,0 +1,23 @@ +# +# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. +# Run `pod lib lint flutter_native_splash.podspec` to validate before publishing. +# +Pod::Spec.new do |s| + s.name = 'flutter_native_splash' + s.version = '0.0.1' + s.summary = 'A new Flutter project.' + s.description = <<-DESC +A new Flutter project. + DESC + s.homepage = 'http://example.com' + s.license = { :file => '../LICENSE' } + s.author = { 'Your Company' => 'email@example.com' } + s.source = { :path => '.' } + s.source_files = 'Classes/**/*' + s.public_header_files = 'Classes/**/*.h' + s.dependency 'Flutter' + s.platform = :ios, '9.0' + + # Flutter.framework does not contain a i386 slice. + s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } +end diff --git a/lib/android.dart b/lib/android.dart index fdf8303..9e69f74 100644 --- a/lib/android.dart +++ b/lib/android.dart @@ -126,25 +126,17 @@ void _createAndroidSplash({ } print('[Android] Updating styles...'); - var sdkVersion = getSdkVersion(); - if (sdkVersion != null && sdkVersion > 30) { + _applyStylesXml( + fullScreen: fullscreen, + file: _androidV31StylesFile, + template: _androidV31StylesXml, + android12BackgroundColor: color); + if (darkColor != null) { _applyStylesXml( fullScreen: fullscreen, - file: _androidV31StylesFile, - template: _androidV31StylesXml, - android12BackgroundColor: color); - if (darkColor != null) { - _applyStylesXml( - fullScreen: fullscreen, - file: _androidV31StylesNightFile, - template: _androidV31StylesNightXml, - android12BackgroundColor: darkColor); - } - } else { - var file = File(_androidV31StylesFile); - if (file.existsSync()) file.deleteSync(); - file = File(_androidV31StylesNightFile); - if (file.existsSync()) file.deleteSync(); + file: _androidV31StylesNightFile, + template: _androidV31StylesNightXml, + android12BackgroundColor: darkColor); } _applyStylesXml( @@ -329,22 +321,3 @@ void replaceElement( launchTheme.children.add(XmlElement(XmlName('item'), [XmlAttribute(XmlName('name'), name)], [XmlText(value)])); } - -int? getSdkVersion() { - int? sdk; - try { - const title = 'compileSdkVersion'; - File('android/app/build.gradle') - .readAsStringSync() - .split('\n') - .forEach((line) { - if (line.contains(title)) { - var sdkVersion = line.substring(line.indexOf(title) + title.length); - sdk = int.tryParse(sdkVersion.trim()); - } - }); - } catch (e) { - return null; - } - return sdk; -} diff --git a/lib/flutter_native_splash.dart b/lib/flutter_native_splash.dart index fa22e75..8fee823 100644 --- a/lib/flutter_native_splash.dart +++ b/lib/flutter_native_splash.dart @@ -7,10 +7,12 @@ library flutter_native_splash; import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; -import 'package:flutter_native_splash/remove_splash.dart'; class FlutterNativeSplash { + static const MethodChannel _channel = MethodChannel('flutter_native_splash'); + static void removeAfter(Function initializeFunction) { final binding = WidgetsFlutterBinding.ensureInitialized(); @@ -26,7 +28,7 @@ class FlutterNativeSplash { // Closes splash screen, and show the app layout. binding.allowFirstFrame(); if (kIsWeb) { - removeSplashFromWeb(); + remove(); } }); } @@ -44,7 +46,7 @@ class FlutterNativeSplash { _widgetsBinding = null; if (kIsWeb) { try { - removeSplashFromWeb(); + _channel.invokeMethod('remove'); } catch (e) { throw Exception(e.toString() + '\nDid you forget to run ' diff --git a/lib/flutter_native_splash_web.dart b/lib/flutter_native_splash_web.dart new file mode 100644 index 0000000..b339033 --- /dev/null +++ b/lib/flutter_native_splash_web.dart @@ -0,0 +1,42 @@ +import 'dart:async'; + +import 'package:flutter/services.dart'; +import 'package:flutter_native_splash/remove_splash_from_web.dart'; +import 'package:flutter_web_plugins/flutter_web_plugins.dart'; +// In order to *not* need this ignore, consider extracting the "web" version +// of your plugin as a separate package, instead of inlining it in the same +// package as the core of your plugin. +// ignore: avoid_web_libraries_in_flutter + +/// A web implementation of the FlutterNativeSplash plugin. +class FlutterNativeSplashWeb { + static void registerWith(Registrar registrar) { + final MethodChannel channel = MethodChannel( + 'flutter_native_splash', + const StandardMethodCodec(), + registrar, + ); + + final pluginInstance = FlutterNativeSplashWeb(); + channel.setMethodCallHandler(pluginInstance.handleMethodCall); + } + + Future handleMethodCall(MethodCall call) async { + switch (call.method) { + case 'remove': + try { + removeSplashFromWeb(); + } catch (e) { + throw Exception( + 'Did you forget to run "flutter pub run flutter_native_splash:create"? \n Could not run the JS command removeSplashFromWeb()'); + } + return; + default: + throw PlatformException( + code: 'Unimplemented', + details: + 'flutter_native_splash for web doesn\'t implement \'${call.method}\'', + ); + } + } +} diff --git a/lib/remove_splash.dart b/lib/remove_splash.dart deleted file mode 100644 index 3dc7576..0000000 --- a/lib/remove_splash.dart +++ /dev/null @@ -1,2 +0,0 @@ -export 'remove_splash_from_web.dart' - if (dart.library.io) 'remove_splash_non_web.dart'; diff --git a/lib/remove_splash_non_web.dart b/lib/remove_splash_non_web.dart deleted file mode 100644 index 5830e6d..0000000 --- a/lib/remove_splash_non_web.dart +++ /dev/null @@ -1,4 +0,0 @@ -void removeSplashFromWeb() { - // You can remove the below line below and include your own implementation if you need - throw UnimplementedError(); -} diff --git a/pubspec.yaml b/pubspec.yaml index f604e1a..9e5a342 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_native_splash description: Customize Flutter's default white native splash screen with background color and splash image. Supports dark mode, full screen, and more. -version: 2.0.4 +version: 2.0.5 homepage: https://github.com/jonbhanson/flutter_native_splash environment: @@ -18,6 +18,8 @@ dependencies: universal_io: ^2.0.4 flutter: sdk: flutter + flutter_web_plugins: + sdk: flutter dev_dependencies: flutter_test: @@ -25,3 +27,17 @@ dev_dependencies: flutter_lints: ^1.0.4 flutter: + # This section identifies this Flutter project as a plugin project. + # The 'pluginClass' and Android 'package' identifiers should not ordinarily + # be modified. They are used by the tooling to maintain consistency when + # adding or updating assets for this project. + plugin: + platforms: + android: + package: net.jonhanson.flutter_native_splash + pluginClass: FlutterNativeSplashPlugin + ios: + pluginClass: FlutterNativeSplashPlugin + web: + pluginClass: FlutterNativeSplashWeb + fileName: flutter_native_splash_web.dart diff --git a/test/flutter_native_splash_test.dart b/test/flutter_native_splash_test.dart index 84cebe8..495c185 100644 --- a/test/flutter_native_splash_test.dart +++ b/test/flutter_native_splash_test.dart @@ -34,7 +34,7 @@ void main() { Directory.current = path; } - setUp(() { + setUp(() { currentDirectory = Directory.current.path; }); tearDown(() { @@ -51,7 +51,7 @@ flutter_native_splash: File('flutter_native_splash.yaml').deleteSync(); expect(config, isNotNull); expect(config!['color'], '#00ff00'); - }); + }); test('default_use_pubspec', () { setCurrentDirectory('pubspec_only'); File('pubspec.yaml').writeAsStringSync(''' @@ -65,6 +65,6 @@ flutter_native_splash: // fails if config file is missing expect(() => getConfig(), throwsException); - }); + }); }); }