Skip to content

Commit 6ef4b4c

Browse files
committed
v3.3.0
- use new version of widget_with_codeview - migrate to dart 2.17 - add `TypographyExample` - add option to change code theme for `CodeHighlightExample` - fix PieChartExample crashing - other improvements and fixups
1 parent b616896 commit 6ef4b4c

File tree

117 files changed

+285
-193
lines changed

Some content is hidden

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

117 files changed

+285
-193
lines changed

Diff for: CHANGELOG.md

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
# Change Log
22

3-
## v3.2.0
4-
[2022-10-21]
3+
## v3.3.0
4+
[2022-10-23]
5+
- better source code syntax highlighting with [widget_with_codeview v3.0.1](https://pub.dev/packages/widget_with_codeview)
6+
- migrate to dart 2.17
7+
- add `TypographyExample`
8+
- add option to change code theme for `CodeHighlightExample`
9+
- other improvements and fixups
510

11+
## v3.2.0
12+
[2022-10-21]
613
- add monetization examples
714
- banner ads
815
- interstitial ads
916
- rewarded ads
10-
- add FlutterFireLoginUI example
11-
- add selectable example
17+
- add `FlutterFireLoginUiExample`
18+
- add `SelectableExample`
1219
- add crashlytics and analytics event logging
1320
- upgrade packages & fix firestore error

Diff for: analysis_options.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ linter:
1616
# `this` makes it easier for readers to understand which variables class
1717
# members and which ones are not.
1818
unnecessary_this: false
19-
use_colored_box: false
20-
use_decorated_box: false
21-
no_leading_underscores_for_local_identifiers: false
2219
# Same as above, allow writing local variable types to improve readability
2320
# without IDE.
24-
omit_local_variable_types: false
2521
# We sometimes have print statements just for demo purposes.
2622
avoid_print: false
23+
omit_local_variable_types: false
24+
use_colored_box: false
25+
use_decorated_box: false
26+
no_leading_underscores_for_local_identifiers: false
2727
use_string_buffers: false
2828
avoid_redundant_argument_values: false
2929
prefer_const_constructors: false

Diff for: lib/constants.dart

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import 'dart:io' show Platform;
22

3+
import 'package:firebase_analytics/firebase_analytics.dart';
34
import 'package:flutter/foundation.dart';
45
import 'package:flutter/material.dart';
6+
import 'package:package_info_plus/package_info_plus.dart';
57

68
// ignore_for_file: constant_identifier_names
79

8-
// *Note*: when APP_VERSION is changed, remember to also update pubspec.yaml.
9-
const APP_VERSION = 'v3.2.0';
10+
late final PackageInfo kPackageInfo;
1011
const APP_NAME = 'Flutter Catalog';
1112
final kAppIcon =
1213
Image.asset('res/images/app_icon.png', height: 64.0, width: 64.0);
@@ -25,6 +26,12 @@ final kPlatformType = getCurrentPlatformType();
2526
final kIsOnMobile =
2627
{PlatformType.Android, PlatformType.iOS}.contains(kPlatformType);
2728

29+
final kIsMobileOrWeb = kIsWeb ||
30+
defaultTargetPlatform == TargetPlatform.iOS ||
31+
defaultTargetPlatform == TargetPlatform.android;
32+
33+
final kAnalytics = kIsMobileOrWeb ? FirebaseAnalytics.instance : null;
34+
2835
/// ! Adapted from https://www.flutterclutter.dev/flutter/tutorials/how-to-detect-what-platform-a-flutter-app-is-running-on/2020/127/
2936
enum PlatformType { Web, iOS, Android, MacOS, Fuchsia, Linux, Windows, Unknown }
3037

Diff for: lib/home_page.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'package:badges/badges.dart';
2-
import 'package:firebase_analytics/firebase_analytics.dart';
32
import 'package:flutter/material.dart';
3+
import 'constants.dart';
44
import 'my_app_routes.dart';
55
import 'package:provider/provider.dart';
66

@@ -10,7 +10,7 @@ import './my_app_settings.dart';
1010
import './my_route.dart';
1111

1212
class MyHomePage extends StatefulWidget {
13-
const MyHomePage({Key? key}) : super(key: key);
13+
const MyHomePage({super.key});
1414

1515
@override
1616
_MyHomePageState createState() => _MyHomePageState();
@@ -111,7 +111,7 @@ class _MyHomePageState extends State<MyHomePage> {
111111
if (isNew) {
112112
mySettings.markRouteKnown(myRoute);
113113
}
114-
FirebaseAnalytics.instance.logEvent(
114+
kAnalytics?.logEvent(
115115
name: 'evt_openRoute',
116116
parameters: {'routeName': myRoute.routeName},
117117
);

Diff for: lib/main.dart

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import 'package:firebase_core/firebase_core.dart';
22
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
3-
import 'package:flutter/foundation.dart';
43
import 'package:flutter/material.dart';
54
import 'package:flutter_riverpod/flutter_riverpod.dart';
65
import 'package:google_mobile_ads/google_mobile_ads.dart';
6+
import 'package:package_info_plus/package_info_plus.dart';
77

88
import './constants.dart';
99
import './firebase_options.dart';
@@ -12,13 +12,14 @@ import './my_main_app.dart';
1212

1313
Future<void> main() async {
1414
WidgetsFlutterBinding.ensureInitialized();
15-
if (kIsOnMobile || kIsWeb) {
15+
if (kIsMobileOrWeb) {
1616
await Firebase.initializeApp(
1717
options: DefaultFirebaseOptions.currentPlatform);
1818
// Pass all uncaught errors from the framework to Crashlytics.
1919
FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError;
2020
await MobileAds.instance.initialize();
2121
}
22+
kPackageInfo = await PackageInfo.fromPlatform();
2223
final settings = await MyAppSettings.create();
2324
runApp(
2425
ProviderScope(

Diff for: lib/my_app_routes.dart

+8-1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ import 'routes/widgets_stateful_widgets_ex.dart';
111111
import 'routes/widgets_text_ex.dart';
112112
import 'routes/widgets_textfield_ex.dart';
113113
import 'routes/widgets_textformfield_ex.dart';
114+
import 'routes/widgets_typography_ex.dart';
114115

115116
const kHomeRoute = MyRoute(
116117
sourceFilePath: 'lib/routes/home.dart',
@@ -165,6 +166,12 @@ const kMyAppRoutesBasic = <MyRouteGroup>[
165166
sourceFilePath: 'lib/routes/widgets_text_ex.dart',
166167
title: 'Text',
167168
),
169+
MyRoute(
170+
child: TypographyExample(),
171+
sourceFilePath: 'lib/routes/widgets_typography_ex.dart',
172+
title: 'Typography',
173+
description: 'Peek all built-in text styles.',
174+
),
168175
MyRoute(
169176
child: TextFieldExample(),
170177
sourceFilePath: 'lib/routes/widgets_textfield_ex.dart',
@@ -1139,7 +1146,7 @@ const kMyAppRoutesAdvanced = <MyRouteGroup>[
11391146
routes: <MyRoute>[
11401147
MyRoute(
11411148
child: BottomBannerAdExample(),
1142-
sourceFilePath: 'lib/routes/monetization_banner_ad_ex.dart',
1149+
sourceFilePath: 'lib/routes/monetization_bottom_banner_ad_ex.dart',
11431150
title: 'Bottom banner ads',
11441151
description: 'Display an ad at screen bottom',
11451152
links: {

Diff for: lib/my_app_settings.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import 'package:firebase_analytics/firebase_analytics.dart';
21
import 'package:flutter/material.dart';
32
import 'package:path_provider/path_provider.dart';
43
import 'package:shared_preferences/shared_preferences.dart';
54

65
import './my_app_routes.dart' show MyRouteGroup, kAboutRoute, kAllRoutes;
76
import './my_route.dart';
7+
import 'constants.dart';
88

99
class MyAppSettings extends ChangeNotifier {
1010
static const _kDarkModePreferenceKey = 'DARK_MODE';
@@ -82,7 +82,7 @@ class MyAppSettings extends ChangeNotifier {
8282
),
8383
onPressed: () {
8484
this.toggleStarred(routeName);
85-
FirebaseAnalytics.instance.logEvent(
85+
kAnalytics?.logEvent(
8686
name:
8787
'evt_${this.isStarred(routeName) ? 'starRoute' : 'unstarRoute'}',
8888
parameters: {'routeName': routeName},

Diff for: lib/my_main_app.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import './themes.dart';
77

88
class MyMainApp extends StatelessWidget {
99
final MyAppSettings settings;
10-
const MyMainApp(this.settings, {Key? key}) : super(key: key);
10+
const MyMainApp(this.settings, {super.key});
1111

1212
@override
1313
Widget build(BuildContext context) {
@@ -19,7 +19,7 @@ class MyMainApp extends StatelessWidget {
1919
}
2020

2121
class _MyMaterialApp extends StatelessWidget {
22-
const _MyMaterialApp({Key? key}) : super(key: key);
22+
const _MyMaterialApp();
2323

2424
@override
2525
Widget build(BuildContext context) {

Diff for: lib/my_route.dart

+13-6
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import 'package:widget_with_codeview/widget_with_codeview.dart';
99
import './constants.dart'
1010
show
1111
APP_NAME,
12-
APP_VERSION,
1312
GITHUB_URL,
1413
PlatformType,
14+
kAnalytics,
1515
kAppIcon,
16+
kPackageInfo,
1617
kPlatformType;
1718
import './my_app_settings.dart';
1819
import './my_route_search_delegate.dart';
@@ -38,7 +39,7 @@ class MyRoute extends StatelessWidget {
3839
final Iterable<PlatformType> supportedPlatforms;
3940

4041
const MyRoute({
41-
Key? key,
42+
super.key,
4243
required this.sourceFilePath,
4344
required this.child,
4445
String? title,
@@ -47,8 +48,7 @@ class MyRoute extends StatelessWidget {
4748
String? routeName,
4849
this.supportedPlatforms = PlatformType.values,
4950
}) : _title = title,
50-
_routeName = routeName,
51-
super(key: key);
51+
_routeName = routeName;
5252

5353
String get routeName =>
5454
this._routeName ?? '/${basenameWithoutExtension(sourceFilePath)}';
@@ -83,8 +83,14 @@ class MyRoute extends StatelessWidget {
8383
routeName == Navigator.defaultRouteName
8484
? this.child
8585
: WidgetWithCodeView(
86-
sourceFilePath: this.sourceFilePath,
86+
filePath: this.sourceFilePath,
8787
codeLinkPrefix: '$GITHUB_URL/blob/master',
88+
tabChangeListener: (TabController tabc) {
89+
if (!tabc.indexIsChanging) return;
90+
if (tabc.index == 1) {
91+
debugPrint('Changing to code view!');
92+
}
93+
},
8894
child: this.child,
8995
),
9096
),
@@ -100,6 +106,7 @@ class MyRoute extends StatelessWidget {
100106
IconButton(
101107
icon: const Icon(Icons.search),
102108
onPressed: () async {
109+
kAnalytics?.logEvent(name: 'evt_Search');
103110
await showSearch<String>(
104111
context: context,
105112
delegate: MyRouteSearchDelegate(),
@@ -139,7 +146,7 @@ class MyRoute extends StatelessWidget {
139146
ListTile(
140147
leading: kAppIcon,
141148
title: const Text(APP_NAME),
142-
subtitle: const Text(APP_VERSION),
149+
subtitle: Text(kPackageInfo.version),
143150
),
144151
...MyAboutRoute.kAboutListTiles,
145152
Consumer<MyAppSettings>(

Diff for: lib/routes/about.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import '../constants.dart';
66
// Inspired by the about page in Eajy's flutter demo:
77
// https://github.com/Eajy/flutter_demo/blob/master/lib/route/about.dart
88
class MyAboutRoute extends StatelessWidget {
9-
const MyAboutRoute({Key? key}) : super(key: key);
9+
const MyAboutRoute({super.key});
1010

1111
// These tiles are also used as drawer nav items in home route.
1212
static final List<Widget> kAboutListTiles = <Widget>[
@@ -46,14 +46,14 @@ class MyAboutRoute extends StatelessWidget {
4646
final header = ListTile(
4747
leading: kAppIcon,
4848
title: const Text(APP_NAME),
49-
subtitle: const Text(APP_VERSION),
49+
subtitle: Text(kPackageInfo.version),
5050
trailing: IconButton(
5151
icon: const Icon(Icons.info),
5252
onPressed: () {
5353
showAboutDialog(
5454
context: context,
5555
applicationName: APP_NAME,
56-
applicationVersion: APP_VERSION,
56+
applicationVersion: kPackageInfo.version,
5757
applicationIcon: kAppIcon,
5858
children: <Widget>[const Text(APP_DESCRIPTION)],
5959
);

Diff for: lib/routes/animation_animated_builder_ex.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'dart:math';
22
import 'package:flutter/material.dart';
33

44
class AnimatedBuilderExample extends StatefulWidget {
5-
const AnimatedBuilderExample({Key? key}) : super(key: key);
5+
const AnimatedBuilderExample({super.key});
66

77
@override
88
_AnimatedBuilderExampleState createState() => _AnimatedBuilderExampleState();

Diff for: lib/routes/animation_animated_container_ex.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'dart:math';
22
import 'package:flutter/material.dart';
33

44
class AnimatedContainerExample extends StatefulWidget {
5-
const AnimatedContainerExample({Key? key}) : super(key: key);
5+
const AnimatedContainerExample({super.key});
66

77
@override
88
_AnimatedContainerExampleState createState() =>

Diff for: lib/routes/animation_animated_icons_ex.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const _kAllANimatedIcons = <String, AnimatedIconData>{
1818
};
1919

2020
class AnimatedIconsExample extends StatelessWidget {
21-
const AnimatedIconsExample({Key? key}) : super(key: key);
21+
const AnimatedIconsExample({super.key});
2222

2323
@override
2424
Widget build(BuildContext context) {
@@ -47,8 +47,7 @@ class _AnimIconDemoBox extends StatefulWidget {
4747
final AnimatedIconData iconData;
4848
final String name;
4949

50-
const _AnimIconDemoBox({Key? key, required this.iconData, required this.name})
51-
: super(key: key);
50+
const _AnimIconDemoBox({required this.iconData, required this.name});
5251

5352
@override
5453
_AnimIconDemoBoxState createState() => _AnimIconDemoBoxState();

Diff for: lib/routes/animation_animated_radial_menu_ex.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'package:animated_radial_menu/animated_radial_menu.dart';
22
import 'package:flutter/material.dart';
33

44
class RadialMenuExample extends StatelessWidget {
5-
const RadialMenuExample({Key? key}) : super(key: key);
5+
const RadialMenuExample({super.key});
66

77
@override
88
Widget build(BuildContext context) {
@@ -62,7 +62,7 @@ class RadialMenuExample extends StatelessWidget {
6262
}
6363

6464
class TargetScreen extends StatelessWidget {
65-
const TargetScreen({Key? key}) : super(key: key);
65+
const TargetScreen({super.key});
6666

6767
@override
6868
Widget build(BuildContext context) {

Diff for: lib/routes/animation_animated_text_kit_ex.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const _kTextStyle = TextStyle(
99
);
1010

1111
class AnimatedTextKitExample extends StatelessWidget {
12-
const AnimatedTextKitExample({Key? key}) : super(key: key);
12+
const AnimatedTextKitExample({super.key});
1313

1414
@override
1515
Widget build(BuildContext context) {

Diff for: lib/routes/animation_animated_widget_ex.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import 'package:flutter/material.dart';
33
// The AnimatedWidget base class allows you to separate out the core widget code
44
// from the animation code.
55
class _AnimatedLogo extends AnimatedWidget {
6-
const _AnimatedLogo({Key? key, required Animation<double> animation})
7-
: super(key: key, listenable: animation);
6+
const _AnimatedLogo({required Animation<double> animation})
7+
: super(listenable: animation);
88

99
@override
1010
Widget build(BuildContext context) {
@@ -21,7 +21,7 @@ class _AnimatedLogo extends AnimatedWidget {
2121
}
2222

2323
class AnimatedWidgetExample extends StatefulWidget {
24-
const AnimatedWidgetExample({Key? key}) : super(key: key);
24+
const AnimatedWidgetExample({super.key});
2525
@override
2626
_AnimatedWidgetExampleState createState() => _AnimatedWidgetExampleState();
2727
}

Diff for: lib/routes/animation_animations_pkg_ex.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
33
import 'package:url_launcher/url_launcher.dart';
44

55
class AnimationsPackageExample extends StatelessWidget {
6-
const AnimationsPackageExample({Key? key}) : super(key: key);
6+
const AnimationsPackageExample({super.key});
77

88
@override
99
Widget build(BuildContext context) {
@@ -106,7 +106,7 @@ class AnimationsPackageExample extends StatelessWidget {
106106
}
107107

108108
class _PageTransitionSwitcherEx extends StatefulWidget {
109-
const _PageTransitionSwitcherEx({Key? key}) : super(key: key);
109+
const _PageTransitionSwitcherEx();
110110

111111
@override
112112
__PageTransitionSwitcherExState createState() =>
@@ -158,7 +158,7 @@ class __PageTransitionSwitcherExState extends State<_PageTransitionSwitcherEx> {
158158
}
159159

160160
class _SharedAxisEx extends StatefulWidget {
161-
const _SharedAxisEx({Key? key}) : super(key: key);
161+
const _SharedAxisEx();
162162

163163
@override
164164
__SharedAxisExState createState() => __SharedAxisExState();

0 commit comments

Comments
 (0)