Platform conditions for image_picker library

This commit is contained in:
Miroslav Mazel
2023-03-22 11:55:36 +01:00
parent f388e1e7ca
commit e470b8809d
2 changed files with 33 additions and 26 deletions

View File

@@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:provider/provider.dart';
@@ -35,20 +37,22 @@ class GalleryScreen extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
appBar: EmptyAppBar(AppLocalizations.of(context).gallery),
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.add),
onPressed: () {
Navigator.pushNamed(
context,
FormScreen.routeName,
arguments: FormScreenArguments(
AppLocalizations.of(context).addImage,
ImageForm(),
hasListView: true,
floatingActionButton: (Platform.isLinux || Platform.isMacOS)
? null
: FloatingActionButton(
child: const Icon(Icons.add),
onPressed: () {
Navigator.pushNamed(
context,
FormScreen.routeName,
arguments: FormScreenArguments(
AppLocalizations.of(context).addImage,
ImageForm(),
hasListView: true,
),
);
},
),
);
},
),
body: Consumer<GalleryProvider>(
builder: (context, workoutProvider, child) => const Gallery(),
),

View File

@@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
@@ -77,19 +79,20 @@ class Gallery extends StatelessWidget {
.deleteImage(currentImage);
Navigator.of(context).pop();
}),
IconButton(
icon: const Icon(Icons.edit),
onPressed: () {
Navigator.pushNamed(
context,
FormScreen.routeName,
arguments: FormScreenArguments(
AppLocalizations.of(context).edit,
ImageForm(currentImage),
hasListView: true,
),
);
}),
if (!(Platform.isLinux || Platform.isMacOS))
IconButton(
icon: const Icon(Icons.edit),
onPressed: () {
Navigator.pushNamed(
context,
FormScreen.routeName,
arguments: FormScreenArguments(
AppLocalizations.of(context).edit,
ImageForm(currentImage),
hasListView: true,
),
);
}),
],
)
],