在颤振中我知道我们可以画线来设计弧形布局,如下图所示
但我只是在 flutter 上学习这个功能,我无法设计它,也许在 flutter 中我们有一些实现的库或源代码,但我无法找到和设计它
请注意,屏幕右侧和曲线之间的空白可在高度和宽度上调整大小,并且customPaint不使用clipping widget
当我使用时DraggableScrollableSheet我遇到了一些问题,它们是:
appBar,检测最大尺寸SizedBox.expand(
child: SlideTransition(
position: _draggableBottomSheetTween.animate(_draggableBottomSheetController),
child: DraggableScrollableSheet(
builder: (BuildContext context, ScrollController scrollController) {
return ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10.0),
topRight: Radius.circular(10.0)
),
child: Container(
height: 500.0,
color: pageBackgroundColor,
child: ListView.builder(
controller: scrollController,
itemCount: 5,
itemBuilder: (BuildContext context, int index) {
return ListTile(title: Text('Item $index'));
},
),
),
);
},
),
),
),
Run Code Online (Sandbox Code Playgroud) 在 java 9 中,我们可以简单地转换camelCase为下划线,就像camel_case
String text = "camelCase";
Matcher m = Pattern.compile("(?<=[a-z])[A-Z]").matcher(text);
String result = m.replaceAll(match -> "_" + match.group().toLowerCase());
Run Code Online (Sandbox Code Playgroud)
现在我的问题是什么相当于飞镖中的这段代码?
这里解决了有关设计此布局的问题。
我在使用它时遇到了问题,因为屏幕右侧的这条曲线不是小部件,而当我想在绿色一侧有一些其他小部件时,我不能,因为设计的曲线不是从绿色布局中剪下的小部件。
假设我想在屏幕右侧有这条曲线,在其下方有一些小部件。
源代码
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(home: Scaffold(body: Test())));
}
class Test extends StatefulWidget {
@override
_TestState createState() => _TestState();
}
class _TestState extends State<Test> {
double _height = 0.0;
double _width = 0.0;
double _rightPadding = 2.0;
double _btnSize = 25.0;
double _btnY = 0.0;
@override
Widget build(BuildContext context) {
if (_height == 0.0)
setState(() {
_height = MediaQuery.of(context).size.height;
_width = MediaQuery.of(context).size.width;
_btnY = _height / 3 * 2;
});
return _height == 0.0
? …Run Code Online (Sandbox Code Playgroud) 不幸的是,在我的简单代码中作为新屏幕FutureBuilder工作并从方法中获取数据两次!
我不确定出了什么问题以及如何避免这个问题
class LessonDetail extends StatefulWidget {
final String monthKey;
final String lessonFileKey;
LessonDetail({@required this.monthKey, @required this.lessonFileKey});
@override
State<StatefulWidget> createState() {
return _LessonDetailState(monthKey, lessonFileKey);
}
}
class _LessonDetailState extends BaseState<LessonDetail> {
String monthKey;
String lessonFileKey;
_LessonDetailState(this.monthKey, this.lessonFileKey);
@override
Widget build(BuildContext context) {
return Directionality(
textDirection: TextDirection.rtl,
child: Scaffold(
body: FutureBuilder(
future: _getLessonDetail(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
PlayLessonResponse response = snapshot.data;
print(response);
}
return Center(
child: CircularProgressIndicator(),
);
}),
),
);
}
Future<PlayLessonResponse> _getLessonDetail() …Run Code Online (Sandbox Code Playgroud) 就我而言,我需要公共 IP 地址。但是,在研究了几乎所有与本地 IP 相关的纪录片后,例如:Get_IP,我想要像 202.xxx 而不是 192.168.xxx 这样的东西。有人可以给一些建议吗?
我该如何解决这个问题:
更喜欢使用 null 感知运算符
在这段代码上?
AnimationControllerValue halfBoundValue;
double get halfBound => halfBoundValue != null ? halfBoundValue.percentage : null;
Run Code Online (Sandbox Code Playgroud)
文档: https: //dart-lang.github.io/linter/lints/prefer_null_aware_operators.html
我如何BackdropFilter在颤振中使用Appbar?当我将它用于Appbar其他Scaffold模糊的小部件时,而不是AppBar
例如:
BackdropFilter(
filter: ImageFilter.blur(
sigmaX: 5,
sigmaY: 5
),
child: AppBar(
automaticallyImplyLeading: false,
// Used for removing back button.
elevation: 8.0,
titleSpacing: 0.0,
backgroundColor: theme.appMainColor,
title: Stack(
children: <Widget>[
],
)),
),
Run Code Online (Sandbox Code Playgroud) 就像Instagram在个人资料页面中一样,我想Tabbar在滚动视图时修复屏幕顶部,例如:
我认为我应该用 来实现SliverAppBar,这是我的代码,但它无法正常工作,并且选项卡元素的顶部将更改高度
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage>
with SingleTickerProviderStateMixin {
TabController _tabController;
ScrollController _scrollViewController;
@override
void initState() {
super.initState();
_tabController = TabController(vsync: this, length: 2);
_scrollViewController = ScrollController(initialScrollOffset: 0.0);
}
@override
void …Run Code Online (Sandbox Code Playgroud) 在Flutter怎样绘制边框半径选项卡指示灯像下面的图片?
下面的代码只能绘制我在github.
TabBar(
isScrollable: true,
controller: _tabController,
labelColor: Colors.black,
tabs: <Widget>[
Tab(
text: 'DOTTED',
),
Tab(
text: 'Tab',
),
Tab(
text: 'INDICATOR',
),
],
indicator: DotIndicator(
indicatorColor: Colors.black,
radius: 3,
),
indicatorWeight: 2 * kDefaultDotIndicatorRadius,
),
Run Code Online (Sandbox Code Playgroud)
图书馆:
const kDefaultDotIndicatorRadius = 3.0;
class DotTabIndicator extends Decoration {
const DotTabIndicator({this.indicatorColor, this.radius = kDefaultDotIndicatorRadius});
final Color indicatorColor;
final double radius;
@override
BoxPainter createBoxPainter([onChanged]) {
return _DotPainter(this, onChanged);
}
}
class _DotPainter extends BoxPainter {
_DotPainter(this.decoration, VoidCallback onChanged) : super(onChanged); …Run Code Online (Sandbox Code Playgroud)