Skip to content

Commit 13910fd

Browse files
author
Vivek Chib
committed
initial commit
0 parents  commit 13910fd

19 files changed

+899
-0
lines changed

.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.build/
9+
.buildlog/
10+
.history
11+
.svn/
12+
.swiftpm/
13+
migrate_working_dir/
14+
15+
# IntelliJ related
16+
*.iml
17+
*.ipr
18+
*.iws
19+
.idea/
20+
21+
# The .vscode folder contains launch configuration and tasks you configure in
22+
# VS Code which you may wish to be included in version control, so this line
23+
# is commented out by default.
24+
#.vscode/
25+
26+
# Flutter/Dart/Pub related
27+
**/doc/api/
28+
**/ios/Flutter/.last_build_id
29+
.dart_tool/
30+
.flutter-plugins
31+
.flutter-plugins-dependencies
32+
.pub-cache/
33+
.pub/
34+
/build/
35+
36+
# Symbolication related
37+
app.*.symbols
38+
39+
# Obfuscation related
40+
app.*.map.json
41+
42+
# Android Studio will place build artifacts here
43+
/android/app/debug
44+
/android/app/profile
45+
/android/app/release

.metadata

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: "8495dee1fd4aacbe9de707e7581203232f591b2f"
8+
channel: "stable"
9+
10+
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: 8495dee1fd4aacbe9de707e7581203232f591b2f
17+
base_revision: 8495dee1fd4aacbe9de707e7581203232f591b2f
18+
- platform: web
19+
create_revision: 8495dee1fd4aacbe9de707e7581203232f591b2f
20+
base_revision: 8495dee1fd4aacbe9de707e7581203232f591b2f
21+
22+
# User provided section
23+
24+
# List of Local paths (relative to this file) that should be
25+
# ignored by the migrate tool.
26+
#
27+
# Files that are not part of the templates will be ignored by default.
28+
unmanaged_files:
29+
- 'lib/main.dart'
30+
- 'ios/Runner.xcodeproj/project.pbxproj'

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# flutter_curve_visualizer
2+
3+
A new Flutter project.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter application.
8+
9+
A few resources to get you started if this is your first Flutter project:
10+
11+
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
12+
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
13+
14+
For help getting started with Flutter development, view the
15+
[online documentation](https://docs.flutter.dev/), which offers tutorials,
16+
samples, guidance on mobile development, and a full API reference.

analysis_options.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
7+
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
11+
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at https://dart.dev/lints.
17+
#
18+
# Instead of disabling a lint rule for the entire project in the
19+
# section below, it can also be suppressed for a single line of code
20+
# or a specific dart file by using the `// ignore: name_of_lint` and
21+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
22+
# producing the lint.
23+
rules:
24+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
25+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
26+
27+
# Additional information about this file can be found at
28+
# https://dart.dev/guides/language/analysis-options

lib/main.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import 'package:flutter/material.dart';
2+
3+
import 'views/home_page.dart';
4+
5+
void main() {
6+
runApp(const MyApp());
7+
}
8+
9+
class MyApp extends StatelessWidget {
10+
const MyApp({super.key});
11+
12+
@override
13+
Widget build(BuildContext context) {
14+
return MaterialApp(
15+
title: 'Flutter Curve Visualizer',
16+
theme: ThemeData(
17+
useMaterial3: true,
18+
),
19+
home: const HomePage(),
20+
);
21+
}
22+
}

lib/model/graph_config.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import 'package:flutter/material.dart';
2+
3+
class GraphConfiguration {
4+
final int graphDivisions;
5+
final int curveDivisions;
6+
final Color graphAxisColor;
7+
final Color graphCurveColor;
8+
final Color graphMarkerColor;
9+
final double graphAxisWidth;
10+
final double graphCurveWidth;
11+
final double graphMarkerSize;
12+
13+
const GraphConfiguration({
14+
this.graphDivisions = 10,
15+
this.curveDivisions = 1000,
16+
required this.graphAxisColor,
17+
required this.graphCurveColor,
18+
required this.graphMarkerColor,
19+
required this.graphAxisWidth,
20+
required this.graphCurveWidth,
21+
required this.graphMarkerSize,
22+
});
23+
}

lib/utils/curves_enum.dart

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import 'package:flutter/material.dart';
2+
3+
enum CurvesEnum {
4+
linear(Curves.linear),
5+
decelerate(Curves.decelerate),
6+
fastLinearToSlowEaseIn(Curves.fastLinearToSlowEaseIn),
7+
fastEaseInToSlowEaseOut(Curves.fastEaseInToSlowEaseOut),
8+
ease(Curves.ease),
9+
easeIn(Curves.easeIn),
10+
easeInToLinear(Curves.easeInToLinear),
11+
easeInSine(Curves.easeInSine),
12+
easeInQuad(Curves.easeInQuad),
13+
easeInCubic(Curves.easeInCubic),
14+
easeInQuart(Curves.easeInQuart),
15+
easeInQuint(Curves.easeInQuint),
16+
easeInExpo(Curves.easeInExpo),
17+
easeInCirc(Curves.easeInCirc),
18+
easeInBack(Curves.easeInBack),
19+
easeOut(Curves.easeOut),
20+
linearToEaseOut(Curves.linearToEaseOut),
21+
easeOutSine(Curves.easeOutSine),
22+
easeOutQuad(Curves.easeOutQuad),
23+
easeOutCubic(Curves.easeOutCubic),
24+
easeOutQuart(Curves.easeOutQuart),
25+
easeOutQuint(Curves.easeOutQuint),
26+
easeOutExpo(Curves.easeOutExpo),
27+
easeOutCirc(Curves.easeOutCirc),
28+
easeOutBack(Curves.easeOutBack),
29+
easeInOut(Curves.easeInOut),
30+
easeInOutSine(Curves.easeInOutSine),
31+
easeInOutQuad(Curves.easeInOutQuad),
32+
easeInOutCubic(Curves.easeInOutCubic),
33+
easeInOutCubicEmphasized(Curves.easeInOutCubicEmphasized),
34+
easeInOutQuart(Curves.easeInOutQuart),
35+
easeInOutQuint(Curves.easeInOutQuint),
36+
easeInOutExpo(Curves.easeInOutExpo),
37+
easeInOutCirc(Curves.easeInOutCirc),
38+
easeInOutBack(Curves.easeInOutBack),
39+
fastOutSlowIn(Curves.fastOutSlowIn),
40+
slowMiddle(Curves.slowMiddle),
41+
bounceIn(Curves.bounceIn),
42+
bounceOut(Curves.bounceOut),
43+
bounceInOut(Curves.bounceInOut),
44+
elasticIn(Curves.elasticIn),
45+
elasticOut(Curves.elasticOut),
46+
elasticInOut(Curves.elasticInOut);
47+
48+
final Curve curve;
49+
50+
const CurvesEnum(this.curve);
51+
52+
static Curve get getFirst => CurvesEnum.values.first.curve;
53+
}

lib/views/home_page.dart

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_curve_visualizer/utils/curves_enum.dart';
3+
import 'package:flutter_curve_visualizer/views/widgets/animation_graph.dart';
4+
5+
class HomePage extends StatefulWidget {
6+
const HomePage({super.key});
7+
8+
@override
9+
State<HomePage> createState() => _HomePageState();
10+
}
11+
12+
class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
13+
late AnimationController controller;
14+
15+
late CurvedAnimation animation;
16+
17+
late CurvesEnum selectedCurve;
18+
19+
late int animationTimeInSeconds;
20+
21+
@override
22+
void initState() {
23+
super.initState();
24+
25+
selectedCurve = CurvesEnum.values.first;
26+
27+
animationTimeInSeconds = 2;
28+
29+
controller = AnimationController(
30+
vsync: this,
31+
duration: Duration(seconds: animationTimeInSeconds),
32+
);
33+
34+
animation = CurvedAnimation(
35+
parent: controller,
36+
curve: selectedCurve.curve,
37+
);
38+
39+
controller.repeat(reverse: true);
40+
}
41+
42+
@override
43+
void dispose() {
44+
controller.dispose();
45+
super.dispose();
46+
}
47+
48+
void updateCurve(CurvesEnum curve) {
49+
selectedCurve = curve;
50+
51+
animation = CurvedAnimation(
52+
parent: controller,
53+
curve: selectedCurve.curve,
54+
);
55+
56+
setState(() {});
57+
}
58+
59+
void updateAnimationTime(int seconds) {
60+
animationTimeInSeconds = seconds;
61+
controller = AnimationController(
62+
vsync: this,
63+
duration: Duration(seconds: animationTimeInSeconds),
64+
);
65+
setState(() {});
66+
67+
animation = CurvedAnimation(
68+
parent: controller,
69+
curve: selectedCurve.curve,
70+
);
71+
controller.repeat(reverse: true);
72+
}
73+
74+
@override
75+
Widget build(BuildContext context) {
76+
return Scaffold(
77+
appBar: AppBar(
78+
title: const Text('Flutter Curve Visualizer'),
79+
actions: [
80+
DropdownButton(
81+
value: selectedCurve,
82+
items: CurvesEnum.values
83+
.map((curve) => DropdownMenuItem(
84+
value: curve,
85+
child: Text(curve.name),
86+
))
87+
.toList(),
88+
onChanged: (value) => updateCurve(value!),
89+
),
90+
],
91+
),
92+
body: Column(
93+
spacing: 50.0,
94+
children: [
95+
LayoutBuilder(builder: (context, constraints) {
96+
return Container(
97+
width: constraints.maxWidth,
98+
alignment: Alignment.topLeft,
99+
padding: EdgeInsets.all(8.0),
100+
child: AnimatedBuilder(
101+
animation: controller,
102+
builder: (context, child) {
103+
final constrainedOffset =
104+
animation.value * (constraints.maxWidth - 100);
105+
106+
return Transform.translate(
107+
offset: Offset(constrainedOffset, 0),
108+
child: Container(
109+
height: 50,
110+
width: 50,
111+
decoration: BoxDecoration(
112+
shape: BoxShape.circle,
113+
color: Colors.red,
114+
),
115+
),
116+
);
117+
},
118+
),
119+
);
120+
}),
121+
LayoutBuilder(builder: (context, constraints) {
122+
return AnimationGraph(
123+
controller: controller,
124+
animation: animation,
125+
);
126+
}),
127+
],
128+
),
129+
);
130+
}
131+
}

0 commit comments

Comments
 (0)