如何使用flutter,wordpress在我的应用程序中添加拉动刷新? [关闭]
Posted
技术标签:
【中文标题】如何使用flutter,wordpress在我的应用程序中添加拉动刷新? [关闭]【英文标题】:How do I add pull to refresh in my app with flutter , wordpress? [closed] 【发布时间】:2020-09-07 16:47:39 【问题描述】:我的应用程序构建测试应用程序博客与颤振,后端 wordpress 但我不知道在哪里添加 你能帮我吗? 我的应用程序使用颤振,后端 wordpress 构建测试应用程序博客,但我不知道在哪里添加 你能帮忙吗?
main.dart
void main() => runApp(MyApp());
class MyApp extends StatelessWidget
@override
Widget build(BuildContext context)
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'blog',
home: HomeScreen(),);
home.dart
class HomeScreen extends StatefulWidget
@override
_HomeScreenState createState() => _HomeScreenState();
List<SinglePost> parsePosts(response)
final parsed = jsonDecode(response)['posts'].cast<Map<String, dynamic>>();
return parsed.map<SinglePost>((json) => SinglePost.fromJson(json)).toList();
Future<List<SinglePost>> _getPosts() async
final response = await http.get(baseUrl);
return compute(parsePosts, response.body);
class _HomeScreenState extends State<HomeScreen>
Future<List<SinglePost>> _postsFuture;
@override
void initState()
super.initState();
_postsFuture = _getPosts();
@override
Widget build(BuildContext context)
return SafeArea(
child: FutureBuilder<List<SinglePost>>(
future: _postsFuture,
builder: (context, snapshot)
if (snapshot.hasError)
return Scaffold(
body: Center(
child: Text("Error"),
),
);
if (snapshot.hasData)
return Scaffold(
appBar: AppBar(
elevation: 0,
title: Text(
"blog",
style: Theme.of(context)
.textTheme
.title
.copyWith(color: Colors.black),
),
actions: <Widget>[
Padding(
padding: const EdgeInsets.all(9.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(9),
child: Image.network(
"$snapshot.data[0].avatarURL",
fit: BoxFit.cover,
),
),
)
],
),
body: ListView(
children: <Widget>[
Container(
height: MediaQuery.of(context).size.height * .35,
margin: const EdgeInsets.symmetric(vertical: 15.0),
child: PageView.builder(
controller: PageController(viewportFraction: .76),
scrollDirection: Axis.horizontal,
itemCount: snapshot.data.length,
itemBuilder: (context, i) => OverlayedContainer(
authorAvatar: "$snapshot.data[i].avatarURL",
author: "$snapshot.data[i].authorName",
image: "$snapshot.data[i].featuredImage",
title: "$snapshot.data[i].title",
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
PostScreen(postData: snapshot.data[i]),
),
),
),
),
),
Padding(
padding: const EdgeInsets.all(9),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"All Posts",
style: Theme.of(context).textTheme.subtitle,
),
ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: 5,
itemBuilder: (context, i) => PostContainer(
author: "$snapshot.data[i].authorName",
image: "$snapshot.data[i].featuredImage",
title: "$snapshot.data[i].title",
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
PostScreen(postData: snapshot.data[i]),
),
),
),
)
],
),
)
],
),
);
else
return Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
,
),
);
我不知道在哪里添加 你能帮我吗? 我的应用程序使用颤振,后端 wordpress 构建测试应用程序博客,但我不知道在哪里添加 你能帮忙吗?
【问题讨论】:
【参考方案1】:我知道 添加 pubsec.yaml 并导入包 .. .. 但是在home.dart里面写代码我不知道
【讨论】:
以上是关于如何使用flutter,wordpress在我的应用程序中添加拉动刷新? [关闭]的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 JWT 和 flutter_wordpress 包在 Flutter 应用程序中验证 WordPress 非管理员用户?
我应该如何处理:Wordpress 社交登录(网络)和 Flutter(移动)