我是Flutter/Dart的新手,正在尝试编写一个登录UI,当我尝试运行程序时,调试器停在这里,errors_patch.dart
,我假设它是内置的:
@pragma("vm:external-name", "AssertionError_throwNew")
external static _doThrowNew(
int assertionStart, int assertionEnd, Object? message);
@pragma("vm:external-name", "AssertionError_throwNewSource")
external static _doThrowNewSource(
String failedAssertion, int line, int column, Object? message);
我该如何继续?我没有修改任何设置文件或其他内容。Android Studio和Flutter/Dart是最新的,并且我之前构建过此项目。此处有一些内容被破坏,但编辑器(VS代码)未指示任何错误或警告。
下面是我所有的源代码:
lib/main.dart
import 'package:flutter/material.dart';
import 'config.dart';
import 'ui/setup/login_page.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'WiCon',
theme: wiconTheme,
home: const MainPage(),
);
}
}
class MainPage extends StatelessWidget {
const MainPage({super.key});
@override
Widget build(BuildContext context) {
return loginPage;
}
}
lib/ui/setup/login_page.dart
import 'package:flutter/material.dart';
var loginPage = Scaffold(
appBar: AppBar(
title: Row(
children: const [
Padding(
padding: EdgeInsets.all(8.0),
child: Icon(Icons.wifi),
),
Padding(
padding: EdgeInsets.all(8.0),
child: Text("WiCon"),
),
],
),
),
body: Row(
children: [
// Left side
// Define the welcome message
Column(
children: const [
Padding(
padding: EdgeInsets.all(8.0),
child: Text("Welcome to WiCon"),
),
Padding(
padding: EdgeInsets.all(8.0),
child: Text("Please login to continue"),
),
],
),
// Right side
// Define the form, buttons, and status info
Column(
children: [
Form(
child: Column(
children: [
TextFormField(
decoration: const InputDecoration(labelText: "Register Number"),
),
TextFormField(
decoration: const InputDecoration(
labelText: "Password",
),
obscureText: true,
),
],
),
),
],
)
],
),
);
lib/config.dart
import 'package:flutter/material.dart';
final wiconTheme = ThemeData(
useMaterial3: true,
primarySwatch: Colors.blue,
);
1条答案
按热度按时间5cg8jx4n1#
这是由于在
Row
中使用了Column
s。您必须使用Expanded
或Flexible
,或SizedBox
(带有fixed with)来解决此问题。我使用Flexible
来解决此问题,如下所示。您还可以使用
flex
来决定Row
的子级的大小。希望这能帮上忙。