- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以基本上我正在开发一个货币应用程序,在您使用应用程序货币向您的帐户收费后,我验证了付款是否已完成,我需要重定向到主页,但每次都会崩溃,当所有其他自定义路线正在运行。
app.dart:(这是我的路线)
navigatorKey: _navigatorKey,
initialRoute: '/',
routes: {
'/register': (context) => RegisterScreen(),
'/login': (context) => LoginScreen(),
'/home': (context) => HomeScreen(),
'/info': (context) => InfoPage(),
'/accueil': (context) => Onboarding(),
'/wallet' : (context) => WalletScreenContainer(),
},
在确认.dart 页面中,我通过调用运行良好的 API 来检查付款状态:
import 'package:corsicoin/src/models/transaction.dart';
import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../home_screen.dart';
import '../../auth/auth.dart';
import '../../lang/lang.dart';
import '../shared/current_credit.dart';
class Confirmation extends StatefulWidget {
final String transactionToken;
@override
Confirmation(this.transactionToken);
_ConfirmationState createState() => _ConfirmationState();
}
class _ConfirmationState extends State<Confirmation> with SingleTickerProviderStateMixin {
String get transactionToken => widget.transactionToken;
AuthBloc _authBloc;
Future<String> _asyncFetch;
@override
void initState() {
print('token : '+transactionToken);
_authBloc = BlocProvider.of<AuthBloc>(context);
_asyncFetch = getPaymentDetails(transactionToken);
super.initState();
}
@override
void dispose(){
this.dispose;
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Confirmation"),//LocalizedText(Localization.payment),
// leading: null,
// automaticallyImplyLeading: false,
),
body: buildPage()
);
}
Widget buildPage() {
return FutureBuilder<String>(
// _initiatepayment() will await for the url sended bck by Cyclos
future: _asyncFetch,
builder: (context, snapshot) {
if (snapshot.hasData) {
if(snapshot.data == "true"){
//this will be what is returned if the payment is successful
return Container(
padding: EdgeInsets.fromLTRB(30,50,30,150),
child : Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Center(child : LocalizedText(Localization.payment_done, textAlign: TextAlign.center,)),
Center(child :Icon(
Icons.check_circle_outline,
color: Colors.green,
size : 100,
)),
MaterialButton(
minWidth: 500,
color: Theme.of(context).primaryColor,
textColor: Colors.white,
padding: EdgeInsets.all(12),
child: LocalizedText(Localization.ok_understood,),
onPressed: (){
Navigator.pushNamed(context, '/home');
},
),
],
)
);
} else {
//this is waht we return if the payment failed
return Container(
padding: EdgeInsets.fromLTRB(30,50,30,150),
child : Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Center(child : LocalizedText(Localization.payment_failed, textAlign: TextAlign.center,)),
Center(child :Icon(
Icons.block,
color: Colors.red,
size : 100,
)),
MaterialButton(
minWidth: 500,
color: Theme.of(context).primaryColor,
textColor: Colors.white,
padding: EdgeInsets.all(12),
child: LocalizedText(Localization.ok_understood,),
onPressed: (){
print("yo");
},
),
],
)
);
}
} else if (snapshot.hasError) {
return Scaffold(
body: Center(
child: Text("${snapshot.error}"),
),
);
}
return Scaffold(
body:
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Container(padding: EdgeInsets.all(50),
child : LocalizedText(Localization.wait_payment, textAlign: TextAlign.center,),),
Center(child : CircularProgressIndicator()),
]),
);
},
);
}
Future<String> getPaymentDetails(String token) async {
final confirmationBool = await _authBloc.authRepository.getPaymentDetails(token);
print("bool returned : "+confirmationBool);
return confirmationBool;
}
}
当我点击 RaisingButton 时,应用程序崩溃了。是因为 Future Builder 还是因为/home 页面要求提供参数,但在到达确认页面之前它就已经构建完成了。如果您想要的话,这里是代码:
home_screen.dart:
import 'package:flutter/material.dart';
import 'pay/pay_screen.dart';
import 'cash/cash_screen.dart';
import 'shops/shops_screen.dart';
import 'account/account_screen.dart';
import 'account/shop_account_screen.dart';
import 'transfer/transfer_screen.dart';
import 'wallet/wallet_screen.dart';
import '../lang/lang.dart';
class HomeScreen extends StatefulWidget {
final bool isShop;
HomeScreen({this.isShop});
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
List<Widget> _widgets;
int _currentIndex = 2;
bool get isShop => widget.isShop;
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
_widgets = isShop
? [
ShopAccountScreen(),
ShopsScreen(),
CashScreenContainer(),
PayScreenContainer(),
TransferScreen(),
]
: [
WalletScreenContainer(),
ShopsScreen(),
PayScreenContainer(),
TransferScreen(),
AccountScreen(),
];
return Scaffold(
body: _widgets.elementAt(_currentIndex),
bottomNavigationBar: NavigationBar(
currentIndex: _currentIndex,
isShop: isShop,
onTap: (int index) {
setState(() {
_currentIndex = index;
});
},
),
resizeToAvoidBottomInset: _currentIndex != 2 || _currentIndex != 3,
);
}
}
class NavigationBar extends StatelessWidget {
final int currentIndex;
final void Function(int index) onTap;
final bool isShop;
NavigationBar({this.currentIndex, this.onTap, this.isShop});
@override
Widget build(BuildContext context) {
return isShop
? _buildNavigationBarForShop(context)
: _buildNavigationBarForUser(context);
}
Widget _buildNavigationBarForUser(BuildContext context) {
return BottomNavigationBar(
items: [
BottomNavigationBarItem(
icon: Icon(Icons.account_balance_wallet),
title: LocalizedText(Localization.menu_wallet),
backgroundColor: Colors.white,
),
BottomNavigationBarItem(
icon: Icon(Icons.shopping_cart),
title: LocalizedText(Localization.menu_shops),
backgroundColor: Colors.white,
),
BottomNavigationBarItem(
icon: Icon(Icons.credit_card),
title: LocalizedText(Localization.menu_pay),
backgroundColor: Colors.white,
),
BottomNavigationBarItem(
icon: Icon(Icons.swap_horiz),
title: LocalizedText(Localization.menu_transfer),
backgroundColor: Colors.white,
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
title: LocalizedText(Localization.menu_account),
backgroundColor: Colors.white,
),
],
currentIndex: currentIndex,
type: BottomNavigationBarType.fixed,
// backgroundColor: Colors.white,
// selectedItemColor: Theme.of(context).primaryColor,
// unselectedItemColor: Theme.of(context).colorScheme.secondary,
onTap: onTap,
);
}
Widget _buildNavigationBarForShop(BuildContext context) {
return BottomNavigationBar(
items: [
BottomNavigationBarItem(
icon: Icon(Icons.business_center),
title: LocalizedText(Localization.menu_account),
backgroundColor: Colors.white,
),
BottomNavigationBarItem(
icon: Icon(Icons.shopping_cart),
title: LocalizedText(Localization.menu_shops),
backgroundColor: Colors.white,
),
BottomNavigationBarItem(
icon: Icon(Icons.arrow_downward),
title: LocalizedText(Localization.menu_cash),
backgroundColor: Colors.white,
),
BottomNavigationBarItem(
icon: Icon(Icons.credit_card),
title: LocalizedText(Localization.menu_pay),
backgroundColor: Colors.white,
),
BottomNavigationBarItem(
icon: Icon(Icons.swap_horiz),
title: LocalizedText(Localization.menu_transfer),
backgroundColor: Colors.white,
),
],
currentIndex: currentIndex,
type: BottomNavigationBarType.fixed,
onTap: onTap,
);
}
}
name: corsicoin
description: Corsicoin app.
# 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 used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.1.46
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
shared_preferences: ^0.5.2
cached_network_image: ^1.1.0
flutter_svg: ^0.13.1
rflutter_alert: ^1.0.3
flutter_bloc: ^0.11.1
equatable: ^0.1.6
flutter_secure_storage: ^3.2.1
local_auth: ^0.4.0+1
http_auth: ^0.2.5
firebase_core: ^0.4.0+6
firebase_messaging: ^5.1.3
cloud_firestore: ^0.12.9+6
firebase_auth: ^0.14.0+5
validate: ^1.7.0
kiwi: ^0.1.0
image_picker: ^0.6.1
flutter_crashlytics: ^1.0.0
flutter_sticky_header: ^0.4.0
dio: ^2.1.0
auto_size_text: ^1.1.1
flutter_masked_text: ^0.8.0
permission_handler: '^3.2.0'
path_provider: ^0.5.0+1
flutter_email_sender: ^2.0.0
flutter_swiper: ^1.1.6
contacts_service: ^0.2.8
geolocator: ^5.1.1+1
google_maps_flutter: ^0.5.20+1
url_launcher: ^5.0.2
qr_mobile_vision: ^0.2.2
qr_flutter: ^2.0.0+51
csv: ^4.0.3
share_extend: ^1.0.8
country_pickers: ^1.1.0
diacritic: ^0.1.1
recase: ^2.0.1
keyboard_visibility: ^0.5.6
http: 0.12.0
flutter_webview_plugin: ^0.3.10
webview_flutter : ^0.3.17
flutter_worldpay:
path: ../flutter_worldpay/
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
assets:
- assets/images/
- assets/icons/
- assets/html/
# 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:
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.io/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.io/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
#
# For details regarding fonts from package dependencies,
# see https://flutter.io/custom-fonts/#from-packages
fonts:
- family: Lato
fonts:
- asset: assets/fonts/Lato.ttf
- asset: assets/fonts/Lato-Light.ttf
weight: 300
- asset: assets/fonts/Lato-Bold.ttf
weight: 700
- family: Nunito
fonts:
- asset: assets/fonts/Nunito.ttf
- asset: assets/fonts/Nunito-Light.ttf
weight: 300
- asset: assets/fonts/Nunito-Bold.ttf
weight: 700
flutter doctor 中的一切都在点上
最佳答案
最可能的崩溃原因似乎是 HomeScreen
中的 isShop
bool 值。
原因如下:
isShop
是一个可选的 bool 值,这意味着,如果没有明确指定值,它将保持 null
initState
中初始化即可使用来处理默认场景要解决此问题,只需替换:
HomeScreen({this.isShop});
与
HomeScreen({this.isShop = false});
如果您需要更多帮助,请告诉我。
关于android - Flutter - Navigator.pushNamed 使应用程序在调用路线时崩溃(在 FutureBuilder 内),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59613216/
为了让我的代码几乎完全用 Jquery 编写,我想用 Jquery 重写 AJAX 调用。 这是从网页到 Tomcat servlet 的调用。 我目前情况的类似代码: var http = new
我想使用 JNI 从 Java 调用 C 函数。在 C 函数中,我想创建一个 JVM 并调用一些 Java 对象。当我尝试创建 JVM 时,JNI_CreateJavaVM 返回 -1。 所以,我想知
环顾四周,我发现从 HTML 调用 Javascript 函数的最佳方法是将函数本身放在 HTML 中,而不是外部 Javascript 文件。所以我一直在网上四处寻找,找到了一些简短的教程,我可以根
我有这个组件: import {Component} from 'angular2/core'; import {UserServices} from '../services/UserService
我正在尝试用 C 实现一个简单的 OpenSSL 客户端/服务器模型,并且对 BIO_* 调用的使用感到好奇,与原始 SSL_* 调用相比,它允许一些不错的功能。 我对此比较陌生,所以我可能会完全错误
我正在处理有关异步调用的难题: 一个 JQuery 函数在用户点击时执行,然后调用一个 php 文件来检查用户输入是否与数据库中已有的信息重叠。如果是这样,则应提示用户确认是否要继续或取消,如果他单击
我有以下类(class)。 public Task { public static Task getInstance(String taskName) { return new
嘿,我正在构建一个小游戏,我正在通过制作一个数字 vector 来创建关卡,该数字 vector 通过枚举与 1-4 种颜色相关联。问题是循环(在 Simon::loadChallenge 中)我将颜
我有一个java spring boot api(数据接收器),客户端调用它来保存一些数据。一旦我完成了数据的持久化,我想进行另一个 api 调用(应该处理持久化的数据 - 数据聚合器),它应该自行异
首先,这涉及桌面应用程序而不是 ASP .Net 应用程序。 我已经为我的项目添加了一个 Web 引用,并构建了各种数据对象,例如 PayerInfo、Address 和 CreditCard。但问题
我如何告诉 FAKE 编译 .fs文件使用 fsc ? 解释如何传递参数的奖励积分,如 -a和 -target:dll . 编辑:我应该澄清一下,我正在尝试在没有 MSBuild/xbuild/.sl
我使用下划线模板配置了一个简单的主干模型和 View 。两个单独的 API 使用完全相同的配置。 API 1 按预期工作。 要重现该问题,请注释掉 API 1 的 URL,并取消注释 API 2 的
我不确定什么是更好的做法或更现实的做法。我希望从头开始创建目录系统,但不确定最佳方法是什么。 我想我在需要显示信息时使用对象,例如 info.php?id=100。有这样的代码用于显示 Game.cl
from datetime import timedelta class A: def __abs__(self): return -self class B1(A):
我在操作此生命游戏示例代码中的数组时遇到问题。 情况: “生命游戏”是约翰·康威发明的一种细胞自动化技术。它由一个细胞网格组成,这些细胞可以根据数学规则生存/死亡/繁殖。该网格中的活细胞和死细胞通过
如果我像这样调用 read() 来读取文件: unsigned char buf[512]; memset(buf, 0, sizeof(unsigned char) * 512); int fd;
我用 C 编写了一个简单的服务器,并希望调用它的功能与调用其他 C 守护程序的功能相同(例如使用 ./ftpd start 调用它并使用 ./ftpd stop 关闭该实例)。显然我遇到的问题是我不知
在 dos 中,当我粘贴此命令时它会起作用: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" https://google.
在 dos 中,当我粘贴此命令时它会起作用: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" https://google.
我希望能够从 cmd 在我的 Windows 10 计算机上调用 python3。 我已重新安装 Python3.7 以确保选择“添加到路径”选项,但仍无法调用 python3 并使 CMD 启动 P
我是一名优秀的程序员,十分优秀!