import 'dart:async'; import 'package:mobdr/main.dart'; import 'package:mobdr/config/global_style.dart'; import 'package:mobdr/config/constant.dart'; import 'package:flutter/material.dart'; import 'package:mobdr/db/box_photo_typology.dart'; import 'package:mobdr/ui/home/photo_list.dart'; class PhotoTypologyPage extends StatefulWidget { @override _PhotoTypologyPageState createState() => _PhotoTypologyPageState(); } class _PhotoTypologyPageState extends State { GestureDetector Function(BuildContext, int) _itemBuilder( List PhotoTypology) => (BuildContext context, int index) => GestureDetector( onTap: () { Route route = MaterialPageRoute(builder: (context) => PhotoListPage()); Navigator.push(context, route).then(onGoBack); }, ///objectbox.noteBox.remove(PhotoTypology[index].id), child: Row( children: [ Expanded( child: Container( decoration: const BoxDecoration( border: Border(bottom: BorderSide(color: Colors.black12))), child: Padding( padding: const EdgeInsets.symmetric( vertical: 15.0, horizontal: 10.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( PhotoTypology[index].libelle + " " + objectbox .getVisitPhotoCount(0, PhotoTypology[index].id_photo_typologie) .toString(), style: const TextStyle( fontSize: 15.0, ), // Provide a Key for the integration test key: Key('list_log_$index'), ), Icon(Icons.chevron_right, size: 20, color: SOFT_GREY), ], ), ), ), ), ], ), ); @override void initState() { super.initState(); } @override void dispose() { super.dispose(); } FutureOr onGoBack(dynamic value) { //refreshData(); setState(() {}); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: AppBar( iconTheme: IconThemeData( color: GlobalStyle.appBarIconThemeColor, ), elevation: GlobalStyle.appBarElevation, title: Text( 'Visite de ...', style: GlobalStyle.appBarTitle, ), backgroundColor: GlobalStyle.appBarBackgroundColor, systemOverlayStyle: GlobalStyle.appBarSystemOverlayStyle), body: Column(children: [ Expanded( child: StreamBuilder>( stream: objectbox.getPhotoTypologies(), builder: (context, snapshot) => ListView.builder( shrinkWrap: true, //padding: const EdgeInsets.symmetric(horizontal: 20.0), itemCount: snapshot.hasData ? snapshot.data!.length : 0, itemBuilder: _itemBuilder(snapshot.data ?? [])))) ])); } }