package_replaced 1.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 50

package_replaced #

Allow Flutter to respond to Android MY_PACKAGE_REPLACED intent

To use this plugin, besides importing, you will also have to add PackageReplacedPlugin.setPluginRegistrantCallback() to the Android side of your app.

i.e. subclass FlutterApplication/implement PluginRegistry.PluginRegistrantCallback and call it in onCreate:

class OverrideApplication: FlutterApplication(), PluginRegistry.PluginRegistrantCallback{

    override fun onCreate() {

    override fun registerWith(p0: PluginRegistry?) {

and in your manifest,

<application android:name=".OverrideApplication">
    **other manifest stuff here**

1.1.0 #

Add function setDeferHandlerExecution

1.0.0+1 #

Flutter format

1.0.0 #

Baseline functionality (i.e. once PackageReplaced.setHandlerFunction has been called, MY_PACKAGE_REPLACED should trigger a callback to that function)


import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:io';

import 'package:package_replaced/package_replaced.dart';
import 'package:path_provider/path_provider.dart' as path_provider;

void main() {

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

void handlePackageReplaced() async {
  await _incrementReplaceCount();

class _MyAppState extends State<MyApp> {
  int _replaceCount = 0;
  String _miscMessage = "";

  void initState() {

  void _showReplaceCount() async {
    final replaceCount = await _getReplaceCount();

    setState(() {
      _replaceCount = replaceCount;

  void _artificalIncrement() async {
    await _incrementReplaceCount();

  void _artificalReset() async {
    await _setReplaceCount(0);

  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: const Text('package_replaced plugin example app'),
          body: Center(
            child: Column(
              children: <Widget>[
                Text('Package replaced $_replaceCount time(s)'),
          floatingActionButton: Column(
            children: <Widget>[
                child: Text("+"),
                onPressed: _artificalIncrement,
                child: Text("0"),
                onPressed: _artificalReset,
            mainAxisAlignment: MainAxisAlignment.end,

Future<File> getCountFile() async {
  final myStorageDirectory =
      await path_provider.getApplicationDocumentsDirectory();

  var countFilePath = myStorageDirectory.path;

  if (!countFilePath.endsWith("/")) {
    countFilePath += "/";

  countFilePath += "org.thebus.package_replaced_example.replaceCount";

  return File(countFilePath);

Future<int> _getReplaceCount() async {
  var retCount = 0;

  final countFile = await getCountFile();

  if (await countFile.exists()) {
    retCount = int.tryParse((await countFile.readAsString()));

    if (retCount == null) {
      retCount = 0;

  return retCount;

Future<void> _setReplaceCount(int newCountValue) async {
  final countFile = await getCountFile();

  if (!(await countFile.parent.exists())) {
    await countFile.parent.create(recursive: true);

  await countFile.writeAsString(newCountValue.toString());

Future<void> _incrementReplaceCount() async {
  final currentReplaceCount = await _getReplaceCount();
  await _setReplaceCount(currentReplaceCount + 1);

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  package_replaced: ^1.1.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:package_replaced/package_replaced.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jun 13, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.9+1
  • Flutter: 1.17.3

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:package_replaced/package_replaced.dart]

Package does not support Flutter platform macos

Because of import path [package:package_replaced/package_replaced.dart]

Package does not support Flutter platform web

Because of import path [package:package_replaced/package_replaced.dart]

Package does not support Flutter platform windows

Because of import path [package:package_replaced/package_replaced.dart]

Package not compatible with SDK dart

because of import path [package_replaced]


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies