[英]Flutter app(android) not working on real device in release mode
I've been building a demo app to practice flutter, the app's running perfectly fine in the emulator as well as on real devices when connected.我一直在构建一个演示应用程序来练习颤振,该应用程序在模拟器以及连接后的真实设备上运行得非常好。 But now, I've been trying to run the APK file on my mobile and it seems to not work.
但是现在,我一直在尝试在我的手机上运行 APK 文件,但它似乎不起作用。 I can log in to the app meaning the internet permission is working.
我可以登录该应用程序,这意味着互联网许可正在运行。 But when it comes to the home screen which pulls data from a server, the app does not work.
但是,当涉及从服务器提取数据的主屏幕时,该应用程序无法运行。 Maybe there's something wrong in the code relevant, but I can't seem to fix it.
也许相关代码有问题,但我似乎无法修复它。
I've attached the code for the home screen as well, the provider part is the thing that is having issues.我也附上了主屏幕的代码,提供者部分是有问题的东西。 AND ALSO THE DATABASE HAS THE DATA MEANING THE LIST IS NOT EMPTY AT ALL
并且数据库有数据意味着列表根本不是空的
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import './new_enquiry_screen.dart'; import '../providers/enquiries_provider.dart'; import '../screens/new_enquiry_screen.dart'; import '../widgets/drawer_widget.dart'; import '../widgets/follow_up_list_tile_widget.dart'; class EnquiryScreen extends StatelessWidget { const EnquiryScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return DefaultTabController( length: 3, child: Scaffold( drawer: DrawerWidget(), appBar: AppBar( bottom: const TabBar( tabs: [ Tab(text: 'Follow Ups'), Tab(text: 'Leads'), Tab(text: 'Past'), ], ), title: Text( 'Enquiries', ), backgroundColor: Theme.of(context).primaryColor, ), body: TabBarView( children: [ ChangeNotifierProvider<EnquiriesProvider>.value( value: EnquiriesProvider(), child: Consumer<EnquiriesProvider>( builder: (_, provider, child) { int length = provider.enquiries.length; return length == 0 ? Center( child: CircularProgressIndicator(), ) : ListView.builder( itemCount: length, itemBuilder: (_, index) { return FollowUpListTileWidget( provider.enquiries.elementAt(index), ); }, ); }, ), ), const Center( child: Text('Leads Up'), ), const Center( child: Text('Past Up'), ), ], ), floatingActionButton: FloatingActionButton( backgroundColor: Theme.of(context).primaryColor, onPressed: () { Navigator.of(context).pushNamed(NewEnquiryScreen.routeName); }, child: Icon( Icons.add, color: Theme.of(context).accentColor, size: 30, ), ), ), ); } }
import 'package:flutter/material.dart'; import '../models/enquiry.dart'; class FollowUpListTileWidget extends StatelessWidget { const FollowUpListTileWidget(this._enquiry, {Key? key}) : super(key: key); final Enquiry _enquiry; @override Widget build(BuildContext context) { return Card( elevation: 10, margin: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 5.0), child: ListTile( leading: CircleAvatar( child: Text( _enquiry.name.characters.first.toUpperCase(), style: TextStyle( color: Theme.of(context).accentColor, ), ), backgroundColor: Theme.of(context).primaryColor, ), title: Text(_enquiry.name), subtitle: FittedBox(child: Text(_enquiry.email)), trailing: Row( mainAxisSize: MainAxisSize.min, children: [ IconButton( color: Theme.of(context).primaryColor, onPressed: () {}, icon: const Icon( Icons.phone, ), ), IconButton( color: Theme.of(context).primaryColor, onPressed: () {}, icon: const Icon(Icons.whatsapp), ), IconButton( color: Theme.of(context).primaryColor, onPressed: () {}, icon: const Icon(Icons.edit), ), ], ), ), ); } }
尝试在真实设备上以调试模式运行应用程序,如果它正在运行,则检查清单文件是否已在android/app/main/AndroidManifest.xml
中授予互联网权限,默认情况下在调试模式下互联网权限已退出且最重要请从您的问题标题中删除所有大写字母,因为它很难阅读。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.