flutter_core_spotlight 1.0.4 copy "flutter_core_spotlight: ^1.0.4" to clipboard
flutter_core_spotlight: ^1.0.4 copied to clipboard

PlatformiOS

Flutter plugin used for indexing items in Spotlight search on iOS.

example/lib/main.dart

import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter_core_spotlight/flutter_core_spotlight.dart';
// ignore: import_of_legacy_library_into_null_safe
import 'package:flutter_native_alert/flutter_native_alert.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _textController = TextEditingController();

  @override
  void initState() {
    FlutterCoreSpotlight.instance.configure(
      onSearchableItemSelected: (userActivity) {
        print(userActivity);
        FlutterNativeAlert.getInstance().showConfirm(
          title: userActivity?.uniqueIdentifier ?? 'Unknown title',
          message: jsonEncode(userActivity?.userInfo ?? {}),
          confirmButtonText: 'OK',
        );
      },
    );
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          children: [
            Padding(
              padding: const EdgeInsets.all(16),
              child: TextField(
                controller: _textController,
                autocorrect: false,
              ),
            ),
            Padding(
              padding: const EdgeInsets.all(16),
              child: ElevatedButton(
                child: Text('Index'),
                onPressed: () {
                  FlutterCoreSpotlight.instance.indexSearchableItems([
                    FlutterSpotlightItem(
                      uniqueIdentifier: _textController.text,
                      domainIdentifier: 'com.example.flutter_spotlight_plugin',
                      attributeTitle: _textController.text,
                      attributeDescription: 'This is an example description',
                    )
                  ]);
                },
              ),
            )
          ],
        ),
      ),
    );
  }
}
20
likes
150
points
146
downloads

Publisher

verified publisherciannapps.com

Weekly Downloads

Flutter plugin used for indexing items in Spotlight search on iOS.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_core_spotlight