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/cupertino.dart'; | |
| import 'package:flutter/material.dart'; | |
| import 'package:flutter_bloc/flutter_bloc.dart'; | |
| import 'package:flutter_blocs_testing/bloc_tutorial/bloc/login_bloc.dart'; | |
| class LoginScreen extends StatelessWidget { | |
| const LoginScreen({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
| TextButton( | |
| onPressed: () { | |
| context.read<LoginBloc>().add(LoginButtonTappedEvent()); | |
| }, | |
| child: const Text("Tap me!!!"), | |
| ) |
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
| Widget _prepareLoginScreen() { | |
| return BlocProvider( | |
| create: (BuildContext context) { | |
| return LoginBloc(); | |
| }, | |
| child: const LoginScreen(), | |
| ); | |
| } |
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/cupertino.dart'; | |
| import 'package:flutter/material.dart'; | |
| class LoginScreen extends StatelessWidget { | |
| const LoginScreen({Key? key}) : super(key: key); | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| appBar: AppBar(title: const Text("Login")), |
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 'login_bloc.dart'; | |
| // This is also an abstract class | |
| // which can be again extended by other classes | |
| /* | |
| * The reason for having a one base class is because, | |
| * We can refer it for all other child class, | |
| * throughout other files where it is used. | |
| * */ |
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 'login_bloc.dart'; | |
| // It's a simple abstract class | |
| // which can be extended for other event's | |
| abstract class LoginEvent { | |
| const LoginEvent(); | |
| } | |
| /* | |
| Will be used later |
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'; | |
| part 'login_event.dart'; | |
| part 'login_state.dart'; | |
| /* | |
| We extend the the Bloc class and also mention the | |
| type for event and state. | |
| */ | |
| class LoginBloc extends Bloc<LoginEvent, LoginState> { |
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 UIKit | |
| import Flutter | |
| @UIApplicationMain | |
| @objc class AppDelegate: FlutterAppDelegate { | |
| override func application( | |
| _ application: UIApplication, | |
| didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? | |
| ) -> Bool { | |
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 UIKit | |
| import Flutter | |
| @UIApplicationMain | |
| @objc class AppDelegate: FlutterAppDelegate { | |
| override func application( | |
| _ application: UIApplication, | |
| didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? | |
| ) -> Bool { | |
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
| Future<void> _getDeviceModel() async { | |
| String _model; | |
| try { | |
| // 1 | |
| _model = await platformChannel.invokeMethod('getDeviceModel'); | |
| } catch (e) { | |
| // 2 |
NewerOlder