createFixtureFromShape method

Fixture createFixtureFromShape(
  1. Shape shape, {
  2. double density = 1.0,
  3. double friction = 0.0,
  4. double restitution = 0.0,
})

Creates a fixture from a shape and attach it to this body. This is a convenience function. Use FixtureDef if you need to set parameters like friction, restitution, user data, or filtering. If the density is non-zero, this function automatically updates the mass of the body.

Implementation

Fixture createFixtureFromShape(
  Shape shape, {
  double density = 1.0,
  double friction = 0.0,
  double restitution = 0.0,
}) {
  return createFixture(
    FixtureDef(shape)
      ..density = density
      ..friction = friction
      ..restitution = restitution,
  );
}