field_suggestion 0.1.5 copy "field_suggestion: ^0.1.5" to clipboard
field_suggestion: ^0.1.5 copied to clipboard

outdated

Create highly customizable, simple, and controllable autocomplete fields.

example/lib/main.dart

import 'package:field_suggestion/field_suggestion.dart';
import 'package:flutter/material.dart';

import 'user_model.dart';

void main() => runApp(App());

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'FieldSuggestion Example',
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final firstTextController = TextEditingController();
  final secondTextController = TextEditingController();

  final firstBoxController = BoxController();
  final secondBoxController = BoxController();

  List<String> stringSuggestions = [
    '[email protected]',
    '[email protected]',
    '[email protected]',
  ];

  List<int> numSuggestions = [
    13187829696,
    13102743803,
    15412917703,
  ];

  List<UserModel> userSuggestions = [
    UserModel(email: '[email protected]', password: 'test123'),
    UserModel(email: '[email protected]', password: 'test123'),
    UserModel(email: '[email protected]', password: 'test123')
  ];

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        firstBoxController.close!();
        secondBoxController.close!();
      },
      child: Scaffold(
        appBar: AppBar(title: const Text("FieldSuggestion Example")),
        body: SingleChildScrollView(
          padding: const EdgeInsets.all(15),
          child: Center(
            child: Column(
              children: [
                // Basic usage.
                FieldSuggestion(
                  hint: 'Email',
                  boxController: firstBoxController,
                  textController: firstTextController,
                  suggestionList: stringSuggestions,
                ),

                const SizedBox(height: 100),

                // Custom usage with num type variables.
                FieldSuggestion(
                  boxController: secondBoxController,
                  textController: secondTextController,
                  suggestionList: numSuggestions,
                  fieldDecoration: InputDecoration(
                    hintText: "Phone Number",
                    enabledBorder: const OutlineInputBorder(),
                    focusedBorder: const OutlineInputBorder(),
                  ),
                  wDivider: true,
                  divider: const SizedBox(height: 5),
                  wSlideAnimation: true,
                  slideAnimationStyle: SlideAnimationStyle.LTR,
                  slideCurve: Curves.linearToEaseOut,
                  animationDuration: const Duration(milliseconds: 300),
                  suggestionItemStyle:
                      SuggestionItemStyle.WhiteNeumorphismedStyle,
                  suggestionBoxStyle: SuggestionBoxStyle(
                    backgroundColor: Colors.white,
                    borderRadius: BorderRadius.circular(15),
                    boxShadow: [
                      BoxShadow(
                        color: Colors.blue.withOpacity(.2),
                        spreadRadius: 5,
                        blurRadius: 10,
                        offset: const Offset(0, 5),
                      ),
                    ],
                  ),
                ),
                const SizedBox(height: 100),

                // Usage with custom class suggestions.
                FieldSuggestion(
                  hint: 'Email',
                  // If y're using list where are classes,
                  // Don't forget adding search by property.
                  searchBy: 'email',
                  boxController: firstBoxController,
                  textController: firstTextController,
                  suggestionList: userSuggestions,
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
45
likes
0
points
1.23k
downloads

Publisher

verified publishertheiskaa.com

Weekly Downloads

Create highly customizable, simple, and controllable autocomplete fields.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on field_suggestion