form_floating_action_button
peiffer-innovations/form_floating_action_button open-source repository details.
- 星标
- 3
- 复刻
- 0
- 最近推送(UTC)
- 2026年2月16日
- 项目状态
- 已归档
原始 README
以下为英文项目原文快照,最新内容请访问 GitHub。
Table of Contents
form_floating_action_button
A plugin to add some basic form functionality to the Floating Action Button.
Demo
Installation
Add to pubspec.yaml
dependencies:
...
form_floating_action_button: any
Usage Example
Import form_floating_action_button.dart
import 'package:form_floating_action_button/form_floating_action_button.dart';
Usage within a Form
Widget build(BuildContext context) {
return Form(
child: Scaffold(
appBar: AppBar(
title: Text('Form Validate'),
),
body: Material(
child: ListView(
children: <Widget>[
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0),
child: TextFormField(
decoration: InputDecoration(
labelText: 'Email',
),
onFieldSubmitted: (_) {
_controller.firePressed();
},
validator: (value) {
String error;
if (value?.isNotEmpty != true) {
error = 'Email is required';
} else if (value.contains('@') != true ||
value.contains('.') != true) {
error = 'Email is not valid';
}
return error;
},
),
),
],
),
),
floatingActionButton: FormFloatingActionButton(
controller: _controller,
loading: _loading,
onSubmit: () {
setState(() => _loading = true);
Future.delayed(Duration(seconds: 5)).then((_) {
if (mounted) {
setState(() {
_loading = false;
});
}
});
},
),
),
);
}
Custom On Validate
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('On Validate'),
),
body: Material(
child: ListView(
children: <Widget>[
ListTile(
onTap: () {
setState(() => _validateSuccess = !_validateSuccess);
},
title: Text('Validation Successful'),
trailing: IgnorePointer(
child: Switch(
value: _validateSuccess,
onChanged: (_) {},
),
),
)
],
),
),
floatingActionButton: FormFloatingActionButton(
loading: _loading,
onSubmit: () {
setState(() => _loading = true);
Future.delayed(Duration(seconds: 5)).then((_) {
if (mounted) {
setState(() {
_loading = false;
});
}
});
},
onValidate: () {
return Future.value(_validateSuccess);
},
),
);
}
语言DartHTMLSwiftObjective-CKotlin
使用的依赖
依赖清单 4 项
- flutter
{"sdk":"flutter"} - vector_math
^2.1.4 - flutter_lints开发依赖
^5.0.0 - flutter_test开发依赖
{"sdk":"flutter"}
如何选择适合项目的代码仓?
先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。
- 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
- 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
- 使用前在 GitHub 核对 README、许可证与 Issues。
来源与维护
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗
