Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Flutter 3.10 and Dart 3 #327

Merged
merged 6 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
include: package:flutter_lints/flutter.yaml

analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
language:
strict-casts: true
strict-raw-types: true

linter:
rules:
Expand Down
6 changes: 3 additions & 3 deletions example/book_store/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
include: package:flutter_lints/flutter.yaml

analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: true
language:
strict-casts: true
strict-raw-types: true

linter:
rules:
Expand Down
5 changes: 2 additions & 3 deletions example/book_store/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RouteMap _buildRouteMap(BuildContext context) {
body: Center(
child: Text(
"Couldn't find page '$path'",
style: Theme.of(context).textTheme.headline3,
style: Theme.of(context).textTheme.displaySmall,
),
),
),
Expand Down Expand Up @@ -146,8 +146,7 @@ class BookStoreApp extends StatelessWidget {
primaryColor: Color(0xFF131921),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
primary: Color(0xfffebd68),
onPrimary: Color(0xff333333),
foregroundColor: Color(0xff333333), backgroundColor: Color(0xfffebd68),
),
),
platform: TargetPlatform.macOS,
Expand Down
4 changes: 2 additions & 2 deletions example/book_store/lib/search_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class SearchPage extends StatelessWidget {
if (categoryMatches.isNotEmpty) ...[
Text(
'Categories',
style: Theme.of(context).textTheme.headline5,
style: Theme.of(context).textTheme.headlineSmall,
),
for (final category in categoryMatches) ...[
Text(category.displayName),
Expand All @@ -110,7 +110,7 @@ class SearchPage extends StatelessWidget {
],
Text(
'Books',
style: Theme.of(context).textTheme.headline5,
style: Theme.of(context).textTheme.headlineSmall,
),
if (books.isEmpty)
Padding(
Expand Down
4 changes: 2 additions & 2 deletions example/book_store/lib/wishlist_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class WishlistHomePage extends StatelessWidget {
children: [
Text(
wishlist.title,
style: Theme.of(context).textTheme.headline6,
style: Theme.of(context).textTheme.titleLarge,
),
Text('Share: ${wishlist.shareUrl}'),
],
Expand Down Expand Up @@ -89,7 +89,7 @@ class WishlistPage extends StatelessWidget {
children: [
Text(
'Wishlist ${wishList.title}',
style: Theme.of(context).textTheme.headline4,
style: Theme.of(context).textTheme.headlineMedium,
),
Text('Share this wishlist! ${wishList.shareUrl}'),
for (final bookId in wishList.bookIds)
Expand Down
2 changes: 1 addition & 1 deletion example/book_store/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ publish_to: "none"
version: 1.0.0+1

environment:
sdk: ">=2.17.0 <3.0.0"
sdk: ">=2.18.0 <4.0.0"

dependencies:
flutter:
Expand Down
27 changes: 18 additions & 9 deletions example/book_store/test/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,32 @@ class SystemUrlTracker {

/// Records changes in URL
Future<void> recordUrlChanges(
Future Function(SystemUrlTracker url) callback) async {
Future<dynamic> Function(SystemUrlTracker url) callback) async {
try {
final tracker = SystemUrlTracker();
final stackTraces = <StackTrace>[];

SystemChannels.navigation.setMockMethodCallHandler((call) async {
if (call.method == 'routeInformationUpdated') {
final location = call.arguments['location'] as String;
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(
SystemChannels.navigation,
(call) async {
if (call.method == 'routeInformationUpdated') {
final args = call.arguments as Map;
final location = args.containsKey('uri')
? args['uri'] as String
: args['location'] as String;

tracker.current = location;
stackTraces.add(StackTrace.current);
}
});
tracker.current = location;
stackTraces.add(StackTrace.current);
}
return null;
},
);

await callback(tracker);
} finally {
SystemChannels.navigation.setMockMethodCallHandler(null);
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(SystemChannels.navigation, null);
}
}

Expand Down
2 changes: 1 addition & 1 deletion example/deep_linking/lib/article_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class _ArticlePageState extends State<ArticlePage> {
children: [
Text(
'Article ${widget.id}',
style: Theme.of(context).textTheme.headline3,
style: Theme.of(context).textTheme.displaySmall,
),
SizedBox(height: 20),
Text('Hello this is article ${widget.id}'),
Expand Down
2 changes: 1 addition & 1 deletion example/deep_linking/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class HomePage extends StatelessWidget {
children: [
Text(
'Home page',
style: Theme.of(context).textTheme.headline3,
style: Theme.of(context).textTheme.displaySmall,
),
SizedBox(height: 20),
ElevatedButton(
Expand Down
2 changes: 1 addition & 1 deletion example/deep_linking/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ publish_to: "none"
version: 1.0.0+1

environment:
sdk: ">=2.17.0 <3.0.0"
sdk: ">=2.18.0 <4.0.0"

dependencies:
flutter:
Expand Down
6 changes: 3 additions & 3 deletions example/mobile_app/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
include: package:flutter_lints/flutter.yaml

analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: true
language:
strict-casts: true
strict-raw-types: true

linter:
rules:
Expand Down
6 changes: 3 additions & 3 deletions example/mobile_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void main() {
/// This shows in a browser tab's title.
class TitleObserver extends RoutemasterObserver {
@override
void didChangeRoute(RouteData routeData, Page page) {
void didChangeRoute(RouteData routeData, Page<dynamic> page) {
if (page.name != null) {
SystemChrome.setApplicationSwitcherDescription(
ApplicationSwitcherDescription(
Expand Down Expand Up @@ -201,13 +201,13 @@ RouteMap _buildRouteMap(AppState appState) {
}

// For custom animations, just use the existing Flutter [Page] and [Route] objects
class FancyAnimationPage extends Page {
class FancyAnimationPage<T> extends Page<T> {
final Widget child;

FancyAnimationPage({required this.child});

@override
Route createRoute(BuildContext context) {
Route<T> createRoute(BuildContext context) {
return PageRouteBuilder(
settings: this,
pageBuilder: (context, animation, animation2) {
Expand Down
13 changes: 4 additions & 9 deletions example/mobile_app/lib/pages/bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PageBasedMaterialWithModalsPageRoute<T>
required MaterialPage<T> page,
}) : super(page: page);

ModalBottomSheetRoute? _nextModalRoute;
ModalSheetRoute<dynamic>? _nextModalRoute;

@override
bool canTransitionTo(TransitionRoute<dynamic> nextRoute) {
Expand All @@ -29,23 +29,18 @@ class PageBasedMaterialWithModalsPageRoute<T>
(nextRoute is CupertinoPageRoute && !nextRoute.fullscreenDialog) ||
(nextRoute is MaterialWithModalsPageRoute &&
!nextRoute.fullscreenDialog) ||
(nextRoute is ModalBottomSheetRoute);
(nextRoute is ModalSheetRoute);
}

@override
void didChangeNext(Route? nextRoute) {
if (nextRoute is ModalBottomSheetRoute) {
void didChangeNext(Route<dynamic>? nextRoute) {
if (nextRoute is ModalSheetRoute) {
_nextModalRoute = nextRoute;
}

super.didChangeNext(nextRoute);
}

@override
void didPopNext(Route nextRoute) {
super.didPopNext(nextRoute);
}

@override
bool didPop(T? result) {
_nextModalRoute = null;
Expand Down
4 changes: 2 additions & 2 deletions example/mobile_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ publish_to: "none"
version: 1.0.0+1

environment:
sdk: ">=2.17.0 <3.0.0"
sdk: ">=2.18.0 <4.0.0"

dependencies:
flutter:
Expand All @@ -13,7 +13,7 @@ dependencies:
path: ../../
provider: ^5.0.0
cupertino_icons: ^1.0.0
modal_bottom_sheet: ^2.0.1
modal_bottom_sheet: ^3.0.0-pre

dev_dependencies:
flutter_test:
Expand Down
2 changes: 1 addition & 1 deletion example/mobile_app/test/bottom_navigation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:mobile_app/pages/home_page.dart';
import 'package:mobile_app/pages/notifications_page.dart';
import 'helpers.dart';

Future pumpBottomNavigationPage(WidgetTester tester) async {
Future<void> pumpBottomNavigationPage(WidgetTester tester) async {
await tester.pumpWidget(MyApp());
await tester.tap(find.text('Log in'));
await tester.pump();
Expand Down
2 changes: 1 addition & 1 deletion example/mobile_app/test/feed_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:mobile_app/main.dart';
import 'package:mobile_app/pages/feed_page.dart';
import 'helpers.dart';

Future pumpFeedPage(WidgetTester tester) async {
Future<void> pumpFeedPage(WidgetTester tester) async {
await tester.pumpWidget(MyApp());
await tester.tap(find.text('Log in'));
await tester.pump();
Expand Down
14 changes: 10 additions & 4 deletions example/mobile_app/test/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,29 @@ class SystemUrlTracker {

/// Records changes in URL
Future<void> recordUrlChanges(
Future Function(SystemUrlTracker url) callback) async {
Future<void> Function(SystemUrlTracker url) callback) async {
try {
final tracker = SystemUrlTracker();
final stackTraces = <StackTrace>[];

SystemChannels.navigation.setMockMethodCallHandler((call) async {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(SystemChannels.navigation, (call) async {
if (call.method == 'routeInformationUpdated') {
final location = call.arguments['location'] as String;
final args = call.arguments as Map;
final location = args.containsKey('uri')
? args['uri'] as String
: args['location'] as String;

tracker.current = location;
stackTraces.add(StackTrace.current);
}
return null;
});

await callback(tracker);
} finally {
SystemChannels.navigation.setMockMethodCallHandler(null);
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(SystemChannels.navigation, null);
}
}

Expand Down
2 changes: 1 addition & 1 deletion example/mobile_app/test/replace_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:mobile_app/main.dart';
import 'package:mobile_app/pages/feed_page.dart';
import 'helpers.dart';

Future pumpBottomNavigationPage(WidgetTester tester) async {
Future<void> pumpBottomNavigationPage(WidgetTester tester) async {
await tester.pumpWidget(MyApp());
await tester.tap(find.text('Log in'));
await tester.pump();
Expand Down
2 changes: 1 addition & 1 deletion example/navigation_bar/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ publish_to: "none"
version: 1.0.0+1

environment:
sdk: ">=2.17.0 <3.0.0"
sdk: ">=2.18.0 <4.0.0"

dependencies:
flutter:
Expand Down
6 changes: 3 additions & 3 deletions example/simple_example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
include: package:flutter_lints/flutter.yaml

analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: true
language:
strict-casts: true
strict-raw-types: true

linter:
rules:
Expand Down
2 changes: 1 addition & 1 deletion example/simple_example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ publish_to: "none"
version: 1.0.0+1

environment:
sdk: ">=2.17.0 <3.0.0"
sdk: ">=2.18.0 <4.0.0"

dependencies:
flutter:
Expand Down
6 changes: 3 additions & 3 deletions integration_test_app/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: true
language:
strict-casts: true
strict-raw-types: true

linter:
rules:
Expand Down
10 changes: 9 additions & 1 deletion integration_test_app/integration_test/navigation_hash_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
replaceTests(
expectUrl: (expected) {
expect(window.location.hash, '#$expected');
// Flutter after 3.10 has empty URLs for home route
final hashUrl = '#$expected';
final allowEmpty = hashUrl == '#/';

expect(
window.location.hash == hashUrl ||
(allowEmpty && window.location.hash.isEmpty),
isTrue,
);
},
);
}
2 changes: 1 addition & 1 deletion integration_test_app/macos/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
platform :osx, '10.11'
platform :osx, '10.14'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
6 changes: 3 additions & 3 deletions integration_test_app/macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral

SPEC CHECKSUMS:
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24

PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c
PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7

COCOAPODS: 1.11.2
COCOAPODS: 1.12.1
Loading
Loading