我在实际设备上测试发行版apk时遇到一些麻烦,这些应用程序在调试模式下可以正常工作,但是发行版apk中没有加载许多小部件。
我是否需要对发布apk进行任何设置?
p.s。我已经在AndroidManifest上添加了INTERNET和ACCESS_NETWORK_STATE权限
编辑: 我的main.dart
void main() async {
// Set default home.
Widget _defaultHome = new LoginScreen();
SharedPreferences preferences = await SharedPreferences.getInstance();
bool isloggedin = preferences.getBool("isLoggedin");
if (isloggedin != null && isloggedin) {
_defaultHome = new Home();
}
runApp(new StateWidget(
child: new MaterialApp(
title: 'Firebase Login Demo',
theme: buildTheme(),
debugShowCheckedModeBanner: false,
home: _defaultHome,
routes: <String, WidgetBuilder>{
'/home' : (BuildContext context) => new Home(),
'/login' : (BuildContext context) => new LoginScreen(),
},
)
));
}
我的login.dart:
class LoginScreen extends StatefulWidget {
@override
_LoginScreenState createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
StateModel appState;
BoxDecoration _buildBackground() {
return BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/back.jpg"),
fit: BoxFit.cover,
),
);
}
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
appState = StateWidget.of(context).state;
return Scaffold(
body: Container(
decoration: _buildBackground() ,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
//_buildText(),
// Space between "Recipes" and the button:
SizedBox(height: 300.0),
GoogleSignInButton(
onPressed: () async {
await signInWithGoogle(context);
bool isloggedin = appState.isLoggedin;
if (isloggedin) {
Navigator.pushReplacement(context,
MaterialPageRoute(
builder: (context) => new Home(),
),
);
}
}
),
SizedBox(height: 40.0),
FacebookSignInButton(
onPressed: () async {
await signInWithFacebook(context);
bool isloggedin = appState.isLoggedin;
if (isloggedin) {
Navigator.pushReplacement(context,
MaterialPageRoute(
builder: (context) => new Home(),
),
);
}
}
),
],
),
),
),
);
}
}