keyboard_suggestions 0.5.0 copy "keyboard_suggestions: ^0.5.0" to clipboard
keyboard_suggestions: ^0.5.0 copied to clipboard

A keyboard suggesstions view

example/lib/main.dart

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

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage();
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int number = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Container(
        height: MediaQuery.of(context).size.height,
        child: Stack(
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.all(8.0),
              child: TextField(
                enableSuggestions: false,
                autocorrect: false,
                decoration: InputDecoration(labelText: "Type something"),
                onChanged: (v) {
                  setState(() {
                    number = v.length;
                  });
                },
              ),
            ),
            Positioned(
              bottom: 0,
              child: KeyboardSuggestionsView(
                backgroundColor: Colors.white,
                onTap: (v) {
                  print(v);
                },
                textStyle: Theme.of(context).textTheme.bodyText1.copyWith(
                      fontSize: 16,
                    ),
                suggestions: [
                  Suggestion<int>(title: "${number + 1}", value: number + 1),
                  Suggestion<int>(title: "${number + 2}", value: number + 2),
                  Suggestion<int>(title: "${number + 3}", value: number + 3),
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
0
likes
20
pub points
0%
popularity

Publisher

unverified uploader

A keyboard suggesstions view

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on keyboard_suggestions