Giter Club home page Giter Club logo

fitness's Introduction

Fitness app

Example of Fitness app done using Flutter for iOS and Android platforms.

Home Workout

See Behance UI/UX case:

https://www.behance.net/gallery/132549709/Selfit-Fitness-app?tracking_source=for_you_feed_user_published

See our tutorial posts:

Part 1 - How to Make a Fitness App With Flutter: A Tutorial by Perpetio. Part I

Part 2 - How to Make a Fitness App With Flutter: A Tutorial by Perpetio. Part II

Part 3 - How to Make a Fitness App With Flutter: A Tutorial by Perpetio. Part III

Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

fitness's People

Contributors

dherasymyuk avatar dvuyiv avatar v1nnk1 avatar yberdnikov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fitness's Issues

Unhandled error LateInitializationError: Field 'currentUser' has not been initialized. occurred in Instance of 'Home Bloc'.

Hello, i was following the tutorial from your site and I do get this error :
E/flutter (11536): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Unhandled error LateInitializationError: Field 'currentUser' has not been initialized. occurred in Instance of 'Home Bloc'. E/flutter (11536): #0 GlobalConstants.currentUser (package:fitness_flutter/core/const/global_constants.dart) E/flutter (11536): #1 DataService.getWorkoutsForUser (package:fitness_flutter/core/service/data_service.dart:9:43) E/flutter (11536): #2 HomeBloc.mapEventToState (package:fitness_flutter/screens/home/bloc/home_bloc.dart:27:36) E/flutter (11536): <asynchronous suspension>

I did follow the tutorial exactly.

data_service.dart :

import 'dart:convert';

import 'package:fitness_flutter/core/const/global_constants.dart';
import 'package:fitness_flutter/core/service/user_storage_service.dart';
import 'package:fitness_flutter/data/workout_data.dart';

class DataService {
  static Future<List<WorkoutData>> getWorkoutsForUser() async {
    final currUserEmail = GlobalConstants.currentUser.mail;

    //await UserStorageService.deleteSecureData('${currUserEmail}Workouts');

    final workoutsStr =
        await UserStorageService.readSecureData('${currUserEmail}Workouts');
    if (workoutsStr == null) return [];
    final decoded = (json.decode(workoutsStr) as List?) ?? [];
    final workouts = decoded.map((e) {
      final decodedE = json.decode(e) as Map<String, dynamic>?;
      return WorkoutData.fromJson(decodedE!);
    }).toList();
    GlobalConstants.workouts = workouts;
    return workouts;
  }

  static Future<void> saveWorkout(WorkoutData workout) async {
    final allWorkouts = await getWorkoutsForUser();
    final index = allWorkouts.indexWhere((w) => w.id == workout.id);
    if (index != -1) {
      allWorkouts[index] = workout;
    } else {
      allWorkouts.add(workout);
    }
    GlobalConstants.workouts = allWorkouts;
    final workoutsStr = allWorkouts.map((e) => e.toJsonString()).toList();
    final encoded = json.encode(workoutsStr);
    final currUserEmail = GlobalConstants.currentUser.mail;
    await UserStorageService.writeSecureData(
      '${currUserEmail}Workouts',
      encoded,
    );
  }
}

home_bloc.dart :

import 'dart:async';

import 'package:bloc/bloc.dart';
import 'package:fitness_flutter/core/const/data_constants.dart';
import 'package:fitness_flutter/core/service/auth_service.dart';
import 'package:fitness_flutter/core/service/data_service.dart';
import 'package:fitness_flutter/core/service/user_storage_service.dart';
import 'package:fitness_flutter/data/exercise_data.dart';
import 'package:fitness_flutter/data/workout_data.dart';
import 'package:meta/meta.dart';

part 'home_event.dart';
part 'home_state.dart';

class HomeBloc extends Bloc<HomeEvent, HomeState> {
  HomeBloc() : super(HomeInitial());

  List<WorkoutData> workouts = <WorkoutData>[];
  List<ExerciseData> exercises = <ExerciseData>[];
  int timeSent = 0;

  @override
  Stream<HomeState> mapEventToState(
    HomeEvent event,
  ) async* {
    if (event is HomeInitialEvent) {
      workouts = await DataService.getWorkoutsForUser();
      yield WorkoutsGotState(workouts: workouts);
    } else if (event is ReloadImageEvent) {
      String? photoURL = await UserStorageService.readSecureData('image');
      if (photoURL == null) {
        photoURL = AuthService.auth.currentUser?.photoURL;
        photoURL != null
            ? await UserStorageService.writeSecureData('image', photoURL)
            : print('no image');
      }
      yield ReloadImageState(photoURL: photoURL);
    } else if (event is ReloadDisplayNameEvent) {
      final displayName = await UserStorageService.readSecureData('name');
      yield ReloadDisplayNameState(displayName: displayName);
    }
  }

  int getProgressPercentage() {
    final completed = workouts
        .where((w) =>
            (w.currentProgress ?? 0) > 0 && w.currentProgress == w.progress)
        .toList();
    final percent01 =
        completed.length.toDouble() / DataConstants.workouts.length.toDouble();
    final percent = (percent01 * 100).toInt();
    return percent;
  }

  int? getFinishedWorkouts() {
    final completedWorkouts =
        workouts.where((w) => w.currentProgress == w.progress).toList();
    return completedWorkouts.length;
  }

  int? getInProgressWorkouts() {
    final completedWorkouts = workouts.where(
        (w) => (w.currentProgress ?? 0) > 0 && w.currentProgress != w.progress);
    return completedWorkouts.length;
  }

  int? getTimeSent() {
    for (final WorkoutData workout in workouts) {
      exercises.addAll(workout.exerciseDataList!);
    }
    final exercise = exercises.where((e) => e.progress == 1).toList();
    exercise.forEach((e) {
      timeSent += e.minutes!;
    });
    return timeSent;
  }
}

Nice work

I like this.. I want to rebuild it as my final project in college

Cannot Find Symbol POST_NOTIFICATIONS

Hello, I updated compileSdkVersion to 33, and I still have this error.

error
      String permissionNotif = Manifest.permission.POST_NOTIFICATIONS;
                                                  ^
  symbol:   variable POST_NOTIFICATIONS
  location: class permission
2 errors

FAILURE: Build failed with an exception.

image

PageSwipe/Change not working (animation + logic) + SDK Requirements

PageSwipe not working (animation + logic)

After I run it, I either swipe right or press the continue button in order to move between the first registry screens, but the animation of the arrow circle does not work (it stays on the first image like), the swipe work on the body image with the person and the texts, but when i get to the last one nothing happened.

On every swipe I do there I get the following error:

Bad state: add(PageSwipedEvent) was called without a registered event handler.
Make sure to register a handler via on<PageSwipedEvent>((event, emit) {...})

following the stack trace I can see it was originated here (onboarding_content.dart):

onPageChanged: (index) {
  bloc.add(PageSwipedEvent(index: index));
},

SDK Requirements

first of all in order for it to run I had to change the following
minSdkVersion 18
and
compileSdkVersion 33


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.