Skip to content

Commit

Permalink
Merge pull request #78 from Kanyade/main
Browse files Browse the repository at this point in the history
Add new animation demo project
  • Loading branch information
danim1130 authored Nov 4, 2024
2 parents fddfc35 + 2de7765 commit 4d408da
Show file tree
Hide file tree
Showing 98 changed files with 122,646 additions and 0 deletions.
2 changes: 2 additions & 0 deletions material/07.md
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,8 @@ When an item is clicked on either the list or grid version of the photo listing

Check out the [*stock_photo_animations*](../projects/chapters/chapter_07/stock_photo_animations) project to see how tween animations can be implemented in Flutter.

For even more use-cases and techniques, take a look at the [*animation_demo*](../projects/chapters/chapter_07/animation_demo) project.

## Conclusion

In this chapter, we've seen how easy input handling is in Flutter, then we experienced a few different solutions for in-app navigation with Navigator 1.0, and the more flexible (and more complex) Navigator 2.0. On top of that, we can now build scrollable lists and grids effectively with`ListView` and `GridView`. We also briefly scratched the surface of UI animations with Flutter and met with some `Hero`es. 🦸🦸
Expand Down
3 changes: 3 additions & 0 deletions projects/chapters/chapter_07/animation_demo/.fvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"flutter": "3.24.3"
}
47 changes: 47 additions & 0 deletions projects/chapters/chapter_07/animation_demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release


# FVM Version Cache
.fvm/
45 changes: 45 additions & 0 deletions projects/chapters/chapter_07/animation_demo/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "2663184aa79047d0a33a14a3b607954f8fdd8730"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
- platform: android
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
- platform: ios
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
- platform: linux
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
- platform: macos
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
- platform: web
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
- platform: windows
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
62 changes: 62 additions & 0 deletions projects/chapters/chapter_07/animation_demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Flutter Animation Demo App

## Overview

This project is a demo application built using Flutter and is designed to showcase various animation techniques and libraries. It serves as an educational resource for developers who want to explore Flutter's animation APIs, as well as popular libraries like Lottie and Rive. Each page within the app demonstrates a specific animation technique, providing a clear and interactive example.

This project was (re)built using **Flutter version 3.24.3** through **FVM (Flutter Version Management)** for easy version control and management. It also utilizes **flutter_screenutil** for responsive design across various screen sizes and **flutter_gen** for safe and convenient asset generation.

---


## Demo Pages

### 1. **AnimatedSize Demo Page**
- **Purpose**: Demonstrates the use of `AnimatedSize` to smoothly animate size changes of widgets when they resize. It automatically transitions between the old and new size when a size change occurs.
- **Example**: A container that expands and contracts on button press, with smooth size transitions.

### 2. **AnimatedContainer Demo Page**
- **Purpose**: Showcases the `AnimatedContainer` widget, which animates changes in its properties such as width, height, color, and padding.
- **Example**: A container whose dimensions and colors change on user interaction, with smooth animations between states.

### 3. **AnimatedBuilder Demo Page**
- **Purpose**: Displays the usage of `AnimatedBuilder` to animate widgets by listening to an `AnimationController`. `AnimatedBuilder` helps create animations in a more reusable and efficient manner.
- **Example**: A rotating square that is animated using a custom controller, with the ability to modify the animation curve.

### 4. **Staggering Animation Demo Page**
- **Purpose**: Demonstrates a more complex, staggered animation sequence where multiple animations start at different times and durations using Flutter's `Tween` and `AnimationController`.
- **Example**: Animations such as fading, sliding, and resizing of several widgets happening in a staggered fashion.

### 5. **Animated SVG Demo Page**
- **Purpose**: Illustrates how to animate SVG graphics using Flutter's `flutter_svg` package, enabling smooth vector graphic animations.
- **Example**: An SVG icon that animates its path drawing, scaling, or color transitions over time.

### 6. **Drawing Animation Demo Page**
- **Purpose**: Showcases drawing animations, where lines or shapes are drawn progressively on the screen, creating dynamic and engaging visuals.
- **Example**: A path being drawn in real-time, simulating a hand-drawing effect.

### 7. **Lottie Demo Page**
- **Purpose**: Integrates the popular **Lottie** animation format, which allows the rendering of JSON-based vector animations created in tools like After Effects and exported using the Bodymovin plugin.
- **Example**: A Lottie animation that plays on a loop, showcasing an animated character or illustration with interactive controls for playback.

### 8. **Rive Demo Page**
- **Purpose**: Demonstrates the use of **Rive** to run complex animations created in the Rive app. Rive animations can be dynamic and interactive, supporting state machines and real-time user input.
- **Example**: A Rive animation that responds to user input, such as pressing buttons or sliding controls to change animation states.

---

## How to Run the App

- **Run using FVM**:
Ensure you have **FVM** installed. If not, install it by running the following command:
```bash
dart pub global activate fvm
```
Then:
```bash
fvm flutter run
```
- **Or just simply run**:
```bash
flutter run
```
178 changes: 178 additions & 0 deletions projects/chapters/chapter_07/animation_demo/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
include: package:flutter_lints/flutter.yaml

linter:
rules:
############################################
# CODE STYLING

require_trailing_commas: true
avoid_types_as_parameter_names: true
prefer_single_quotes: true
sort_constructors_first: true
sort_child_properties_last: true
sort_unnamed_constructors_first: true
always_use_package_imports: true
directives_ordering: true
use_key_in_widget_constructors: true
use_full_hex_values_for_flutter_colors: true
prefer_foreach: true
prefer_collection_literals: true
sized_box_shrink_expand: true
prefer_conditional_assignment: true
use_if_null_to_convert_nulls_to_bools: true
no_leading_underscores_for_local_identifiers: true
no_leading_underscores_for_library_prefixes: true
use_is_even_rather_than_modulo: true
slash_for_doc_comments: true
use_function_type_syntax_for_parameters: true
type_literal_in_constant_pattern: true
type_init_formals: true
no_wildcard_variable_uses: true
missing_code_block_language_in_doc_comment: true
annotate_overrides: true
prefer_null_aware_operators: true
prefer_null_aware_method_calls: true
prefer_is_not_operator: true
prefer_is_not_empty: true
prefer_is_empty: true
prefer_initializing_formals: true
prefer_if_null_operators: true
prefer_generic_function_type_aliases: true
non_constant_identifier_names: true
leading_newlines_in_multiline_strings: true
eol_at_end_of_file: true
curly_braces_in_flow_control_structures: true
camel_case_types: true
camel_case_extensions: true
combinators_ordering: true
deprecated_consistency: true
file_names: true
avoid_private_typedef_functions: true
avoid_init_to_null: true
avoid_multiple_declarations_per_line: true
avoid_escaping_inner_quotes: true

############################################
# BASIC PERFORMANCE RULES

avoid_unnecessary_containers: true
prefer_const_constructors: true
prefer_const_declarations: true
prefer_const_constructors_in_immutables: true
prefer_const_literals_to_create_immutables: true
sized_box_for_whitespace: true
use_decorated_box: true
use_colored_box: true
prefer_contains: true
prefer_final_locals: true
prefer_final_in_for_each: true
prefer_final_fields: true
prefer_constructors_over_static_methods: true
avoid_slow_async_io: true

############################################
# KEEPING IT CLEAN

unnecessary_to_list_in_spreads: true
unnecessary_this: true
unnecessary_string_interpolations: true
unnecessary_string_escapes: true
unnecessary_parenthesis: true
unnecessary_overrides: true
unnecessary_nullable_for_final_variable_declarations: true
unnecessary_null_in_if_null_operators: true
unnecessary_null_aware_operator_on_extension_on_nullable: true
unnecessary_null_aware_assignments: true
unnecessary_new: true
unnecessary_late: true
unnecessary_lambdas: true
unnecessary_getters_setters: true
unnecessary_constructor_name: true
unnecessary_const: true
unnecessary_breaks: true
unnecessary_brace_in_string_interps: true
unnecessary_await_in_return: true
use_named_constants: true
no_logic_in_create_state: true
only_throw_errors: true
one_member_abstracts: true
parameter_assignments: true
prefer_spread_collections: true
avoid_empty_else: true
empty_statements: true
no_adjacent_strings_in_list: true
literal_only_boolean_expressions: true
prefer_void_to_null: true
always_declare_return_types: true
prefer_mixin: true
prefer_inlined_adds: true
prefer_interpolation_to_compose_strings: true
prefer_if_elements_to_conditional_expressions: true
prefer_function_declarations_over_variables: true
prefer_asserts_in_initializer_lists: true
no_literal_bool_comparisons: true
exhaustive_cases: true
empty_constructor_bodies: true
empty_catches: true
cascade_invocations: true
cast_nullable_to_non_nullable: true
join_return_with_assignment: true
avoid_void_async: true
avoid_unused_constructor_parameters: true
avoid_types_on_closure_parameters: true
avoid_single_cascade_in_expression_statements: true
avoid_shadowing_type_parameters: true
avoid_returning_this: true
avoid_returning_null_for_void: true
avoid_return_types_on_setters: true
avoid_renaming_method_parameters: true
avoid_redundant_argument_values: true
avoid_positional_boolean_parameters: true
avoid_null_checks_in_equality_operators: true
avoid_implementing_value_types: true
avoid_field_initializers_in_const_classes: true
avoid_equals_and_hash_code_on_mutable_classes: true
avoid_double_and_int_checks: true

############################################
# CORE RULES

use_build_context_synchronously: true
close_sinks: true
avoid_dynamic_calls: true
cancel_subscriptions: true
control_flow_in_finally: true
throw_in_finally: true
overridden_fields: true
type_annotate_public_apis: true
tighten_type_of_initializing_formals: true
test_types_in_equals: true

############################################
# TRIVIAL STUFF THAT SHOULD NOT EVEN TRIGGER

await_only_futures: true
collection_methods_unrelated_type: true
recursive_getters: true
void_checks: true
null_closures: true
hash_and_equals: true
unrelated_type_equality_checks: true
no_duplicate_case_values: true
no_self_assignments: true
unnecessary_statements: true
matching_super_parameters: true

############################################
# BETTER SAFE THAN SORRY

avoid_print: true
avoid_web_libraries_in_flutter: true
depend_on_referenced_packages: true
provide_deprecation_message: true
avoid_type_to_string: true
valid_regexps: true
implementation_imports: true
conditional_uri_does_not_exist: true

############################################
13 changes: 13 additions & 0 deletions projects/chapters/chapter_07/animation_demo/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java

# Remember to never publicly share your keystore.
# See https://flutter.dev/to/reference-keystore
key.properties
**/*.keystore
**/*.jks
Loading

0 comments on commit 4d408da

Please sign in to comment.