How to make text look like its going out of screen - flutter

I am making my app in which I want the font to look like its going out of the screen or has been cut off. I am unable to find anything in flutter related to it. If anyone knows about it please check the picture and let me know if its possible then how can I make it.

try this:
return Scaffold(
body: Transform.scale(
scaleX: 1.3,
child: Container(
color: Colors.blueGrey,
transform: Matrix4.translationValues(
7.0, 50.0, 0.0),
child: Text('Groupp',
style: TextStyle(fontSize: 100),
),
),
),
);

Related

Flutter app UI disappears after restarting once in apk release

After downloading the app through the apk release, in the first time, it works normally. But once you close the app and open it again, the ui elements disappears. It has a very strange behavior, if I restart the device, it works in the first time the app is open (after the restart), and after closing it, it doens't work again.
This only happens in the release version, debugging works as expected.
I am using Getx, I don't see a relation since I have already develop other apps with this structure. This is the code of the first page loaded.
return Container(
constraints: BoxConstraints(minWidth: Get.width, minHeight: Get.height),
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
image: DecorationImage(
opacity: 0.35,
repeat: ImageRepeat.repeat,
image: AssetImage(AppConstants.assets.background_image),
),
),
child: Scaffold(
backgroundColor: Colors.transparent,
body: Container(
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
width: Get.width,
height: Get.height * 0.45,
child: Center(
child: Padding(
padding: const EdgeInsets.only(top: 80.0),
child: SizedBox(
width: Get.width * 0.8,
height: Get.height * 0.3,
child: Image.asset(AppConstants.assets.logo_image),
),
),
),
),
SizedBox(
height: Get.height * 0.55,
child: TabBarView(
controller: controller.tabController,
physics: NeverScrollableScrollPhysics(),
children: [
TelephoneTab(),
CodeTab(),
],
),
),
],
),
),
),
),
);
I have tried removing the background image by removing the Container before the Scaffold entirely, removing every element in the UI and adding just a small button in the middle. Updating my kotlin.
Tried running with flutter run --release. No logs.
May be the same thing as this.
Flutter doctor is fine.
The problem seems to be something related to the Scaffold and the Container with the background image. Elements outside the Scaffold were drawn as usual.
I changed the first page of the app in order to go directly to the HomePage and it worked fine, even logging out to the LoginPage.
Then I tried creating a SplashPage before the LoginPage, initially, I used the same structure with the Container, BoxDecoration, and Scaffold. The problem was happening again, but this time in the SplashPage, everything inside the Scaffold was invisible with the same behavior as mentioned above.
After that, I simply define the extendBody as true in the Scaffold of the SplashPage and the problem stopped occurring.
I don't exactly understand what this changes. Feel free to add an explanation to this answer.

how can i make a progress indicator using flutter?

the result i want to achieve
how can i make a progress indicator using flutter?
I've tried using Flutter's built-in progress indicator but it's not what I want
https://api.flutter.dev/flutter/material/CircularProgressIndicator-class.html
I've used it before, something went wrong. when I move pages (from home to settings) and back again to the home page. home page doesn't reload when I delete ProgressIndicator home page works fine
For tour purposes you can use percent_indicator library
Stack(
alignment: Alignment.center,
children: const [
SizedBox(
width: 45,
height: 45,
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(
Color(0XFFA81E61),
),
backgroundColor: Color(0XFFeab5b5),
value: 0.5,
),
),
Text('1 / 2')
],
)

Customize the container shape

How to achieve following shape in flutter without using plugins? I want to implement the customized container using clippath. I'm trying to use lineTo() method. I did not get exactly this one.
try this package, clippy_flutter, using Point:
Point(
triangleHeight: 30.0,
edge: Edge.LEFT,
child: Container(
color: Colors.pink,
width: 100.0,
height: 100.0,
child: Center(child: Text('Point')),
),
),
and then stack them and overlap a little at the egde.

How to increase height of CupertinoSliverNavigationBar

I was trying to clone WhatsApp(iOS version) with flutter using Cupertino Widgets.
while trying to make the header with CupertinoSliverNavigationBar i noticed that the height of CupertinoSliverNavigationBar cannot be increased.
My Code
return CupertinoPageScaffold(
child: NotificationListener<ScrollNotification>(
onNotification: (scrollNotification) {
if (scrollNotification is ScrollStartNotification) {
_onStartScroll(scrollNotification.metrics);
} else if (scrollNotification is ScrollUpdateNotification) {
_onUpdateScroll(scrollNotification.metrics);
} else if (scrollNotification is ScrollEndNotification) {
_onEndScroll(scrollNotification.metrics);
}
},
child: CustomScrollView(
slivers: <Widget>[
CupertinoSliverNavigationBar(
leading: GestureDetector(
child: Padding(
padding: EdgeInsets.only(top: 10.0),
child: Text(
"Edit",
style: TextStyle(
color: Constants.primaryColor,
fontSize: 18.0,
),
),
),
onTap: ()=>print("Tapped"),
),
trailing: GestureDetector(
child: Icon(
CupertinoIcons.create_solid,
size: 25.0,
),
onTap: ()=>print("Tapped"),
),
automaticallyImplyLeading: false,
largeTitle: Column(
children: <Widget>[
Container(
child: Text(
"Chats",
textAlign: TextAlign.left,
),
),
GestureDetector(
child: SearchBar(),
),
],
),
),
],
),
),
);
Screenshots below:
What i want to achieve
What i got
Is there any work around or anyway to increase the height? Thanks!
Flutter purists and advocates will kill me, but those sizes are part of the constants values (like MaterialDesign guidelines values), 2 quick options:
Option 1:
Modify the SDK directly:
Ctrl (or Cmd) + click in CustomScrollView, will open flutter/lib/src/cupertino/nav_bar.dart
Modify line 22 or 26:
/// This height is constant and independent of accessibility as it is in iOS.
const double _kNavBarPersistentHeight = 44.0;
/// Size increase from expanding the navigation bar into an iOS-11-style large title
/// form in a [CustomScrollView].
const double _kNavBarLargeTitleHeightExtension = 52.0; // change this one!
Option 2:
copy nav_bar.dart directly in your project, and modify it, or better yet, grab all the dependencies of CustomScrollView(), and put ur own name, and ur own values there... I guess that beyond being a standard design guideline from Apple, the ability to change those values are required for several devs. We should open a Github request maybe.
Hope you find my "hacky" solution useful!
Result:
You don't need to modify the SDK or something like that.
I have found a simple solution.
add this to CustomScrollView, adjust the anchor until you get a good UI.
CustomScrollView(
anchor: 0.07,
See the image here

Title not displaying correctly on flexibleSpaceBar

I'm trying to show the title but as you can see, it does not do it correctly.
I tried to put softWrap to true but it is still the same.
The code is from flutter contacts_demo gallery
flexibleSpace: FlexibleSpaceBar(
title: const Text('Fantastic Beasts And Where To Find Them'),
background: Stack(
fit: StackFit.expand,
children: <Widget>[
Image.asset(
'people/ali_landscape.png',
package: 'flutter_gallery_assets',
fit: BoxFit.cover,
height: _appBarHeight,
),
// This gradient ensures that the toolbar icons are distinct
// against the background image.
const DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment(0.0, -1.0),
end: Alignment(0.0, -0.4),
colors: <Color>[Color(0x60000000), Color(0x00000000)],
),
),
),
],
),
),
You can use a ConstrainedBox along with MediaQuery.of(context).size.width
final mediaQuery = MediaQuery.of(context);
final availableWidth = mediaQuery.size.width - 160;
along with
title: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: availableWidth,
),
child: const Text('Fantastic Beasts And Where To Find Them'),
),
I dug into a FlexibleSpaceBar sources and at least now I understand what happens. Turns out that in an expanded state title is scaled up to be 1.5 of its size, so naturally it will overflow offscreen. As user scrolls up, title is scaled down towards its source size of 1.0. At this size it will sit in the top toolbar.
Maybe this information will help someone to base their workarounds on until this is fixed.
I wondered why my hack of wrapping title in ConstraintedBox with maxWidth: MediaQuery.of(context).size.width didn't work. Now I know: I must divide this maxWidth by 1.5.
See also this bug on the Flutter github issue tracker.
The title length in combination with the font size you've set have no way to be displayed on a single line on smaller devices, for obvious reasons.
You may want to play with MediaQuery.of(context).size.width to get the device width and set the header text fontSize accordingly as a fraction of that. Try in the emulator to see which works best for your text length.
const Text(
'Fantastic Beasts And Where To Find Them',
style: TextStyle(fontSize: MediaQuery.of(context).size.width/ SOME_NUMBER),
),
Or just hardcode some font sizes based on some width intervals:
int _getFontSize(BuildContext context) {
int width = MediaQuery.of(context).size.width;
if (width < 300) {
return 10;
} else if (width < 600) {
return 13;
// etc ...
} else {
return 18;
}
}
...
const Text(
'Fantastic Beasts And Where To Find Them',
style: _getFontSize(context),
),
Thanks to dimsuz's answer it is possible to eliminate the upscaling of text in a FlexibleSpaceBar:
SliverAppBar(
actions: <Widget>[
IconButton(
icon: Icon(Icons.save),
onPressed: () {},
),
],
floating: true,
pinned: false,
snap: false,
flexibleSpace: FlexibleSpaceBar(
title: Text(title, style: TextStyle(fontSize: 20.0 / 1.5)),
centerTitle: false,
background: Container(
color: Theme.of(context).primaryColor,
),
),
expandedHeight: 120,
),
The 20.0 in fontSize I took from here.