-
Notifications
You must be signed in to change notification settings - Fork 99
Description
السلام عليكم استاذ عبدالرحمن الزر الموجود فى الappbar ليس له اى تأثير على الرغم انه يعمل ومن المفترض ان يقوم بتغيير الوضع الى الوضع الليلى .. وعند تغيير القيمه يدويا فى الكود لا يحدث تغيير الا بعد الخروج من الصفحه والدخول مجددا
هل من حل.. وشكرا
// ignore_for_file: prefer_const_constructors, avoid_print, unused_element, unused_field
import 'package:flutter/material.dart';
import 'package:flutter_cached_pdfview/flutter_cached_pdfview.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class Z2 extends StatefulWidget {
const Z2({Key? key}) : super(key: key);
@OverRide
State createState() => _ManzomaState();
}
class _ManzomaState extends State {
bool isValue = false;
int _adad = 0;
double _currentPage = 0;
int _totalPages = 0;
PDFViewController? _pdfController;
void _hesab() {
setState(() {
_adad++;
});
}
void _e3adh() {
setState(() {
_adad = 0;
});
}
void onPageChanged(int? page, int? total) {
setState(() {
_currentPage = page?.toDouble() ?? 0.0;
});
}
void jumpToPage(int page) {
setState(() {
_currentPage = page.toDouble();
_pdfController?.setPage(page);
});
}
@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
iconTheme: IconThemeData(color: Colors.white),
title: FittedBox(
child: Text(
"صلوات الأمان ",
style: TextStyle(
color: Color.fromARGB(249, 243, 246, 245),
fontFamily: "a3",
fontSize: 22.sp,
fontWeight: FontWeight.w700,
),
),
),
actions: [
IconButton(
icon: Icon(
isValue ? Icons.nightlight_round : Icons.sunny,
color: Colors.white,
),
onPressed: () {
setState(() {
isValue = !isValue;
});
},
),
],
centerTitle: true,
backgroundColor: Color.fromARGB(255, 15, 88, 48),
elevation: 20,
shadowColor: Color.fromARGB(255, 163, 255, 187),
),
body: Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
height: MediaQuery.of(context).size.height * 0.02,
),
],
),
PDF(
pageSnap: false,
defaultPage: 0,
preventLinkNavigation: true,
nightMode: isValue,
fitEachPage: false,
enableSwipe: true,
swipeHorizontal: false,
pageFling: false,
autoSpacing: false,
onRender: (pages) {
setState(() {
_totalPages = pages!;
});
print('Total Pages: $_totalPages');
_pdfController?.setPage(_currentPage.round());
},
onPageChanged: onPageChanged,
).fromAsset('assets/pdfs/pdf_zaad/z2.pdf'),
Positioned(
top: 20.0,
right: 20.0,
child: Container(
padding: EdgeInsets.all(8.0),
decoration: BoxDecoration(
color: Colors.black54,
borderRadius: BorderRadius.circular(10.0),
),
child: Text(
'${_currentPage.toInt() + 1} / $_totalPages',
style: TextStyle(
color: Colors.white,
fontSize: 16.0,
),
),
),
),
Positioned(
bottom: 0,
right: 0,
child: Container(
padding: EdgeInsets.all(1),
alignment: Alignment.center,
color: Color.fromARGB(255, 10, 61, 16),
height: 55.h,
width: MediaQuery.of(context).size.width * 1,
child: Row(mainAxisSize: MainAxisSize.min, children: [
Container(
width: 100,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(23)),
color: Color.fromARGB(255, 13, 123, 70),
),
child: IconButton(
icon: Icon(Icons.refresh_rounded),
iconSize: 33,
color: Color.fromARGB(255, 174, 255, 185),
onPressed: () {
_e3adh();
},
),
),
Container(
height: 55,
padding: EdgeInsets.only(right: 5, left: 5),
margin: EdgeInsets.only(
left: 30,
right: 30,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(10)),
color: Color.fromARGB(255, 13, 123, 70),
),
child: Center(
child: FittedBox(
child: Text(
'$_adad',
style: TextStyle(
fontFamily: "a14",
color: Color.fromARGB(255, 169, 252, 180),
fontSize: 40.sp,
),
),
),
),
),
Container(
width: 100,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(23)),
color: Color.fromARGB(255, 13, 123, 70),
),
child: IconButton(
icon: Icon(Icons.add),
iconSize: 33,
color: Color.fromARGB(255, 205, 255, 198),
onPressed: () {
_hesab();
},
),
),
]),
),
),
],
),
);
}
}