flutter - apk 中的在线图像问题(Flutter)
问题描述
我是新来的,一周前刚开始学习飞镖。我正在构建一个项目,并且我正在使用 Image.Network(url) 来显示图像,因为稍后我将需要在项目中与数据库进行通信。应用程序中的所有照片都来自互联网......当我将apk文件构建到我的手机时,照片就不会出现。它显然与互联网的通信有问题..但我知道它是什么.. 这是应用程序照片(请忽略语言..)
这是源代码:
class HomeScreen extends StatelessWidget {
Container myHomework(
String heading, String subHeading, String hwCategoryEmoji) {
return Container(
width: 150,
child: Card(
color: Color(0xFF3D3D3D),
child: Wrap(
children: <Widget>[
Align(
alignment: Alignment.topRight,
child: Container(
height: 25,
width: 25,
decoration: BoxDecoration(shape: BoxShape.circle),
child: Image.asset("assets/images/123.png"),
),
),
ListTile(
title: Text(
heading,
style: TextStyle(
fontWeight: FontWeight.w900,
fontSize: 13,
color: Colors.white),
),
subtitle: Text(
subHeading,
style: TextStyle(fontWeight: FontWeight.w800, fontSize: 11),
),
)
],
),
));
}
final String personName = "ליאם רחום";
final String personImage =
"https://instagram.ftlv6-1.fna.fbcdn.net/v/t51.2885-15/e35/p1080x1080/100909907_261706925023177_4991314082934193948_n.jpg?_nc_ht=instagram.ftlv6-1.fna.fbcdn.net&_nc_cat=101&_nc_ohc=qvNVUzKyb04AX-jlrb_&oh=55c9b8538d7c55375e5cf9d976d64c4c&oe=5F15CB42";
final String currentCourse = "פייתון - מתקדמים";
final String currentCourseImage =
"https://images.unsplash.com/photo-1461749280684-dccba630e2f6?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80";
final String popularCourseImage =
"https://images.wallpapersden.com/image/download/liquicity-digital-art_62312_1920x1080.jpg";
final String popularCourseTitle = "למדו אומנות דיגיטלית\n עכשיו בשידור חי!";
final String hw = "מתמטיקה";
final String hwCategory = "נושא - אלגברה";
final String hwCategoryPicture =
"https://c4.wallpaperflare.com/wallpaper/926/800/33/math-wallpaper-preview.jpg";
final String hwCategoryEmoji = "";
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xFF1C1D21),
body: Stack(
children: <Widget>[
Row(
children: <Widget>[
SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Align(
alignment: Alignment.topLeft,
child: Container(
alignment: Alignment.center,
height: 62,
width: 62,
decoration: BoxDecoration(shape: BoxShape.circle),
),
)
],
),
)),
Padding(
padding: EdgeInsets.only(
left: 90,
),
),
Align(
alignment: Alignment(0, -0.85),
child: Flexible(
child: Text("שלום, $personName!",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w900,
fontSize: 16)),
))
],
),
SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Align(
alignment: Alignment.topLeft,
child: Container(
alignment: Alignment.center,
height: 62,
width: 62,
decoration: BoxDecoration(
color: Color(0xFF3D3D3D),
shape: BoxShape.circle,
),
child: Container(
width: 62,
height: 62,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
image: NetworkImage(personImage),
fit: BoxFit.cover,
),
boxShadow: [
BoxShadow(
color: Colors.black,
spreadRadius: -8,
blurRadius: 13,
offset: Offset(3, 3))
],
),
),
),
),
Padding(
padding: EdgeInsets.only(top: 30),
),
Container(
child: Row(
children: <Widget>[
Padding(
padding: EdgeInsets.only(left: 10),
),
Container(
height: 80,
width: 300,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFFFF2424),
Color(0xFF8630F6)
])),
child: Row(
children: <Widget>[
Padding(
padding: EdgeInsets.only(left: 10),
),
Align(
alignment: Alignment.centerRight,
child: Container(
width: 75.0,
height: 55.0,
decoration: new BoxDecoration(
shape: BoxShape.rectangle,
image: new DecorationImage(
fit: BoxFit.fill,
image: NetworkImage(currentCourseImage),
),
borderRadius: BorderRadius.circular(20))),
),
Flexible(
child: ListView(
children: <Widget>[
Align(
alignment: Alignment(0, -0.7),
child: Row(
children: <Widget>[
Padding(
padding: EdgeInsets.only(left: 100),
),
Text(
":קורס נוכחי",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w900,
fontSize: 17,
decoration:
TextDecoration.underline),
),
Padding(
padding: EdgeInsets.only(top: 10),
),
],
)),
Padding(
padding: EdgeInsets.only(top: 5),
),
Align(
alignment: Alignment(-3, 0),
child: Flexible(
child: Align(
alignment: Alignment(.44, 0),
child: Text(
currentCourse,
style: TextStyle(
fontWeight: FontWeight.w900,
fontSize: 17,
color: Colors.white,
),
),
),
),
),
],
),
),
],
),
),
],
)),
Padding(
padding: EdgeInsets.only(top: 18),
),
Flexible(
child: Align(
alignment: Alignment.topRight,
child: Text(
"פופולארי בקרב תלמידים",
style: TextStyle(
fontWeight: FontWeight.w900,
fontSize: 15,
color: Colors.white),
),
)),
Align(
alignment: Alignment.center,
child: Container(
width: 300.0,
height: 85.0,
decoration: new BoxDecoration(
shape: BoxShape.rectangle,
image: new DecorationImage(
fit: BoxFit.cover,
image: NetworkImage(popularCourseImage),
),
borderRadius: BorderRadius.circular(20),
),
child: Align(
alignment: Alignment(0, -0.5),
child: Text(
popularCourseTitle,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w900,
fontSize: 15,
shadows: [
Shadow(
color: Color(0xFF000000),
offset: Offset(-1, 1),
blurRadius: 3,
)
]),
),
),
),
),
Padding(
padding: EdgeInsets.only(top: 15),
),
Flexible(
child: Align(
alignment: Alignment.topRight,
child: Text("משימות לעשות",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w900,
fontSize: 16)),
)),
Container(
margin: EdgeInsets.symmetric(vertical: 10.0),
height: 100,
child: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
myHomework(hw, hwCategory, hwCategoryEmoji),
myHomework(hw, "נושא - גיאומטריה", hwCategoryEmoji),
myHomework(hw, hwCategory, hwCategoryEmoji),
],
)),
Padding(
padding: EdgeInsets.only(top: 20),
),
Padding(
padding: EdgeInsets.only(top: 20),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Align(
alignment: Alignment.bottomRight,
child: FloatingActionButton.extended(
heroTag: "profileBtn",
icon: Icon(Icons.person),
label: Text(
"פרופיל",
style: TextStyle(fontWeight: FontWeight.w800),
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ProfilePage()),
);
})),
Padding(
padding: EdgeInsets.only(left: 10),
),
Align(
child: FloatingActionButton.extended(
splashColor: Color(0xFFFF1170),
backgroundColor: Color(0xFFFF1170),
heroTag: "searchBtn",
icon: Icon(Icons.search),
label: Text("חיפוש",
style:
TextStyle(fontWeight: FontWeight.w800)),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SearchPage()),
);
})),
],
),
Padding(
padding: EdgeInsets.only(bottom: 10),
),
],
),
),
)
],
),
);
}
}
谢谢 :)
解决方案
由于 Flutter 本身具有管理互联网权限,我认为这不是由于权限。
我建议你使用Image.network
而不是NetworkImage(),
推荐阅读
- android - 获取 onStop() 的原因
- mongodb - 无法连接到服务器 127.0.0.1:27017 连接尝试失败 MongoDB
- angular - Angular 6 @angular/pwa - sw 没有成功地服务于清单的 start_url
- postfix-mta - Postfix smtpd - 在 /var/log/mail.log 中不断连接和断开连接
- javascript - 在 Angular 6 中调用函数并将其传递给 *ngIf
- android - WifiPermissionsUtil 在 React Native 上被拒绝
- javascript - 如果 html 表中的字符串 == 带有 Javascript 的内容,则显示按钮
- xaml - 如何在网格视图中换行
- android - 当 NDEF 被发送/触摸到光束被按下时得到通知
- php - 无法加载动态库“C:\php\ext\php_pthreads.dll”