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: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, |
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
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())); |
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
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; |
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
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; |
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: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')), |
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:bloc/bloc.dart'; | |
class SimpleBloc extends Bloc<dynamic, String> { | |
@override | |
Stream<String> mapEventToState(String state, dynamic event) async* { | |
yield 'state'; | |
} | |
} |
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 LoginState { | |
final bool isLoading; | |
final bool isLoginButtonEnabled; | |
final String error; | |
final String token; | |
const LoginState({ | |
@required this.isLoading, | |
@required this.isLoginButtonEnabled, | |
@required this.error, |
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
abstract class LoginEvent {} | |
class LoginButtonPressed extends LoginEvent { | |
final String username; | |
final String password; | |
LoginButtonPressed({@required this.username, @required this.password}); | |
} |
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 LoginBloc extends Bloc<LoginEvent, LoginState> { | |
LoginState get initialState => LoginState.initial(); | |
void onLoginButtonPressed({String username, String password}) { | |
dispatch( | |
LoginButtonPressed( | |
username: username, | |
password: password, | |
), | |
); |
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 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>( |
OlderNewer