Skip to content

Instantly share code, notes, and snippets.

☕️
coding

Felix Angelov felangel

View GitHub Profile
@felangel
felangel / text_view.dart
Last active Sep 7, 2018
[platform_views] TextView
View text_view.dart
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
typedef void TextViewCreatedCallback(TextViewController controller);
class TextView extends StatefulWidget {
const TextView({
Key key,
@felangel
felangel / TextViewPlugin.java
Created Sep 7, 2018
[platform_views] TextViewPlugin
View TextViewPlugin.java
package angelov.felix.textview;
import io.flutter.plugin.common.PluginRegistry.Registrar;
public class TextViewPlugin {
public static void registerWith(Registrar registrar) {
registrar
.platformViewRegistry()
.registerViewFactory(
"plugins.felix.angelov/textview", new TextViewFactory(registrar.messenger()));
@felangel
felangel / TextViewFactory.java
Created Sep 7, 2018
[platform_views] TextViewFactory
View TextViewFactory.java
package angelov.felix.textview;
import android.content.Context;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.StandardMessageCodec;
import io.flutter.plugin.platform.PlatformView;
import io.flutter.plugin.platform.PlatformViewFactory;
public class TextViewFactory extends PlatformViewFactory {
private final BinaryMessenger messenger;
@felangel
felangel / FlutterTextView.java
Created Sep 7, 2018
[platform_views] FlutterTextView
View FlutterTextView.java
package angelov.felix.textview;
import android.content.Context;
import android.view.View;
import android.widget.TextView;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import static io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import static io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.BinaryMessenger;
@felangel
felangel / main.dart
Last active Sep 7, 2018
[platform_views] TextViewExample
View main.dart
import 'package:flutter/material.dart';
import 'package:text_view/text_view.dart';
void main() => runApp(MaterialApp(home: TextViewExample()));
class TextViewExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Flutter TextView example')),
@felangel
felangel / login_form.dart
Created Oct 8, 2018
[bloc_package] LoginForm
View login_form.dart
class LoginForm extends StatelessWidget {
final LoginBloc loginBloc;
final usernameController = TextEditingController();
final passwordController = TextEditingController();
const LoginForm({Key key, @required this.loginBloc}): super(key: key);
@override
Widget build(BuildContext context) {
return BlocBuilder<LoginState>(
@felangel
felangel / login_event.dart
Last active Oct 9, 2018
[bloc_package] LoginEvent
View login_event.dart
abstract class LoginEvent {}
class LoginButtonPressed extends LoginEvent {
final String username;
final String password;
LoginButtonPressed({@required this.username, @required this.password});
}
@felangel
felangel / login_state.dart
Last active Oct 9, 2018
[bloc_package] LoginState
View login_state.dart
class LoginState {
final bool isLoading;
final bool isLoginButtonEnabled;
final String error;
final String token;
const LoginState({
@required this.isLoading,
@required this.isLoginButtonEnabled,
@required this.error,
@felangel
felangel / simple_bloc.dart
Last active Oct 14, 2018
[bloc_package] simple bloc example
View simple_bloc.dart
import 'dart:async';
import 'package:bloc/bloc.dart';
class SimpleBloc extends Bloc<dynamic, String> {
@override
Stream<String> mapEventToState(String state, dynamic event) async* {
yield 'state';
}
}
@felangel
felangel / login_bloc.dart
Last active Oct 14, 2018
[bloc_package] LoginBloc
View login_bloc.dart
class LoginBloc extends Bloc<LoginEvent, LoginState> {
LoginState get initialState => LoginState.initial();
void onLoginButtonPressed({String username, String password}) {
dispatch(
LoginButtonPressed(
username: username,
password: password,
),
);
You can’t perform that action at this time.