我是否必须TextEditingController为每个TextField
示例创建多个
var oneController = TextEditingController();
var twoController = TextEditingController();
Run Code Online (Sandbox Code Playgroud)
然后
TextField(
controller: oneController,
decoration: new InputDecoration(labelText: "add type *income"),
),
TextField(
controller: twoController,
decoration: new InputDecoration(labelText: "Enter a number"),
keyboardType: TextInputType.number,
),
Run Code Online (Sandbox Code Playgroud)
或者有没有办法只使用一个?
我有一个使用 Cupertino 应用程序的简单应用程序。我在底部有四个选项卡,允许我在页面之间导航。在AddCashPage我在页面上添加的最后一个选项卡上的按钮上,这将允许我导航到第二页CalendarPage
该应用程序只有一页,所以我会发布整个内容
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// import 'styles.dart';
import 'pages/summary_page.dart';
import 'pages/calendar_page.dart';
import 'pages/remove_cash_page.dart';
final scakey = new GlobalKey<_BottomState>();
class CashOnHandApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Cash on Hand',
home: HomePage(),
);
}
}
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: const Text('Cash on Hand'),
),
child: Bottom(key: scakey),
),
);
}
}
class Bottom extends StatefulWidget { …Run Code Online (Sandbox Code Playgroud)