toggle_rotate 0.0.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 48

pub地址 】 【github地址

dependencies:
  toggle_rotate: $lastVersion

一、描述

目标: 让一个组件点击时执行旋转,再点击旋转回去。

最简使用时长、曲线、方向一切组件旋转角度
1.所有属性:
名称类型功能备注默认
raddouble旋转角度弧度制pi / 2
durationMsint动画时长毫秒200
curveCurve动画曲线-Curves.fastOutSlowIn
clockwisebool是否顺时针旋转-true
onTapFunction点击事件@requirednull
childWidget子组件@requirednull

2.最简使用:

ToggleRotate(
  child: Icon(Icons.arrow_upward,size: 60,color: Colors.orangeAccent),
  onTap: () {}, //点击事件
),

3.指定时长和曲线和方向

ToggleRotate(
  curve: Curves.decelerate,
  durationMs: 400,//动画时长
  clockwise: false, //是否是顺时针
  child: Icon(Icons.arrow_upward,size: 60,color: Colors.orangeAccent),
  onTap: () {},
),

4.可使一切组件进行旋转切换

ToggleRotate(
  curve: Curves.decelerate,
  durationMs: 400,
  child: Image(width:60,height: 60,image: AssetImage("assets/images/icon_28.jpg")),
  onTap: () {},
)

5.可使旋转的角度

ToggleRotate(
  rad: pi / 4,
  curve: Curves.linear,
  child: Image(width:60,height: 60,image: AssetImage("assets/images/icon_28.jpg")),
  onTap: () {},
)

[0.0.1] - TODO: Add release date. #

  • TODO: Describe initial release.

example/main.dart

import 'dart:math';

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: Scaffold(
          appBar: AppBar(),
          body: Center(child: HomePage()),
        ));
  }
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Wrap(
        spacing: 20,
        children: <Widget>[
          ToggleRotate(
            rad: pi / 2, //选择角度
            curve: Curves.linear, //动画曲线
            child: Icon(Icons.arrow_upward,size: 60,color: Colors.orangeAccent,),
            onTap: () {}, //点击事件
          ),
          ToggleRotate(
            rad: pi / 2,
            curve: Curves.linear,
            durationMs: 400,//动画时长
            clockwise: false, //是否是顺时针
            child: Icon(Icons.arrow_upward,size: 60,color: Colors.orangeAccent,),
            onTap: () {},
          ),
          ToggleRotate(
            rad: pi / 2,
            curve: Curves.linear,
            child: Image(width:60,height: 60,image: AssetImage("assets/images/head_icon/icon_9.jpg")),
            onTap: () {},
          ),
          ToggleRotate(
            rad: pi / 4,
            curve: Curves.linear,
            child: Image(width:60,height: 60,image: AssetImage("assets/images/head_icon/icon_9.jpg")),
            onTap: () {},
          ),
        ],
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  toggle_rotate: ^0.0.5

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:toggle_rotate/toggle_rotate.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
48
Learn more about scoring.

We analyzed this package on Apr 7, 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

Health suggestions

Format lib/toggle_rotate.dart.

Run flutter format to format lib/toggle_rotate.dart.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

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