flutter_other_plugin 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 49

flutter_other_plugin #

Use this plugin to save images locally Geolocation in China does not use Google services Call the ringtone if the user is mute the case directly call the vibrator otherwise use the ringtone you set

使用这个插件 可以将图片 保存到本地 在中国地区获取地理位置 不使用Google 服务 调用铃声 如果用户是 静音的情况下 直接调用震动 否则使用 您设定的铃声

Getting Started #

##IOS 调用铃声 请将 文件下的 example 下的 detection.aiff 拷贝到您的ios 项目中 ##Android 调用铃声 请在 AndroidManifest.xml 添加

##IOS call ring Please copy the detection. Aiff file under example to your ios project ##Android calling ring Please add the in the androidmanifest.xml < USES - the permission of the android: name = "android. Permission. VIBRATE" / > Get permission to vibrate

See code example

0.0.1 #

  • TODO: Describe initial release.


import 'dart:async';
import 'dart:ui' as ui;
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_other_plugin/flutter_other_plugin.dart';
import 'package:path_provider/path_provider.dart';

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

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

class _MyAppState extends State<MyApp> {
  LocationData _startLocation;
  LocationData _currentLocation;
  Map<String, File> loadedFiles = {};
  String localFilePath;

  StreamSubscription<LocationData> _locationSubscription;

  FlutterOtherPlugin _flutterOtherPlugin = new FlutterOtherPlugin();
  bool _permission = false;
  bool _save = false;
  String error;

  bool currentWidget = true;

  Image image1;

  GlobalKey _globalKey;

  void initState() {



    _locationSubscription =
        _flutterOtherPlugin.onLocationChanged().listen((LocationData result) {
      setState(() {
        _currentLocation = result;

  Future<ByteData> _fetchAsset(String fileName) async {
    return await rootBundle.load('assets/$fileName');

  Future<File> fetchToMemory(String fileName) async {
    final file = new File(
        '${(await getApplicationDocumentsDirectory()).path}/$fileName');
    await file.create(recursive: true);
    return await file
        .writeAsBytes((await _fetchAsset(fileName)).buffer.asUint8List());

  Future<File> load(String fileName) async {
    if (!loadedFiles.containsKey(fileName)) {
      loadedFiles[fileName] = await fetchToMemory(fileName);
    return loadedFiles[fileName];

  Future _loadFile() async {
    File file = await fetchToMemory("msgSound.mp3");
    setState(() {
      localFilePath = file.path.toString();

  // Platform messages are asynchronous, so we initialize in an async method.
  initPlatformState() async {
    LocationData location;
    // Platform messages may fail, so we use a try/catch PlatformException.

    try {
      _permission = await _flutterOtherPlugin.hasPermission();
      location = await _flutterOtherPlugin.getLocation();

      error = null;
    } on PlatformException catch (e) {
      if (e.code == 'PERMISSION_DENIED') {
        error = 'Permission denied';
      } else if (e.code == 'PERMISSION_DENIED_NEVER_ASK') {
        error =
            'Permission denied - please ask the user to enable it from the app settings';

      location = null;

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    //if (!mounted) return;

    setState(() {
      _startLocation = location;

  _saved() async {
    RenderRepaintBoundary boundary =
    ui.Image image = await boundary.toImage();
    ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
    _save = await FlutterOtherPlugin.save(byteData.buffer.asUint8List());

  _playBell() async {

  Widget build(BuildContext context) {
    List<Widget> widgets = new List();
    _globalKey = GlobalKey();

    widgets.add(new Center(
        child: new Text(_startLocation != null
            ? 'Start location: ${_startLocation.latitude} & ${_startLocation.longitude}\n'
            : 'Error: $error\n')));

    widgets.add(new Center(
        child: new Text(_currentLocation != null
            ? 'Continuous location: ${_currentLocation.latitude} & ${_currentLocation.longitude}\n'
            : 'Error: $error\n')));

    widgets.add(new Center(
        child: new Text(
            _permission ? 'Has permission : Yes' : "Has permission : No")));

    widgets.add(new RepaintBoundary(
      key: _globalKey,
      child: Container(
        width: 200,
        height: 200,
        color: Colors.red,

    widgets.add(new Container(
      child: RaisedButton(
        onPressed: _saved,
        child: Text("保存到相册"),
      width: 100,
      height: 50,

    widgets.add(new Container(
      child: RaisedButton(
        onPressed: _playBell,
        child: Text("播放铃声"),
      width: 100,
      height: 50,

    return new MaterialApp(
        home: new Scaffold(
            appBar: new AppBar(
              title: new Text('Location plugin example app'),
            body: new Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisSize: MainAxisSize.min,
              children: widgets,

Use this package as a library

1. Depend on it

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

  flutter_other_plugin: ^0.1.1

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:flutter_other_plugin/flutter_other_plugin.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 Apr 1, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Maintenance suggestions

The package description is too short. (-4 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is getting outdated. (-1.10 points)

The package was last published 52 weeks ago.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
meta ^1.1.5 1.1.8
Transitive dependencies
collection 1.14.11 1.14.12
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies