Skip to content

Commit

Permalink
style: remove paremeter final
Browse files Browse the repository at this point in the history
  • Loading branch information
foxsofter committed Sep 16, 2023
1 parent d67f077 commit 0589425
Show file tree
Hide file tree
Showing 112 changed files with 943 additions and 1,037 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 4.6.2
- faet: call onJsonableRegister
- style: remove paremeter final

## 4.6.1
- faet: add registerJsonable
Expand Down
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ linter:
prefer_final_fields: true # 推荐使用 final 定义私有变量
prefer_final_in_for_each: true # 再 for-each 中,如果未重新定义,推荐使用 final
prefer_final_locals: true # 对于局部变量,如果未重新定义,推荐使用 final
prefer_final_parameters: true # Prefer final for parameter declarations if they are not reassigned.
prefer_final_parameters: false # Prefer final for parameter declarations if they are not reassigned.
prefer_for_elements_to_map_fromIterable: true
prefer_foreach: true # 给所有元素应用某个方法,推荐使用 foreach
prefer_function_declarations_over_variables: true # 使用函数声明为函数添加名称
Expand Down
6 changes: 3 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ import 'src/app.dart' as app;

Future<void> main() async {
ThrioLogger.v('main');
runZonedGuarded(app.main, (final error, final stack) {
runZonedGuarded(app.main, (error, stack) {
Zone.current.handleUncaughtError(error, stack);
});
}

@pragma('vm:entry-point')
Future<void> biz1() async {
runZonedGuarded(app.biz1, (final error, final stack) {
runZonedGuarded(app.biz1, (error, stack) {
Zone.current.handleUncaughtError(error, stack);
});
}

@pragma('vm:entry-point')
Future<void> biz2() async {
runZonedGuarded(app.biz2, (final error, final stack) {
runZonedGuarded(app.biz2, (error, stack) {
Zone.current.handleUncaughtError(error, stack);
});
}
8 changes: 4 additions & 4 deletions example/lib/src/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void biz1() => runApp(const MainApp(entrypoint: 'biz1'));
void biz2() => runApp(const MainApp(entrypoint: 'biz2'));

class MainApp extends StatefulWidget {
const MainApp({super.key, final String entrypoint = 'main'})
const MainApp({super.key, String entrypoint = 'main'})
: _entrypoint = entrypoint;

final String _entrypoint;
Expand All @@ -22,15 +22,15 @@ class _MainAppState extends State<MainApp> {
void initState() {
super.initState();
ThrioModule.init(Module(), entrypoint: widget._entrypoint,
onModuleInitStart: (final url) {
onModuleInitStart: (url) {
ThrioLogger.i('module start init: $url');
});
}

@override
Widget build(final BuildContext context) => NavigatorMaterialApp(
Widget build(BuildContext context) => NavigatorMaterialApp(
transitionPage: const NavigatorHome(showRestartButton: true),
builder: (final context, final child) => Container(
builder: (context, child) => Container(
child: child,
),
theme: ThemeData(
Expand Down
2 changes: 1 addition & 1 deletion example/lib/src/biz/biz1/biz1.context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extension Biz1Context on ModuleContext {
int get intValue =>
get<int>('intValue') ?? (throw ArgumentError('intValue not exists'));

bool setIntValue(final int value) => set<int>('intValue', value);
bool setIntValue(int value) => set<int>('intValue', value);

/// remove an int value.remove an int value.remove an int value.
///
Expand Down
2 changes: 1 addition & 1 deletion example/lib/src/biz/biz1/biz1.route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'flutter7/flutter7.route.dart';
import 'flutter9/flutter9.route.dart';

class Biz1Route extends NavigatorRouteNode {
factory Biz1Route(final NavigatorRouteNode parent) =>
factory Biz1Route(NavigatorRouteNode parent) =>
_instance ??= Biz1Route._(parent);

Biz1Route._(super.parent);
Expand Down
8 changes: 4 additions & 4 deletions example/lib/src/biz/biz1/flutter1/flutter1.route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:flutter_thrio/flutter_thrio.dart';
import 'home/home.route.dart';

class Flutter1Route extends NavigatorRouteNode {
factory Flutter1Route(final NavigatorRouteNode parent) =>
factory Flutter1Route(NavigatorRouteNode parent) =>
_instance ??= Flutter1Route._(parent);

Flutter1Route._(super.parent);
Expand All @@ -23,15 +23,15 @@ class Flutter1Route extends NavigatorRouteNode {

/// 通知 flutter1
///
Future<bool> flutter1({required final int intValue}) => ThrioNavigator.notify(
Future<bool> flutter1({required int intValue}) => ThrioNavigator.notify(
url: url,
name: 'flutter1',
params: intValue,
);

/// get people
///
Future<People?> getPeople({final int? intValue}) =>
Future<People?> getPeople({int? intValue}) =>
ThrioNavigator.act<Map<String, dynamic>, People>(
url: url,
action: 'getPeople{intValue?}',
Expand All @@ -42,7 +42,7 @@ class Flutter1Route extends NavigatorRouteNode {

/// get string
///
Future<String?> getString({required final bool boolValue}) =>
Future<String?> getString({required bool boolValue}) =>
ThrioNavigator.act<Map<String, dynamic>, String>(
url: url,
action: 'getString{boolValue}',
Expand Down
15 changes: 6 additions & 9 deletions example/lib/src/biz/biz1/flutter1/home/home.context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ extension HomeContext on ModuleContext {

String get stringKeyBiz1OrDefault => get<String>('stringKeyBiz1') ?? 'weewr';

bool setStringKeyBiz1(final String value) =>
set<String>('stringKeyBiz1', value);
bool setStringKeyBiz1(String value) => set<String>('stringKeyBiz1', value);

String? removeStringKeyBiz1() => remove<String>('stringKeyBiz1');

Expand All @@ -35,8 +34,7 @@ extension HomeContext on ModuleContext {
get<int>('intKeyRootModule') ??
(throw ArgumentError('intKeyRootModule not exists'));

bool setIntKeyRootModule(final int value) =>
set<int>('intKeyRootModule', value);
bool setIntKeyRootModule(int value) => set<int>('intKeyRootModule', value);

Stream<int> get onIntKeyRootModule =>
on<int>('intKeyRootModule') ??
Expand All @@ -46,8 +44,7 @@ extension HomeContext on ModuleContext {
onWithNull<int>('intKeyRootModule') ??
(throw ArgumentError('intKeyRootModule stream not exists'));

Stream<int> onIntKeyRootModuleWithInitial(
{required final int initialValue}) =>
Stream<int> onIntKeyRootModuleWithInitial({required int initialValue}) =>
on<int>('intKeyRootModule', initialValue: initialValue) ??
(throw ArgumentError('intKeyRootModule stream not exists'));

Expand All @@ -56,10 +53,10 @@ extension HomeContext on ModuleContext {

People? get peopleOrNull => get<People>('people');

People getPeopleOrDefault({required final People defaultValue}) =>
People getPeopleOrDefault({required People defaultValue}) =>
get<People>('people') ?? defaultValue;

bool setPeople(final People value) => set<People>('people', value);
bool setPeople(People value) => set<People>('people', value);

People? removePeople() => remove<People>('people');

Expand All @@ -70,7 +67,7 @@ extension HomeContext on ModuleContext {
onWithNull<People>('people') ??
(throw ArgumentError('people stream not exists'));

Stream<People> onPeopleWithInitial({required final People initialValue}) =>
Stream<People> onPeopleWithInitial({required People initialValue}) =>
on<People>('people', initialValue: initialValue) ??
(throw ArgumentError('people stream not exists'));
}
16 changes: 8 additions & 8 deletions example/lib/src/biz/biz1/flutter1/home/home.page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class _HomePageState extends State<HomePage>
super.initState();
if (mounted) {
WidgetsBinding.instance.addObserver(this);
widget.moduleContext.onStringKeyBiz1.listen((final i) {
widget.moduleContext.onStringKeyBiz1.listen((i) {
ThrioLogger.v('onIntKeyRootModule value is $i');
});
}
Expand All @@ -65,20 +65,20 @@ class _HomePageState extends State<HomePage>
bool get wantKeepAlive => true;

@override
void didAppear(final RouteSettings routeSettings) {
void didAppear(RouteSettings routeSettings) {
super.didAppear(routeSettings);
}

@override
void didDisappear(final RouteSettings routeSettings) {
void didDisappear(RouteSettings routeSettings) {
super.didDisappear(routeSettings);
}

@override
Widget build(final BuildContext context) {
Widget build(BuildContext context) {
super.build(context);
return NavigatorRoutePush(
onPush: (final settings, {final animated = true}) async {
onPush: (settings, {animated = true}) async {
// root.biz1.flutter1.home.replace(newUrl: root.biz2.flutter2.url);
if (settings.url == biz.biz2.flutter2.url) {
ThrioLogger.d('page2 onPush');
Expand All @@ -87,10 +87,10 @@ class _HomePageState extends State<HomePage>
},
child: NavigatorPageNotify(
name: 'all_page_notify',
onPageNotify: (final params) =>
onPageNotify: (params) =>
ThrioLogger.v('flutter1 receive all page notify:$params'),
child: Flutter1Notify(
onNotify: ({final intValue = 0}) =>
onNotify: ({intValue = 0}) =>
ThrioLogger.v('flutter1 receive notify:$intValue'),
child: Scaffold(
appBar: PreferredSize(
Expand Down Expand Up @@ -220,7 +220,7 @@ class _HomePageState extends State<HomePage>
'${biz.biz2.flutter2.url}?fewfew=2131&fwe=1&&',
params: People(name: '大宝剑', age: 0, sex: 'x'),
animated: false,
result: (final index) {
result: (index) {
ThrioLogger.v('test_async_queue: push $index');
},
);
Expand Down
18 changes: 9 additions & 9 deletions example/lib/src/biz/biz1/flutter1/home/home.route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import 'package:flutter_thrio/flutter_thrio.dart';

class HomeRoute extends NavigatorRouteLeaf {
factory HomeRoute(final NavigatorRouteNode parent) =>
factory HomeRoute(NavigatorRouteNode parent) =>
_instance ??= HomeRoute._(parent);

HomeRoute._(super.parent);
Expand All @@ -23,10 +23,10 @@ class HomeRoute extends NavigatorRouteLeaf {
/// 测试 集合 传参
///
Future<TPopParams?> push<TPopParams>({
final List<String> strList = const <String>[],
final Map<String, dynamic> goodMap = const <String, dynamic>{},
final bool animated = true,
final NavigatorIntCallback? result,
List<String> strList = const <String>[],
Map<String, dynamic> goodMap = const <String, dynamic>{},
bool animated = true,
NavigatorIntCallback? result,
}) =>
ThrioNavigator.push<Map<String, dynamic>, TPopParams>(
url: url,
Expand All @@ -45,10 +45,10 @@ class HomeRoute extends NavigatorRouteLeaf {
/// 测试 集合 传参
///
Future<TPopParams?> pushSingle<TPopParams>({
final List<String> strList = const <String>[],
final Map<String, dynamic> goodMap = const <String, dynamic>{},
final bool animated = true,
final NavigatorIntCallback? result,
List<String> strList = const <String>[],
Map<String, dynamic> goodMap = const <String, dynamic>{},
bool animated = true,
NavigatorIntCallback? result,
}) =>
ThrioNavigator.pushSingle<Map<String, dynamic>, TPopParams>(
url: url,
Expand Down
6 changes: 3 additions & 3 deletions example/lib/src/biz/biz1/flutter1/home/module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ class Module with ThrioModule, ModuleParamScheme, ModulePageBuilder {
String get key => 'home';

@override
void onPageBuilderSetting(final ModuleContext moduleContext) =>
pageBuilder = (final settings) => HomePage(
void onPageBuilderSetting(ModuleContext moduleContext) =>
pageBuilder = (settings) => HomePage(
moduleContext: moduleContext,
settings: settings,
);

@override
void onParamSchemeRegister(final ModuleContext moduleContext) {
void onParamSchemeRegister(ModuleContext moduleContext) {
registerParamScheme('stringKeyBiz1');
}
}
20 changes: 10 additions & 10 deletions example/lib/src/biz/biz1/flutter1/module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import 'home/module.dart' as home;

class Module with ThrioModule, ModuleRouteAction {
@override
void onRouteActionRegister(final ModuleContext moduleContext) {
void onRouteActionRegister(ModuleContext moduleContext) {
registerRouteAction('getPeople{intValue?}', <TParams, TResult>(
final url,
final action,
final queryParams, {
final params,
url,
action,
queryParams, {
params,
}) {
final result = onGetPeople(
moduleContext,
Expand All @@ -33,10 +33,10 @@ class Module with ThrioModule, ModuleRouteAction {
});

registerRouteAction('getString{boolValue}', <TParams, TResult>(
final url,
final action,
final queryParams, {
final params,
url,
action,
queryParams, {
params,
}) {
final result = onGetString(
moduleContext,
Expand All @@ -58,7 +58,7 @@ class Module with ThrioModule, ModuleRouteAction {
String get key => 'flutter1';

@override
void onModuleRegister(final ModuleContext moduleContext) {
void onModuleRegister(ModuleContext moduleContext) {
registerModule(home.Module(), moduleContext);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ typedef Flutter1NotifyCallback = void Function({int intValue});
class Flutter1Notify extends NavigatorPageNotify {
Flutter1Notify({
super.key,
required final Flutter1NotifyCallback onNotify,
final int? intValue,
required Flutter1NotifyCallback onNotify,
int? intValue,
required super.child,
}) : super(
name: 'flutter1',
onPageNotify: (final params) =>
onPageNotify: (params) =>
onNotify(intValue: params['intValue'] as int),
initialParams: intValue == null ? null : {'intValue': intValue});
}
12 changes: 6 additions & 6 deletions example/lib/src/biz/biz1/flutter11/flutter11.page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Flutter11Page extends NavigatorStatefulPage {

class _Flutter11PageState extends State<Flutter11Page> {
@override
Widget build(final BuildContext context) => Scaffold(
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
title: const Text('thrio_deeplink_example',
Expand All @@ -51,10 +51,10 @@ class PermissionHandlerWidget extends StatefulWidget {

class _PermissionHandlerWidgetState extends State<PermissionHandlerWidget> {
@override
Widget build(final BuildContext context) => Center(
Widget build(BuildContext context) => Center(
child: ListView(
children: Permission.values
.where((final permission) {
.where((permission) {
if (Platform.isIOS) {
return permission != Permission.unknown &&
permission != Permission.phone &&
Expand Down Expand Up @@ -132,7 +132,7 @@ class _PermissionState extends State<PermissionWidget> {
}

@override
Widget build(final BuildContext context) => ListTile(
Widget build(BuildContext context) => ListTile(
title: Text(
_permission.toString(),
style: Theme.of(context).textTheme.bodyLarge,
Expand All @@ -158,13 +158,13 @@ class _PermissionState extends State<PermissionWidget> {
);

Future<void> checkServiceStatus(
final BuildContext context, final PermissionWithService permission) async {
BuildContext context, PermissionWithService permission) async {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text((await permission.serviceStatus).toString()),
));
}

Future<void> requestPermission(final Permission permission) async {
Future<void> requestPermission(Permission permission) async {
final status = await permission.request();

setState(() {
Expand Down
Loading

0 comments on commit 0589425

Please sign in to comment.