Как сблизить кнопки?
Необходимо уменьшить расстояние между кнопками, хочется сделать их немного плотнее друг к другу.
Expanded(
child: Align(
alignment: Alignment.bottomLeft,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Padding(padding: EdgeInsets.fromLTRB(10, 0, 0, 0),
child: Row(
children: [
TextButton(onPressed: () => launch('tel://111'),
child: Row(
children: [
Icon(Icons.phone_iphone_outlined, color: Colors.white, size: 20),
Padding(padding: EdgeInsets.only(left: 7.0),),
Text('446-777',
style: TextStyle(color: Colors.white,
fontSize: 16)),
],
),
),
],
),
),
Row(
children: <Widget>[
Padding(padding: EdgeInsets.fromLTRB(10, 0, 0, 0),
child: Row(
children: [
TextButton(onPressed: () {
openSite();
},
child: Row(
children: [
Icon(Icons.laptop_chromebook_outlined, color: Colors.white, size: 20),
Padding(padding: EdgeInsets.only(left: 7.0),),
Text('www.aaa.ru',
style: TextStyle(color: Colors.white,
fontSize: 16)),
],
),
),
],
),
),
],
),
Row(
children: <Widget>[
Padding(padding: EdgeInsets.fromLTRB(10, 0, 0, 15),
child: Row(
children: [
TextButton(onPressed: () {
openMaps();
},
child: Row(
children: [
Icon(Icons.location_on_outlined, color: Colors.white, size: 20,),
Padding(padding: EdgeInsets.only(left: 7.0),),
Text('г. Москва',
style: TextStyle(color: Colors.white,
fontSize: 16)),
],
),
),
],
),
),
],
),
Ответы (1 шт):
Автор решения: MiT
→ Ссылка
У TextButton есть style который принимает ButtonStyle. Через метод TextButton.styleFrom мы можем определить minimumSize и padding:
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: MyWidget(),
),
),
);
}
}
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Padding(
padding: EdgeInsets.fromLTRB(10, 0, 0, 0),
child: TextButton(
onPressed: () {},
style: TextButton.styleFrom(
minimumSize: Size(50, 0),
padding: EdgeInsets.zero,
),
child: Row(
children: [
Icon(Icons.phone_iphone_outlined,
color: Colors.white, size: 20),
Padding(
padding: EdgeInsets.only(left: 7.0),
),
Text('446-777',
style: TextStyle(color: Colors.white, fontSize: 16)),
],
),
),
),
Padding(
padding: EdgeInsets.fromLTRB(10, 0, 0, 0),
child: TextButton(
onPressed: () {},
style: TextButton.styleFrom(
minimumSize: Size(50, 0),
padding: EdgeInsets.zero,
),
child: Row(
children: [
Icon(Icons.laptop_chromebook_outlined,
color: Colors.white, size: 20),
Padding(
padding: EdgeInsets.only(left: 7.0),
),
Text('www.aaa.ru',
style: TextStyle(color: Colors.white, fontSize: 16)),
],
),
),
),
Padding(
padding: EdgeInsets.fromLTRB(10, 0, 0, 15),
child: TextButton(
onPressed: () {},
style: TextButton.styleFrom(
minimumSize: Size(50, 0),
padding: EdgeInsets.zero,
),
child: Row(
children: [
Icon(
Icons.location_on_outlined,
color: Colors.white,
size: 20,
),
Padding(
padding: EdgeInsets.only(left: 7.0),
),
Text('г. Москва',
style: TextStyle(color: Colors.white, fontSize: 16)),
],
),
),
),
],
);
}
}