a4c3106a
吴启风
feat:游戏列表页
|
1
2
3
|
import 'package:bloc/bloc.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
4
|
import 'package:wow_english/common/extension/string_extension.dart';
|
a4c3106a
吴启风
feat:游戏列表页
|
5
6
|
import 'event.dart';
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
7
|
import 'game_entity.dart';
|
a4c3106a
吴启风
feat:游戏列表页
|
8
9
10
11
12
13
|
import 'state.dart';
class GamesBloc extends Bloc<GamesEvent, GamesState> {
late MethodChannel _methodChannel;
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
//手动初始化4个GameEntity对象
final List<GameEntity> _games = [
GameEntity()
..id = 1
..imageName = 'pic_module_game'.assetPng
..name = '游戏1',
GameEntity()
..id = 2
..imageName = 'pic_module_game'.assetPng
..name = '游戏2',
GameEntity()
..id = 3
..imageName = 'pic_module_game'.assetPng
..name = '游戏3',
GameEntity()
..id = 4
..imageName = 'pic_module_game'.assetPng
..name = '游戏4'
];
List<GameEntity> get listData => _games;
|
a4c3106a
吴启风
feat:游戏列表页
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
GamesBloc() : super(GamesState().init()) {
on<InitEvent>(_init);
on<GotoGamePageEvent>(_gotoGamePage);
}
void _init(InitEvent event, Emitter<GamesState> emit) async {
emit(state.clone());
}
void _gotoGamePage(GotoGamePageEvent event, Emitter<GamesState> emit) async {
try {
_methodChannel = const MethodChannel('wow_english/game_method_channel');
await _methodChannel.invokeMethod('openGamePage', { "gameId": event.gameId });
} on PlatformException catch (e) {
debugPrint("Failed to go to native page: '${e.message}'.");
}
}
}
|