Flutter Dev

Flutter Dev

1632295608

Helper math class for easily creating Matrix4 transformations in Flutt

matrix4_transform

Have you noticed the transform parameter in the Container and Transform widgets, that let you move, rotate, resize and flip?

This package is a helper math class that makes it easy to create Matrix4 transformations.

Example:

// Rotates the Container 45 degrees and then
// translates 25 pixels to the right. 
Container(
   transform:
     Matrix4Transform()
       .rotateDegrees(45, origin: Offset(25, 25))
       .translate(x: 25)
       .matrix4,
   child: ...
);

To see it in action, run the example in the example tab.

How to use it

Matrix4Transform is immutable (in contrast, Matrix4 is mutable).

First create a Matrix4Transform:

Matrix4Transform();

Then call the methods to transform it. For example:

Matrix4Transform()
   .scale(1.5)
   .upRight(35)
   .rotate(pi/2);

In the end, call matrix4:

Matrix4 myMatrix 
   = Matrix4Transform()
     .scale(1.5)
     .upRight(35)
     .rotate(pi/2)
     .matrix4;                        

Note: The transformations will be applied in order, and their order may change the end result.

If you already have a matrix4 and want to further transform it, you can use the from constructor:

Matrix4 myMatrix = ...;

var myTransform = Matrix4Transform.from(myMatrix);

Methods you can use

  • rotate(double angleRadians, {Offset origin})
  • rotateDegrees(double angleDegrees, {Offset origin})
  • rotateByCenterDegrees(double angleDegrees, Size size)
  • rotateByCenter(_toRadians(angleDegrees), size)
  • translate({double x = 0, double y = 0})
  • translateOriginalCoordinates({double x = 0, double y = 0})
  • scale(double factor, {Offset origin})
  • scaleBy({double x = 1, double y = 1, Offset origin})
  • scaleHorizontally(double factor)
  • scaleVertically(double factor)
  • translateOffset(Offset offset)
  • up(double distance)
  • down(double distance)
  • right(double distance)
  • left(double distance)
  • direction(double directionRadians, double distance)
  • directionDegrees(double directionDegrees, double distance)
  • upRight(double distance)
  • upLeft(double distance)
  • downRight(double distance)
  • downLeft(double distance)
  • flipDiagonally({Offset origin})
  • flipHorizontally({Offset origin})
  • flipVertically({Offset origin})

And, of course:

  • Matrix4 toMatrix4

Tween

A Matrix4TransformTween is provided in this package, and can be used in animations.

Animate it

A Matrix4Transform can be used to animate:

AlignPositioned or AnimatedAlignPositioned widgets from the AlignPositioned package, that accept a Matrix4Transform directly. The center of rotation/scale can be defined by their alignment parameter.

Any widget that accepts a Matrix4 transformation parameter, like Container, or AnimatedContainer. Note: Since Matrix4Tween will not animate linearly as you'd expect, it's possible that the intermediary transformations will be "strange", although the start and end should be correct.


Special thanks to Martin Kamleithner and Simon Lightfoot.


The Flutter packages I've authored:

My Medium Articles:

My article in the official Flutter documentation:

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add matrix4_transform

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  matrix4_transform: ^2.0.1

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

Import it

Now in your Dart code, you can use:

import 'package:matrix4_transform/matrix4_transform.dart';

example/lib/main.dart

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

// Developed by Marcelo Glasberg (Aug 2019).
// For more info, see: https://pub.dartlang.org/packages/matrix4_transform

void main() async => runApp(MaterialApp(home: Demo()));

