我正在尝试使用 SingleChildScrollView 使堆栈布局可滚动,但它不滚动。这里应该使用 SingleChildScrollView 吗?
我想我已经给出了足够的描述,让任何人都能理解我的问题。此处提供更多文本以满足 StackOverflow 提出问题的要求。为此事道歉。
这是示例代码。
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Container(
child: Center(
child: LayoutBuilder(
builder:
(BuildContext context, BoxConstraints viewportConstraints) {
return SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: viewportConstraints.maxHeight,
),
child: IntrinsicHeight(
child: Column(
children: <Widget>[
Container(
// A fixed-height child.
color: Colors.white,
height: 120.0,
),
Expanded(
// A flexible child that will grow to fit the viewport but
// still be at least as big as necessary to fit its …
Run Code Online (Sandbox Code Playgroud) 我正在使用 dart 的 http 包来发出帖子请求。由于某些服务器问题,其抛出异常。我已将代码包装在 try catch 块代码中,但它没有捕获异常。
这是发出网络请求的代码
class VerificationService {
static Future<PhoneVerification> requestOtp(
PhoneNumberPost phoneNumberPostData) async {
final String postData = jsonEncode(phoneNumberPostData);
try {
final http.Response response = await http.post(
getPhoneRegistrationApiEndpoint(),
headers: {'content-type': 'Application/json'},
body: postData,
);
if(response.statusCode == 200) {
return PhoneVerification.fromJson(json.decode(response.body));
} else {
throw Exception('Request Error: ${response.statusCode}');
}
} on Exception {
rethrow;
}
}
}
Run Code Online (Sandbox Code Playgroud)
使用上述静态方法的单独类的函数。
void onButtonClick() {
try {
VerificationService.requestOtp(PhoneNumberPost(phone))
.then((PhoneVerification onValue) {
//Proceed to next screen
}).catchError((Error onError){
enableInputs();
});
} …
Run Code Online (Sandbox Code Playgroud) 我有一个按钮,启用时颜色为蓝色,禁用时颜色为黑色。我想要的是,当我启用按钮时,颜色应该逐渐从黑色变为蓝色,而不是立即变化,反之亦然。我怎样才能做到这一点?
我正在将Drawer与BottomAppBar一起使用。当我单击菜单图标时,它将显示抽屉。我想更改Flutter Drawer的左上角和右上角半径。可以自定义拐角半径吗?