-
Notifications
You must be signed in to change notification settings - Fork 28.7k
[Release] Page Restoration Restore Freezes and throws Dart Error: Class not found in library ''.
#118565
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
Comments
Dart Error: Class not found in library ''.
I can reproduce the issue on both Steps to reproduce
Android
iOS
I suspect you should get the same error as you would on android. I attempted to attach to the Runner in xcode to see if I could get any logs but I had no success there.
code sampleimport 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
restorationScopeId: 'app',
home: Banner(
message: kDebugMode ? 'DEBUG' : 'RELEASE',
location: BannerLocation.topEnd,
child: Scaffold(
appBar: AppBar(title: const Text('RestorableRouteFuture Example')),
body: const MyHome(),
),
),
);
}
}
class MyHome extends StatefulWidget {
const MyHome({super.key});
@override
State<MyHome> createState() => _MyHomeState();
}
class _MyHomeState extends State<MyHome> with RestorationMixin {
final RestorableInt _lastCount = RestorableInt(0);
late RestorableRouteFuture<int> _counterRoute;
@override
String get restorationId => 'home';
@override
void initState() {
super.initState();
_counterRoute = RestorableRouteFuture<int>(onPresent: (NavigatorState navigator, Object? arguments) {
// Defines what route should be shown (and how it should be added
// to the navigator) when `RestorableRouteFuture.present` is called.
return navigator.restorablePush(
_counterRouteBuilder,
arguments: arguments,
);
}, onComplete: (int count) {
// Defines what should happen with the return value when the route
// completes.
setState(() {
_lastCount.value = count;
});
});
}
@override
void restoreState(RestorationBucket? oldBucket, bool initialRestore) {
// Register the `RestorableRouteFuture` with the state restoration framework.
registerForRestoration(_counterRoute, 'route');
registerForRestoration(_lastCount, 'count');
}
@override
void dispose() {
super.dispose();
_lastCount.dispose();
_counterRoute.dispose();
}
// A static `RestorableRouteBuilder` that can re-create the route during
// state restoration.
static Route<int> _counterRouteBuilder(BuildContext context, Object? arguments) {
return MaterialPageRoute<int>(
builder: (BuildContext context) => MyCounter(
title: arguments!.toString(),
),
);
}
@override
Widget build(BuildContext context) {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text('Last count: ${_lastCount.value}'),
ElevatedButton(
onPressed: () {
// Show the route defined by the `RestorableRouteFuture`.
_counterRoute.present('Awesome Counter');
},
child: const Text('Open Counter'),
),
],
),
);
}
}
// Widget for the route pushed by the `RestorableRouteFuture`.
class MyCounter extends StatefulWidget {
const MyCounter({super.key, required this.title});
final String title;
@override
State<MyCounter> createState() => _MyCounterState();
}
class _MyCounterState extends State<MyCounter> with RestorationMixin {
final RestorableInt _count = RestorableInt(0);
@override
String get restorationId => 'counter';
@override
void restoreState(RestorationBucket? oldBucket, bool initialRestore) {
registerForRestoration(_count, 'count');
}
@override
void dispose() {
super.dispose();
_count.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
leading: BackButton(
onPressed: () {
// Return the current count of the counter from this route.
Navigator.of(context).pop(_count.value);
},
),
),
body: Center(
child: Text('Count: ${_count.value}'),
),
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.add),
onPressed: () {
setState(() {
_count.value++;
});
},
),
);
}
}
flutter doctor -v
|
This is most definitely related to stronger tree-shaking - you can't expect to reflectively access any functions or classes from native side unless they are marked with |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Uh oh!
There was an error while loading. Please reload this page.
I have tried the sample given on this page regarding page restoration. When the application is running in debug mode (in app-debug.apk), the page restoration recovery is running. However, when the application is running in release (production) mode (in app-release.apk), the page restoration recovery freezes when switching from the application task via the multitask tray.
Steps to Reproduce
flutter create --sample=widgets.RestorableRouteFuture.1 mysample
for creating project based on this sample.Result
In Debug Mode
Expected results: Success restore its state.
Actual results: Success restore its state.
Video demonstration source: Here
In Release Mode
Expected results: Success restore its state.
Actual results: The restoration process suddenly freezes (it's been 10 seconds and it's still freezing).
Video demonstration source: Here
APK Source
APK Debug (app-debug.apk): Here
APK Release (app-release.apk): Here
Log
Using
flutter doctor -v
Result:
The text was updated successfully, but these errors were encountered: