Open 2013612 opened 3 years ago
Do you set fixed size for it? I did checked sample. It worked fine.
CustomNumberPicker( initialValue: 99, maxValue: 99, minValue: 1, step: 1, onValue: (value) { print(value.toString()); }, )
Using the above parameters, the number cannot display in 1 line
I found that it happens if I set the textTheme as below
TextTheme(
headline1: GoogleFonts.inter(textStyle: textTheme.headline1)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
headline2: GoogleFonts.inter(textStyle: textTheme.headline2)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
headline3: GoogleFonts.inter(textStyle: textTheme.headline3)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
headline4: GoogleFonts.inter(textStyle: textTheme.headline4)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
headline5: GoogleFonts.inter(textStyle: textTheme.headline5)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
headline6: GoogleFonts.inter(textStyle: textTheme.headline6)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
subtitle1: GoogleFonts.inter(textStyle: textTheme.subtitle1)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
subtitle2: GoogleFonts.inter(textStyle: textTheme.subtitle2)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
bodyText1: GoogleFonts.inter(textStyle: textTheme.bodyText1)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
bodyText2: GoogleFonts.inter(textStyle: textTheme.bodyText2)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
caption: GoogleFonts.inter(textStyle: textTheme.caption)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
button: GoogleFonts.inter(textStyle: textTheme.button)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
overline: GoogleFonts.inter(textStyle: textTheme.overline)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
)
Below is the main.dart to reproduce the problem
import 'package:flutter/material.dart';
import 'package:flutter_number_picker/flutter_number_picker.dart';
import 'package:google_fonts/google_fonts.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
textTheme: _textTheme(
Theme.of(context).textTheme,
),
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: CustomNumberPicker(
initialValue: 99,
maxValue: 99,
minValue: 1,
step: 1,
onValue: (value) {
print(value.toString());
},
),
),
);
}
}
TextTheme _textTheme([TextTheme? textTheme]) {
textTheme ??= ThemeData.light().textTheme;
return TextTheme(
headline1: GoogleFonts.inter(textStyle: textTheme.headline1)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
headline2: GoogleFonts.inter(textStyle: textTheme.headline2)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
headline3: GoogleFonts.inter(textStyle: textTheme.headline3)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
headline4: GoogleFonts.inter(textStyle: textTheme.headline4)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
headline5: GoogleFonts.inter(textStyle: textTheme.headline5)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
headline6: GoogleFonts.inter(textStyle: textTheme.headline6)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
subtitle1: GoogleFonts.inter(textStyle: textTheme.subtitle1)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
subtitle2: GoogleFonts.inter(textStyle: textTheme.subtitle2)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
bodyText1: GoogleFonts.inter(textStyle: textTheme.bodyText1)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
bodyText2: GoogleFonts.inter(textStyle: textTheme.bodyText2)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
caption: GoogleFonts.inter(textStyle: textTheme.caption)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
button: GoogleFonts.inter(textStyle: textTheme.button)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
overline: GoogleFonts.inter(textStyle: textTheme.overline)
.copyWith(fontFamilyFallback: ['Noto Sans HK', 'Noto Sans JP']),
);
}
Thank you. I'll check later.
CustomNumberPicker( initialValue: 99, maxValue: 99, minValue: 1, step: 1, onValue: (value) { print(value.toString()); }, )
Using the above parameters, the number cannot display in 1 line