Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:geocoding/geocoding.dart';
- import '../../../../../../shared/services/geocoding_service.dart';
- import '../../../../../../shared/view/loading_text/loading_text.dart';
- class AddressRow extends StatelessWidget {
- const AddressRow({
- Key? key,
- required this.leading,
- required this.address,
- this.anotherApplicationButton = false,
- this.selectable = false,
- }) : super(key: key);
- final Widget leading;
- final String address;
- final bool anotherApplicationButton;
- final bool selectable;
- @override
- Widget build(BuildContext context) {
- late Widget text;
- if (selectable) {
- text = SelectableText(
- address,
- style: const TextStyle(color: Color(0xFF616161)),
- );
- } else {
- text = Text(
- address,
- style: const TextStyle(color: Color(0xFF616161)),
- );
- }
- return Row(
- children: [
- Expanded(
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- leading,
- const SizedBox(width: 8.0),
- Expanded(
- child: text,
- ),
- ],
- ),
- ),
- if (anotherApplicationButton)
- AnotherApplicationButton(address: address),
- ],
- );
- }
- }
- class AnotherApplicationButton extends StatelessWidget {
- const AnotherApplicationButton({
- Key? key,
- required this.address,
- }) : super(key: key);
- final String address;
- @override
- Widget build(BuildContext context) {
- return FutureBuilder<List<Location>>(
- future: GeocodingService.locationFromAddress(address),
- builder: (context, snapshot) {
- if (snapshot.connectionState != ConnectionState.done) {
- return const LoadingTextComponent();
- } else {
- if (snapshot.data!.isEmpty) {
- return const SizedBox.shrink();
- }
- return TextButton(
- onPressed: GeocodingService.openLocationByAnotherApplication(
- snapshot.data!,
- ),
- child: const Text(
- 'ПЕРЕЙТИ В КАРТЫ',
- style: TextStyle(fontWeight: FontWeight.bold),
- ),
- );
- }
- },
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement