This commit is contained in:
Valentin CZERYBA 2025-02-19 23:32:31 +01:00
parent 47c014cdda
commit 38e9908533
2 changed files with 40 additions and 4 deletions

View File

@ -11,7 +11,12 @@ import '../classes/alert.dart';
import '../variable/globals.dart' as globals;
void main() {
import '../classes/ad_helper.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await MobileAds.instance.initialize();
runApp(MyApp());
}
@ -33,6 +38,8 @@ class AddProfile extends StatefulWidget {
}
class _AddProfileState extends State<AddProfile> with ShowAlertDialog {
BannerAd? _bannerAd;
TextEditingController inputUserName = TextEditingController();
TextEditingController inputName = TextEditingController();
@ -133,6 +140,11 @@ class _AddProfileState extends State<AddProfile> with ShowAlertDialog {
@override
void initState() {
super.initState();
AdHelper.createBannerAd(() => setState(() {})).then((ad) {
setState(() {
_bannerAd = ad;
});
});
}
final _formKey = GlobalKey<FormState>();
@ -154,6 +166,12 @@ class _AddProfileState extends State<AddProfile> with ShowAlertDialog {
child: SingleChildScrollView(
child: Column(
children: <Widget>[
_bannerAd == null
? SizedBox.shrink()
: SizedBox(
height: _bannerAd!.size.height.toDouble(),
width: _bannerAd!.size.width.toDouble(),
child: AdWidget(ad: _bannerAd!)),
Padding(
padding: const EdgeInsets.only(
left: 15.0, right: 15.0, top: 15, bottom: 0),

View File

@ -14,7 +14,12 @@ import 'dart:convert';
import '../variable/globals.dart' as globals;
import '../classes/MyDrawer.dart';
void main() {
import '../classes/ad_helper.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await MobileAds.instance.initialize();
runApp(MyApp());
}
@ -56,9 +61,18 @@ class DisplayPictureScreen extends StatefulWidget {
// A widget that displays the picture taken by the user.
class DisplayPictureScreenState extends State<DisplayPictureScreen>
with ShowDescImageAdd, ShowAlertDialog, TickerProviderStateMixin {
BannerAd? _bannerAd;
late AnimationController controller;
@override
void initState() {
super.initState();
AdHelper.createBannerAd(() => setState(() {})).then((ad) {
setState(() {
_bannerAd = ad;
});
});
controller = AnimationController(
/// [AnimationController]s can be created with `vsync: this` because of
/// [TickerProviderStateMixin].
@ -68,7 +82,6 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen>
setState(() {});
});
controller.repeat(reverse: false);
super.initState();
_getEventInfosFromImage();
}
@ -160,12 +173,17 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen>
// The image is stored as a file on the device. Use the `Image.file`
// constructor with the given path to display the image.
drawer: MyDrawer(),
body: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
_bannerAd == null
? SizedBox.shrink()
: SizedBox(
height: _bannerAd!.size.height.toDouble(),
width: _bannerAd!.size.width.toDouble(),
child: AdWidget(ad: _bannerAd!)),
Text(
'Analyse de l\'image en cours',
style: Theme.of(context).textTheme.titleLarge,