Options constructor
Options({
- double tension = 0.45,
- double width = 50,
- double height = 20,
- double hoverFactor = -0.3,
- double gap = 5,
- double forceFactor = 0.15,
- double forceFactorBuild = 1,
- double forceFactorOnTap = 1,
- int stepRedrawing = 2,
- List<
LayerModel> ? layers, - List<
TouchModel> ? touches, - List<
int> ? layerNumbers, - List<
double> ? scaleOptionLayer, - double noise = 0,
Options - powerful customization engine for fluid physics widget
- Example of a Minimum Liquid Effect Setting
final options = Options(
layers: [
LayerModel(
points: [],
viscosity: 0.9,
touchForce: 30,
forceLimit: 15,
color: const Color(0xFF00FF00),
),
],
gap: 15,
noise: 5,
forceFactorBuild: 10,
forceFactorOnTap: 150,
);
- Use
options
Widget _buildLiquidButton() {
return LiquidContainer(
onTap: () {
// same code
},
optionsParam: options,
child: const SizedBox(
height: 80,
width: 300,
),
);
}
Implementation
Options({
this.tension = 0.45,
this.width = 50,
this.height = 20,
this.hoverFactor = -0.3,
this.gap = 5,
this.forceFactor = 0.15,
this.forceFactorBuild = 1,
this.forceFactorOnTap = 1,
this.stepRedrawing = 2,
List<LayerModel>? layers,
List<TouchModel>? touches,
/// To draw layers
List<int>? layerNumbers,
/// Scale object size at each level, independent of layer order
List<double>? scaleOptionLayer,
this.noise = 0,
}) : layers = layers ??
[
LayerModel(
points: [],
viscosity: 0.5,
touchForce: 100,
forceLimit: 2,
),
LayerModel(
points: [],
viscosity: 0.8,
touchForce: 150,
forceLimit: 3,
),
],
touches = touches ?? [] {
assert(stepRedrawing > 0);
this.layerNumbers =
layerNumbers ?? List.generate(this.layers.length, (index) => index);
layerScales =
scaleOptionLayer ?? List.generate(this.layers.length, (index) => 1.0);
}