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/material.dart'; | |
| import 'package:flutter_route_obser/main.dart'; | |
| class PageTwo extends StatefulWidget { | |
| @override | |
| _PageTwoState createState() => _PageTwoState(); | |
| } | |
| class _PageTwoState extends State<PageTwo> with RouteAware { | |
| @override |
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/material.dart'; | |
| import 'package:flutter_cubit/flutter_cubit.dart'; | |
| import 'package:flutter_cubit_demo/cubit/counter_cubit.dart'; | |
| class HomePage extends StatefulWidget { | |
| @override | |
| _HomePageState createState() => _HomePageState(); | |
| } | |
| class _HomePageState extends State<HomePage> { |
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
| MaterialApp( | |
| theme: ThemeData( | |
| primarySwatch: Colors.blue, | |
| visualDensity: VisualDensity.adaptivePlatformDensity, | |
| ), | |
| home: CubitProvider( | |
| create: (context) => CounterCubit(), | |
| child: HomePage(), | |
| ), |
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
| void main() { | |
| Cubit.observer = MainCubitObserver(); | |
| runApp(MyApp()); | |
| } |
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:cubit/cubit.dart'; | |
| class MainCubitObserver extends CubitObserver { | |
| @override | |
| void onTransition(Cubit cubit, Transition transition) { | |
| print("CubitObserver $transition"); | |
| super.onTransition(cubit, transition); | |
| } | |
| } |
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:cubit/cubit.dart'; | |
| class CounterCubit extends Cubit<int> { | |
| CounterCubit() : super(1); | |
| void increment() { | |
| emit(state + 1); | |
| } | |
| void decrement() { |
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
| mixin Hunt on Reptile { | |
| void hunt(food) { | |
| print('${this.runtimeType}'); | |
| swim(); | |
| crawl(); | |
| bite(); | |
| print('Eat $food'); | |
| } | |
| } |
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
| mixin Hunt on Reptile { | |
| void hunt(food) { | |
| print('${this.runtimeType}'); | |
| swim(); | |
| crawl(); | |
| bite(); | |
| print('Eat $food'); | |
| } | |
| } |
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
| mixin Swim { | |
| void swim() => print('Swimming'); | |
| } | |
| mixin Bite { | |
| void bite() => print('Chomp'); | |
| } | |
| mixin Crawl { | |
| void crawl() => print('Crawling'); |
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
| abstract class Reptile { | |
| void bite() => print('Chomp'); | |
| void swim() => print('Swimming'); | |
| void crawl() => print('Crawling'); | |
| void hunt() { | |
| print('${this.runtimeType} '); | |
| swim(); | |
| crawl(); | |
| bite(); | |
| } |
NewerOlder