Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added a FAQ to address the deprecation of
SplashScreenDrawable
. C…
…loses #199. * Added `<picture>` tag to `index.html` by finding the `</body>` tag instead of `src="main.dart.js`, which was removed in Flutter 2.5. Fixes #202. * Added `<item name="android:forceDarkAllowed">false</item>` tag to dark mode `styles.xml` to improve Xiaomi support. Closes #184. * Use nulls more effectively. Update example app with better dark mode support.
- Loading branch information
1 parent
f8c56be
commit 9c404dd
Showing
32 changed files
with
274 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This file configures the analyzer, which statically analyzes Dart code to | ||
# check for errors, warnings, and lints. | ||
# | ||
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled | ||
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be | ||
# invoked from the command line by running `flutter analyze`. | ||
|
||
# The following line activates a set of recommended lints for Flutter apps, | ||
# packages, and plugins designed to encourage good coding practices. | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
linter: | ||
# The lint rules applied to this project can be customized in the | ||
# section below to disable rules from the `package:flutter_lints/flutter.yaml` | ||
# included above or to enable additional rules. A list of all available lints | ||
# and their documentation is published at | ||
# https://dart-lang.github.io/linter/lints/index.html. | ||
# | ||
# Instead of disabling a lint rule for the entire project in the | ||
# section below, it can also be suppressed for a single line of code | ||
# or a specific dart file by using the `// ignore: name_of_lint` and | ||
# `// ignore_for_file: name_of_lint` syntax on the line or in the file | ||
# producing the lint. | ||
rules: | ||
# avoid_print: false # Uncomment to disable the `avoid_print` rule | ||
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule | ||
|
||
# Additional information about this file can be found at | ||
# https://dart.dev/guides/language/analysis-options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 0 additions & 99 deletions
99
example/android/app/src/main/java/com/example/example/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,105 +1,6 @@ | ||
package com.example.example; | ||
|
||
import android.animation.Animator; | ||
import android.content.Context; | ||
import android.content.pm.PackageManager; | ||
import android.graphics.drawable.Drawable; | ||
import android.os.Build; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.ImageView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
|
||
import io.flutter.embedding.android.FlutterActivity; | ||
import io.flutter.embedding.android.SplashScreen; | ||
|
||
public class MainActivity extends FlutterActivity { | ||
|
||
// By default, Flutter makes a 1/2 second fade between the native splash screen | ||
// and the first Flutter frame. However, loading an image for a secondary splash | ||
// screen takes a moment, causing a flash that can be observed in spite of the fade. | ||
// To prevent this, a CustomSplashScreen is used that keeps the splash screen | ||
// visible over the Flutter app 1/2 second to conceal the flash from the image loading. | ||
// To restore the Flutter default behavior, remove the contents of MainActivity and | ||
// the CustomSplashScreen class. | ||
|
||
@Nullable | ||
@Override | ||
public SplashScreen provideSplashScreen() { | ||
Drawable manifestSplashDrawable = getSplashScreenFromManifest(); | ||
if (manifestSplashDrawable != null) { | ||
return new CustomSplashScreen(manifestSplashDrawable); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
/* package */ static final String SPLASH_SCREEN_META_DATA_KEY = | ||
"io.flutter.embedding.android.SplashScreenDrawable"; | ||
|
||
@Nullable | ||
private Drawable getSplashScreenFromManifest() { | ||
try { | ||
Bundle metaData = getMetaData(); | ||
int splashScreenId = metaData != null ? metaData.getInt(SPLASH_SCREEN_META_DATA_KEY) : 0; | ||
return splashScreenId != 0 | ||
? Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP | ||
? getResources().getDrawable(splashScreenId, getTheme()) | ||
: getResources().getDrawable(splashScreenId) | ||
: null; | ||
} catch (PackageManager.NameNotFoundException e) { | ||
// This is never expected to happen. | ||
return null; | ||
} | ||
} | ||
} | ||
|
||
class CustomSplashScreen implements SplashScreen { | ||
private final Drawable drawable; | ||
private io.flutter.embedding.android.DrawableSplashScreen.DrawableSplashScreenView splashView; | ||
|
||
public CustomSplashScreen(@NonNull Drawable drawable) { | ||
this.drawable = drawable; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public View createSplashView(@NonNull Context context, @Nullable Bundle savedInstanceState) { | ||
splashView = new io.flutter.embedding.android.DrawableSplashScreen.DrawableSplashScreenView(context); | ||
splashView.setSplashDrawable(drawable, ImageView.ScaleType.FIT_XY); | ||
return splashView; | ||
} | ||
|
||
@Override | ||
public void transitionToFlutter(@NonNull Runnable onTransitionComplete) { | ||
if (splashView == null) { | ||
onTransitionComplete.run(); | ||
return; | ||
} | ||
|
||
splashView | ||
.animate() | ||
.alpha(1.0f) | ||
.setDuration(500) | ||
.setListener( | ||
new Animator.AnimatorListener() { | ||
@Override | ||
public void onAnimationStart(Animator animation) {} | ||
|
||
@Override | ||
public void onAnimationEnd(Animator animation) { | ||
onTransitionComplete.run(); | ||
} | ||
|
||
@Override | ||
public void onAnimationCancel(Animator animation) { | ||
onTransitionComplete.run(); | ||
} | ||
|
||
@Override | ||
public void onAnimationRepeat(Animator animation) {} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.