Woher kommt die Blaue Farbe bei actionlabel? Füge einen Border ganz ganz dünn ein, der…
- User
Woher kommt die Blaue Farbe bei actionlabel? Füge einen Border ganz ganz dünn ein, der nur um das bild geht und unten soll der rahmen nicht sein. Wo passe ich den Abstand an? import 'package:flutter/material.dart'; import 'package:patient_app/theme/patient_app_colors.dart'; import 'package:patient_app/theme/patient_app_theme.dart' as theme; import 'package:patient_app/widgets/overlay_ink.dart'; import 'package:photo_view/photo_view.dart';
class LocationMapCard extends StatelessWidget { const LocationMapCard({ Key? key, required this.actionLabel, required this.imageName, }) : super(key: key);
final String actionLabel; final String imageName;
@override Widget build(BuildContext context) { return Card( shape: RoundedRectangleBorder( borderRadius: theme.cardBorderRadius, ), color: AppColors.cardColor, elevation: theme.cardElevation, margin: EdgeInsets.zero, child: Stack( children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ ClipRRect( borderRadius: const BorderRadius.only( topLeft: Radius.circular(theme.radiusValue), topRight: Radius.circular(theme.radiusValue)), child: Image.asset(imageName, fit: BoxFit.fill), ), Padding( padding: theme.extraSmallEdgeInsets, child: TextButton( style: theme.PatientAppTheme.actionButtonStyle(), onPressed: () { openDialog(context); }, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( actionLabel, style: Theme.of(context).textTheme.headline3, ), const Icon(Icons.map, color: theme.defaultIconColor), ], ), ), ) ], ), OverlayInk( borderRadius: theme.cardBorderRadius, hoverColor: AppColors.transparent, onTap: () { openDialog(context); }, ), ], ), ); }
void openDialog(BuildContext context) { showDialog( context: context, builder: (BuildContext context) { return Dialog( backgroundColor: AppColors.transparent, elevation: theme.imageDialogElevation, child: PhotoView( backgroundDecoration: const BoxDecoration( color: AppColors.transparent, ), tightMode: true, minScale: PhotoViewComputedScale.contained, maxScale: PhotoViewComputedScale.covered * 1.8, initialScale: PhotoViewComputedScale.contained, imageProvider: AssetImage(imageName), heroAttributes: const PhotoViewHeroAttributes(tag: 'appointment_location_plan'), ), ); }, ); } }
- Assistant
Um eine dünne blaue Umrandung um das Bild hinzuzufügen und die Unterseite ohne Rahmen zu lassen, können Sie einen BoxDecoration-Widget mit BoxDecoration.border hinzufügen. Sie können den Abstand z.B. mit Padding-Widgets anpassen.
Hier ist der aktualisierte Code:
import 'package:flutter/material.dart'; import 'package:patient_app/theme/patient_app_colors.dart'; import 'package:patient_app/theme/patient_app_theme.dart' as theme; import 'package:patient_app/widgets/overlay_ink.dart'; import 'package:photo_view/photo_view.dart'; class LocationMapCard extends StatelessWidget { const LocationMapCard({ Key? key, required this.actionLabel, required this.imageName, }) : super(key: key); final String actionLabel; final String imageName; @override Widget build(BuildContext context) { return Card( shape: RoundedRectangleBorder( borderRadius: theme.cardBorderRadius, ), color: AppColors.cardColor, elevation: theme.cardElevation, margin: EdgeInsets.zero, child: Stack( children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ ClipRRect( borderRadius: const BorderRadius.only( topLeft: Radius.circular(theme.radiusValue), topRight: Radius.circular(theme.radiusValue)), child: Container( decoration: BoxDecoration( border: Border( top: BorderSide(color: Colors.blue, width: 1.0), left: BorderSide(color: Colors.blue, width: 1.0), right: BorderSide(color: Colors.blue, width: 1.0), ), ), child: Image.asset(imageName, fit: BoxFit.fill), ), ), Padding( padding: theme.extraSmallEdgeInsets, child: TextButton( style: theme.PatientAppTheme.actionButtonStyle(), onPressed: () { openDialog(context); }, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( actionLabel, style: Theme.of(context).textTheme.headline3, ), const Icon(Icons.map, color: theme.defaultIconColor), ], ), ), ) ], ), OverlayInk( borderRadius: theme.cardBorderRadius, hoverColor: AppColors.transparent, onTap: () { openDialog(context); }, ), ], ), ); } void openDialog(BuildContext context) { showDialog( context: context, builder: (BuildContext context) { return Dialog( backgroundColor: AppColors.transparent, elevation: theme.imageDialogElevation, child: PhotoView( backgroundDecoration: const BoxDecoration( color: AppColors.transparent, ), tightMode: true, minScale: PhotoViewComputedScale.contained, maxScale: PhotoViewComputedScale.covered * 1.8, initialScale: PhotoViewComputedScale.contained, imageProvider: AssetImage(imageName), heroAttributes: const PhotoViewHeroAttributes(tag: 'appointment_location_plan'), ), ); }, ); } }In diesem Code haben wir:
- Eine
Container-Widget um dasImage.asset-Widget gewrapped. - Eine
BoxDecoration-Widget mit einerBorderhinzugefügt, um den gewünschten Bildrahmen zu erstellen. - Eine Border mit nur oben, links und rechts definiert, um keine Unterseite zu haben.
Relevante Änderungen zur Verbesserung des Abstands können mit dem Padding-Widget in der Datei
LocationMapCardgemacht werden. - Eine