This repository has been archived by the owner on Jul 20, 2022. It is now read-only.
onInit handler is not called on initialisation #68
Comments
I just tried the example, but it's working. It's called on initialization |
Here is the minimum code. import 'package:flutter/material.dart';
import 'package:country_code_picker/country_code_picker.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
print('build');
return MaterialApp(
home: Scaffold(
body: Center(
child: CountryCodePicker(
initialSelection: 'US',
onInit: print,
),
),
),
);
}
} If it is true that Additionally, would you try the following code as well please? It does not print "didUpdateWidget", which means import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
MyApp();
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
print('initState');
}
@override
void didUpdateWidget(MyApp oldWidget) {
super.didUpdateWidget(oldWidget);
print('didUpdateWidget');
}
@override
Widget build(BuildContext context) {
return const SizedBox.shrink();
}
} |
I can swear that the minimum code part prints "+1" Anyway I believe that there is a problem, I'll analyze it better |
#74 fixes this bug |
Thank you! 😄 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
onInit
is called fromdidUpdateWidget()
, which is called only on rebuild, resulting in it not getting called on initialisation.The text was updated successfully, but these errors were encountered: