'Static Text in flutter not showing
I put my all labels in AppLabels class and fetching. In debug mode during development its work fine but when I run "flutter build apk --release" and run the app, all the labels not showing in my app.
and I am showing Text by using AppLabels.mytext
and my result APK shows like this with no text
This is my main class code:
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
LocationPermission locationPermission = Get.put(LocationPermission());
@override
void initState() {
locationPermission.getlocation();
super.initState();
}
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return Sizer(builder: (context, orientation, deviceType) {
return GetMaterialApp(home: GettingStarted());
// home: Home(),
});
}
}
and this is my app Labels class code:
class AppLabels {
static String gpsNavigation = "GPS Navigation";
static String getStarted = "Get Started";
static String allYouNeed =
"All you need is the plan, the road map, and \n the courage to press on to your destination.";
static String gettingStarted = "Get Started >";
static String agree = 'Agree ';
static String termsOfServices = 'Terms of Services';
}
and I am using that labels in my app like this
// ignore_for_file: prefer_const_constructors
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:navigation_project/Constants/app_colors.dart';
import 'package:navigation_project/Constants/app_images.dart';
import 'package:navigation_project/Constants/app_labels.dart';
import 'package:navigation_project/Constants/app_text_style.dart';
import 'package:sizer/sizer.dart';
import 'main_tabs_screen.dart';
class GettingStarted extends StatelessWidget {
const GettingStarted({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(crossAxisAlignment: CrossAxisAlignment.center,
// mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: 50.h,
width: 60.w,
child: Image.asset(
AppImages.papermap,
// fit: BoxFit,
),
),
Padding(
padding: EdgeInsets.only(left: 5.w, right: 5.w),
child: Text(
AppLabels.gpsNavigation,
style: AppTextStyle.poopinsRegularBlack33,
),
),
Padding(
padding: EdgeInsets.only(top: 2.0.h, left: 5.w, right: 5.w),
child: Text(
AppLabels.allYouNeed,
textAlign: TextAlign.center,
style: AppTextStyle.poopinsRegularBlack12,
),
),
SizedBox(height: 10.h),
ElevatedButton(
onPressed: () {
Get.to(() => MainTabPage());
},
child: Text(
AppLabels.getStarted,
style: AppTextStyle.poopinsRegularBlack14
.copyWith(color: AppColors.kwhite),
),
),
SizedBox(height: 8.h),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Radio(value: 0, groupValue: 0, onChanged: (a) {}),
Text.rich(TextSpan(children: <InlineSpan>[
TextSpan(
text: AppLabels.agree,
style: AppTextStyle.poopinsRegularBlack11,
),
TextSpan(
text: AppLabels.privacyPolicy,
style: AppTextStyle.poopinsRegularBlue11
.copyWith(decoration: TextDecoration.underline),
),
TextSpan(
text: ' & ',
style: AppTextStyle.poopinsRegularBlack11,
),
TextSpan(
text: AppLabels.termsOfServices,
style: AppTextStyle.poopinsRegularBlue11
.copyWith(decoration: TextDecoration.underline),
)
])),
],
),
]));
}
}
Result in debug mode during development:

Result after running flutter build apk --release :

White spaces contain text, but there is no text in
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
