import 'package:dma_inc/widgets_common/bg_widget.dart';
import 'package:dma_inc/widgets_common/applogo_widget.dart';
import 'package:dma_inc/consts/consts.dart';
import 'package:dma_inc/widgets_common/custom_textfield.dart';
import 'package:dma_inc/widgets_common/our_button.dart';
class Loginscreen extends StatelessWidget {
const Loginscreen({super.key});
@override
Widget build(BuildContext context) {
return bgWidget(Scaffold(
body: Center(
child: Column(
children: [
(context.screenHeight * 0.1).heightBox,
applogoWidget(),
"Log in to $appName".text.fontFamily(bold).white.size(18).make(),
20.heightBox,
Column(
children: [
customTextfield(hint: emailHint, title: email),
customTextfield(hint: passwordHint, title: password),
Align(
alignment: Alignment.centerRight,
child: (TextButton(
onPressed: () {}, child: forgetPass.text.make()))),
5.heightBox,
// ourButton().box.width(context.screenWidth - 50).make(),
ourButton(() {}, dmaRed, dmaWhite, 'login')
.box
.width(context.screenWidth - 50)
.make(),
],
)
.box
.white
.rounded
.padding(const EdgeInsets.all(16))
.width(context.screenWidth - 70)
.make()
],
),
),
));
}
}
这是使用按钮的地方
import 'package:dma_inc/consts/consts.dart';
Widget ourButton(onPress, color, textcolor, title) {
return ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: color,
padding: const EdgeInsets.all(12),
),
onPressed: () {
onPress;
},
child: title.text.color(textcolor).fontFamily(bold).make());
}
这是其定义的地方
exception: Exception was thrown: NoSuchMethodError: 'text'
https://drive.google.com/file/d/1SBOOKEWNfdVIWPL_la76MsWryUFyVL2p/view?usp=sharing 如果您需要查看整个项目。 请帮我解决这个异常,已经两天了,我仍然卡住了。
我尝试将登录名设置为直线字符串(“登录”)。 我尝试将 onPassed 全部删除。
尝试这样。也许这会有所帮助。
Widget ourButton(Function onPress,Color color,Color textcolor, String title) {
return ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: color,
padding: const EdgeInsets.all(12),
),
onPressed: onPress;
child: Text(title,style:TextStyle(color:textColor)));
}