Search
 
SCRIPT & CODE EXAMPLE
 

DART

Autocomplete Widget in Flutter

import 'package:flutter/material.dart'
void main() {
  runApp(const MyApp());
}
class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Autocomplete Basic'),
        ),
        body: const Center(
          child: Padding(
            padding: EdgeInsets.all(10.0),
            child: AutocompleteText(),
          ),
        ),
      ),
    );
  }
}

class AutocompleteText extends StatelessWidget {
  const AutocompleteText({Key? key}) : super(key: key);
  static const List<String> data = <String>[
    'Adrian',
    'Axel',
    'jhonn',
    'bobcat',
    'chameleon',
    'Oliver',
    'William',
    'Ethan',
    'Everett',
    'Jayden',
  ];

  @override
  Widget build(BuildContext context) {
    return Autocomplete<String>(
      optionsBuilder: (TextEditingValue textEditingValue) {
        if (textEditingValue.text == '') {
          return const Iterable<String>.empty();
        }
        return data.where((String option) {
          return option.contains(textEditingValue.text.toLowerCase());
        });
      },
      onSelected: (String selection) {
        debugPrint('You just selected $selection');
      },
    );
  }
};
Comment

PREVIOUS NEXT
Code Example
Dart :: dart inheritance 
Dart :: how to put two trailing icons in list tile flutter 
Dart :: how to get image file size in flutter 
Dart :: using flutter google places 
Dart :: vertically Center a Text in Flutter 
Dart :: dart http image upload 
Dart :: flutter push and pop doesnt work 
Dart :: api not working on release apk in android 
Dart :: dart map.foreach 
Dart :: string to int in dart, string to double in dart, int to string in dart 
Dart :: flutter pageview show next page 
Dart :: AnimatedCrossFade 
Dart :: flutter after return push 
Dart :: flutter logo text color 
Dart :: install dart sass 
Dart :: how to get real time data flutter 
Dart :: flutter write file 
Dart :: flutter multi icon button 
Dart :: onpressed flutter calculate 
Dart :: bloc to bloc communication in flutter 
Dart :: flutter: unhandled element defs; Picture key: AssetBundlePictureKey 
Dart :: how to stop listening to location change listener on dispose in flutter 
Dart :: This constructor cannot be used in null-safe code. Use [List.filled] to create a non-empty list. 
Dart :: flutter when to use methods 
Swift :: swift change button text 
Swift :: convert string to int swift 
Swift :: gap between table header uitableview 
Swift :: swift get top constraint 
Swift :: swift filter dictionary 
Swift :: swift how to animate constraint change 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =