Skip to content

Instantly share code, notes, and snippets.

@Lxxyx
Created February 23, 2025 06:14
Show Gist options
  • Save Lxxyx/7bf5669c63e9a1ab28ecc93ca630aba5 to your computer and use it in GitHub Desktop.
Save Lxxyx/7bf5669c63e9a1ab28ecc93ca630aba5 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Web3 News',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorSchemeSeed: Colors.blue,
),
home: const NewsPage(),
);
}
}
class NewsPage extends StatefulWidget {
const NewsPage({super.key});
@override
State<NewsPage> createState() => _NewsPageState();
}
class _NewsPageState extends State<NewsPage> with TickerProviderStateMixin {
late TabController _tabController;
@override
void initState() {
super.initState();
_tabController = TabController(length: 5, vsync: this);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Web3 News'),
bottom: TabBar(
controller: _tabController,
tabs: const [
Tab(text: 'All'),
Tab(text: 'DeFi'),
Tab(text: 'NFT'),
Tab(text: 'DAO'),
Tab(text: 'Metaverse'),
],
onTap: (index) {
setState(() {
// update the content based on the selected tab
_tabController.animateTo(index);
});
},
),
),
body: TabBarView(
controller: _tabController,
children: [
_buildCircleContent('All', [
_buildNewsItem('Bitcoin Surges to New High'),
_buildNewsItem('Ethereum 2.0 Launches Successfully'),
_buildNewsItem('Dogecoin Becomes Top 10 Cryptocurrency'),
]),
_buildCircleContent('DeFi', [
_buildNewsItem('Uniswap V3 Launches with Liquidity Rewards'),
_buildNewsItem('Aave Launches New Lending Platform'),
_buildNewsItem('MakerDAO Announces New Governance Model'),
]),
_buildCircleContent('NFT', [
_buildNewsItem('OpenSea Raises $100M in Funding'),
_buildNewsItem('CryptoPunks Sells for $1M'),
_buildNewsItem('SuperRare Launches New NFT Marketplace'),
]),
_buildCircleContent('DAO', [
_buildNewsItem('DAOhaus Launches New Governance Platform'),
_buildNewsItem('MetaDAO Announces New Funding Round'),
_buildNewsItem('DAOstack Raises $2M in Funding'),
]),
_buildCircleContent('Metaverse', [
_buildNewsItem('Decentraland Launches New Land Sales'),
_buildNewsItem('The Sandbox Raises $93M in Funding'),
_buildNewsItem('Meta Announces New Metaverse Platform'),
]),
],
),
);
}
Widget _buildCircleContent(String title, List<Widget> newsItems) {
return ListView.builder(
itemCount: newsItems.length,
itemBuilder: (context, index) {
return newsItems[index];
},
);
}
Widget _buildNewsItem(String title) {
return Card(
child: ListTile(
title: Text(title),
subtitle: const Text('This is a sample news item'),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment