我正在尝试使用Flutter Provider 包中的ChangeNotifierProvider类。但是,它给了我一个错误说
未为类 MyCustomWidget 定义该方法
我已将提供程序依赖项添加到我的pubspec.yaml文件中。
我有一个像这样的自定义小部件类
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider<Name>()
}
Run Code Online (Sandbox Code Playgroud) 我在 Flutter 应用中有聊天窗口。消息显示为小部件内的ListView小部件,我还有附加到窗口底部的消息输入小部件。
我想要
ListViewInputWidget代码:
class _MessagesPageState extends State<MessagesPage> {
final ScrollController listScrollController = ScrollController();
@override
Widget build(BuildContext context) {
return Scaffold(
....
body: Stack(
children: [
ListView.builder(
controller: listScrollController
....
),
InputWidget()]
);
}
class InputWidget extends StatelessWidget {
final TextEditingController _textEditingController = TextEditingController();
....
Row (
children: [
TextField(
controller: _textEditingController
),
IconButton(icon: ...., onPressed: (){})
]
)}
Run Code Online (Sandbox Code Playgroud) 我的Fragment画中有 3 个主要观点ConstraintLayout。
页眉和页脚应固定位置,中间内容/视图应可滚动。就我而言,中间内容重叠页眉和页脚
下面是我的xml代码
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
tools:context=".home.BookingFragment">
<!-- TODO: Update blank fragment layout -->
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="10dp"
android:gravity="center"
android:text="REGISTRATION FORM"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintTop_toTopOf="parent" />
<ScrollView
android:id="@+id/scrollContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="20dp"
app:layout_constraintBottom_toTopOf="@+id/bookingLayout"
app:layout_constraintTop_toBottomOf="@+id/title">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/nameTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Name"
android:textColor="@android:color/black"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" …Run Code Online (Sandbox Code Playgroud) 我正在使用 flutter 开发移动应用程序,我制作了一个图标和文本的选项卡栏,但结果正确溢出了 88 像素\n这是结果的屏幕截图
\n\n\n\n这是代码
\n\n bottom: new TabBar(controller: controller,\n tabs: <Widget>[\n new Tab(\n child: new Row(\n children: <Widget>[\n new Icon(Icons.local_hospital,color: Colors.white),\n new Text ( "\xd9\x83\xd9\x84\xd8\xa7\xd9\x85",\n style:TextStyle(color: Colors.white,\n )),\n ]),\n ),\n new Tab(\n child: new Row(\n children: <Widget>[\n new Icon(Icons.school,color: Colors.white),\n new Text ( "\xd9\x83\xd9\x84\xd8\xa7\xd9\x85",style:TextStyle(\n color: Colors.white\n )),\n ]),\n ),\n new Tab(\n child: new Row(\n children: <Widget>[\n new Icon(Icons.account_balance,color: Colors.white),\n new Text ( "\xd9\x83\xd9\x84\xd8\xa7\xd9\x85" ,style:TextStyle(\n color: Colors.white\n )),\n ]),\n ),\n new Tab(\n child: new Row(\n children: <Widget>[\n …Run Code Online (Sandbox Code Playgroud)