I have a Flutter application, it works perfectly fine when I run it in debug mode, but when I configured the signing key and everything that’s needed for a release build and run it in release mode, it shows a white blank screen, what’s even more weird is that there’s chances it worked fine in release mode, about once out of 7-8 release install, which makes me really crazy about this issue, I have googled for solution, searched for issues in the flutter repo, tried everything I found on the web, yet I still don’t find a solution, can anyone help me please!
This is my main file:
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:shutiaotv_app/data/user_manager.dart';
import 'package:shutiaotv_app/presentation/splash_screen/splash_screen.dart';
import 'package:feedback/feedback.dart';
import 'package:upgrader/upgrader.dart';
import 'core/theme/theme_constants.dart';
import 'core/theme/theme_manager.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(
const BetterFeedback(
child: MyApp(),
),
);
}
ThemeManager themeManager = ThemeManager();
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
themeManager.addListener(themeListener);
UserManager().loadData().then((value) => themeManager.toggleTheme(UserManager().isDark));
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
}
@override
void dispose() {
themeManager.removeListener(themeListener);
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft,
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
super.dispose();
}
void themeListener() {
if (mounted) {
setState(() {});
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: '泰美影视',
debugShowCheckedModeBanner: false,
theme: lightTheme,
darkTheme: darkTheme,
themeMode: themeManager.themeMode,
home: UpgradeAlert(
showIgnore: false,
child: const SplashScreen(),
),
);
}
}
This is my pubspec yaml file:
name: shutiaotv_app
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter 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 is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+3
environment:
# sdk: '>=2.19.3 <3.0.0'
sdk: '>=3.3.4 <4.0.0'
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
cached_network_image: ^3.3.0
flutter_svg: ^2.0.9
flutter_switch: ^0.3.2
pin_code_fields: ^8.0.1
video_player: ^2.4.6
smooth_page_indicator: ^1.0.0+2
country_list_pick: ^1.0.1+5
flutter_rating_bar: ^4.0.0
meilisearch: ^0.15.0
fijkplayer: ^0.11.0
dio: ^5.3.0
expandable: ^5.0.1
shared_preferences: ^2.2.3
email_validator: ^2.1.17
timer_count_down: ^2.2.2
infinite_scroll_pagination: ^4.0.0
shimmer: ^3.0.0
animated_text_kit: ^4.2.2
getwidget: ^4.0.0
expandable_text: ^2.3.0
extended_wrap: ^0.1.5
flutter_animated_icon_button: ^1.1.3
animated_snack_bar: ^0.4.0
duration: ^3.0.13
url_launcher: ^6.2.6
path_provider: ^2.1.2
filesize: ^2.0.1
disk_space_plus: ^0.2.3
feedback: ^3.0.1
page_transition: ^2.1.0
upgrader: ^10.0.1
in_app_review: ^2.0.9
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.6
dev_dependencies:
flutter_test:
sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^3.0.0
flutter_launcher_icons: ^0.13.1
flutter_native_splash: ^2.3.10
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
flutter_launcher_icons:
android: "launcher_icon"
ios: true
image_path: "assets/app_icon.png"
min_sdk_android: 21 # android min sdk min:16, default 21
flutter_native_splash:
background_image: "assets/splash_background.png"
# The following section is specific to Flutter packages.
flutter:
# 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
assets:
- assets/
- assets/images/
# 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
fonts:
- family: SF Pro Display
fonts:
- asset: assets/fonts/Noto_Sans_SC/NotoSansSC-Regular.ttf
weight: 400
- asset: assets/fonts/Noto_Sans_SC/NotoSansSC-Medium.ttf
weight: 600
- asset: assets/fonts/Noto_Sans_SC/NotoSansSC-Bold.ttf
weight: 700
# - asset: assets/fonts/SFPRODISPLAYREGULAR.OTF
# weight: 400
# - asset: assets/fonts/SFPRODISPLAYMEDIUM.OTF
# weight: 600
# - asset: assets/fonts/SFPRODISPLAYBOLD.OTF
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
This is my splash_screen file which is the home page of the material app widget:
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:shutiaotv_app/core/app_export.dart';
import 'package:shutiaotv_app/data/user_manager.dart';
import 'package:shutiaotv_app/presentation/home.dart';
import 'package:shutiaotv_app/presentation/onboarding_1_vone_screen/onboarding_1_vone_screen.dart';
import 'package:animated_text_kit/animated_text_kit.dart';
class SplashScreen extends StatefulWidget {
const SplashScreen({super.key});
@override
State<SplashScreen> createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
Timer(const Duration(seconds: 3), () {
UserManager().loadUser().then((user) {
if (user == null) {
Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (_) => const Onboarding1VoneScreen()));
} else {
Navigator.of(context).pushAndRemoveUntil(MaterialPageRoute(builder: (_) => const Home()), (route) => false);
}
});
});
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: ColorConstant.splashBackground,
body: Stack(
children: [
Align(
alignment: Alignment.center,
child: CommonImageView(
imagePath: ImageConstant.tvLogo,
fit: BoxFit.contain,
width: getHorizontalSize(200.00),
),
),
Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: const EdgeInsets.only(bottom: 48),
child: AnimatedTextKit(
totalRepeatCount: 1,
animatedTexts: [
TypewriterAnimatedText(
'泰美影视',
speed: const Duration(milliseconds: 300),
textStyle: TextStyle(
color: Colors.white,
fontSize: getFontSize(48),
fontFamily: 'SF Pro Display',
fontWeight: FontWeight.w500,
height: 1.00,
),
),
],
),
),
),
],
),
);
}
}
This is the screenshot of a rare situation when it worked in release mode and doesn’t show just a white blank screen.
This is the screenshot when most of the times when it only shows a white blank screen when run in release mode.
I tried disabling the R8 code obfuscation and resource shrinking, not working, add a flutter error listener in the main function, nothing printed.