Skip to content

Commit 3d3b1ce

Browse files
committed
+chore: Minor performance updates
1 parent 31df343 commit 3d3b1ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1024
-1637
lines changed

example/example.dart

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
import 'package:flutter/material.dart';
21
import 'package:df_router/df_router.dart';
32

3+
import 'package:flutter/material.dart';
4+
import 'package:flutter/foundation.dart' show kDebugMode;
5+
import 'package:flutter/rendering.dart' show debugRepaintRainbowEnabled;
6+
47
void main() {
8+
debugRepaintRainbowEnabled = kDebugMode;
59
runApp(const MyApp());
610
}
711

@@ -32,8 +36,7 @@ final class BaseChatRouteState extends RouteState {
3236
final class ChatRouteState extends BaseChatRouteState {
3337
final String chatId;
3438

35-
ChatRouteState({required this.chatId})
36-
: super(queryParameters: {'chatId': chatId});
39+
ChatRouteState({required this.chatId}) : super(queryParameters: {'chatId': chatId});
3740

3841
ChatRouteState.from(super.other)
3942
: chatId = other.uri.queryParameters['chatId'] ?? '',
@@ -59,15 +62,14 @@ class MyApp extends StatelessWidget {
5962
shouldPrebuild: true,
6063
// Preserve the HomeScreen widget to avoid rebuilding it.
6164
shouldPreserve: true,
62-
builder: (context, routeState) =>
63-
HomeScreen(routeState: HomeRouteState()),
65+
builder: (context, routeState) => HomeScreen(routeState: HomeRouteState()),
6466
),
6567
RouteBuilder(
6668
// Use the BaseChatRouteState instead of the ChatRouteState
6769
// since it does not require a chatId to be pushed.
6870
routeState: BaseChatRouteState(),
69-
builder: (context, routeState) =>
70-
ChatScreen(routeState: ChatRouteState.from(routeState)),
71+
builder:
72+
(context, routeState) => ChatScreen(routeState: ChatRouteState.from(routeState)),
7173
),
7274
],
7375
);
@@ -83,6 +85,7 @@ class HomeScreen extends StatelessWidget with RouteWidgetMixin {
8385

8486
@override
8587
Widget build(BuildContext context) {
88+
debugPrint('Building HomeScreen with routeState: $routeState');
8689
return Scaffold(
8790
appBar: AppBar(title: const Text('Home')),
8891
backgroundColor: Colors.green,
@@ -111,6 +114,7 @@ class ChatScreen extends StatelessWidget with RouteWidgetMixin {
111114

112115
@override
113116
Widget build(BuildContext context) {
117+
debugPrint('Building ChatScreen with routeState: $routeState');
114118
return Scaffold(
115119
appBar: AppBar(title: Text('Chat - ${routeState?.chatId}')),
116120
backgroundColor: Colors.blue,
@@ -128,7 +132,7 @@ class ChatScreen extends StatelessWidget with RouteWidgetMixin {
128132
ElevatedButton(
129133
onPressed: () {
130134
final controller = RouteController.of(context);
131-
controller.pushBack(animationEffect: const QuickBackEffect());
135+
controller.pushBack(animationEffect: const QuickBackwardEffect());
132136
},
133137
child: const Text('Go Back - Quick Back Effect'),
134138
),
@@ -142,21 +146,14 @@ class ChatScreen extends StatelessWidget with RouteWidgetMixin {
142146
ElevatedButton(
143147
onPressed: () {
144148
final controller = RouteController.of(context);
145-
controller.push(
146-
HomeRouteState().copyWith(
147-
animationEffect: const MaterialEffect(),
148-
),
149-
);
149+
controller.push(HomeRouteState().copyWith(animationEffect: const MaterialEffect()));
150150
},
151151
child: const Text('Go Home - Material Effect'),
152152
),
153153
ElevatedButton(
154154
onPressed: () {
155155
final controller = RouteController.of(context);
156-
controller.push(
157-
HomeRouteState(),
158-
animationEffect: const PageFlapDown(),
159-
);
156+
controller.push(HomeRouteState(), animationEffect: const PageFlapDown());
160157
},
161158
child: const Text('Go Home - Page Flap Down Effect'),
162159
),

example/example_2.dart

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
import 'package:flutter/material.dart';
21
import 'package:df_router/df_router.dart';
32

3+
import 'package:flutter/material.dart';
4+
import 'package:flutter/foundation.dart' show kDebugMode;
5+
import 'package:flutter/rendering.dart' show debugRepaintRainbowEnabled;
6+
47
void main() {
5-
//debugRepaintRainbowEnabled = true;
8+
debugRepaintRainbowEnabled = kDebugMode;
69
runApp(const MyApp());
710
}
811

912
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
1013

1114
final class HomeRouteState extends RouteState {
12-
HomeRouteState()
13-
: super.parse('/home', animationEffect: const CupertinoEffect());
15+
HomeRouteState() : super.parse('/home', animationEffect: const CupertinoEffect());
1416
}
1517

1618
final class MessagesRouteState extends RouteState {
17-
MessagesRouteState()
18-
: super.parse('/messages', animationEffect: const CupertinoEffect());
19+
MessagesRouteState() : super.parse('/messages', animationEffect: const CupertinoEffect());
1920
}
2021

2122
final class ChatRouteState extends RouteState<String> {
22-
ChatRouteState()
23-
: super.parse('/chat', animationEffect: const CupertinoEffect());
23+
ChatRouteState() : super.parse('/chat', animationEffect: const CupertinoEffect());
2424
}
2525

2626
final class MessagesRouteState1 extends RouteState {
@@ -42,8 +42,7 @@ final class MessagesRouteState2 extends RouteState {
4242
}
4343

4444
final class HomeDetailRouteState extends RouteState {
45-
HomeDetailRouteState()
46-
: super.parse('/home_detail', animationEffect: const CupertinoEffect());
45+
HomeDetailRouteState() : super.parse('/home_detail', animationEffect: const CupertinoEffect());
4746
}
4847

4948
class MyApp extends StatelessWidget {
@@ -212,11 +211,10 @@ class _MessagesScreenState extends State<MessagesScreen> {
212211
),
213212

214213
FilledButton(
215-
onPressed: () => controller.push(
216-
MessagesRouteState2().copyWith(
217-
extra: 'HELLO THERE HOW ARE YOU?',
218-
),
219-
),
214+
onPressed:
215+
() => controller.push(
216+
MessagesRouteState2().copyWith(extra: 'HELLO THERE HOW ARE YOU?'),
217+
),
220218
child: const Text('Go to Messages (key2=value2)'),
221219
),
222220
],
@@ -262,9 +260,8 @@ class HomeScreen extends StatelessWidget with RouteWidgetMixin {
262260
child: const Text('Go to Home Detail'),
263261
),
264262
FilledButton(
265-
onPressed: () => controller.push(
266-
ChatRouteState().copyWith(extra: 'Hello from Home!'),
267-
),
263+
onPressed:
264+
() => controller.push(ChatRouteState().copyWith(extra: 'Hello from Home!')),
268265
child: const Text('Go to Chat'),
269266
),
270267
],
@@ -315,18 +312,18 @@ class _ChatScreenState extends State<ChatScreen> {
315312
child: const Text('Go to Home'),
316313
),
317314
FilledButton(
318-
onPressed: () => controller.push(
319-
ChatRouteState().copyWith(extra: 'Hello from Chat!'),
320-
),
315+
onPressed:
316+
() => controller.push(ChatRouteState().copyWith(extra: 'Hello from Chat!')),
321317
child: const Text('Go to Chat (No ID)'),
322318
),
323319
FilledButton(
324-
onPressed: () => controller.push(
325-
ChatRouteState().copyWith(
326-
queryParameters: {'dude': '22'},
327-
extra: 'Hello from Chat!',
328-
),
329-
),
320+
onPressed:
321+
() => controller.push(
322+
ChatRouteState().copyWith(
323+
queryParameters: {'dude': '22'},
324+
extra: 'Hello from Chat!',
325+
),
326+
),
330327
child: const Text('Go to Chat (ID=123)'),
331328
),
332329
],

ios/.gitignore

Lines changed: 0 additions & 34 deletions
This file was deleted.

ios/Flutter/AppFrameworkInfo.plist

Lines changed: 0 additions & 26 deletions
This file was deleted.

ios/Flutter/Debug.xcconfig

Lines changed: 0 additions & 2 deletions
This file was deleted.

ios/Flutter/Release.xcconfig

Lines changed: 0 additions & 2 deletions
This file was deleted.

ios/Podfile

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)