forked from toly1994328/FlutterUnit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e70593
commit 1812ab8
Showing
12 changed files
with
330 additions
and
24 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
lib/widget_system/widgets/StatelessWidget/Autocomplete/node1_base.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:flutter/material.dart'; | ||
/// create by 张风捷特烈 on 2022-04-18 | ||
/// contact me by email 1981462002@qq.com | ||
/// 说明: | ||
// { | ||
// "widgetId": 356, | ||
// "name": 'Autocomplete基本使用', | ||
// "priority": 1, | ||
// "subtitle": "【optionsBuilder】 : 选项构造器 【AutocompleteOptionsBuilder<T>】\n" | ||
// "【onSelected】 : 选择时回调 【AutocompleteOnSelected<T>】", | ||
// } | ||
class AutocompleteDemo extends StatelessWidget { | ||
const AutocompleteDemo({Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Autocomplete<String>( | ||
optionsBuilder: buildOptions, | ||
onSelected: onSelected, | ||
); | ||
} | ||
|
||
void onSelected(String selection) { | ||
debugPrint('当前选择了 $selection'); | ||
} | ||
|
||
Future<Iterable<String>> buildOptions( | ||
TextEditingValue textEditingValue, | ||
) async { | ||
if (textEditingValue.text == '') { | ||
return const Iterable<String>.empty(); | ||
} | ||
return searchByArgs(textEditingValue.text); | ||
} | ||
|
||
Future<Iterable<String>> searchByArgs(String args) async{ | ||
// 模拟网络请求 | ||
await Future.delayed(const Duration(milliseconds: 200)); | ||
const List<String> data = [ | ||
'toly', 'toly49', 'toly42', 'toly56', | ||
'card', 'ls', 'alex', 'fan sha', | ||
]; | ||
return data.where((String name) => name.contains(args)); | ||
} | ||
} |
Oops, something went wrong.