flutter_pinned_shortcut_plus 0.0.1 copy "flutter_pinned_shortcut_plus: ^0.0.1" to clipboard
flutter_pinned_shortcut_plus: ^0.0.1 copied to clipboard

PlatformAndroid

Flutter pinned shortcuts are UI elements that provide quick access to specific actions or views in an app. In the context of chat applications or similar use cases, pinned shortcuts allow users to "pi [...]

flutter_pinned_shortcut_plus #

      Flutter pinned shortcuts offer quick access to actions or views within an app.
      In chat apps, they allow users to pin chat threads, contacts, or actions to the main
      interface, making them easily accessible without navigating multiple screens. 
      These shortcuts enhance user experience by providing direct access to important features,
      streamlining navigation, and improving overall app efficiency.
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:flutter_pinned_shortcut_plus/flutter_pinned_shortcut_plus.dart';
import 'package:flutter_pinned_shortcut_plus_example/followers.dart';
import 'package:flutter_pinned_shortcut_plus_example/profile_screen.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final GlobalKey<NavigatorState> _navigatorKey = GlobalKey<NavigatorState>();
  final _flutterPinnedShortcutPlugin = FlutterPinnedShortcut();

  @override
  void initState() {
    super.initState();
    //Manage condition according to your need
    WidgetsBinding.instance.addPostFrameCallback((_) {
      getIncomingAction();
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      navigatorKey: _navigatorKey,  // Set the navigatorKey here
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Pinned Shortcut'),
        ),
        body: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Center(
              child: ElevatedButton(
                onPressed: addPinnedShortcut,
                child: const Text("Add Follower Shortcut with Icon"),
              ),
            ),
            const SizedBox(height: 10,),
            Center(
              child: ElevatedButton(
                onPressed: addPinnedShortcut1,
                child: const Text("Add Profile Shortcut With Url"),
              ),
            ),
          ],
        ),
      ),
    );
  }

  void addPinnedShortcut() {
    //first of all it will check iconUri if it will be null it will display assetIcon otherwise it will add url icon
    _flutterPinnedShortcutPlugin.createPinnedShortcut(
        id: "1",
        label: "Followers",
        action: "followers",
        iconAssetName: "assets/splash.png",
        iconUri: null
    );
  }

  void addPinnedShortcut1() async{
    //first of all it will check iconUri if it will be null it will display assetIcon otherwise it will add url icon
    File? file;
      file = await DefaultCacheManager().getSingleFile("https://cdn-icons-png.flaticon.com/512/7347/7347153.png");
    _flutterPinnedShortcutPlugin.createPinnedShortcut(
        id: "2",
        label: "Profile",
        action: "profile",
        iconAssetName: "assets/splash.png",
        iconUri: Uri.file(file.path).toString()
    );
  }

  void getIncomingAction() {
    _flutterPinnedShortcutPlugin.getLaunchAction((action) {
      switch (action) {
        case "followers":
          if (kDebugMode) {
            print("Malik Tariq Azam-$action");
          }
          // Use the navigatorKey to push the route or any other state manage
          _navigatorKey.currentState?.push(
            MaterialPageRoute(builder: (context) => MyFollowers()),
          );
          break;
        case "profile":
        // Use the navigatorKey to push the route or any other state manage
          _navigatorKey.currentState?.push(
            MaterialPageRoute(builder: (context) => MyProfile()),
          );
          break;
      }
    });
  }
}

import 'package:flutter/material.dart';
class MyFollowers extends StatelessWidget {
  const MyFollowers({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(
        body: Center(
          child: Text(
            'This is followers Screen',
            style: TextStyle(fontSize: 24),
          ),
        ),
      ),
    );
  }
}

import 'package:flutter/material.dart';
class MyProfile extends StatelessWidget {
  const MyProfile({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(
        body: Center(
          child: Text(
            'This is profile Screen',
            style: TextStyle(fontSize: 24),
          ),
        ),
      ),
    );
  }
}

For more information, see the full documentation at: https://github.com/tariqarbi03/flutter_pinned_shortcut_plus/tree/master

See also:

- [Pinned_Shortcut], a widget for creating and managing website.

import 'package:flutter/material.dart';

7
likes
140
points
206
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter pinned shortcuts are UI elements that provide quick access to specific actions or views in an app. In the context of chat applications or similar use cases, pinned shortcuts allow users to "pin" certain chat threads, contacts, or actions to a prominent place within the app interface, making them easily accessible without having to navigate through multiple screens.

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_pinned_shortcut_plus

Packages that implement flutter_pinned_shortcut_plus