twitter_cards 0.0.2 copy "twitter_cards: ^0.0.2" to clipboard
twitter_cards: ^0.0.2 copied to clipboard

Platformweb

This library provides the easiest way to integrate Twitter Cards in Flutter web apps.

example/lib/main.dart

// Copyright 2022 Kato Shinya. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided the conditions.

import 'package:flutter/material.dart';
import 'package:twitter_cards/twitter_cards.dart';

void main() {
  // Add this line to use the Twitter Summary Card.
  // This setting is possible on a per-HTML basis.
  setupSummaryCard(
    title: 'Small Island Developing States Photo Submission',
    site: '@flickr',
    description: 'View the album on Flickr.',
    imageUrl:
        'https://farm6.staticflickr.com/5510/14338202952_93595258ff_z.jpg',
  );

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
10
likes
140
pub points
0%
popularity

Publisher

unverified uploader

This library provides the easiest way to integrate Twitter Cards in Flutter web apps.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on twitter_cards