Search
 
SCRIPT & CODE EXAMPLE
 

DART

flutter flip image

import 'dart:math' as math; // import this

Transform(
  alignment: Alignment.center,
  transform: Matrix4.rotationY(math.pi),
  child: Icon(Icons.rotate_left, size: 100,),
)
Comment

flutter flip card

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePageState createState() => new MyHomePageState();
}

class MyCustomCard extends StatelessWidget {
  MyCustomCard({ this.colors });

  final MaterialColor colors;

  Widget build(BuildContext context) {
    return new Container(
      alignment: FractionalOffset.center,
      height: 144.0,
      width: 360.0,
      decoration: new BoxDecoration(
        color: colors.shade50,
        border: new Border.all(color: new Color(0xFF9E9E9E)),
      ),
      child: new FlutterLogo(size: 100.0, colors: colors),
    );
  }
}

class MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
  AnimationController _controller;
  Animation<double> _frontScale;
  Animation<double> _backScale;

  @override
  void initState() {
    super.initState();
    _controller = new AnimationController(
      vsync: this,
      duration: const Duration(seconds: 1),
    );
    _frontScale = new Tween(
      begin: 1.0,
      end: 0.0,
    ).animate(new CurvedAnimation(
      parent: _controller,
      curve: new Interval(0.0, 0.5, curve: Curves.easeIn),
    ));
    _backScale = new CurvedAnimation(
      parent: _controller,
      curve: new Interval(0.5, 1.0, curve: Curves.easeOut),
    );
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    ThemeData theme = Theme.of(context);

    return new Scaffold(
      appBar: new AppBar(),
      floatingActionButton: new FloatingActionButton(
        child: new Icon(Icons.flip_to_back),
        onPressed: () {
          setState(() {
            if (_controller.isCompleted || _controller.velocity > 0)
              _controller.reverse();
            else
              _controller.forward();
          });
        },
      ),
      body: new Center(
        child: new Stack(
          children: <Widget>[
            new AnimatedBuilder(
              child: new MyCustomCard(colors: Colors.orange),
              animation: _backScale,
              builder: (BuildContext context, Widget child) {
                final Matrix4 transform = new Matrix4.identity()
                  ..scale(1.0, _backScale.value, 1.0);
                return new Transform(
                  transform: transform,
                  alignment: FractionalOffset.center,
                  child: child,
                );
              },
            ),
            new AnimatedBuilder(
              child: new MyCustomCard(colors: Colors.blue),
              animation: _frontScale,
              builder: (BuildContext context, Widget child) {
                final Matrix4 transform = new Matrix4.identity()
                  ..scale(1.0, _frontScale.value, 1.0);
                return new Transform(
                  transform: transform,
                  alignment: FractionalOffset.center,
                  child: child,
                );
              },
            ),
          ],
        ),
      ),
    );
  }
}
Comment

PREVIOUS NEXT
Code Example
Dart :: how to disable screen rotation in flutter 
Dart :: alertdialog flutter barrierColor 
Dart :: no scroll physics flutter 
Dart :: Attribute application@icon value=(@mipmap/launcher_icon) from AndroidManifest.xml:17:9-45 
Dart :: dart list map index 
Dart :: flutter absorb pointer 
Dart :: how to disable windows build flutter 
Dart :: Flutter Text size to fit 
Dart :: dartpad missing browser features 
Dart :: dart every 
Dart :: add dollar sign in flutter 
Dart :: how to subtract dates in flutter 
Dart :: random colors for container flutter 
Dart :: sign out from firebase flutter 
Dart :: flutter rename 
Dart :: flutter blur background 
Dart :: flutter add text on image 
Dart :: flutter dart sort list of objects 
Dart :: How to Style DropdownButton in Flutter 
Dart :: flutter get key from map 
Dart :: flutter remove dropdown shadow appbar 
Dart :: best visual studio code extensions for flutter development 
Dart :: how to print data types in dart 
Dart :: flutter container image overlay 
Dart :: flutter icon size 
Dart :: dart httop client 
Dart :: what is interface in dart 
Dart :: flutter check if null 
Dart :: dart list of maps 
Dart :: flutter button playing sound 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =