我是新手,我正在尝试制作一个应用程序,但我仅停留在初始阶段,无法弄清楚问题出在哪里。 下面是我的代码:
import 'package:flutter/material.dart';
void main() => runApp(BMICalculator());
class BMICalculator extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('BMI CALCULATOR'),
),
body: InputPage(),
),
);
}
}
class InputPage extends StatefulWidget {
@override
_InputPageState createState() => _InputPageState();
}
class _InputPageState extends State<InputPage> {
@override
Widget build(BuildContext context) {
return Center(
child: Text('Body Text'),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () {},
),
);
}
}
我的浮动操作按钮上出现错误。
下面是错误消息:
Compiler message:
lib/main.dart:29:7: Error: No named parameter with the name 'floatingActionButton'.
floatingActionButton: FloatingActionButton(
^^^^^^^^^^^^^^^^^^^^
../../../desktop/flutter/flutter/packages/flutter/lib/src/widgets/basic.dart:1870:9: Context: Found this candidate, but the arguments don't match.
const Center({ Key key, double widthFactor, double heightFactor, Widget child })
^^^^^^
我需要在屏幕中央显示正文文本,并在右下角单击按钮。