class Demo extends StatelessWidget {
  final boxes = [
    Box(null, "Original"),
    Box(Matrix4Transform().translate(x: 25).matrix4, ".translate(x: 25)"),
    Box(Matrix4Transform().rotateDegrees(20).matrix4, ".rotateDegrees(20)"),
    Box(Matrix4Transform().rotateDegrees(45).matrix4, ".rotateDegrees(45)"),
    Box(Matrix4Transform().rotateDegrees(20, origin: Offset(25, 25)).matrix4,
        ".rotateDegrees(20, origin: Offset(25, 25))"),
    Box(Matrix4Transform().rotateDegrees(45, origin: Offset(25, 25)).matrix4,
        ".rotateDegrees(45, origin: Offset(25, 25))"),
    Box(Matrix4Transform().rotateDegrees(45, origin: Offset(25, 25)).translate(x: 25).matrix4,
        ".rotateDegrees(45, origin: Offset(25, 25)).\ntranslate(x: 25)"),
    Box(Matrix4Transform().scaleBy(x: 2.0, y: 0.5).matrix4, ".scaleBy(x: 2.0, y: 0.5)"),
    Box(Matrix4Transform().scaleBy(x: 2.0, y: 0.5, origin: Offset(25, 25)).matrix4,
        ".scaleBy(x: 2.0, y: 0.5, origin: Offset(25, 25))"),
    Box(Matrix4Transform().scaleBy(x: 2, y: 0.5, origin: Offset(25, 25)).right(25).matrix4,
        ".scaleBy(x: 2, y: 0.5, origin: Offset(25, 25))\n.right(25)"),
    Box(
        Matrix4Transform()
            .scaleBy(x: 2, y: 0.5, origin: Offset(25, 25))
            .translateOriginalCoordinates(x: 25)
            .matrix4,
        ".scaleBy(x: 2, y: 0.5, origin: Offset(25, 25))\n.translateOriginalCoordinates(x: 25)"),
    //
    Box(Matrix4Transform().flipHorizontally().matrix4, ".flipHorizontally()"),
    Box(Matrix4Transform().flipHorizontally(origin: Offset(25, 25)).matrix4,
        ".flipHorizontally(origin: Offset(25, 25))"),
    Box(Matrix4Transform().flipVertically().matrix4, ".flipVertically()"),
    Box(Matrix4Transform().flipVertically(origin: Offset(25, 25)).matrix4,
        ".flipVertically(origin: Offset(25, 25))"),
    Box(Matrix4Transform().flipDiagonally().matrix4, ".flipDiagonally())"),
    Box(Matrix4Transform().flipDiagonally(origin: Offset(25, 25)).matrix4,
        ".flipDiagonally(origin: Offset(25, 25))"),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Matrix4Transform Example')),
      body: Stack(
        children: <Widget>[
          SingleChildScrollView(
            child: Container(
              color: Colors.grey[400],
              child: Column(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  for (var box in boxes) wrap(box),
                ],
              ),
            ),
          ),
          Center(
            child: Container(
              width: 50,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Container(width: 1.5, height: double.infinity, color: Colors.black),
                  Container(width: 0.75, height: double.infinity, color: Colors.black26),
                  Container(width: 1.0, height: double.infinity, color: Colors.black26),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }
}

Widget wrap(Box box) {
  return Column(
    children: <Widget>[
      if (box.description != null)
        Align(
          alignment: Alignment.centerLeft,
          child: Text(box.description.toString(), style: TextStyle(fontSize: 11)),
        ),
      Container(height: 1.5, width: double.infinity, color: Colors.black),
      Container(child: box, alignment: Alignment.center, height: 50, width: double.infinity),
      Container(height: 1.0, width: double.infinity, color: Colors.black26),
      SizedBox(height: 70.0),
    ],
  );
}

class Box extends StatelessWidget {
  final Matrix4 matrix;
  final String? description;

  Box(
    Matrix4? matrix,
    this.description,
  ) : matrix = matrix ?? Matrix4.identity();

  @override
  Widget build(BuildContext context) {
    return Container(
      transform: matrix,
      color: Colors.red,
      width: 50,
      height: 50,
      child: Center(
        child: Stack(
          children: [
            Icon(Icons.cancel, color: Colors.yellow, size: 38),
            Icon(Icons.expand_less, color: Colors.yellow, size: 38),
            Icon(Icons.add_circle, color: Colors.yellow, size: 10),
          ],
        ),
      ),
    );
  }
}

Download Details:
 

Author: marcglasberg
Download Link: Download The Source Code
Official Website: https://github.com/marcglasberg/matrix4_transform 
License: View license

#flutter 

What is GEEK

Buddha Community

Helper math class for easily creating Matrix4 transformations in Flutt

Laravel 8 Create Custom Helper Function Example

Today, We will see laravel 8 create custom helper function example, as we all know laravel provides many ready mate function in their framework, but many times we need to require our own customized function to use in our project that time we need to create custom helper function, So, here i am show you custom helper function example in laravel 8.

Laravel 8 Create Custom Helper Function Example

https://websolutionstuff.com/post/laravel-8-create-custom-helper-function-example


Read Also : Cron Job Scheduling In Laravel

https://websolutionstuff.com/post/cron-job-scheduling-in-laravel

#laravel 8 create custom helper function example #laravel #custom helper function #how to create custom helper in laravel 8 #laravel helper functions #custom helper functions in laravel

Yashi Tyagi

1617449307

CA Classes - Best CA Classes Online

Chartered Accountancy course requires mental focus & discipline, coaching for CA Foundation, CA Inter and CA Finals are omnipresent, and some of the best faculty’s classes have moved online, in this blog, we are going to give the best way to find online videos lectures, various online websites provide the CA lectures, Smartnstudy one of the best site to CA preparation, here all faculty’s video lecture available.

check here : ca classes

#ca classes online #ca classes in delhi #ca classes app #ca pendrive classes #ca google drive classes #best ca classes online

Flutter Dev

Flutter Dev

1632295608

Helper math class for easily creating Matrix4 transformations in Flutt

matrix4_transform

Have you noticed the transform parameter in the Container and Transform widgets, that let you move, rotate, resize and flip?

This package is a helper math class that makes it easy to create Matrix4 transformations.

Example:

// Rotates the Container 45 degrees and then
// translates 25 pixels to the right. 
Container(
   transform:
     Matrix4Transform()
       .rotateDegrees(45, origin: Offset(25, 25))
       .translate(x: 25)
       .matrix4,
   child: ...
);

To see it in action, run the example in the example tab.

How to use it

Matrix4Transform is immutable (in contrast, Matrix4 is mutable).

First create a Matrix4Transform:

Matrix4Transform();

Then call the methods to transform it. For example:

Matrix4Transform()
   .scale(1.5)
   .upRight(35)
   .rotate(pi/2);

In the end, call matrix4:

Matrix4 myMatrix 
   = Matrix4Transform()
     .scale(1.5)
     .upRight(35)
     .rotate(pi/2)
     .matrix4;                        

Note: The transformations will be applied in order, and their order may change the end result.

If you already have a matrix4 and want to further transform it, you can use the from constructor:

Matrix4 myMatrix = ...;

var myTransform = Matrix4Transform.from(myMatrix);

Methods you can use

  • rotate(double angleRadians, {Offset origin})
  • rotateDegrees(double angleDegrees, {Offset origin})
  • rotateByCenterDegrees(double angleDegrees, Size size)
  • rotateByCenter(_toRadians(angleDegrees), size)
  • translate({double x = 0, double y = 0})
  • translateOriginalCoordinates({double x = 0, double y = 0})
  • scale(double factor, {Offset origin})
  • scaleBy({double x = 1, double y = 1, Offset origin})
  • scaleHorizontally(double factor)
  • scaleVertically(double factor)
  • translateOffset(Offset offset)
  • up(double distance)
  • down(double distance)
  • right(double distance)
  • left(double distance)
  • direction(double directionRadians, double distance)
  • directionDegrees(double directionDegrees, double distance)
  • upRight(double distance)
  • upLeft(double distance)
  • downRight(double distance)
  • downLeft(double distance)
  • flipDiagonally({Offset origin})
  • flipHorizontally({Offset origin})
  • flipVertically({Offset origin})

And, of course:

  • Matrix4 toMatrix4

Tween

A Matrix4TransformTween is provided in this package, and can be used in animations.

Animate it

A Matrix4Transform can be used to animate:

AlignPositioned or AnimatedAlignPositioned widgets from the AlignPositioned package, that accept a Matrix4Transform directly. The center of rotation/scale can be defined by their alignment parameter.

Any widget that accepts a Matrix4 transformation parameter, like Container, or AnimatedContainer. Note: Since Matrix4Tween will not animate linearly as you'd expect, it's possible that the intermediary transformations will be "strange", although the start and end should be correct.


Special thanks to Martin Kamleithner and Simon Lightfoot.


The Flutter packages I've authored:

My Medium Articles:

My article in the official Flutter documentation:

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add matrix4_transform

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  matrix4_transform: ^2.0.1

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

Import it

Now in your Dart code, you can use:

import 'package:matrix4_transform/matrix4_transform.dart';

example/lib/main.dart

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

// Developed by Marcelo Glasberg (Aug 2019).
// For more info, see: https://pub.dartlang.org/packages/matrix4_transform

void main() async => runApp(MaterialApp(home: Demo()));

class Demo extends StatelessWidget {
  final boxes = [
    Box(null, "Original"),
    Box(Matrix4Transform().translate(x: 25).matrix4, ".translate(x: 25)"),
    Box(Matrix4Transform().rotateDegrees(20).matrix4, ".rotateDegrees(20)"),
    Box(Matrix4Transform().rotateDegrees(45).matrix4, ".rotateDegrees(45)"),
    Box(Matrix4Transform().rotateDegrees(20, origin: Offset(25, 25)).matrix4,
        ".rotateDegrees(20, origin: Offset(25, 25))"),
    Box(Matrix4Transform().rotateDegrees(45, origin: Offset(25, 25)).matrix4,
        ".rotateDegrees(45, origin: Offset(25, 25))"),
    Box(Matrix4Transform().rotateDegrees(45, origin: Offset(25, 25)).translate(x: 25).matrix4,
        ".rotateDegrees(45, origin: Offset(25, 25)).\ntranslate(x: 25)"),
    Box(Matrix4Transform().scaleBy(x: 2.0, y: 0.5).matrix4, ".scaleBy(x: 2.0, y: 0.5)"),
    Box(Matrix4Transform().scaleBy(x: 2.0, y: 0.5, origin: Offset(25, 25)).matrix4,
        ".scaleBy(x: 2.0, y: 0.5, origin: Offset(25, 25))"),
    Box(Matrix4Transform().scaleBy(x: 2, y: 0.5, origin: Offset(25, 25)).right(25).matrix4,
        ".scaleBy(x: 2, y: 0.5, origin: Offset(25, 25))\n.right(25)"),
    Box(
        Matrix4Transform()
            .scaleBy(x: 2, y: 0.5, origin: Offset(25, 25))
            .translateOriginalCoordinates(x: 25)
            .matrix4,
        ".scaleBy(x: 2, y: 0.5, origin: Offset(25, 25))\n.translateOriginalCoordinates(x: 25)"),
    //
    Box(Matrix4Transform().flipHorizontally().matrix4, ".flipHorizontally()"),
    Box(Matrix4Transform().flipHorizontally(origin: Offset(25, 25)).matrix4,
        ".flipHorizontally(origin: Offset(25, 25))"),
    Box(Matrix4Transform().flipVertically().matrix4, ".flipVertically()"),
    Box(Matrix4Transform().flipVertically(origin: Offset(25, 25)).matrix4,
        ".flipVertically(origin: Offset(25, 25))"),
    Box(Matrix4Transform().flipDiagonally().matrix4, ".flipDiagonally())"),
    Box(Matrix4Transform().flipDiagonally(origin: Offset(25, 25)).matrix4,
        ".flipDiagonally(origin: Offset(25, 25))"),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Matrix4Transform Example')),
      body: Stack(
        children: <Widget>[
          SingleChildScrollView(
            child: Container(
              color: Colors.grey[400],
              child: Column(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  for (var box in boxes) wrap(box),
                ],
              ),
            ),
          ),
          Center(
            child: Container(
              width: 50,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Container(width: 1.5, height: double.infinity, color: Colors.black),
                  Container(width: 0.75, height: double.infinity, color: Colors.black26),
                  Container(width: 1.0, height: double.infinity, color: Colors.black26),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }
}

Widget wrap(Box box) {
  return Column(
    children: <Widget>[
      if (box.description != null)
        Align(
          alignment: Alignment.centerLeft,
          child: Text(box.description.toString(), style: TextStyle(fontSize: 11)),
        ),
      Container(height: 1.5, width: double.infinity, color: Colors.black),
      Container(child: box, alignment: Alignment.center, height: 50, width: double.infinity),
      Container(height: 1.0, width: double.infinity, color: Colors.black26),
      SizedBox(height: 70.0),
    ],
  );
}

class Box extends StatelessWidget {
  final Matrix4 matrix;
  final String? description;

  Box(
    Matrix4? matrix,
    this.description,
  ) : matrix = matrix ?? Matrix4.identity();

  @override
  Widget build(BuildContext context) {
    return Container(
      transform: matrix,
      color: Colors.red,
      width: 50,
      height: 50,
      child: Center(
        child: Stack(
          children: [
            Icon(Icons.cancel, color: Colors.yellow, size: 38),
            Icon(Icons.expand_less, color: Colors.yellow, size: 38),
            Icon(Icons.add_circle, color: Colors.yellow, size: 10),
          ],
        ),
      ),
    );
  }
}

Download Details:
 

Author: marcglasberg
Download Link: Download The Source Code
Official Website: https://github.com/marcglasberg/matrix4_transform 
License: View license

#flutter 

Harry Patel

Harry Patel

1614145832

A Complete Process to Create an App in 2021

It’s 2021, everything is getting replaced by a technologically emerged ecosystem, and mobile apps are one of the best examples to convey this message.

Though bypassing times, the development structure of mobile app has also been changed, but if you still follow the same process to create a mobile app for your business, then you are losing a ton of opportunities by not giving top-notch mobile experience to your users, which your competitors are doing.

You are about to lose potential existing customers you have, so what’s the ideal solution to build a successful mobile app in 2021?

This article will discuss how to build a mobile app in 2021 to help out many small businesses, startups & entrepreneurs by simplifying the mobile app development process for their business.

The first thing is to EVALUATE your mobile app IDEA means how your mobile app will change your target audience’s life and why your mobile app only can be the solution to their problem.

Now you have proposed a solution to a specific audience group, now start to think about the mobile app functionalities, the features would be in it, and simple to understand user interface with impressive UI designs.

From designing to development, everything is covered at this point; now, focus on a prelaunch marketing plan to create hype for your mobile app’s targeted audience, which will help you score initial downloads.

Boom, you are about to cross a particular download to generate a specific revenue through your mobile app.

#create an app in 2021 #process to create an app in 2021 #a complete process to create an app in 2021 #complete process to create an app in 2021 #process to create an app #complete process to create an app

Joseph  Murray

Joseph Murray

1624063200

Creating an Immutable Class in Java

In this article, we’ll define the typical steps for creating an immutable class in Java and then implement it.

Steps to create Immutable class in java

  1. Make your class final, so that no other classes can extend it.
  2. Make all fields private so that direct access is not allowed.
  3. Don’t provide “setter” methods — methods that modify fields or objects referred to by fields.
  4. Special attention when having mutable instance variables
  5. Inside the constructor, make sure to use a clone copy of the passed argument and never set your mutable field to the real instance passed through the constructor.
  6. Make sure to always return a clone copy of the field and never return the real object instance.

#java #class #objects #immutable #creating an immutable class in java #immutable class in java