Skip to content

Instantly share code, notes, and snippets.

@ubershmekel
Created September 26, 2023 06:08
Show Gist options
  • Save ubershmekel/512790bee6ee8f5a14f1e6d4fc6b47f1 to your computer and use it in GitHub Desktop.
Save ubershmekel/512790bee6ee8f5a14f1e6d4fc6b47f1 to your computer and use it in GitHub Desktop.
Word wrapping text labels is hard
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
final String title;
const MyHomePage({
Key? key,
required this.title,
}) : super(key: key);
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
// title: const Text('Popup example'),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(children: [
FloatingActionButton.extended(
heroTag: UniqueKey(),
icon: const Icon(Icons.nordic_walking),
label: const Text(
'j laskdjfla sdlf alsdk flakj flkasj dlk jalsd asdf asdlf asldkj fal ads aa da s ',
),
onPressed: () {},
)
]),
const SizedBox(height: 20),
Row(children: [
SizedBox(
height: 80,
child: FloatingActionButton.extended(
heroTag: UniqueKey(),
icon: const Icon(Icons.directions_bike),
label: const Text(
'asdfasdjlfk asdk jfla sdflak sdfla df.a sdf askd.jf .aksd ak jf.a ksjdja .kja. jad.k j sda jflaksd jlas jdlfka sdlkfja lskdfjlak sdjlfkj asldkf jalskjflkjasd lkj faljd lasjlk jdlkaj s',
softWrap: true,
),
onPressed: () {},
))
]),
],
),
));
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment