This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | |
| void main() => runApp(const MyApp()); | |
| class MyApp extends StatelessWidget { | |
| const MyApp({Key? key}) : super(key: key); | |
| @override | |
| Widget build(BuildContext context) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:bloc/bloc.dart'; | |
| import 'package:equatable/equatable.dart'; | |
| import '../models/language.dart'; | |
| part 'language_event.dart'; | |
| part 'language_state.dart'; | |
| class LanguageBloc extends Bloc<LanguageEvent, LanguageState> { | |
| LanguageBloc() : super(const LanguageState()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| part of 'language_bloc.dart'; | |
| abstract class LanguageEvent extends Equatable { | |
| const LanguageEvent(); | |
| @override | |
| List<Object> get props => []; | |
| } | |
| class ChangeLanguage extends LanguageEvent { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| part of 'language_bloc.dart'; | |
| class LanguageState extends Equatable { | |
| const LanguageState({ | |
| Language? selectedLanguage, | |
| }) : selectedLanguage = selectedLanguage ?? Language.english; | |
| final Language selectedLanguage; | |
| @override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:ui'; | |
| import '../../../../gen/assets.gen.dart'; | |
| enum Language { | |
| english( | |
| Locale('en', 'US'), | |
| Assets.english, | |
| 'English', | |
| ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | |
| import '../../../gen/assets.gen.dart'; | |
| import '../../components/components.dart'; | |
| class OnboardingScreen extends StatelessWidget { | |
| const OnboardingScreen({Key? key}) : super(key: key); | |
| @override | |
| Widget build(BuildContext context) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | |
| void main() => runApp(const MyApp()); | |
| class MyApp extends StatelessWidget { | |
| const MyApp({Key? key}) : super(key: key); | |
| @override | |
| Widget build(BuildContext context) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SomeController { | |
| Future login(String email, String password) async { | |
| final _result = await _repository.login(email, password); | |
| _result.fold( | |
| (l) { | |
| /// Handle left | |
| /// For example: show dialog or alert | |
| }, | |
| (r) { | |
| /// Handle right |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// Create variety of exceptions | |
| /// Enum to help create conditions | |
| enum LoginFailure { invalidCredentials, error } | |
| /// Repository | |
| /// This class can be consumed by controller, provider, or other state management later | |
| class SomeRepository { | |
| final http.Client _client; | |
| Future<Either<LoginFailure, bool>> login(String email, String password) async { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RequestException implements Exception {} | |
| class ServerException implements Exception {} |