This file contains 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:async'; | |
import 'package:connectivity_plus/connectivity_plus.dart'; | |
import 'package:flutter/material.dart'; | |
class InheritedNetworkHandler extends InheritedWidget { | |
final bool isNetworkAvailable; | |
const InheritedNetworkHandler( | |
{required this.isNetworkAvailable, required Widget child}) |
This file contains 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 MyApp extends StatelessWidget { | |
const MyApp({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
// Option 1 | |
return MaterialApp( | |
title: 'Flutter Demo', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, |
This file contains 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 | |
final String result = await platformChannel.invokeMethod('getDeviceModel'); | |
// 2 | |
_model = result; |
This file contains 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 | |
final String result = await platformChannel.invokeMethod('getDeviceModel'); | |
// 2 | |
_model = result; | |
This file contains 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 |
This file contains 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 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 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 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 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. | |
* */ |
OlderNewer