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:state_notifier/state_notifier.dart'; | |
class CounterService extends StateNotifier<int> { | |
CounterService(int intialValue) : super(intialValue); | |
void incrementCounter() { | |
this.state++; | |
} | |
void decrementCounter() { |
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
name: state_notifier_example | |
description: A new Flutter project. | |
publish_to: "none" # Remove this line if you wish to publish to pub.dev | |
version: 1.0.0+1 | |
environment: | |
sdk: ">=2.12.0 <3.0.0" | |
dependencies: | |
cupertino_icons: ^1.0.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 'package:flutter/material.dart'; | |
import 'package:flutter_redux/flutter_redux.dart'; | |
import 'package:redux/redux.dart'; | |
import 'package:redux_example/redux_service.dart'; | |
class Home extends StatelessWidget { | |
Home({Key? key}) : super(key: key); | |
final store = Store<int>(ReduxActions.counterUpdate, initialState: 0); |
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:flutter_redux/flutter_redux.dart'; | |
import 'package:redux_example/home.dart'; | |
import 'package:redux/redux.dart'; | |
import 'package:redux_example/redux_service.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override |
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
enum CounterActions { Increment, Decrement, Reset } | |
class ReduxActions { | |
static int counterUpdate(int state, dynamic action) { | |
if (action == CounterActions.Increment) { | |
return state + 1; | |
} else if (action == CounterActions.Decrement) { | |
return (state - 1).toUnsigned(state.bitLength); | |
} else if (action == CounterActions.Reset) { | |
state = 0; |
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:io'; | |
import 'dart:convert'; | |
main(List<String> arguments) { | |
String data = ''; | |
for (int i = 0; i < 100000; i++) { | |
data = data + 'Hello world\r\n'; | |
} | |
//Original Data |
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
# This file configures the analyzer, which statically analyzes Dart code to | |
# check for errors, warnings, and lints. | |
# | |
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled | |
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be | |
# invoked from the command line by running `flutter analyze`. | |
# The following line activates a set of recommended lints for Flutter apps, | |
# packages, and plugins designed to encourage good coding practices. | |
include: package:flutter_lints/flutter.yaml |
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_bloc/flutter_bloc.dart'; | |
import 'package:meta/meta.dart'; | |
part 'counter_event.dart'; | |
part 'counter_state.dart'; | |
class CounterBloc extends Bloc<CounterEvent, CounterState> { | |
CounterBloc() : super(CounterDataState(counter: 0)) { | |
on<InitialCounterEvent>((event, emit) => emit(CounterDataState(counter: 0))); | |
on<IncrementCounterEvent>((event, emit) => emit(CounterDataState(counter: event.counter + 1))); |
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 'main.dart'; | |
class Page2 extends StatefulWidget { | |
const Page2({Key? key}) : super(key: key); | |
@override | |
_Page2State createState() => _Page2State(); | |
} |
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:routeaware_example/page2.dart'; | |
import 'main.dart'; | |
class Page1 extends StatefulWidget { | |
const Page1({Key? key}) : super(key: key); | |
@override | |
_Page1State createState() => _Page1State(); |