Discrete with Custom Theme 我尝试改变拇指形状。但我想将拇指更改为图像。
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:math' as math;
import 'package:flutter/material.dart';
class SliderDemo extends StatefulWidget {
static const String routeName = '/material/slider';
@override
_SliderDemoState createState() => new _SliderDemoState();
}
Path _triangle(double size, Offset thumbCenter, {bool invert = false}) {
final Path thumbPath = new Path();
final double height = …Run Code Online (Sandbox Code Playgroud)我想用颤振构建一个如下图所示的有向图。我不知道从哪里开始。我在互联网上搜索没有成功。这种图形需要哪些算法?我尝试使用自定义画家类构建此图。我不知道如何在自定义画家类中使用自定义小部件。(例如,旁边有人物图片和文字的矩形)。我只能绘制矩形和线条......缩放和平移我认为我可以用 GestureDetector 类来做。该图应该是动态可定制的。
我有一个包含 6 个项目的网格视图(带有图像和文本的卡片)。我希望这 6 个项目适合我在屏幕上的大小,但 gridview 通过将 2 个项目从屏幕上跳出来,在项目之间留下所有空间。
我留下一张我想要的和我拥有的照片。
谢谢你。
return MaterialApp(
home: Scaffold(
body: Container(
margin: EdgeInsets.only(top: 0),
child: Stack(
alignment: AlignmentDirectional.topCenter,
children: <Widget>[
Container(
height: 200,
color: Colors.black,
),
Container(
margin: EdgeInsets.only(top: 200),
decoration: BoxDecoration(
image: new DecorationImage(
image: AssetImage("assets/fondo.png"), fit: BoxFit.fill)),
),
Image.asset("assets/cara_simio_banner.png"),
Padding(
padding: EdgeInsets.only(top: 220),
child: Text(
"{CodeJaVu}",
style: TextStyle(
color: Colors.white,
fontSize: 25,
fontWeight: FontWeight.bold),
),
),
Container(
margin: EdgeInsets.only(top: 230),
child: GridView.count(
crossAxisCount: 2,
children: items.map((item) {
return GestureDetector(
onTap: () {}, …Run Code Online (Sandbox Code Playgroud) 我希望标题位于图像下方并与图像折叠......
我取得了什么成就
home: Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
expandedHeight: 220.0,
floating: true,
pinned: true,
snap: true,
elevation: 50,
backgroundColor: Colors.pink,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
title: Text('Title',
style: TextStyle(
color: Colors.white,
fontSize: 16.0,
)),
background: Image.network(
'https://images.pexels.com/photos/443356/pexels-photo-443356.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940',
fit: BoxFit.cover,
)
),
),
new SliverList(
delegate: new SliverChildListDelegate(_buildList(50))
),
],
),
Run Code Online (Sandbox Code Playgroud)
我想要的是
感谢帮助
我用条子做了一些类似的事情
import 'package:flutter/material.dart';
class ProfilePage extends StatefulWidget {
@override
_ProfilePageState createState() => _ProfilePageState();
}
class _ProfilePageState extends State<ProfilePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: DefaultTabController(
length: 4,
child: NestedScrollView(
body: TabBarView(children: [
//pages of tabBar
]),
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return [
SliverAppBar(
//for the pinned appBar
elevation: 0.0,
backgroundColor: Colors.red,
leading: Padding(
padding: const EdgeInsets.all(8.0),
child: CircleAvatar(backgroundColor: Colors.red.withOpacity(0.4),
child: Icon(Icons.arrow_back,color: Colors.white,),
),
),
pinned: true,
flexibleSpace: FlexibleSpaceBar(
background: Image.network(
"https://images.pexels.com/photos/396547/pexels-photo-396547.jpeg?auto=compress&cs=tinysrgb&h=350",
fit: …Run Code Online (Sandbox Code Playgroud)
我有像上面这样的设计,我的标签栏位于 BottomNavigationBar 内,我想将标签栏放在我的 BottomNavigationBar 菜单中。问题是,我不想有嵌套的脚手架,我不想使用,TabController因为我的选项卡是动态的,选项卡长度可以根据用户添加它而减少或增加。如果我TabController在内部使用并定义它initState,则选项卡无法增加/减少,因为在 initState 中仅定义一次值。
我怎样才能做到这一点 ?
我的期望与下面的示例类似,当我添加选项卡和 tabMenu 时,它会增加。但出现这个错误
The following assertion was thrown building TabBar(dirty, dependencies: [_InheritedTheme,
_LocalizationsScope-[GlobalKey#a56a4]], state: _TabBarState#fb337):
Controller's length property (2) does not match the number of tabs (3) present in TabBar's tabs
property.
The relevant error-causing widget was:
TabBar
Run Code Online (Sandbox Code Playgroud)
class TaskScreen extends StatefulWidget {
@override
_TaskScreenState createState() => _TaskScreenState();
}
class _TaskScreenState extends State<TaskScreen> with SingleTickerProviderStateMixin {
TabController _tabController;
final List<Tab> _tab = [
Tab(text: …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)