Flutter Tutorials

Flutter app development tutorials


flutter – Container transform rotation

main.dart


import 'package:flutter/material.dart';

void main() => runApp(const FlutterExample());

class FlutterExample extends StatelessWidget {
  const FlutterExample({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter Example',
        theme: ThemeData(primarySwatch: Colors.red),
        home: const StateExample()
    );
  }
}

class StateExample extends StatefulWidget {
  const StateExample({Key? key}) : super(key: key);

  @override
  _StateExampleState createState() => _StateExampleState();
}

class _StateExampleState extends State<StateExample> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: const Color(0xFFF5F5F5),
        appBar: AppBar(
            title: const Text("Flutter - Container Transform")
        ),
        body: bodyContent()
    );
  }


  bodyContent(){
    return Container(
        color: Colors.blue[100],
        child: Container(
          color: Colors.blue[200],
          padding: const EdgeInsets.all(32),
          transform: Matrix4.rotationZ(0.3),
          child: const Align(
            alignment: Alignment.topRight,
            child: Icon(
              Icons.mail,
              size: 100,
              color: Colors.blue,
            ),
          ),
        )
    );
  }
}

More flutter tutorials



About Me

Flutter Developer

Design a site like this with WordPress.com
Get started